File Exchange

image thumbnail

Color Histogram of an RGB Image

version 1.4 (2.17 KB) by

computes color histogram of an RGB image, number of bins is user input and is same for R,G and B.

37 Downloads

Updated

View License

Computes color histogram of an RGB image, number of bins(for each color component) is user input and is same for R,G and B. The output histogram can be un-normalized, l1-normalized or l2-normalized. The functin can compute color histogram for an image for a patch also.

Comments and Ratings (10)

why it is nbins^3 long ?

Sagar Mahajan

@vijaya: If i understood your issue correctly, you are trying to cluster the rgb histograms. Which can be done using different clustering approaches. You can look from the simple K-means clustering. Many of clustering approaches are there in the literature like meanshift based, spectral etc. Most of them are implemented in MATLAB and you can get the codes in file-exchange.

Vijaya

Vijaya (view profile)

can u tell me how to cluster the features which i have extracted using ur rgbhist_fast program. i need to extract the rgb features for videos and need to cluster them. please help me with the code.

@Ibrahim
It seems, you have executed the function directly (without the input parameters 'I' ans 'nBins'). Can you please read an rgb image into a variable 'I' using 'imread' and pass it as the input argument. For example, H=rgbhist_fast(I,4); will give the histogram into a variable 'H'.

dear, when i tried this code it gives me error

??? Input argument "I" is undefined.

Error in ==> rgbhist_fast at 16
if (size(I, 3) ~= 3)

could you explain me why it happens

Tai Tran

Nikolay S.

Nikolay S. (view profile)

Good implementation- short and efficient. A little bit straight forward- implemented pixel-wise. Will be best for small images.

Vijaya

Vijaya (view profile)

sir can u tell me how to get the 32 dimensional RGB color histograms of an image in the range of [0,1] using matlab.help me with the code sir. please.

Updates

1.4

A new function 'rgbhist_fast.m' is added to the existing 'rgbhist.m' function. The new function is nearly four times faster.

1.1

Added the normalization option. The function can output un-normalized or l1-normalized or l2-normalized histogram.

MATLAB Release
MATLAB 7.11 (R2010b)
Acknowledgements

Inspired: RGB Image Histogram

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video