Thursday, June 19, 2008

Assign 9, Q5 - And Photomosaic start...

Here we had to change spidey to a greyscale image with only 16 intensity values.

I thought that the image would be even more grainy...however the new 16 intensity values greyscale image had more detail. Perhaps because there are now less intensity values to choose from and so not much shading could take place but more detail in certain areas can now be seen.



The lessening of intensity values with grey scale images and the 'apparent increasing' of detail seems to work "in reverse" for colour images as can be noted in my comments of Assignment9 Question 1 (below).

Here is the start of my photomosaic...

I tried to use the spiderman image but when I shrunk it, reduced the colours, and enlarged it...the image was too distorted.



So I used a different picture...the ATARI icon.

Step 1:




step 2:




Step 3:



Step 4 & 5:

I used Photoshop to adjust the image size via pixels because I had to 'crop'/grap the 'small pictures' I wanted from a screen grab. I want to use the pac-man ghosts and ms. pac-man as my small pictures.












Here is part of my octave code:

# step 1 - shrink image - the size of the original is 200 by 200 pixels...

function [smallimage]=shrink2(pic,f);
Mp = floor(size(pic,1)*f);
Np = floor(size(pic,2)*f);
smallimage(:,:,1) = zeros(Mp-1,Np-1);
smallimage(:,:,2) = zeros(Mp-1,Np-1);
smallimage(:,:,3) = zeros(Mp-1,Np-1);
for i=0:(Mp-1);
for j=0:(Np-1);
a=floor((i/f)+1);
b=floor((j/f)+1);
if a 0 & a<(size(pic,1)) & b>0 & b<(size(pic,2));
smallimage(i+1,j+1,:)=pic(a,b,:);
end;
end;
end;
endfunction;

# To show image which was scaled down by factor f = 0.1, the resulting image will be 20 by 20 pixels.
A=imread("logo.png");
B=shrink2(A,.1);
C=double(B)/255;
imwrite("logo1.png",C(:,:,1),C(:,:,2),C(:,:,3))

# step 2 - reduce colour to 27...

A=imread("logo1.png");
B = floor(double(A)/86)*86+42;
imwrite("logo2.png",double(B)(:,:,1)/255, double(B)(:,:,2)/255, double(B)(:,:,3)/255);

# step 3 - enlarge...

function [smallimage]=enlarge(pic,f);
Mp = floor(size(pic,1)*f);
Np = floor(size(pic,2)*f);
smallimage(:,:,1) = zeros(Mp-1,Np-1);
smallimage(:,:,2) = zeros(Mp-1,Np-1);
smallimage(:,:,3) = zeros(Mp-1,Np-1);
for i=0:(Mp-1);
for j=0:(Np-1);
a=floor((i/f)+1);
b=floor((j/f)+1);
if a > 0 & a < (size(pic,1)) & b > 0 & b < (size(pic,2));
smallimage(i+1,j+1,:)=pic(a,b,:);
end;
end;
end;
endfunction;

A=imread("logo2.png");
B=enlarge(A,20);
C=double(B)/255;
imwrite("logo3.png",C(:,:,1),C(:,:,2),C(:,:,3));


# Put pixels in...

a=imread("logo3.png");
p=imread("pink.png");
r=imread("red.png");
y=imread("mspac.png");

# Pink...(column, row, :) pixel coords...

a(140:159,300:319,:)=p;
a(160:179,300:319,:)=p;
a(180:199,300:319,:)=p;
a(200:219,300:319,:)=p;

a(140:159,320:339,:)=p;
a(160:179,320:339,:)=p;
a(180:199,320:339,:)=p;
a(200:219,320:339,:)=p;



a(140:159,380:399,:)=p;
a(160:179,380:399,:)=p;
a(180:199,380:399,:)=p;
a(200:219,380:399,:)=p;

a(140:159,400:419,:)=p;
a(160:179,400:419,:)=p;
a(180:199,400:419,:)=p;
a(200:219,400:419,:)=p;

a(140:159,420:439,:)=p;
a(160:179,420:439,:)=p;
a(180:199,420:439,:)=p;
a(200:219,420:439,:)=p;



a(140:159,480:499,:)=p;
a(160:179,480:499,:)=p;
a(180:199,480:499,:)=p;
a(200:219,480:499,:)=p;

a(140:159,500:519,:)=p;
a(160:179,500:519,:)=p;
a(180:199,500:519,:)=p;
a(200:219,500:519,:)=p;


# red pixels coords...

a(80:99,300:319,:)=r;
a(80:99,320:339,:)=r;

a(80:99,380:399,:)=r;
a(80:99,400:419,:)=r;
a(80:99,420:439,:)=r;

a(80:99,480:499,:)=r;
a(80:99,500:519,:)=r;


# yellow pixels coords...

a(600:619,160:179,:)=y;
a(600:619,180:199,:)=y;
a(600:619,200:219,:)=y;
a(600:619,220:239,:)=y;
a(600:619,240:259,:)=y;

a(620:639,120:139,:)=y;
a(620:639,140:159,:)=y;
a(620:639,160:179,:)=y;
a(620:639,180:199,:)=y;
a(620:639,200:219,:)=y;
a(620:639,220:239,:)=y;

a(640:659,80:99,:)=y;
a(640:659,100:119,:)=y;
a(640:659,120:139,:)=y;
a(640:659,140:159,:)=y;
a(640:659,160:179,:)=y;
a(640:659,180:199,:)=y;
a(640:659,200:219,:)=y;


a(660:679,80:99,:)=y;
a(660:679,100:119,:)=y;
a(660:679,120:139,:)=y;
a(660:679,140:159,:)=y;
a(660:679,160:179,:)=y;
a(660:679,180:199,:)=y;


a(600:619,380:399,:)=y;
a(620:639,380:399,:)=y;
a(640:659,380:399,:)=y;
a(660:679,380:399,:)=y;

a(600:619,400:419,:)=y;
a(620:639,400:419,:)=y;
a(640:659,400:419,:)=y;
a(660:679,400:419,:)=y;

a(600:619,420:439,:)=y;
a(620:639,420:439,:)=y;
a(640:659,420:439,:)=y;
a(660:679,420:439,:)=y;


f=double(a)/255;
imwrite("atari5.png",f(:,:,1),f(:,:,2),f(:,:,3));

here is the resulting mosaic to date:

No comments: