You can manually increase the contrast of a grayscale image in Matlab by adjusting the intensity values of the pixels using the imadjust
function. Here's an example code snippet that increases the contrast of a grayscale image by a factor of 2 using imadjust
:
main.m359 chars13 lines
In the above code, we first read the grayscale image using imread
. Then, we convert the image to double precision format and scale the pixel intensities to the range [0, 1]. We then call imadjust
with the input grayscale image im
, an empty array for the low and high intensity values (so that they are automatically determined), and a contrast factor of 2. This returns the adjusted grayscale image im_adj
. Finally, we display the original and adjusted images side by side using imshow
and subplot
.
gistlibby LogSnag