Filter löschen
Filter löschen

How to detect a specific color in photo?

44 Ansichten (letzte 30 Tage)
JunYoung Seo
JunYoung Seo am 30 Mai 2017
Beantwortet: Kushagr Gupta am 8 Jun. 2017
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..??

Antworten (1)

Kushagr Gupta
Kushagr Gupta am 8 Jun. 2017
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!

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!