How to color code a black and white image by area?
11 ビュー (過去 30 日間)
古いコメントを表示
Hi Everyone,
I have a black and white image that I've done some morphological operations on and then run regionprops to get information about region areas and perimeters.

My question is how would I go about creating an image that has these regions color coded by the area found using region props? I've searched all over the internet and can't seem to find any leads.
Thanks for your help
0 件のコメント
採用された回答
Walter Roberson
2015 年 8 月 5 日
編集済み: Walter Roberson
2015 年 8 月 5 日
labelBW = bwlabel(YourBWImage);
reginfo = regionprops(labelBW, 'Area');
all_area = [reginfo.Area];
rel_area = all_area(:) ./ max(all_area);
Now that we have relative areas, we need to color code. We could easily convert to grayscale but that would not be very colorfull. So for lack of better instructions as to how to code the colors, code the relative area as being the hue. Do not just take the raw relative area as that would range 0 to 1 and hue 1 is the same as hue 0 (it wraps around). To prevent color confusion, we limit the upper value of the hue
hue = rel_area * 0.85;
hsvtab = [hue, ones(size(hue,1),2)];
rgbtab = hsv2rgb(hsvtab);
Now that we have an RGB color table we can display the image and activate the colormap
image(labelBW);
colormap(rgbtab);
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で White についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!