In MATLAB, the imadjust
function can be used to adjust the intensity values of an image to improve its contrast. Here is the basic syntax for using imadjust
:
main.m61 chars2 lines
I
is the input image.[low_in high_in]
specifies the range of pixel values in the input image that will be mapped to the output range [low_out high_out]
. By default, [low_in high_in]
is the minimum and maximum pixel values in I
.[low_out high_out]
specifies the desired range of output pixel values. By default, [low_out high_out]
is the minimum and maximum values that can be represented by the image's class.gamma
is an optional parameter that adjusts the shape of the intensity mapping function. A value of 1 (the default) means a linear mapping.Here is an example of using imadjust
to enhance the contrast of an image:
main.m93 chars4 lines
This code reads in the "cameraman.tif" image, sets the input intensity range to be from 0.3 to 0.7, and sets the output intensity range to be from 0 to 1. It then displays the original image and the adjusted image side-by-side for comparison using the imshowpair
function.
Note that imadjust
can be very useful for improving the visibility of details in an image, but it can also lead to loss of information or artifacts if used excessively. Always experiment with different intensity ranges and the gamma parameter to find the best settings for your particular image.
gistlibby LogSnag