how to calculate the total white dots/ white region in this image

 채택된 답변

Jeppe
Jeppe 2013년 2월 24일
To read in the image, use
M = imread('result2cars.jpg');
Because your image is a grayscale image, M is just a matrix. Each entry corresponds to one pixel. The entries are integers from 0 (black) to 255 (white). To calculate the number of completely white pixels, use
sum(M(:) == 255)
If you accept very light gray as white as well, use
sum(M(:) > t)
where t sets the white tolerance. For example, using t = 128 would count all pixels who is brighter than 50% gray as being white.

추가 답변 (1개)

Image Analyst
Image Analyst 2013년 2월 24일
편집: Image Analyst 2013년 2월 24일

0 개 추천

See my image segmentation tutorial "BlobsDemo": http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 It will work for you.
Of course if you just want to count the white pixels, you can sum them like Jeppe said. But if you want measurements, like a count of the number of cars, their sizes, etc. then you'll have to use regionprops().

질문:

2013년 2월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by