A more gentle method for contrast enhancement is using imadjust
. In its default form, this function maps pixel values in the original image to new, altered values while ensuring that only a small percentage (1 percent) of the values are saturated at low and high intensities of the original image. This results in a smoother transformation that mostly enhances useful details. We can see the result of applying this method if we add some more lines to our previous script:
img = imread('my_image.bmp'); img_eq = histeq(img); img_adj = imadjust(img); subplot(2,3,1),imshow(img),title('Original Image'); subplot(2,3,2),imshow(img_eq),title('Equalized Image'); subplot(2,3,3),imshow(img_adj),title('Adjusted Intensity Image'); subplot(2,3,4),imhist(img,64),title('Original Image Histogram'); subplot(2,3,5),imhist(img_eq,64),title('Equalized Image Histogram'); subplot(2,3,6),imhist(img_adj,64),title('Adjusted Image Histogram');