detecting colours

3 Ansichten (letzte 30 Tage)
FIR
FIR am 23 Feb. 2012
Bearbeitet: Anusha am 25 Okt. 2013
I want to detect both brown and whit colours,can anyone tell how to proceed plz

Antworten (2)

Jan
Jan am 23 Feb. 2012
You find a lot of color detection questions in this forum. Please take the time to read, how to detect red and yellow colors, and make a transfer to brown and white.
  5 Kommentare
FIR
FIR am 23 Feb. 2012
JAn the code fro yellow is
data=imread('myimage.jpg')
diff_im = imsubtract(data(:,:,1), rgb2gray(data));
%Use a median filter to filter out noise
diff_im = medfilt2(diff_im, [3 3]);
% Convert the resulting grayscale image into a binary image.
diff_im = im2bw(diff_im,0.18);
% Remove all those pixels less than 300px
diff_im = bwareaopen(diff_im,300);
% Label all the connected components in the image.
bw = bwlabel(diff_im, 8);
% Here we do the image blob analysis.
% We get a set of properties for each labeled region.
stats = regionprops(bw, 'BoundingBox', 'Centroid');
% Display the image
imshow(data)
hold on
%This is a loop to bound the red objects in a rectangular box.
for object = 1:length(stats)
bb = stats(object).BoundingBox;
bc = stats(object).Centroid;
rectangle('Position',bb,'EdgeColor','g','LineWidth',2)
plot(bc(1),bc(2), '-m+')
a=text(bc(1)+15,bc(2), strcat('X: ', num2str(round(bc(1))), '
G: ', num2str(round(bc(2)))));
set(a, 'FontName', 'Arial', 'FontWeight', 'bold', 'FontSize', 12, 'Color', 'green');
end
hold off,please tell in which line have to change for brown and white
Jan
Jan am 25 Feb. 2012
In "diff_im = imsubtract(data(:,:,1), rgb2gray(data));" you subtract the grey value from the red component. Are you sure this concerns the color yellow?!

Melden Sie sich an, um zu kommentieren.


Image Analyst
Image Analyst am 23 Feb. 2012
See my color detection examples:
I detect colors in three different ways.
  2 Kommentare
FIR
FIR am 23 Feb. 2012
I mean brown color MR.Analyst
Image Analyst
Image Analyst am 25 Feb. 2012
Yes, I read that. Both brown and whit. I know. It should be easy to modify my apps, in fact the delta E app will work right out of the box. So how did it go? Do you have it working yet? By the way your code in your comment to Jan has nothing whatsoever to do with color segmentation, your comments notwithstanding. It just doesn't - I don't know why you think it should.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Convert Image Type 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!

Translated by