Can I get code for contrast limited adaptive histogram equalisation (CLAHE)?

Answers (1)

If you have the Image Processing Toolbox, see the function adapthisteq.

6 Comments

but how to select parameters for adapthisteq specially for MRI images
You need to be specific as to what you're looking for. Steve's link provides some additional settings for adapthisteq.
I need to compute background model by following the sequence mentioned in a given paragraph
"To compute this background model all of the pixels in the image are histogrammed-namely, for each pixel its color intensity is placed in the proper bin of a preferred possible 256 intensity levels. This is preferably done for each of the red, green and blue (RGB) channels thus generating three separate histograms. Alternately, one histogram could be generated using some joint space representation of the channels. Once the histogram has been computed, a Gaussian distribution for each histogram is calculated to provide the mean pixel intensity of the background and the variance."
This is what I have done so far.Could you please assist me what am I suppose to do next and verify the code whether I am doing it right or not? Below is my code
rgbImage=imread('frame-10.jpg');
[rows columns numberOfColorBands] = size(rgbImage); col=256; for i=1:256
rhistogram(i)=0;
ghistogram(i)=0;
bhistogram(i)=0;
end
for i=1:rows
for j=1:columns
% this can also be done using rgbvalues=impixel(rgbImage,j,i);
%r=pixel(1);g=pixel(2);b=pixel(3);
r=rgbImage(i,j,1);
g=rgbImage(i,j,2);
b=rgbImage(i,j,3);
if r==0
r=256;
rhistogram(r)=rhistogram(r)+1;
else
rhistogram(r)=rhistogram(r)+1;
end
if g==0
g=256;
ghistogram(g)=ghistogram(g)+1;
else
ghistogram(g)=ghistogram(g)+1;
end
if b==0
b=256;
bhistogram(b)=bhistogram(g)+1;
else
bhistogram(b)=bhistogram(g)+1;
end
end
end
lastCol=rhistogram(col);
rhistogram=rhistogram(1:col-1);
rhistogram=[lastCol rhistogram];
lastCol=ghistogram(col);
ghistogram=ghistogram(1:col);
ghistogram=[lastCol ghistogram];
lastCol=bhistogram(col);
bhistogram=bhistogram(1:col-1);
bhistogram=[lastCol bhistogram];
imhist(rhistogram);
imhist(ghistogram);
imhist(bhistogram);
No, that last part is total nonsense. rhistogram(columns) is nothing special and may even be out of range if you have more columns than gray levels (e.g. 1280 columns but only 256 gray levels). Then to call imhist() on a histogram is useless. You don't take the histogram of a histogram. If you want the mean, just do it like I told you in your other post:
meanRedValue = mean2(rgbImage(:,:, 1));
meanGreenValue = mean2(rgbImage(:,:, 2));
meanBlueValue = mean2(rgbImage(:,:, 3));
Oh I am sorry these columns were not of image these columns were the columns of (any of the)histograms that I created. I mistakenly took 'columns' variable which was of image and I am doing this last this because of array index which does not start from 0 so if I get r or g or b value equal to zero i am placing it in last(256th) index of histogram and then placing that index in front at the end
Can you give me a complete code for this since I am completely blank now.I need to do this for couple of images not for a single image. I have lets say 10 images and I have to compute background model this way using all 10 images.

Sign in to comment.

Asked:

on 10 Jul 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!