Best method for identifying the color

Hello. I have read a book in image processing. I have worked it out with matlab too. I want to find out the location (co-ordinates) of a particular color in the image. How should I do this? Which is the best method for color identification?
Thanks in advance.

댓글 수: 6

Walter Roberson
Walter Roberson 2012년 1월 10일
How is the color denoted? If it is by name, then there is no definition for when that colorname stops and a different (or unnamed) color begins. Is (250, 11, 3) "red" or not? When does "olive green" end and "forest green" begin?
i Venky
i Venky 2012년 1월 11일
It's very simple. All I need to do is to find red, yellow and blue colored boxes.
Walter Roberson
Walter Roberson 2012년 1월 11일
Is (250, 11, 3) "red" or not? What are the exact rules you want to use for determining whether something is "red"? "yellow"? "blue" ?
Muhammad Muhammad
Muhammad Muhammad 2019년 11월 20일
이동: DGM 2023년 2월 14일
How to identify yellow colour in images by Matlab software.
Walter Roberson
Walter Roberson 2019년 11월 20일
이동: DGM 2023년 2월 14일
You start by defining exactly what yellow means to you. For example is sunlight yellow, or is it yellow-green (as science tells us), or is it white?
Image Analyst
Image Analyst 2019년 11월 21일
이동: DGM 2023년 2월 14일
Try the Color Thresholder app on the Apps tab of the tool ribbon.
Or check out some demos in my File Exchange.

댓글을 달려면 로그인하십시오.

답변 (3개)

Image Analyst
Image Analyst 2012년 1월 13일

1 개 추천

Color image analysis is not so easy, but it's one of my specialties as you can see from my logo and my File Exchange:
Check out the color segmentation demos I have there. There are three different ways of detecting colors. You can also specify how close you want the colors to be or how different you'll allow them to be from each other (like how much spread there is in the detected color gamut).
Jonathan Sullivan
Jonathan Sullivan 2012년 1월 11일
편집: Walter Roberson 2017년 10월 11일

0 개 추천

Think of the color of a pixel being a vector in a 3 dimensional space. What you want to do is find the angle of the color vector of the pixel to the color vector of the ideal by using the dot product.
For example:
blue = [0 0 255];
pixel = [10 10 200];
ang_thres = 25; % degrees. You should change this to suit your needs
ang = acosd(dot(blue/norm(blue),pixel/norm(pixel)));
isBlue = ang <= ang_thres; % Apply angle threshold
You might also want to apply a magnitude threshold (i.e. is the pixel dark enough). This would filter out any really faint colors (i.e. [0 0 1]);
For example:
blue = [0 0 255];
pixel = [10 10 200];
ang_thres = 25; % degrees. You should change this to suit your needs
ang = acosd(dot(blue/norm(blue),pixel/norm(pixel)));
mag_thres = 64; % You should change this to suit your needs
mag = norm(pixel);
isBlue = ang <= ang_thres & mag >= mag_thres; % Apply both thresholds
Hope this helps!

댓글 수: 2

Alejandro Hernandez6
Alejandro Hernandez6 2017년 10월 11일
thanks to all for this post. Anyway what means 'norm(blue)','norm(pixel)'? normalized ? My task is (given an image representing a floor plan) remove from it all green, red and blue pixels, considered noise, and later I will have to recognize all black segments to produce an floor plan.
Image Analyst
Image Analyst 2017년 10월 11일
You're best off just attaching your image and telling us what you need to do, extract, or measure in a brand new question. Like what, exactly, is considered "noise."
You can also search the Image Analysis literature for papers on floor plans by clicking here.

댓글을 달려면 로그인하십시오.

Walter Roberson
Walter Roberson 2012년 1월 11일

0 개 추천

Unfortunately, the hue-angle solution from Jonathan, and the hsv solution from Chandra, both will likely classify pink as being red, since pink is a saturated form of red. This is why it is important to define exactly what "red" and "yellow" and "blue" mean to you.

댓글 수: 3

Jonathan Sullivan
Jonathan Sullivan 2012년 1월 11일
이동: DGM 2023년 2월 14일
With all do respect, Walter, I don't believe that the solution I gave will include pinks. Here, let's look at an example of all colors.
% Set user parameters
mag_thres = 0.5; % Set magnitude threshold
ang_thres = 10; % Set angular threshold
r = cat(4,1,0,0); % Define "red"
% Create all colors
[R G B] = meshgrid(linspace(0,1,100),linspace(0,1,100),linspace(0,1,100));
RGB = cat(4,R,G,B);
% Threshold
mag = sqrt(sum(RGB.^2,4));
ang = acosd(sum(bsxfun(@times,r,bsxfun(@rdivide,RGB,mag)),4));
f = ang < ang_thres & mag > mag_thres;
% Display Results
figure
image(cat(3,R(f),G(f),B(f)))
As you can tell, no "pinks" are included.
Image Analyst
Image Analyst 2012년 1월 13일
이동: DGM 2023년 2월 14일
I ran it and it looks like it gives a red Chirp or sawtooth function. Not sure I understand.
The example selects colors in a conical region around red.
% Set user parameters
mag_thres = 0.5; % Set magnitude threshold
ang_thres = 30; % Set angular threshold
r = cat(4,1,0,0); % Define "red"
% Create all colors
vv = single(linspace(0,1,200));
[R G B] = meshgrid(vv);
RGB = cat(4,R,G,B);
% Threshold
mag = sqrt(sum(RGB.^2,4));
ang = acosd(sum(bsxfun(@times,r,bsxfun(@rdivide,RGB,mag)),4));
f = ang < ang_thres & mag > mag_thres;
% Display Results
% this is a Nx1x3 stripe of colors within the selected volume
image(cat(3,R(f),G(f),B(f)))
% plot the slected volume
isosurface(R,G,B,f,0)
grid on
axis equal
ll = [0 1];
xlim(ll)
ylim(ll)
zlim(ll)
xlabel('R');
ylabel('G')
zlabel('B')
view(-73,35)
... but it doesn't seem generalized. The thresholds aren't relative to the specified color, so choosing any color other than red doesn't work.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Orange에 대해 자세히 알아보기

질문:

2012년 1월 10일

댓글:

DGM
2023년 2월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by