Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Andrew Redfearn
Andrew Redfearn el 20 de Feb. de 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 comentarios
Andrew Redfearn
Andrew Redfearn el 20 de Feb. de 2019
Editada: Andrew Redfearn el 20 de Feb. de 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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Orange en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by