How to label objects based on their area?
7 views (last 30 days)
I have an image that contains many objects. I want to label each object with different color such that objects with the same area will have the same label color. In the same way, small objects will appear with a color located down of the jet color map (dark blue), while larger object will have a color located up of the jet color map (dark red). I am now using this code which label the objects randomly with different color
img = imread('real_sampel_dilate1.tif'); % input image attached here
I = im2bw(img);
I = ~I;
I = (I==0);
cc = bwconncomp(I,8);
s = regionprops(cc,img,'all');
L = labelmatrix(cc);
RGB_label = label2rgb(L, @jet, 'k', 'shuffle');
imshow(RGB_label); % the result randomly labeled of object attached here
Do anyone knows how to do such area-based labeling?
Any suggestion will be appreciated.