MATLAB: This is the matlab code for detect blue color , by using this equation is it possible to find yellow color??…please help me to find an yellow color in rgb

color segmentationdetect yellow color in an imageImage Processing Toolboxyellow

data = imread('C:\Users\home\Desktop\project\identi\abc.jpg');
diff_im = imsubtract(data(:,:,3), rgb2gray(data));
%Use a median filter to filter out noise
diff_im = medfilt2(diff_im, [3 3]);
diff_im = im2bw(diff_im,0.18);
diff_im = bwareaopen(diff_im,300);
bw = bwlabel(diff_im, 8);
stats = regionprops(bw, 'BoundingBox', 'Centroid');
% Display the image
imshow(data)
hold on
for object = 1:length(stats)
bb = stats(object).BoundingBox;
bc = stats(object).Centroid;
rectangle('Position',bb,'EdgeColor','r','LineWidth',2)
plot(bc(1),bc(2), '-m+')
a=text(bc(1)+15,bc(2), strcat('X: ', num2str(round(bc(1))), ' Y: ', num2str(round(bc(2)))));
set(a, 'FontName', 'Arial', 'FontWeight', 'bold', 'FontSize', 12, 'Color', 'black');
end
hold off

Best Answer

You forgot to attach your image. So while that might work for your particular image, it would not work in general to find yellow things in any image. You need to convert to HSV color space and threshold out the hues that correspond to yellow. I have 3 color segmentation demos in my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 Try the "Simple color detection by hue" one. It's already set up to find yellow by default so no modification is needed.
Related Question