Monday, 2 June 2014

Geometrical transformation of images


Geometrical transformation of images


close all
clear all
a=imread('cameraman.tif');
b=imrotate(a,-30,'bilinear','crop');
imshow(a);
figure,imshow(b);

Image Scaling

b=imrotate(a,-3,'bilinear','crop');
>> imshow(a);
>> figure,imshow(b);
>> [m,n]=size(a);
>> i=0.5;
>> c=imresize(a,[m*i n/i]);
>> figure,imshow(c);


Interpolation

a=imread('cameraman.tif');
[x y]=meshgrid(1:256,1:256);
t=pi/4;
for i=1:256
    for j=1:256
x1(i,j)=cos(t)*x(i,j)+sin(t)*y(i,j);
y1(i,j)=sin(t)*x(i,j)+cos(t)*y(i,j);
end;
end
z=interp2(x,y,a,x1,y1,'cubic');


Sampling rate:

f=ind2gray(a,gray(256));
>> f1=imresize(f,0.2);
>> figure,imshow(f1);
>>  f2=imresize(f1,5);
>> figure,imshow(f2);
imhist(f);


Add noise to an image and median filter is used to remove the noise

f=ind2gray(a,gray(256));
f1=imnoise(f,'salt & pepper',0.05);
f2=medfilt2(f1,[3 3]);
figure; imshow(f);
figure; imshow(f1);
figure; imshow(f2);

No comments:

Post a Comment