How to find all regions of the same color?

2 次查看(过去 30 天)
Hi guys. I wrote a piece of code which finds all the points with the same color as I selected:
In this part we just find the coordinates of the required co
im = imread('Lighthouse.jpg');
n = 1;
figure, imshow(im)
[x,y] = ginput(n);
x = floor(x);
y = floor(y);
%colour(length(x),3);
colour = zeros(1,length(x),3, 'uint8');
for i=1:length(x)
for k=1:3
colour(1,i,k) = im(y(i),x(i),k);
end
end
%image(colour);
%axis off;
Now that I have the colour, I want to search the picture for all the points with the same colour.
[r,c,t] = size(im);
counter = 1;
for i=1:r
for j=1:c
if (im(i,j,:) == colour(1,1,:))
coordr(counter) = i;
coordc(counter) = j;
counter = counter+1;
end
end
end
This way I found all the points with the color the user selected! Now my problem is:
  1. it takes long time to process!!
  2. I want to select colors which are close to my color but I dunno the algorithm to do it! (this is my main problem) because the points which are found are not enough!
for example they are about 200 points in a big picture. they will be seen as dots! any ideas?

回答(3 个)

Walter Roberson
Walter Roberson 2011-10-21
John D'Errico has a MATLAB File Exchange contribution for Fuzzy Color Matching

Image Analyst
Image Analyst 2011-10-21
arman: I suggest you abandon that approach and use my delta E based approach in my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 That uses an industry standard method (delta E) for determining color difference. I believe it will do exactly what you want.
Walter, fuzzy color was one of the submissions that John removed and never replaced. As I recall it didn't do color segmentation anyway but was some sort of a name assignment scheme, though. I still have his code though. He says "Fuzzycolor is a tool for identifying the "color name" of any RGB intensity triad, i.e., sets of 3 color values....."

lya lya
lya lya 2015-11-28
Dear Image Analyst,
Do you still have the Fuzzy Color code from John? If so, I hope you can share it with me.
Thanks.
  3 个评论
Stephen23
Stephen23 2015-11-30
You can also try my FEX submission, which identifies colornames based on RGB values but uses the "industry standard method (delta E) for determining color difference":
It also supports many standard sets of named colors, such as CSS, dvips, HTML, Kelly, MacBeth, MATLAB, Wolfram, X11, xcolor, xkcd,...

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Blue 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by