Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
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

Réponse acceptée

Andrew Redfearn
Andrew Redfearn le 20 Fév 2019
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 commentaires
Andrew Redfearn
Andrew Redfearn le 20 Fév 2019
Modifié(e) : Andrew Redfearn le 20 Fév 2019
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 le 23 Fév 2019
thx andrew this is great.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Orange dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by