|
"rubionelove " <rubionelove@gmail.com> wrote in message <havl73$3pj$1@fred.mathworks.com>...
> I'm sorry john and Imageanalyst if the question was not clear.
> I'll try to clarify the problem.
>
> I'm currently facing a problem computing the euclidean distance between the "a" and "b" components of two colours.
> For example I have 4 colours in rgb format
> dark gray, light gray
> dark brown and light brown
>
> I converted the four colours in lab space.
> I observed that for the two greys the "L" value is different but "a" and "b" remains quite the same, so the euclidean distance between "a" and "b" components of the two grays is very small.
>
Neutrals in Lab all fall on the L* axis, where a*=b*=0.
So very logically, the difference between a* and b*
MUST be small for neutrals.
> I observed also that for the two browns the euclidean distance between two different colours (dark brown and clear brown) is generally larger than with grays. Because also "a" and "b" components are changing.
> In my opinion this is due to the 3dimensional shape of the lab space.
I don't think you understand the different color spaces.
But certainly it makes little sense to talk about the
"shape" of these spaces in this context. These color
spaces are simply cartesian coordinate systems, unless
you start talking about a space like LCH, in which case
it is a cylindrical coordinate system.
Regardless, you are asking questions about what are
called color names. We learn from childhood what
colors are described by the color names "red", "blue",
"black", "brown", etc. And of course, everybody might
have a slightly different definition of those boundaries
in a given color space from everyone else.
The color name boundary of the set of colors one
might describe as "neutral", lives in Lab space along
the L* axis, at a*=b*=0. Slightly off that axis, one
has the set of colors described as "near neutrals".
In RGB space, these neutrals live NEAR the line where
R=G=B. It turns out that the neutrals will generally
not be exactly on that line, but they will lie close to
it. The specific RGB space chosen will differ slightly
in where the neutrals will lie. (RGB has a MUCH less
exact definition than does Lab. In fact, there are many
different spaces that can loosely be called RGB.)
How about "brown"? The color name brown describes
a set of colors that live in the first quadrant in the
(a*,b) plane. Whereas the set of neutrals lives along
a roughly linear set in RGB or Lab, the set of browns
lives in more of a "blob".
> My goal is to remove a selected colour in an image.
>
> C=makecform('srgb2lab');
> imLAB= applycform(Image,C);
> SelectedColor= applycform(color,C);
>
> % Extract a* and b* values
> imA = imLAB(:,:,2);
> imB = imLAB(:,:,3);
> colA = SelectedColor(1,2);
> colB = SelectedColor(1,3);
>
> % compute distance from selected color
> distTresh=5;
> imMask = zeros(r,c);
> imDist =hypot(imA-colA ,imB-colB );
> imMask(imDist>distTresh)=1;
>
> This is working good with grays (color= gray). But to have the same result with other colours I've to change the treshold.
> So, my idea was to convert all the colours in my image in colors available at L=50 for example. And then to be able to remove a colour from the image without changing the treshold.
>
Sorry, but this simply will NOT work.
I'd suggest that you try my fuzzycolor tool, found
on the file exchange. It has the ability to identify
pixels in an RGB image that satisfy a given color
name. (If you disagree with my definition of the
color name boundary for brown, you can change
it as you like, using the tools I provide there.)
http://www.mathworks.com/matlabcentral/fileexchange/12326
HTH,
John
|