I have three images that should have similar range of histogram is the rescaling a correct procedure?
Afficher commentaires plus anciens
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?
Réponses (3)
Bhavana Ravirala
le 25 Août 2022
1 vote
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!!
3 commentaires
DGM
le 25 Août 2022
imcontrast() only allows adjustment of the input range, but not the output range. It's only useful if the output range is the full nominal data range for the numeric class (e.g. [0 255] for uint8). If it's desired to adjust the image with range of [20 80] to an output range like [200 255] to match the other two, then imcontrast() won't work. imadjust() would work in either case.
Both tools do a simple linear transformation. Other than rounding error inherent to dealing with integer images, you shouldn't be losing information unless you select an input range that causes clipping.
2NOR_Kh
le 25 Août 2022
DGM
le 26 Août 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:
y = imadjust(x,[inmin inmax],[outmin outmax]);
... 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
le 26 Août 2022
Modifié(e) : Image Analyst
le 26 Août 2022
1 vote
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?
4 commentaires
2NOR_Kh
le 26 Août 2022
Image Analyst
le 26 Août 2022
Since it's just for visualizations purposes (not image analysis), I'd probably just call imadjust on all three images and then combine with cat, as long as they all have the same rough shape.
correctedImage1 = imadjust(image1);
correctedImage2 = imadjust(image2);
correctedImage3 = imadjust(image3);
% Combine into an RGB image.
compositeImage = cat(3, correctedImage1, correctedImage2, correctedImage3);
If their shapes are drastically different I'd probably scale the two darker ones, or just use imhistmatch to match the histograms. Use the brightest one as the reference to match the others to.
mean1 = mean2(image1)
mean2 = mean2(image1)
mean3 = mean2(image1)
if mean1 > mean2 && mean1 > mean3
refImage = image1;
elseif mean2 > mean1 && mean2 > mean3
refImage = image2;
else
refImage = image3;
end
correctedImage1 = imhistmatch(image1, refImage);
correctedImage2 = imhistmatch(image2, refImage);
correctedImage3 = imhistmatch(image3, refImage);
% Combine into an RGB image.
compositeImage = cat(3, correctedImage1, correctedImage2, correctedImage3);
2NOR_Kh
le 26 Août 2022
Image Analyst
le 27 Août 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
le 26 Août 2022
1 vote
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 commentaires
2NOR_Kh
le 26 Août 2022
Image Analyst
le 27 Août 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.
Catégories
En savoir plus sur Display 2-D Images dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



