Tuesday, June 10, 2008

Assignmet 8 Question 2

Enlarge the color images that you scaled down in assignment 7 using a factor of
1/f. Use the 'nearest neighbor' approximation.

function [largeimage] = enlargenn( picture, f )
picture=double(picture);
Mp = size(picture,1);
Np = size(picture,2);
largeimage(:,:,1)=zeros(f*Mp,f*Np);
largeimage(:,:,3)=zeros(f*Mp,f*Np);
largeimage(:,:,2)=zeros(f*Mp,f*Np);
for i = 1:(f*Mp);
for j = 1:(f*Np );
if (i/f < 1 && j/f < 1)
largeimage(i,j,:)=picture(1,1);
end
if ((i/f < 1) && (j/f >= 1))
largeimage(i,j,:)=picture(1,round(j/f),:);
end
if ((i/f >= 1) && (j/f < 1))
largeimage(i,j,:)=picture(round(i/f),1,:);
end
if ((i/f>=1) && (j/f>=1))
largeimage(i,j,:)=picture(round((i)/f),round((j)/f),:);
end
end;
end;

>> B = shrink3(bluelines,0.1);
>> imshow(enlargenn(B,10))
>> B = shrink3(bluelines,0.25);
>> imshow(enlargenn(B,4))
>> B = shrink3(bluelines,0.75);
>> imshow(enlargenn(B,4/3))






No comments: