# I have three images that should have similar range of histogram is the rescaling a correct procedure?

1 view (last 30 days)
2NOR_Kh on 21 Aug 2022
Commented: Image Analyst on 27 Aug 2022
I have three images that should have similar range of histogram is the rescaling a correct procedure or there may be better solution?
I afraid of any lost of information in my images. Is there any better idea?

Bhavana Ravirala on 25 Aug 2022
Hi ,
For this, you can adjust the contrast of the image with the help of “imcontrast” tool. Or you can adjust the contrast by using different functions.
Refer to the below documentations to know more about the functions and “imcontrast” tool
Hope this helps!!
DGM on 26 Aug 2022
imadjust(), imcontrast(), and rescale() all do similar things. They have no awareness of spatial frequency. It is strictly a linear mapping of intensity values. When both input and output ranges are specified, the transformation is equivalent to:
outpict = (outmax-outmin)*(inpict-inmin)/(inrgmax-inmin) + outmin;
The histogram will simply be translated/stretched, but the general shape of the distribution won't change unless you specify an input range that forces truncation.
Using rescale(), you can either specify the output levels alone, and the input levels are implicitly specified by the image extrema:
y = rescale(x,outmin,outmax);
or you can specify both the output and input levels:
y = rescale(x,outmin,outmax'inputmin',inmin,'inputmax',inmax);
Using imadjust(), you can specify input levels and output levels explicitly:
... though imadjust expects those parameters to be normalized, and it expects the image to be correctly-scaled for its class. Rescale() does not.
Using imcontrast() only allows the adjustment of the input range, not the output range. Imcontrast() does the same thing as imadjust(), it's just less flexible. Its only unique ability is that it's a GUI tool.
If you're after something that's dependent on spatial frequency, or if you're after something that will reshape the distribution shown in the histogram, then that's a different story, and you might want to elaborate.

Image Analyst on 26 Aug 2022
Edited: Image Analyst on 26 Aug 2022
It really depends on what you want to achieve. Explain why you think you want all images to have a similar histogram. It might or might not be needed, depending on what your goal is. Also explain if you just want it for a visually pleasing and comparable display, or if you want to actually change the original pixel values into something different.
Plus we need to know why they're different in the first place. Should they be the same, but, for example, your camera automatically adjusts its parameters (so they're not the same for every photo), or your lighting flickers?
Image Analyst on 27 Aug 2022
What calculations? I can't imagine any calculations that you'd do that can't be done on the original 3 images.

Image Analyst on 26 Aug 2022
If (like @DGM mentioned) you're after something that will reshape the histograms to something custom, see my File Exchange program:
For example in the demo image below, I reshape the original histogram on the left to the silouhette of the woman as show on the right.
You can basically give any histogram you want, of any number of bins and any shape, and the process illustrated in the program will change the image such that the new histogram will have the number of bins and counts (shape) you specified.
##### 2 CommentsShowHide 1 older comment
Image Analyst on 27 Aug 2022
It gives no information. It's just a fun toy with no real world use. Sure you could use it to give a perfectly flat histogram if you wanted but most people know that perfectly flat histograms, which histogram equalization functions attempt to deliver but rarely do because they're too simple and not sophistcated enough, are not useful. Histogram equalized images are not needed for image analysis as far as I've ever seen in my 40+ years of image processing, and they tend to produce harsh, awful, unnatural looking images.
It's like my Maze solving algorithm (also in my File Exchange) - no real use and just for fun.

### Categories

Find more on Histograms in Help Center and File Exchange

R2021a

### Community Treasure Hunt

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

Start Hunting!

Translated by