How to detect a specific color in photo?

11 ビュー (過去 30 日間)
JunYoung Seo
JunYoung Seo 2017 年 5 月 30 日
回答済み: Kushagr Gupta 2017 年 6 月 8 日
Hello. Recently, I faced some problems in using the image analysis. In attached photo, I needed to calculate the percent of shell(or root, sediment etc.) in total area. I already tried to detect the shell and calculate the percent of shell in total circle area.
Then, I plotted the red marker at each point, and could calculate the percent of shell. The following is code to detect the shell.
rgbImage = imread('GEMS_Vegetation.png');
imshow(rgbImage);
[x,y] = ginput(1);
row = round(y);
column = round(x);
r = rgbImage(:,:,1); r_dou = im2double(r)*255; Red = r_dou(row, column);
g = rgbImage(:,:,2); g_dou = im2double(g)*255; Green = g_dou(row, column);
b = rgbImage(:,:,3); b_dou = im2double(b)*255; Blue = b_dou(row, column);
Error_R = 0.15;
[R_r R_c] = find(r_dou <= Red+(Error_R*Red) & r_dou >= Red-(Error_R*Red)); R = [R_r R_c];
[G_r G_c] = find(g_dou <= Green+(Error_R*Green) & g_dou >= Green-(Error_R*Green)); G = [G_r G_c];
[B_r B_c] = find(b_dou <= Blue+(Error_R*Blue) & b_dou >= Blue-(Error_R*Blue)); B = [B_r B_c];
[RG,ia,ib] = intersect(R,G,'rows'); [RGB,ic,id] = intersect(RG,B,'rows');
figure()
imshow(rgbImage); hold on;
plot(RGB(:,2), RGB(:,1), 'ro', 'markersize', 3);
T_color = find(r_dou ~= 0);
Obj_pixels = (length(RGB)/length(T_color))*100;
However, in detecting the roots(greenish color) or stem, we couldn't detect the proper values. I thought that there is a water, inducing a reflection and shadow.
In this point, how can I properly detect the wanted colors..??

回答 (1 件)

Kushagr Gupta
Kushagr Gupta 2017 年 6 月 8 日
I would recommend the following link to do image segmentation in color space:
Moreover, there is a imageSegmenter app in MATLAB that can be used for trying out different segmentation techniques in a quick way to see which performs the best. It can be accessed by executing the following command:
>>imageSegmenter
Hope this helps!

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!