Sunday, June 29, 2008
Sunday, June 15, 2008
Friday, June 13, 2008
Assignment 6 cont'd
3(c) Picture 2nd row 2nd column Picture from row 7 and column 2
pic1.jpg average color
Octave commands
pkg load image
cd t:\
a=imread("pic1.jpg")
sum(sum(a)) # yields
imshow(a)
size (a) #yields
160 107 3
sum(sum(a)) # yields
ans(:,:,1) = 1529983
ans(:,:,2) = 1729019
ans(:,:,3)= 1257798
b=sum(sum(a)/size(a)/size(a,1)/size(a,2);
ans(:,:,1)=89.368
ans(:,:,2)=100.99
ans(:,:,3) =73.470
for 1=1:3;average(:,:,i)=b(i)*ones(100);end;imshow(average)
pic1.jpg average color
Octave commands
pkg load image
cd t:\
a=imread("pic1.jpg")
sum(sum(a)) # yields
imshow(a)
size (a) #yields
160 107 3
sum(sum(a)) # yields
ans(:,:,1) = 1529983
ans(:,:,2) = 1729019
ans(:,:,3)= 1257798
b=sum(sum(a)/size(a)/size(a,1)/size(a,2);
ans(:,:,1)=89.368
ans(:,:,2)=100.99
ans(:,:,3) =73.470
for 1=1:3;average(:,:,i)=b(i)*ones(100);end;imshow(average)
6(c) Rainbow Picture
Sunday, June 8, 2008
Assignment 6
Q(1)
bigT=255*ones(256);
bigT(30:79,64:191)=zeros(50,128);
bigT(50:199,111:146)=zeros(150,36);
newmatrix=128*ones(256)
phi=(pi)/6;
for x=1:256;
for y=1:256;
u=x*cos(phi) - y*sin(phi);
v=x*sin(phi) + y*cos(phi);
up=mod(u,256) + 1;
vp=mod(v,256) + 1;
a=up;
b=mod(vp-1*up,256)+1;
r=floor(a);
s=floor(b);
if (r>0) and (r<256)>0) and (s<256);
mata=[1-a+r, a-r];
matb=[bigT(r,s), bigT(r,s+1); bigT((r+1),s),
bigT((r+1),(s+1))]; matc=[1-b+s;b-s]; newmatrix(x,y)=mata*matb*matc;
end;
end;
end;
imshow(newmatrix)
2 (a). Create a 256 x 256 matrix with 1s in the (i,i+1) position and zeros elsewhere: (Octave commands) >x=tril(ones(256),1);
>y=tril(ones(256),0);
>x-y #yields matrix with 1s in diagonal
for picture type imshow(ans) to get
>
An alternative method using the command "tril" for "lower triangle" of matrix is
x=[tril(ones(256,1))-tril(ones(256),0);
imshow(x)
ex for a 5 X 5 matrix----> x= [tril(ones(5,1)-tril(ones(5),0); yields
01000
00100
00010
00001
3a) R=ones(100);G=tril(ones(100));B=zeros(100);
x(:,:,1)=(ones(100));x(:,:,2)=tril(ones(100));x(:,:,3)=zeros(100);
imshow(x);
sum(sum(x))/100/100
Octave output
ans(:,:,1) = 1
ans(:,:,2) = 0.50500
ans(:,:,3) = 0
bigT=255*ones(256);
bigT(30:79,64:191)=zeros(50,128);
bigT(50:199,111:146)=zeros(150,36);
newmatrix=128*ones(256)
phi=(pi)/6;
for x=1:256;
for y=1:256;
u=x*cos(phi) - y*sin(phi);
v=x*sin(phi) + y*cos(phi);
up=mod(u,256) + 1;
vp=mod(v,256) + 1;
a=up;
b=mod(vp-1*up,256)+1;
r=floor(a);
s=floor(b);
if (r>0) and (r<256)>0) and (s<256);
mata=[1-a+r, a-r];
matb=[bigT(r,s), bigT(r,s+1); bigT((r+1),s),
bigT((r+1),(s+1))]; matc=[1-b+s;b-s]; newmatrix(x,y)=mata*matb*matc;
end;
end;
end;
imshow(newmatrix)
2 (a). Create a 256 x 256 matrix with 1s in the (i,i+1) position and zeros elsewhere: (Octave commands) >x=tril(ones(256),1);
>y=tril(ones(256),0);
>x-y #yields matrix with 1s in diagonal
for picture type imshow(ans) to get
>
An alternative method using the command "tril" for "lower triangle" of matrix is
x=[tril(ones(256,1))-tril(ones(256),0);
imshow(x)
ex for a 5 X 5 matrix----> x= [tril(ones(5,1)-tril(ones(5),0); yields
01000
00100
00010
00001
3a) R=ones(100);G=tril(ones(100));B=zeros(100);
x(:,:,1)=(ones(100));x(:,:,2)=tril(ones(100));x(:,:,3)=zeros(100);
imshow(x);
sum(sum(x))/100/100
Octave output
ans(:,:,1) = 1
ans(:,:,2) = 0.50500
ans(:,:,3) = 0
3(b) Images processing from www.pbase.com
My assigned images are pic1= 2nd row 2nd column, and pic2= 7th row, 2nd column
Both images saved in folder called "images" in my C drive
pkg load image;
cd'C:\images'
a=imread("pic1.jpg");
b= double(a)/255;
size(b)
Octave gives:
106 107 3
Subscribe to:
Posts (Atom)