check if all inputs are are normalized in an image in matlab in matlab

To check if an input image is normalized, you can use the imhist function in Matlab to plot the histogram of the image. The histogram of a normalized image usually has an equal distribution of pixel values across the entire intensity range.

main.m
% Read image
img = imread('test.png');

% Convert to grayscale
gray_img = rgb2gray(img);

% Calculate histogram
histogram = imhist(gray_img);

% Plot histogram
plot(histogram);

% Find threshold for binarization
level = graythresh(gray_img);

% Binarize image using threshold
binarized_img = imbinarize(gray_img, level);

% Show original and binarized images side by side
imshowpair(img, binarized_img, 'montage');
415 chars
21 lines

If the histogram of the image has a relatively equal distribution of pixel values across the entire intensity range and the resulting binarized image shows clear distinction between the object and background, then the input image is most likely normalized.

gistlibby LogSnag