5.0

5.0 | 6 ratings Rate this file 124 Downloads (last 30 days) File Size: 3.74 KB File ID: #20757
image thumbnail

Drawing Color Histograms and Color Clouds

by Chaitanya Sai Gaddam

 

17 Jul 2008 (Updated 01 Aug 2010)

Matlab code to plot color histograms and color clouds

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information
Description

Usage: createColorHistograms(im_str)
im_str can be an image file location or a three-dimensional array

There seem to be two confounds in plotting color histograms. One is the obvious one of showing a three-dimensional distribution in two-dimensions. And the other is the perceptual confound of showing actual colors without contextual interactions.

The usual method of plotting histograms separately for each of the three primary color bands is hardly optimal. There's no reason to believe that the peaks of the individual bands correspond to the same triplet of color, and the even the fundamental idea of showing spectral densities with graphs that could just as well be used for any universal triplet is dicey. Why not have the graphs speak to you in the visual language of color when they are supposed to be describing color?

As a starting point I decided to bin the color triplets into bands of 25 gray-scale values in each of the RGB band. That is, each (r,g,b) triplet is truncated as (r*,g*,b*) where each value can only be a multiple of 25 up to a maximum of 255. That gives you a resolution of 11^3 voxels in the entire color space covered by a 24-bit representation. The next step is deciding how to order the bins. Our perception of color difference varies quite a bit from the euclidean distance between two color triplets. It seemed prudent to take brightness out of the mix by normalizing all triplets by the sum of their values, making them (r/(r+g+b), g/(r+g+b), b/(r+g+b)) and then ordering them with (1,0,0) (primary red) as the leftmost point.

You can view some examples here:
http://cns.bu.edu/~gsc/ColorHistograms.html

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (8)
12 Jun 2009 emrah sar1  
23 Mar 2010 Joao Henriques  
04 Aug 2010 Mohammed El-Said

Great work,
it is really useful,
Thanks for Sharing...

05 Aug 2010 Mohamed Ali Alaswed  
29 Nov 2010 He Zhang

Very heuristical! Like it very much! Kiitos!

06 Dec 2010 Ronny Meza

Thanks a lot, very useful

03 Mar 2011 Stacy

Thanks for the code! The histograms came out great!

I was wondering if you might be able to clarify the text output. Given the text below, what do each of the #'s represent?

ans =

    0.9874 0.9751 0.9515

ans =

    1.8751

Drawing color cloud

ans =

    0.9874 0.9751 0.9515

ans =

    1.8751

  3.3805e+003

(I am looking to make judgements of similarity between color images and thought that this might be of use!)

Thanks!

06 Jun 2011 JASSEM ENIT

how apply this programm on gray image

Please login to add a comment or rating.
Updates
28 Jul 2010

Corrected url location

01 Aug 2010

Updated links

Tag Activity for this File
Tag Applied By Date/Time
color Chaitanya Sai Gaddam 22 Oct 2008 10:10:35
color histogram Chaitanya Sai Gaddam 22 Oct 2008 10:10:35
colour clourds Chaitanya Sai Gaddam 22 Oct 2008 10:10:35
3d array Chaitanya Sai Gaddam 22 Oct 2008 10:10:35
image processing Chaitanya Sai Gaddam 22 Oct 2008 10:10:35
3d Cristina McIntire 07 Nov 2008 12:48:37
color histogram bhaskar shankar 10 Feb 2009 23:14:35
3d array vinicio pelino 15 Jul 2009 23:18:48
3d array Reed Spencer 10 Sep 2009 09:36:13
potw Shari Freedman 30 Jul 2010 09:54:38
color histogram Research 14 Dec 2010 20:44:35
pick of the week Jiro Doke 11 Feb 2011 20:06:33
color histogram Roberto 22 Dec 2011 16:19:54

Contact us at files@mathworks.com