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)
Tuesday, July 1, 2008
Photomosaic (4)
I did not have time to look at the results of checking the average colour, so I shrunk a couple more pictures, since today my computer was not as bad as usual
A1=imread('bllue3.jpg');
image(A1)
size(A1)
T1=decrease4(A1,15/160,15.67/107);
image(T1), axis off
A2=imread('blue 4.jpg');
T2=decrease4(A2,15.42857/104,15/160);
image(T2), axis off
A3=imread('blue 4.jpg');
T3=decrease4(A2,17/115,14.31/149);
image(T3), axis off
A4=imread('bluish.jpg');
T4=decrease4(A4,15.13/107,15/160);
B4=average(T4)
A5=imread('brown 2.jpg');
T5=decrease4(A5,15/120,15/160);
average(T5)
A6=imread('brownish.jpg');
T6=decrease4(A6,15/160,15.67/107);
A7=imread('czerwony1.jpg');
T7=decrease4(A7,15.13/107,15/160);
average(T7)
A8=imread('dark blue.jpg');
T8=decrease4(A8,15/133,15/89);
average(T8)
A9=imread('dark emerald.jpg');
T9=decrease4(A9,15/96,15/137);
average(T9)
A10=imread('dark green.jpg');
T10=decrease4(A10,15/160,15/114);
A11=imread('emerald dark.jpg');
T11=decrease4(A11,15/132,15/99);
average(T11)
A12=imread('fiolet 1.jpg');
T12=decrease4(A12,15/92,15/123);
A13=imread('fiolet.jpg');
T13=decrease4(A13,15/116,15/116);
A14=imread('fiolet3.jpg');
T14=decrease4(A14,15.357/103,15/137);
A15=imread('fuisha lite.jpg');
T15=decrease4(A15,15/113,15/150);
A16=imread('fuisha.jpg');
T16=decrease4(A16,15.64/107,15/160);
A17=imread('gray.jpg');
T17=decrease4(A17,15.64/107,15/160);
A18=imread('gray1.jpg');
T18=decrease4(A18,15.64/107,15/160);
A19=imread('jasna zielen.jpg');
T19=decrease4(A19,15/148,15/160);
A20=imread('niebieski1.jpg');
T20=decrease4(A20,15/533,15/768);
A21=imread('onion.jpg');
T21=decrease4(A21,15/603,15/640);
A22=imread('orange fish.jpg');
T22=decrease4(A22,15/475,15/605);
A23=imread('pale yellow.jpg');
T23=decrease4(A23,15/113,15/150);
A24=imread('purple-red.jpg');
T24=decrease4(A24,15.13/107,15/160);
A25=imread('warm green.jpg');
T25=decrease4(A25,15.85/110,15/160);
A26=imread('white.jpg');
T26=decrease4(A26,15/114,15/143);
A28=imread('yellow1.jpg');
T28=decrease4(A28,15/90,15/135);
A29=imread('zielen srednia.jpg');
T29=decrease4(A28,15/114,15/146);
Well, now I have to somehow put my tiles on the big picture.(?)
Monday, June 30, 2008
Photomosaic (3)
A=imread('flower.jpg');
>> image(A);
size(A)
ans =
600 400 3
>> B=decrease4(A,20/600,20/400);
image(B)
size(B)
ans =
20 20 3
>> B=255*B;
C=floor(B/86)*86+42;
image(double(C)/255)
I tried to decrease the size of my image to 20x20, but it did not look good.
So I stayed with 40x40.
B=decrease4(A,40/600,40/400);
image(B)
size(B)
ans =
40 40 3
>> image(B)
>>
>>
>> B=255*B;
C=floor(B/86)*86+42;
image(double(C)/255)
>> D=increase2v(C,15);
>> image(D)
Above my 27 colours.
Sunday, June 29, 2008
Photomosaic (2)
PROJECT- PHOTOMOSAIC
Tuesday, June 24, 2008
Assignment # 8, question 4 and 5 (finished)
If we enlarge an image beyond its original size, GIMP calculates the missing pixels by interpolation, but it does not add any new detail. The more an image is enlarged, the more blurred it becomes. The appearance of an enlarged image depends upon the interpolation method we choose.
To change the image size, either some pixels have to be removed or new pixels must be added. The process you use determines the quality of the result. The Interpolation drop down list provides a selection of available methods of interpolating the color of pixels in a scaled image:
Interpolation
• None: No interpolation is used. Pixels are simply enlarged or removed, as they are when zooming. This method is low quality, but very fast.
• Linear: This method is relatively fast, but still provides fairly good results.
• Cubic: The method that produces the best results, but also the slowest method.
Sinc (Lanczos 3): New with GIMP-2.4, this method gives less blur in important resizings.
http://docs.gimp.org/en/gimp-image-scale.html
Question # 5
>> A=imread('Start.jpg');
>> B=decrease2(A,.8);
C=decrease2(A,.6);
D=decrease2(A,.4);
E=decrease2(A,.2);
>>
>> size(A)
ans =
512 768 3
>> size(B)
ans =
409 614 3
>> size(C)
ans =
307 460 3
>> size(D)
ans =
204 307 3
>> size(D)
ans =
204 307 3
>> B=255*B;
C=255*C;
D=255*D;
E=255*E;
A(52:size(B,1)+(52-1),77:size(B,2)+(77-1),:)=B;
A(52*2:size(C,1)+(52*2-1),77*2:size(C,2)+(77*2-1),:)=C;
A(52*3:size(D,1)+(52*3-1),77*3:size(D,2)+(77*3-1),:)=D;
A(52*4:size(E,1)+(52*4-1),77*4:size(E,2)+(77*4-1),:)=E;
image(A)
Assignment 8, question # 3
We may use the same function that we used in assignment #7:
function[B]=increase3(A,f)
A=double(A)/255
p=floor(size(A,1)*f);
q=floor(size(A,2)*f);
for i=0:p-1
for j=0:q-1
c=i/f;
d=j/f;
r=floor(c);
s=floor(d);
if(r>0)&(r<256)&(s>0)&(s<256)
for k=1:3
B(i,j,k)=[1-c+r,c-r]*[A(r,s,k),A(r,s+1,k);
A(r+1,s,k),A(r+1,s+1,k)]*[1-d+s;d-s];
end
end
end
end
A=imread('toyboy.jpg.');
B=decrease3(A,.75);
C=increase(B,4/3);
> image(255*C)
>> size(A)
ans =
160 128 3
>> size(B)
ans =
119 95 3
>> size(C)
ans =
157 125 3
Very similar codes for 2 other pictures.
Assignment 8 - 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
Sunday, June 15, 2008
Assignment # 10
unswirled
The code:
function[B]= unswirl(inpic,r,gamma)
inpic=double(inpic)/255;
cx=size(inpic,1)/2;
cy =size(inpic,2)/2;
for x=1:size(inpic,1)
for y=1:size(inpic,2)
d=sqrt((x-cx)^2+(y-cy)^2);
if ((d>r)|(d&gl1))
B(x,y,:)=inpic(x,y,:);
else
if (y>cy)
theta=acos((x-cx)/d);
else
theta=-acos((x-cx)/d);
end
fr=(d/r)^2*(1-d/r)^2*16;
newx=d*cos(theta+gamma*fr)+cx
newy=d*sin(theta+gamma*fr)+cy
ro=floor(newx);
s=floor(newy);
for k=1:3
B(x,y,k)=[1-newx+ro,newx-ro]*[inpic(ro,s,k),inpic(ro,s+1,k);inpic(ro+1,s,k),inpic(ro+1,s+1,k)]*[1-newy+s;newy-s];
end
end
end
end
end
inpic=imread('swirled1.jpg');
image(unswirl(inpic,180,(-3*pi))
Second image:
Code:
function[B]= unswirl(inpic,r,gamma)
inpic=double(inpic);
cx=size(inpic,1)/2;
cy =size(inpic,2)/2;
for x=1:size(inpic,1)
for y=1:size(inpic,2)
d=sqrt((x-cx)^2+(y-cy)^2);
if ((d>r)|(d&gl1))
B(x,y)=inpic(x,y);
else
if (y>cy)
theta=acos((x-cx)/d);
else
theta=-acos((x-cx)/d);
end
fr=(d/r)^2*(1-d/r)^2*16;
newx=d*cos(theta+gamma*fr)+cx
newy=d*sin(theta+gamma*fr)+cy
ro=floor(newx);
s=floor(newy);
B(x,y)=[1-newx+ro,newx-ro]*[inpic(ro,s),inpic(ro,s+1);
inpic(ro+,s),inpic(ro+1,s+1)]*[1-newy+s;newy-s];
end
end
end
inpic=imread('swirled # 2.jpg');
colormap(gray(256));
image(unswirl2(inpic,150,(3*pi)))
Saturday, June 14, 2008
Assignment # 7 - part two (finished)
images using method 3
Method 1- average over all pixels in the destination point:
Code:
function [B]=decrease1(A,f)
A=double(A)/255;
p=floor(size(A,1)*f);
q=floor(size(A,2)*f);
for i=1:3 B(:,:,i)=zeros(p,q);
end
for i=0:p-1
for j=0:q-1
for x=floor(i/f):ceil((i+1)/f)-1
for y=floor(j/f):ceil((j+1)/f)-1
ival=A(x+1,y+1,:);
if (x<i/f) ival=ival*(1+x-i/f);
end
if(x+1>(i+1)/f) ival=ival*(1-(x+1)+(i+1)/f);
end
if(y<j/f) ival=ival*(1+y-j/f);
end
if (y+1>(j+1)/f) ival =ival*(1-(y+1)+(j+1)/f);
end
B(i+1,j+1,:)=B(i+1,j+1,:)+ival;
end
F=imread('raimbowfb.jpg');
image(decrease1(F,.75))
F=imread('raimbowfb.jpg');
image(decrease1(F,.25))
F=imread('raimbowfb.jpg');
image(decrease1(F,.1))
A=imread('bittersweet.jpg');
image(decrease1(A,.75))
>> A=imread('bittersweet.jpg');
image(decrease1(A,.25))
>> A=imread('bittersweet.jpg');
image(decrease1(A,.1)
F=imread('toyboy.jpg');
image(decrease1(F,.1))
>> F=imread('toyboy.jpg');
image(decrease1(F,.25))
For an image toyboy shrunk by a factor of.75, I had to change a second line of the code of the function:
function [B]=decrease1(A,f)
A=double(A)/256;
F=imread('toyboy.jpg');
image(decrease1(F,.75))
Method # 3
Bilinear interpolation of the larger image
Code:
function[B]=decrease3(A,f)
A=double(A)/255
p=floor(size(A,1)*f);
q=floor(size(A,2)*f);
for i=0:p-1
for j=0:q-1
c=i/f;
d=j/f;
r=floor(c);
s=floor(d);
if(r>0)&(r<256)&(s>0)&(s&lgt256)
for k=1:3
B(i,j,k)=[1-c+r,c-r]*[A(r,s,k),A(r,s+1,k);
A(r+1,s,k),A(r+1,s+1,k)]*[1-d+s;d-s];
end
end
end
end
A=imread('rainbowfb.jpg'
image(decrease3(A,.75))
image(decrease3(A,.25))
image(decrease3(A,.1))
A=imread('bittersweet.jpg');
image(decrease3(A,.75))
image(decrease3(A,.25))
image(decrease3(A,.1))
A=imread('toyboy.jpg');
image(decrease3(A,.75))
image(decrease3(A,.25))
image(decrease3(A,.1))
Pictures obtained using method 3- bilinear interpolation seem to be the most clear.
Wednesday, June 11, 2008
Assignment # 9
A=imread('bitter.jpg');
B=floor(A/64)*85;
image(B)
A=imread('toyboy.jpg');
>> B=floor(A/64)*85;
>> image(B)
Question # 3
> A=int16(imread('bitter.jpg'));
>> B=(A(:,:,1)+A(:,:,2)+A(:,:,3))/3;
>> colormap(gray(256));
>> image(B)
Question # 2
a) first option
A=imread('bittersweet.jpg');
>> B=floor((A+64)/128)*128;
>> image(B)
A=imread('toyboy.jpg');
>> B=floor((A+64)/128)*128;
>> image(B)
b) second option
A=imread('bittersweet.jpg');
B=floor(A/85)*128;
image(B)
Question # 4
A=int16(imread('bittersweet.jpg'));
B=(A(:,:,1)+A(:,:,2)+A(:,:,3))/3;
C=floor(B/4)*4;
>> colormap(gray(256));
>> image(C)
A=int16(imread('toyboy.jpg'));
>> B=(A(:,:,1)+A(:,:,2)+A(:,:,3))/3;
C=floor(B/4)*4;
colormap(gray(256));
image(C)
Question # 5
A=int16(imread('toyboy.jpg'));
>> B=(A(:,:,1)+A(:,:,2)+A(:,:,3))/3;
C=floor(B/16)*16;
colormap(gray(256));
image(C)
A=int16(imread('.jpg'));
>> B=(A(:,:,1)+A(:,:,2)+A(:,:,3))/3;
C=floor(B/16)*16;
colormap(gray(256));
image(C)
Assignment #8
Code for shrinking x and y by different factors(average over all pixels in the destination point)
function [B]=decrease4(A,f1,f2)
A=double(A)/255;
p=floor(size(A,1)*f1);
q=floor(size(A,2)*f2);
for i=1:3 B(:,:,i)=zeros(p,q);
end
for i=0:p-1
for j=0:q-1
for x=floor(i/f1):ceil((i+1)/f1)-1
for y=floor(j/f2):ceil((j+1)/f2)-1
ival=A(x+1,y+1,:);
if (x<i/f1) ival=ival*(1+x-i/f1);
end
if(x+1>(i+1)/f1) ival=ival*(1-(x+1)+(i+1)/f1);
end
if(y<j/f2) ival=ival*(1+y-j/f2);
end
if (y+1>(j+1)/f2) ival =ival*(1-(y+1)+(j+1)/f2);
end
B(i+1,j+1,:)=B(i+1,j+1,:)+ival;
end
end
B(i+1,j+1,:)=B(i+1,j+1,:)/(1/f1)/(1/f2);
end
end
A=imread('bittersweet.jpg');
>> image(decrease4(A,1,.5))
a) f1=1, f2=.5
b)f1=.5, f2=1
c) f1=.2 f2=.8
Tuesday, June 10, 2008
Assignment #7 -part one
Function:( in Matlab, thanks to Violetta)
function[B]=decrease2(A,f)
A=double(A)/255;
p=floor(size(A,1)*f);
q=floor(size(A,2)*f);
for i=1:p
for j=1:q
a= round(i/f); b=round(j/f);
B(i,j,:)=A(a,b,:);
end
end
A=imread('rainbowfb.jpg');
>> image(decrease2(A,.75))
A=imread('rainbowfb.jpg');
image(decrease2(A,.25))
A=imread('rainbowfb.jpg');
image(decrease2(A,.1))
f=0.1
A=imread('bittersweet.jpg');
image(decrease2(A,.25))
image(decrease2(A,.75))
image(decrease2(A,.25))
image(decrease2(A,.1))
Sunday, June 1, 2008
ASSIGNMENT # 6
bigT=255*ones(256);
bigT(30:79,64:191)=zeros(50,128);
bigT(50:199,111:146)=zeros(150,36);
bigT1=ones(256);
for x=1:256
for y =1:256
u=x*cos(3*pi/4)+y*sin(3*pi/4);
v=-x*sin(3*pi/4)+y*cos(3*pi/4);
a=u; b=mod(v-u,256)+1;
r=floor(a);s=floor(b);
if((r>0)&(r,256)&(s>0)&(s<256))>
endif
endfor
endfor
imshow(bigT1/255);
imshow(double(bigT1)/255)
#3
a)
compute the average colour for R = ones(100), G= tril(ones (100)0, B=zeros(100);
A(:,:,1)=ones(100);
A(:,:,2)=tril(ones(100));
A(:,:,3)=zeros(100);
B=255*A;
imshow(B)
To get the average colour:
A(:,:,1)=ones(100);
A(:,:,2)=tril(ones(100));
A(:,:,3)=zeros(100);
B=255*A;
size(A)
sum(sum(A))/100/100
C(:,:,1)=1*ones(100);
C(:,:,2)=0.50500*ones(100);
C(:,:,3)=zeros(100);
imshow(C)
images:
b) the rainbow picture we made in assignment #4
pkg load image;
cd C:\;
A=imread(“rainbow.jpg”);
imshow(double(A)/255)
size (A)
sum(sum(A))/(303*376)
B(:,:,1)=221.79*(ones(256));
B(:,:,2)=220.09*(ones(256));
B(:,:,3)=213.46*(ones(256));
imshow(B)
c)
pkg load image;
cd C:\;
A=imread(“biter.jpg”);
imshow(double(A)/255)
'
size (A)
ans =
107 160 3
sum(sum(A))/(107*160)
ans(:,:,1) = 82.482
ans(:,:,2) = 98.460
ans(:,:,3) = 14.894
ans/256
B=ones(256);
B(:,:,1) = 0.32346*ones(256);
B(:,:,2) = 0.38612*ones(256);
B(:,:,3) = 0.058407*ones(256);
imshow(B)
The average colour is the "mixed" green of all greens of this picture.
d)
pkg load image;
cd C:\;
A=imread("toyboy.jpg");
size(A)
ans =
160 128 3
sum(sum(A))/(160*128)
ans =
ans(:,:,1) = 30.857
ans(:,:,2) = 46.076
ans(:,:,3) = 62.843
ans/256
ans =
ans(:,:,1) = 0.12054
ans(:,:,2) = 0.17998
ans(:,:,3) = 0.24548
C=ones(256);
C(:,:,1)=0.12054*ones(256);
C(:,:,2)=0.17998*ones(256);
C(:,:,3)=0.24548*ones(256);
imshow(C)
The average colour is the mixture of "blues" in this picture.
#2