Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Image histogram and difference between color bins

Subject: Image histogram and difference between color bins

From: twin

Date: 8 Feb, 2009 00:18:01

Message: 1 of 8

Hello guys,
I have a question for you.
If I use hist(Y,0:n) function to obtain a descriptor for an image, how can i find what color each bin represents(in RGB or Lab color space). I need this because I want to determine the distance between 2 images using quadratic forms which envolves computation of a matrix M whose weights represent the similarity between bins i and j?

Thank you in advance for the response,
twin

Subject: Image histogram and difference between color bins

From: ImageAnalyst

Date: 8 Feb, 2009 03:12:10

Message: 2 of 8

twin:
I deal with calibrated color images all the time so I'll try to
explain a few things. First of all, you can't pass a color image into
hist. I know - I tried it - it gives an error. You'd have to
histogram each color plane by itself. The histogram (or 3 of them in
the case of a color image), or the 3D gamut, can be one way to
describe an image. To determine "distance" (as you call it) between
two images, what you really do is to calculate the color difference,
which is known as Delta E. Basically it is the square root of the sum
of the squares of delta L squared plus delta A squared plus Delta B
squared. At least that's one formula. There are other forms of Delta
E for cases of close color matches (where Delta E < 5) that purport to
be more accurate or relevant. There is a newsgroup sci.engr.color
that you may want to look at. The only way that the method you gave
could be correct is if you just calculated the mean R, G, and B values
for the whole image and then converted that into an estimated mean L,
A, and B values for the entire image. Then do the same for the other
image and use the formula for Delta E to determine a color
difference. It can work out OK but really it's best for the case
where the entire region is just one fairly "uniform" color.
Mathematically, this way is not the same as calculating the Delta E on
a pixel-by pixel basis and then averaging all the Delta E's together.

There are some simple "book" formulas at http://www.easyrgb.com/ that
may help you. Of course they are only nominal "book" formulas that
aren't really accurate unless you've calibrated your system against
known colorimetric standards (such as a Macbeth chart). Nonetheless,
they can work acceptably in many situations.

OK, now back to your question. a bin doesn't correspond to a color.
For example, let's say that you have 3 histograms: one for the red,
one for the green, and one for the blue. Now let's say you're
referring to bin #100 in the red histogram. Well those pixels that
contributed to that bin could have come from tens of thousands of
different colors - the only thing the colors have in common is that
they have the same value for their red component, but the colors of
the pixel could range from dark red to gray to magenta to yellow to
just about anything, as long as the red value of the color was 100. I
hope that explains it sufficiently for you.

And I don't know what you're talking about when you talk about the
similarity between bin i and j. That really has nothing to do with
anything. It's not even the gray level cooccurrence matrix. For
example, how the value in histogram bin 25 is related to the value in
bin 138 is totally irrelevant. It says nothing about the colors that
are present in the image.

I'm not sure what the quadratic forms you mentioned had to do with
anything. Anyway, it's irrelevant since you need to calculate Delta
E. Maybe you were referring to the Delta E formula - but even then
that doesn't make sense. Do you mean the histograms have some kind of
quadratic shape? Even if they did, this doesn't matter since you need
the Delta E and this does not depend on the shape of the histograms at
all.

Looks like you could use some additional education and tutorials in
color. Here's a nice web site with a big list of color-related links:
http://www.efg2.com/Lab/Library/Color/index.html
Here you can find the color and gamma FAQ's:
http://www.poynton.com/
The Rochester Institute of Technology Munsell Color FAQ:
http://www.cis.rit.edu/mcsl/faq/
A list of hundreds of colors with their names:
http://web.njit.edu/~kevin/rgb.txt.html
A way to visualize the 3D color gamut of your image with this plug-in
for free software ImageJ (very, very cool plug-in!!):
http://rsb.info.nih.gov/ij/plugins/color-inspector.html
Macbeth ColorChecker chart
http://www.xrite.com/product_overview.aspx?ID=824


Regards,
ImageAnalyst (and ColorScientist too)

Subject: Image histogram and difference between color bins

From: twin

Date: 8 Feb, 2009 11:24:01

Message: 3 of 8

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <ec647c85-2331-4123-a4a0-eeab69878119@j38g2000yqa.googlegroups.com>...
> twin:
> I deal with calibrated color images all the time so I'll try to
> explain a few things. First of all, you can't pass a color image into
> hist. I know - I tried it - it gives an error. You'd have to
> histogram each color plane by itself. The histogram (or 3 of them in
> the case of a color image), or the 3D gamut, can be one way to
> describe an image. To determine "distance" (as you call it) between
> two images, what you really do is to calculate the color difference,
> which is known as Delta E. Basically it is the square root of the sum
> of the squares of delta L squared plus delta A squared plus Delta B
> squared. At least that's one formula. There are other forms of Delta
> E for cases of close color matches (where Delta E < 5) that purport to
> be more accurate or relevant. There is a newsgroup sci.engr.color
> that you may want to look at. The only way that the method you gave
> could be correct is if you just calculated the mean R, G, and B values
> for the whole image and then converted that into an estimated mean L,
> A, and B values for the entire image. Then do the same for the other
> image and use the formula for Delta E to determine a color
> difference. It can work out OK but really it's best for the case
> where the entire region is just one fairly "uniform" color.
> Mathematically, this way is not the same as calculating the Delta E on
> a pixel-by pixel basis and then averaging all the Delta E's together.
>
> There are some simple "book" formulas at http://www.easyrgb.com/ that
> may help you. Of course they are only nominal "book" formulas that
> aren't really accurate unless you've calibrated your system against
> known colorimetric standards (such as a Macbeth chart). Nonetheless,
> they can work acceptably in many situations.
>
> OK, now back to your question. a bin doesn't correspond to a color.
> For example, let's say that you have 3 histograms: one for the red,
> one for the green, and one for the blue. Now let's say you're
> referring to bin #100 in the red histogram. Well those pixels that
> contributed to that bin could have come from tens of thousands of
> different colors - the only thing the colors have in common is that
> they have the same value for their red component, but the colors of
> the pixel could range from dark red to gray to magenta to yellow to
> just about anything, as long as the red value of the color was 100. I
> hope that explains it sufficiently for you.
>
> And I don't know what you're talking about when you talk about the
> similarity between bin i and j. That really has nothing to do with
> anything. It's not even the gray level cooccurrence matrix. For
> example, how the value in histogram bin 25 is related to the value in
> bin 138 is totally irrelevant. It says nothing about the colors that
> are present in the image.
>
> I'm not sure what the quadratic forms you mentioned had to do with
> anything. Anyway, it's irrelevant since you need to calculate Delta
> E. Maybe you were referring to the Delta E formula - but even then
> that doesn't make sense. Do you mean the histograms have some kind of
> quadratic shape? Even if they did, this doesn't matter since you need
> the Delta E and this does not depend on the shape of the histograms at
> all.
>
> Looks like you could use some additional education and tutorials in
> color. Here's a nice web site with a big list of color-related links:
> http://www.efg2.com/Lab/Library/Color/index.html
> Here you can find the color and gamma FAQ's:
> http://www.poynton.com/
> The Rochester Institute of Technology Munsell Color FAQ:
> http://www.cis.rit.edu/mcsl/faq/
> A list of hundreds of colors with their names:
> http://web.njit.edu/~kevin/rgb.txt.html
> A way to visualize the 3D color gamut of your image with this plug-in
> for free software ImageJ (very, very cool plug-in!!):
> http://rsb.info.nih.gov/ij/plugins/color-inspector.html
> Macbeth ColorChecker chart
> http://www.xrite.com/product_overview.aspx?ID=824
>
>
> Regards,
> ImageAnalyst (and ColorScientist too)

Hello again and thank for your time. It is true that I am new to this area and I still have more to read . I will try to explain a liitle bit more what I wanted to ask.
I have 2 images and I want to compute the difference between these 2 images using the following formula:
Di,j^2(h1,h2)=(h1-h2)'*M*(h1-h2) (formula for quadratic forms),
where h1,h2 are the color histograms for the 2 images (h1 and h2 were determined using hist(Y,0:n)), and M=[mij] where mij is the similarity between colors represented by bins i and j. This is why I asked how could I know which color each bins represents so that I can use Delta E formula to determine the distance between 2 colors(between color represented by bins i and j).

I hope now is more clear.

Thank you also for the links,
twin

Subject: Image histogram and difference between color bins

From: Oliver Woodford

Date: 8 Feb, 2009 12:20:02

Message: 4 of 8

"twin " <adinaesma@yahoo.com> wrote in message <gml8bp$6jh$1@fred.mathworks.com>...
> Hello guys,
> I have a question for you.
> If I use hist(Y,0:n) function to obtain a descriptor for an image, how can i find what color each bin represents(in RGB or Lab color space). I need this because I want to determine the distance between 2 images using quadratic forms which envolves computation of a matrix M whose weights represent the similarity between bins i and j?
>
> Thank you in advance for the response,
> twin

What is size(Y)? And size(hist(Y,0:n))?

Subject: Image histogram and difference between color bins

From: Image Analyst

Date: 8 Feb, 2009 16:12:03

Message: 5 of 8

twin:
I've never seen this formula. It's not Delta E though. Do you have a citation for it? If you have an RGB image, then what is M? What do you mean by similarity? The color histogram would be a 256 by 256 by 256 3D array. This is also an RGB representation of the color gamut. Check out that Color Inspector for ImageJ that I referred you to so that you can visualize it.

Now I have no idea how you're turning this 3D color gamut/histogram into a 2D matrix, unless perhaps you're referring to the concept delivered in a paper last month by a Japanese professor who gave a paper on "Color Frequency image." The title was "Theory and applications of frequency image of color vectors." http://spie.org//app/program/index.cfm?fuseaction=conferencedetail&export_id=x16280&ID=x16223&redir=x16223.xml&conference_id=863840&event_id=862795&programtrack_id=862800&jsenabled=1

The basic concept there was that you make up the 3D gamut/histogram of your input image, then you create an output image (the "color frequency image") by scanning the input image, and giving the output pixel the value that the 3D histogram had for the color of the input image at that pixel location. (I wrote MATLAB code for it if you want me to post it.) He then went on to perform all kinds of tricks with it like color segmentation, contrast improvement, etc.
Regards,
ImageAnalyst

Subject: Image histogram and difference between color bins

From: Wei

Date: 29 Jul, 2009 17:52:02

Message: 6 of 8

Hi Image Analyst,

Could you post your implementation of the paper on "Color Frequency image." please? or could you send a copy to my email address? Thanks a lot!

Wei

"Image Analyst" <imageanalyst@mailinator.com> wrote in message <gmn08j$5q3$1@fred.mathworks.com>...
> twin:
> I've never seen this formula. It's not Delta E though. Do you have a citation for it? If you have an RGB image, then what is M? What do you mean by similarity? The color histogram would be a 256 by 256 by 256 3D array. This is also an RGB representation of the color gamut. Check out that Color Inspector for ImageJ that I referred you to so that you can visualize it.
>
> Now I have no idea how you're turning this 3D color gamut/histogram into a 2D matrix, unless perhaps you're referring to the concept delivered in a paper last month by a Japanese professor who gave a paper on "Color Frequency image." The title was "Theory and applications of frequency image of color vectors." http://spie.org//app/program/index.cfm?fuseaction=conferencedetail&export_id=x16280&ID=x16223&redir=x16223.xml&conference_id=863840&event_id=862795&programtrack_id=862800&jsenabled=1
>
> The basic concept there was that you make up the 3D gamut/histogram of your input image, then you create an output image (the "color frequency image") by scanning the input image, and giving the output pixel the value that the 3D histogram had for the color of the input image at that pixel location. (I wrote MATLAB code for it if you want me to post it.) He then went on to perform all kinds of tricks with it like color segmentation, contrast improvement, etc.
> Regards,
> ImageAnalyst

Subject: Image histogram and difference between color bins

From: Wei

Date: 29 Jul, 2009 17:52:02

Message: 7 of 8

Hi Image Analyst,

Could you post your implementation of the paper on "Color Frequency image." please? or could you send a copy to my email address? Thanks a lot!

Wei

"Image Analyst" <imageanalyst@mailinator.com> wrote in message <gmn08j$5q3$1@fred.mathworks.com>...
> twin:
> I've never seen this formula. It's not Delta E though. Do you have a citation for it? If you have an RGB image, then what is M? What do you mean by similarity? The color histogram would be a 256 by 256 by 256 3D array. This is also an RGB representation of the color gamut. Check out that Color Inspector for ImageJ that I referred you to so that you can visualize it.
>
> Now I have no idea how you're turning this 3D color gamut/histogram into a 2D matrix, unless perhaps you're referring to the concept delivered in a paper last month by a Japanese professor who gave a paper on "Color Frequency image." The title was "Theory and applications of frequency image of color vectors." http://spie.org//app/program/index.cfm?fuseaction=conferencedetail&export_id=x16280&ID=x16223&redir=x16223.xml&conference_id=863840&event_id=862795&programtrack_id=862800&jsenabled=1
>
> The basic concept there was that you make up the 3D gamut/histogram of your input image, then you create an output image (the "color frequency image") by scanning the input image, and giving the output pixel the value that the 3D histogram had for the color of the input image at that pixel location. (I wrote MATLAB code for it if you want me to post it.) He then went on to perform all kinds of tricks with it like color segmentation, contrast improvement, etc.
> Regards,
> ImageAnalyst

Subject: Image histogram and difference between color bins

From: Abhijeet

Date: 2 Mar, 2013 05:00:13

Message: 8 of 8

"Image Analyst" wrote in message <gmn08j$5q3$1@fred.mathworks.com>...
> twin:
> I've never seen this formula. It's not Delta E though. Do you have a citation for it? If you have an RGB image, then what is M? What do you mean by similarity? The color histogram would be a 256 by 256 by 256 3D array. This is also an RGB representation of the color gamut. Check out that Color Inspector for ImageJ that I referred you to so that you can visualize it.
>
> Now I have no idea how you're turning this 3D color gamut/histogram into a 2D matrix, unless perhaps you're referring to the concept delivered in a paper last month by a Japanese professor who gave a paper on "Color Frequency image." The title was "Theory and applications of frequency image of color vectors." http://spie.org//app/program/index.cfm?fuseaction=conferencedetail&export_id=x16280&ID=x16223&redir=x16223.xml&conference_id=863840&event_id=862795&programtrack_id=862800&jsenabled=1
>
> The basic concept there was that you make up the 3D gamut/histogram of your input image, then you create an output image (the "color frequency image") by scanning the input image, and giving the output pixel the value that the 3D histogram had for the color of the input image at that pixel location. (I wrote MATLAB code for it if you want me to post it.) He then went on to perform all kinds of tricks with it like color segmentation, contrast improvement, etc.
> Regards,
> ImageAnalyst



Hi ImageAnalyst,

I wanted to give you a citation for that quadratic distance talked about. Here is the link
http://scien.stanford.edu/pages/labsite/2002/psych221/projects/02/sojeong/

Under section 3.3.3, you can find Histogram quadratic distance.

I am unable to understand what exactly that "A" does over there. I was very convinced with your logic, but when I saw this one, I am definitely puzzled. How can there be any similarity between two bins of histogram ?

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us