フィルターのクリア

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

2 ビュー (過去 30 日間)
R MONTGOMERY
R MONTGOMERY 2019 年 2 月 20 日
コメント済み: R MONTGOMERY 2019 年 2 月 23 日
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
R MONTGOMERY
R MONTGOMERY 2019 年 2 月 23 日
thx andrew this is great.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrange についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by