Tuesday, June 24, 2008

Assignment 8 - Question # 2

Question #2

The nearest neighbor approximation

function[B]=increase2v(A,f)
A=double(A)/255;
m=size(A,1);n=size(A,2);
p=floor(f*m);
q=floor(f*n);
for i=0:p-1;
for j=0:q-1;
a=round(i/f);
b=round(j/f);
if ((a<=m-1)&(b<=n-1))
B(i+1,j+1,:)=A(a+1,b+1,:);
end
end
end

commands for pictures:

A=imread('bittersweet.jpg');
B=decrease2(A,.75);
>> C=increase2v(B,4/3);
>> image(C)
>> image(255*C)

size(A)

ans =

107 160 3

>> size(B)

ans =

80 120 3
size(C)

ans =

106 160 3




















A=imread('bittersweet.jpg');
>> B=decrease2(A,.25);
>> C=increase2v(B,1/.25);
>> image(C)
>> image(255*C)
>> size(A)

ans =

107 160 3

>> size(B)

ans =

26 40 3

>> size(C)

ans =

102 158 3

















>> A=imread('bittersweet.jpg');
>> B=decrease2(A,.1);
>> C=increase2v(B,1/.1);
>> image(C);
>> image(255*C)
>> size(A)

ans =

107 160 3

>> size(B)

ans =

10 16 3

>> size(C)

ans =

95 155 3





No comments: