How to normalise Image intensity?

Hi,
I have 2 picture of the same object taken on different time. There are intensity different between the 2 picture(minor changes in lighting condition.)
Is there a way for me to make both to have the same intensity? Eg, Im2's intensity follows Im1's intensity?
Im1:
Im2
Thanks

 Réponse acceptée

Dustin
Dustin le 3 Juil 2011

3 votes

Hi Kyle,
The method suggested by Sean de is fine to normalize the maximum intensity. However, it will not necessarily give you the same appearance for both images (due to the intensity distributions not definitely being scaled by a multiplicative factor).
I suggest you try the histogram transfer method in order to get a somewhat similar appearance. Something along the lines of:
b = histeq(b,imhist(a));
Cheers.

7 commentaires

Kyle
Kyle le 3 Juil 2011
Déplacé(e) : DGM le 5 Mar 2023
Thanks Dustin
I tried ur method with below code n i do get a good result. However my main problem havent solve yet. Since now after histogram transfer method, the intensity of both images are similar, Is there a way for me to detect the intensity change of nbz1 from its original image(bz1)? Then applied the intensity changes to an image.
Note: bz1 and az1 each is just part of 2 different image that partially contains same object.
%az1=im1;
%bz1=im2;
r=az1(:,:,1);
g=az1(:,:,2);
b=az1(:,:,3);
r2=bz1(:,:,1);
g2=bz1(:,:,2);
b2=bz1(:,:,3);
nr2 = histeq(r2,imhist(r));
ng2 = histeq(g2,imhist(g));
nb2 = histeq(b2,imhist(b));
nbz1(:,:,1)=nr2;
nbz1(:,:,2)=ng2;
nbz1(:,:,3)=nb2;
c3=[az1 nbz1];
figure, imshow(c3);
Dustin
Dustin le 4 Juil 2011
Déplacé(e) : DGM le 5 Mar 2023
I am not sure exactly what you mean by "applying the intensity change", but I think it would be something like this:
Using imhist, find the histograms of the original and modified images. Subtract the two histograms. This gives you a measure of how much the intensity has changed between the two images. For the new image, add this difference histogram to the image's histogram to get a new one, and use histeq to change the appearance of the image accordingly.
However, more often than not, you will not get a very good result as the histograms of the original images can be markedly different. If this is something like what you require, I suggest also looking at normalizing the differences in the histograms, or regarding them as percent changes in order to get a better appearance.
Kyle
Kyle le 4 Juil 2011
Déplacé(e) : DGM le 5 Mar 2023
Let's say i have 2 image image A and Image B. Then i crop part of image A and name it image az1 and crop part of image B and named it image bz1. Image az1 and image bz1 looks the same as they are the common object of both image A and image B, however both have different lighting intensity.
With the code above, we are able to make both intensity of image az1 and image bz1 same. So i'm wandering how can i calculate the intensity different of image bz1 and image nbz1(image bz1 with same intensity with image az1). After knowing the intensity difference between bz1 and nbz1. Subject image B to the intensity difference found earlier. So that image B would have same intensity with image A.
Dustin
Dustin le 4 Juil 2011
Déplacé(e) : DGM le 5 Mar 2023
OK, thanks for the detailed explanation.
The method you employ depends on what your objective is. If you want the entire images to appear similar, then you can just perform a histeq between A and B.
However, if you want only the common object to have the same intensity, then just use the histogram of az1 as the input to B in order to get the object with the same intensity in B.
If you want to do something else and require the procedure you describe, then the method I suggested above should be a good starting point for exploration.
It all depends on what the aim of your program is.
Kyle
Kyle le 5 Juil 2011
Déplacé(e) : DGM le 5 Mar 2023
Oic.
How do i find the percentage difference of the intensity between bz1 and nbz1?
after getting this percentage difference, let say 10% brighter. I need make Image B 10% brighter.
any matlab command that can help me do that?
Dustin
Dustin le 6 Juil 2011
Déplacé(e) : DGM le 5 Mar 2023
You need to find the difference in the intensity values in the histograms of each image. Then, this difference for each intensity level can be transferred to the histogram of the third image, and histogram equalization performed on that image with this histogram.
Basic arithmetic and histeq should let you solve your problem. Look at this for further information about histogram equalization:
http://en.wikipedia.org/wiki/Histogram_equalization
Farah Nadiah
Farah Nadiah le 2 Avr 2016
Déplacé(e) : DGM le 5 Mar 2023
Dustin..can i ask..how to subtract the two histogram that u mean in previous comment...can i have the coding thanx.. :)

Connectez-vous pour commenter.

Plus de réponses (2)

Sean de Wolski
Sean de Wolski le 1 Juil 2011
Inormalized = double(I)./double(max(I(:)));
Doing this to both will give them both the same maximum intensity (1).

1 commentaire

Kyle
Kyle le 2 Juil 2011
I try the code but the image still looks the same for me.
I uploaded the image,hope u can help me make both the images into same intensity.

Connectez-vous pour commenter.

Image Analyst
Image Analyst le 9 Juil 2011

1 vote

If you really want to match intensities of gray scale images, meaning that the histograms of the two images have EXACTLY the same histograms after transforming one image, then you need to look at my "Custom-shaped histogram" File Exchange submission: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 You could use this on each color channel independently for what will probably give very acceptable results.
If you want to match histograms of a color image, I direct you to the Grundland/Dodgson method: http://www.eyemaginary.com/Portfolio/ColorHistogramWarp.html

Community Treasure Hunt

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

Start Hunting!

Translated by