Sunday, July 6, 2008

Photomosaic (FINAL)

















original image


















I divided my "big picture" into 40 tiles, 15x15 pixels each,and then assigned them according to the big picture's average colour(Jen's method).
I had difficulties running the program because function "increase" did not increase matris exactly to 600x600, although I checked the size of this matrix previously, and it was correct.I used the following function to check the average colour of my big picture:

function[B]= average(X)
B=sum(sum(X))/(size(X,1)*size(X,2));
end

This is the final code for my photomosaic:

A1=imread('stry night.jpg');
T1=decrease4(A1,15/124,15.67/124);
A2=imread('blue 4.jpg');
T2=decrease4(A2,15.42857/104,15/160);
A3=imread('128_214_214t3.jpg');
T3=decrease4(A3,15/115,15.64/149);
A4=imread('bluish.jpg');
T4=decrease4(A4,15.13/107,15/160);
A5=imread('214_42_128tt28.jpg');
T5=decrease4(A5,15/90,15/135);
A6=imread('czerwony1.jpg');
T6=decrease4(A6,15.13/107,15/160);
A7=imread('dark blue.jpg');
T7=decrease4(A7,15/133,15/89);
A8=imread('dark emerald.jpg');
T8=decrease4(A8,15/96,15/137);
A9=imread('42_128_42-t10.jpg');
T9=decrease4(A9,15/160,15/114);
A10=imread('-42,214,128-t11.jpg');
T10=decrease4(A10,15/132,15/99);
A11=imread('128_128_214t12.jpg');
T11=decrease4(A11,15/92,15/123);
A12=imread('128_42_214t13.jpg');
T12=decrease4(A12,15/116,15/116);
A13=imread('-42,42,214,t14.jpg');
T13=decrease4(A13,15.357/103,15/137);
A14=imread('fuisha lite.jpg');
T14=decrease4(A14,15/113,15/150);
A15=imread('128_42_128-t16.jpg');
T15=decrease4(A15,15.64/107,15/160);
A16=imread('gray.jpg');
T16=decrease4(A16,15.64/107,15/160);
A17=imread('jasna zielen.jpg');
T17=decrease4(A17,15/148,15/160);
A18=imread('42_214_214-t20.jpg');
T18=decrease4(A18,15/533,15/768);
A19=imread('onion zmienionyt21.jpg');
T19=decrease4(A19,15/603,15/640);
A20=imread('orange fish.jpg');
T20=decrease4(A20,15/475,15/605);
A21=imread('214_42_214t23.jpg');
T21=decrease4(A21,15/113,15/150);
A22=imread('purple-red.jpg');
T22=decrease4(A22,15.13/107,15/160);
A23=imread('warm green.jpg');
T23=decrease4(A23,15.85/110,15/160);
A24=imread('214_214_128t4.jpg');
T24=decrease4(A24,15/114,15/143);
A25=imread('zielen srednia.jpg');
T25=decrease4(A25,15/114,15/146);
A26=imread('128_214_128t30.jpg');
T26=decrease4(A26,15/160,15/114);
A27=imread('yellow glow.jpg');
T27=decrease4(A27,15/534,15/800);

% End of loading Images----------------


A=imread('flower.jpg');
B=decrease4(A,40/600,40/400);
B=255*B;
C=floor(B/86)* 86+42;
double(C)/255;
D=increase2v(C,15.175)
%image(D);

for i=0:39;
for j=0:39;
pixel=((average(D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)))*255);
pixel=floor(pixel/86)*86+42;
if pixel(:,:,1)==42 && pixel(:,:,2)==42&&pixel(:,:,3)==42
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T1;
end;
if pixel(:,:,1)==42 && pixel(:,:,2)==128&&pixel(:,:,3)==128
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T8;
end;
if pixel(:,:,1)==42 && pixel(:,:,2)==214&&pixel(:,:,3)==214
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T18;
end;
if pixel(:,:,1)==42 && pixel(:,:,2)==42&&pixel(:,:,3)==128
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T7;
end;
if pixel(:,:,1)==42 && pixel(:,:,2)==42&&pixel(:,:,3)==214
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T13;
end;
if pixel(:,:,1)==42 && pixel(:,:,2)==128&&pixel(:,:,3)==214
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T2;
end;
if pixel(:,:,1)==42 && pixel(:,:,2)==214&&pixel(:,:,3)==128
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T10;
end;
if pixel(:,:,1)==42 && pixel(:,:,2)==128&&pixel(:,:,3)==42
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T9;
end;
if pixel(:,:,1)==42 && pixel(:,:,2)==214&&pixel(:,:,3)==42
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T27;
end;
if pixel(:,:,1)==128 && pixel(:,:,2)==128&&pixel(:,:,3)==128
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T16;
end;
if pixel(:,:,1)==128 && pixel(:,:,2)==42&&pixel(:,:,3)==42
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T22;
end;
if pixel(:,:,1)==128 && pixel(:,:,2)==214&&pixel(:,:,3)==214
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T3;
end;
if pixel(:,:,1)==128 && pixel(:,:,2)==128&&pixel(:,:,3)==42
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T17;
end;
if pixel(:,:,1)==128 && pixel(:,:,2)==128&&pixel(:,:,3)==214
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T11;
end;
if pixel(:,:,1)==128 && pixel(:,:,2)==214&&pixel(:,:,3)==42
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T23;
end;
if pixel(:,:,1)==128 && pixel(:,:,2)==42&&pixel(:,:,3)==214
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T12;
end;
if pixel(:,:,1)==128 && pixel(:,:,2)==214&&pixel(:,:,3)==128
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T26;
end;
if pixel(:,:,1)==128 && pixel(:,:,2)==42&&pixel(:,:,3)==128
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T15;
end;
if pixel(:,:,1)==214 && pixel(:,:,2)==214&&pixel(:,:,3)==214
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T4;
end;
if pixel(:,:,1)==214 && pixel(:,:,2)==42&&pixel(:,:,3)==42
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T6;
end;
if pixel(:,:,1)==214 && pixel(:,:,2)==128&&pixel(:,:,3)==128
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T14;
end;
if pixel(:,:,1)==214 && pixel(:,:,2)==214&&pixel(:,:,3)==42
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T27;
end;
if pixel(:,:,1)==214 && pixel(:,:,2)==214&&pixel(:,:,3)==128
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T24;
end;
if pixel(:,:,1)==214 && pixel(:,:,2)==42&&pixel(:,:,3)==128
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T5;
end;
if pixel(:,:,1)==214 && pixel(:,:,2)==128&&pixel(:,:,3)==42
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T20;
end;
if pixel(:,:,1)==214 && pixel(:,:,2)==128&&pixel(:,:,3)==214
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T19;
end;
if pixel(:,:,1)==214 && pixel(:,:,2)==42&&pixel(:,:,3)==214
D((15*i+1):(15*i+15),(15*j+1):(15*j+15),:)=T21;
end;
end;
end;
image(D)

No comments: