Note:-Write this code in Matlab
CODE
%contrast stretching of image
clf;
clc;
clear all;
close all;
i=imread('camera.bmp');
subplot(1,2,1);
imshow(i);
title('original image');
i=double(i);
r1=100;
r2=150;
s1=175;
s2=250;
MAX=255;
[r c]=size(i);
for x=1:c
for y=1:r
if(i(y,x) < r1)
i(y,x)=(i(y,x)*(s1/r1));
if(i(y,x) < r2)
i(y,x)= s1 + (i(y,x)-r1)*((s2-s1)/(r2-r1));
else
i(y,x)= s2 +((i(y,x)-r2)*((MAX-s2)/(MAX-r2)));
end
end
end
end
i=uint8(i);
subplot(1,2,2)
imshow(i);
title('Contrast stretching image');
No comments:
Post a Comment