normalize pixel intensity in matlab

One way to normalize the pixel intensity of an image in Matlab is by using the imadjust function. This function maps the intensity values of an image to a new range of values specified by the user.

Here's an example code that normalizes the pixel intensity of an image:

main.m
% Load the image
img = imread('image.jpg');

% Normalize the pixel intensity to range [0,1]
normalized_img = imadjust(img, [], [], 0.0, 1.0);

% Display the original and normalized images
figure;
subplot(1,2,1);
imshow(img);
title('Original image');
subplot(1,2,2);
imshow(normalized_img);
title('Normalized image');
317 chars
15 lines

In this example, imread is used to read the image from a file. Then, imadjust is used to normalize the pixel intensity values of the image. The [0.0, 1.0] range specifies that the minimum and maximum intensity values in the input image will be mapped to the minimum and maximum intensity values of the output image, respectively. The resulting normalized image is displayed using imshow.

Note that normalization can also be done by subtracting the mean of the pixel intensity values and dividing by the standard deviation, or using other techniques such as histogram equalization.

gistlibby LogSnag