how to manually increase screen contrast in greyscale image in matlab

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.m
% Read grayscale image
im = imread('grayscale_img.jpg');

% Scale pixel intensities to [0, 1] range
im = im2double(im);

% Increase contrast by a factor of 2
im_adj = imadjust(im, [], [], 2);

% Display original and adjusted images side by side
subplot(1, 2, 1); imshow(im); title('Original Image');
subplot(1, 2, 2); imshow(im_adj); title('Adjusted Image');
359 chars
13 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