Aim:- Histogram Stretching
MSc Computer Science Image Processing Practical No. 14
Index of all Practicals ~ Click Here
Code:- Hist_Stretch.m
Output:-
MSc Computer Science Image Processing Practical No. 14
Index of all Practicals ~ Click Here
Code:- Hist_Stretch.m
% **** HISTOGRAM STRETCHING ****
a=imread('old imagelc.jpg');
aa=double(a);
[row col]=size(aa);
h=zeros(1,300);
rmax=(max(max(aa)));
rmin=(min(min(aa)));
slope=255/(rmax-rmin);
smin=0;
aa=aa+1;
for x=1:row
for y=1:col
c(x,y)=slope*(aa(x,y)-rmin)+smin;
end
end
for x=1:row
for y=1:col
%if aa(x,y)==0
% aa(x,y)=1;
t=aa(x,y);
h(t)=h(t)+1;
end
end
figure(1);
bar(h);
z=zeros(1,300);
for x=1:row
for y=1:col
%if aa(x,y)==0
% aa(x,y)=1;
p=round(c(x,y));
z(p)=z(p)+1;
end
end
end
figure(2);
bar(z);
figure(3);
imshow(uint8(c));
figure(4);
imshow(uint8(aa));
a=imread('old imagelc.jpg');
aa=double(a);
[row col]=size(aa);
h=zeros(1,300);
rmax=(max(max(aa)));
rmin=(min(min(aa)));
slope=255/(rmax-rmin);
smin=0;
aa=aa+1;
for x=1:row
for y=1:col
c(x,y)=slope*(aa(x,y)-rmin)+smin;
end
end
for x=1:row
for y=1:col
%if aa(x,y)==0
% aa(x,y)=1;
t=aa(x,y);
h(t)=h(t)+1;
end
end
figure(1);
bar(h);
z=zeros(1,300);
for x=1:row
for y=1:col
%if aa(x,y)==0
% aa(x,y)=1;
p=round(c(x,y));
z(p)=z(p)+1;
end
end
end
figure(2);
bar(z);
figure(3);
imshow(uint8(c));
figure(4);
imshow(uint8(aa));
Output:-
0 comments:
Confused? Feel free to ask
Post a Comment