Professional Documents
Culture Documents
Digital Image Processing Using Matlab: 1. Convert The Input Image Into Its Negative by Point Transformation
Digital Image Processing Using Matlab: 1. Convert The Input Image Into Its Negative by Point Transformation
a= imread('cameraman.tif');
L=256;
s=L-1-a;
imshow(s)
a=imread('cameraman.tif');
b=fft2(double(a));
bc=fftshift(b);
figure(1);
imshow(bc)
bc1=log(1+abs(bc));
figure(2);
imshow(bc1,[])
Note: log transform can also implemented using power law transform equation as
gamma=0.3 %should be less than 1
S=c.*(r+0.1)^gamma;
y=imread('cameraman.tif');
imview(y)
[m n] = size(y);
a=m/2;
b=n/2;
for k=1:8
for i=1:a
for j=1:b
y1(i,j)=y(i*2,j*2); % Downsampling - Shrinking
end
end
end
clear y;
y=y1;
figure;
imview(y1);
clear y1;
% Image Zooming
y=imread('cameraman.tif');
imview(y)
[m n] = size(y);
for k=1:4
for i=1:m
for j=1:n
y1(i*2,j*2)=y(i,j);
y1(i*2-1,j*2-1)=y1(i*2,j*2);
y1(i*2-1,j*2)=y1(i*2,j*2);
y1(i*2,j*2-1)=y1(i*2,j*2);
end
end
end
clear y;
y=y1;
figure;
imview(y1);
clear y1;
clear all
a=imread('cameraman.tif');
[m, n]=size(a);
for i=1:m
for j=1:n
if(((i>=35)&(i<110))&((j>90)&(j<140)))
d(i,j)=255;
e(i,j)=0;
else
d(i,j)=0;
e(i,j)=255;
end
end
end
imshow(d);title('AND Mask');
figure;
imshow(e);title('OR Mask');
f=bitand(uint8(a),uint8(d));
g=bitor(uint8(a),uint8(e));
figure;
imshow(f);title('ANDed Output');
figure;
imshow(g);title('ORed Output');
5.