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

4 次查看(过去 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