Area/Number of pixel in gray-scale image

2 views (last 30 days)
Syahrul Niezam
Syahrul Niezam on 8 Feb 2012
I'm sorry for asking the same question as previous. I'm trying to calculate area/no. of pixel in this image.
I want to calculate no of pixel in white, light gray and dark gray regions separately. I'm very thankful that some of people for some tips. I had tried using bwconncomp and regionprops after binarizing the image. However, error came out for the bwconncomp line.
I'm also trying the labeling process to find area, but the labeling process is failed too.
I hope anybody can help to solve my problems. Thanks in advance.

Answers (1)

Image Analyst
Image Analyst on 8 Feb 2012
Did you try something like
binaryImage = grayImage == 200; % Or whatever
measurements = regionprops(binaryImage, 'area');
allAreas = [measurements.Area];
bwconncomp is done implicitly inside regionprops if you pass regionprops a logical image instead of a labeled image or connected components structure.
  2 Comments
Syahrul Niezam
Syahrul Niezam on 8 Feb 2012
I tried like this
y=bwlabel(b);
x=uint8(y);
C = bwconncomp(x);
CC = labelmatrix(C);

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!