View License

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

» Watch video

Highlights from
Color Histogram of an RGB Image

4.0 | 3 ratings Rate this file 62 Downloads (last 30 days) File Size: 2.17 KB File ID: #43630 Version: 1.4

Color Histogram of an RGB Image



25 Sep 2013 (Updated )

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

| Watch this File

File Information

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.


This file inspired Rgb Image Histogram.

MATLAB release MATLAB 7.11 (R2010b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (10)
02 Feb 2017 Sidra

Sidra (view profile)

Histogram of an RGB image

Comment only
26 Mar 2016 Srinivasan Raman

why it is nbins^3 long ?

Comment only
10 Feb 2015 Sagar Mahajan

21 Jan 2014 Konda Reddy Mopuri

@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.

Comment only
17 Jan 2014 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.

Comment only
28 Nov 2013 Konda Reddy Mopuri

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'.

Comment only
27 Nov 2013 Ibrahim Thorig

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

Comment only
27 Nov 2013 Tai Tran

18 Nov 2013 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.

13 Nov 2013 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 me with the code sir. please.

Comment only
10 Oct 2013 1.1

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

20 Nov 2013 1.4

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

Contact us