You are on page 1of 2

DIGITAL IMAGE PROCESSING LAB 2

AIM:
Write a generalised function called normalisation any colored or gray image
to perform image to perform image normalisation of following types.
a) Pixel Normalisation
b) Pixel Centering
c) Pixel standardization
SOFTWARE USED:
MATLAB
CODE:
C=imread("lena.jpg");
imshow(C);
D=double(im2gray(C));
pixelnorm = normalise(D);
minmax1 = minmax(pixelnorm);
M = mean2(D);

pixelcentring = centering(D,M);
standard = std2(pixelcentring);
pixstandard = standardising(pixelcentring,standard);
stdpix = std2(pixstandard);
meanpix = mean2(pixstandard);
meancentring = mean2(pixelcentring);

disp("min and maximum values of normalised pixel matrix")


disp(minmax1);
disp("mean of pixel centering matrix" )
disp(meancentring);
disp("mean pixel standardising matrix" )
disp(meanpix);
disp("variance of pixel standardising matrix" )
disp(stdpix);

function [m] = standardising(d,standarddev)


x = size(d);
for i=1:x(1)
for j=1:x(2)
d(i,j)= d(i,j)/standarddev;
end
end
m = d;
end
function [m] = centering(d,mean1)
x = size(d);
for i=1:x(1)
for j=1:x(2)
d(i,j)= d(i,j)-mean1;
end
end
m = d;
end
function [m] = normalise(d)
x = size(d);
[min,max] = minmax(d);
for i=1:x(1)
for j=1:x(2)
d(i,j)= (d(i,j)-min)/(max-min);
end
end
m = d;
DIGITAL IMAGE PROCESSING LAB 2
end
function [min,max] = minmax(d)
x = size(d);
min =256;
max =0;
for i=1:x(1)
for j=1:x(2)
if d(i,j) < min
min = d(i,j);
end
if d(i,j) > max
max = d(i,j);
end
end
end
end

RESULT:

min and maximum values of normalised pixel matrix = MIN= 0,MAX = 1

mean of pixel centering matrix = 4.6699e-13

mean pixel standardising matrix = 7.8574e-16

variance of pixel standardising matrix =1.0000

workspace:

CONCLUSION:
This MATLAB experiment processes the Lena image by normalizing, centering,
and standardizing its pixel values. The normalized pixel matrix exhibits
values between 0 and 1. Centering involves subtracting the mean, while
standardizing involves dividing by the standard deviation. The experiment
outputs statistics such as the min and max values of the normalized matrix,
mean of the centered matrix, mean and variance of the standardized matrix.
These transformations are fundamental in image processing for enhancing
comparability and statistical analysis of pixel values.

You might also like