필터 지우기
필터 지우기

How to measure the height of white pixels in column in a binary image?

조회 수: 1 (최근 30일)
Hi Everyone,
I am very new to matlab imaging and matrix stuff.
----------------------------------------------------------------------------------
I have managed to create this image (1080x1920 logical) (as attached) from a colour video.
I want to be able to go along the x-axis, say 200 pixels and 800 pixels; and measure how many white pixels are on that column (y-axis).
Hopefully I can eventually convert these into real world values.
------------------------------------------------------------------------------------
Alternatively I would like to take the image and "mask" it then use regionprops to measure pixel area. Im not too sure what this term means or how to do it
Any advice or code anyone could give me would be very much appreciated as I have struggled on this task for weeks.
Many thanks

채택된 답변

Andrew Redfearn
Andrew Redfearn 2019년 2월 20일
Hello,
Since it is a binary image (white pixels are 1's), to calculate how many white pixels are on a particular column of the image you can just use the sum function.
x = 200; % x position of column of interest
whitePixels = sum(I(:,x)) % sum values in that column
Hope that helps!
Andrew
  댓글 수: 3
Andrew Redfearn
Andrew Redfearn 2019년 2월 20일
편집: Andrew Redfearn 2019년 2월 20일
As in you want the sum of every column in a matrix, or vector in this case?
If so try this:
WhitePixels = sum(I)
When you use the sum function on a matrix (which is your image in this case) it returns a row vector, where each value is the sum of the corresponding column.
Have a look at this graphic in the documentation:
https://uk.mathworks.com/help/matlab/ref/sum.html#btv6ok6-1-dim

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Orange에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by