2. Create a 256x256 matrix with 1s in the (i, i+1) position and zeros elsewhere using the functions tril(M,k) and triu (M,k).
Octave command:
tril(ones(9),1) - tril(ones(9),0)
ans =
or...
triu(ones(9),1) - triu(ones(9),2)
ans =
3.a) A(:,:,1)=255*ones(100);
A(:,:,2)=255*tril(ones(100));
A(:,:,3)=zeros(100);
imshow(A);
B=double(A)/255;
size(B)
{answer: ans = 100 100 3}
sum(sum(B))/(100*100)
{answer: ans(:,:,1)=1}
ans(:,:,2)=0.505
ans(:,:,3)=0
B=ones(100);
B(:,:,1)=ones(100);
B(:,:,2)=0.505*ones(100);
B(:,:,3)=zeros(100);
imshow(B);
As a result, this is the average colour.
c)Pic 1
A=imread("cocochanel.jpg");
B=double(A)/255;
size(B)
{ans. 74 150 3}
sum(sum(B))/(74*150)
{ans. ans(:,:,1)=0.64490}
ans(:,:,2)=0.54085
ans(:,:,3)=0.63316
C=ones(256);
C(:,:,1)=0.64490*ones(256);
C(:,:,2)=0.54085*ones(256);
C(:,:,3)=0.63316*ones(256);
imshow(C);
This picture's average colour is...
Pic 2
A=imread("recycle.jpg");
B=double(A)/255;
size(B)
{ans. 153 104 3}
sum(sum(B))/(153*104)
{ans. ans(:,:,1)=0.052669}
ans(:,:,2)=0.32379
ans(:,:,3)=0.28915
C=ones(256);
C(:,:,1)=0.052669*ones(256);
C(:,:,2)=0.32379*ones(256);
C(:,:,3)=0.28915*ones(256);
imshow(C);
This picture's average colour is ...
Subscribe to:
Post Comments (Atom)
3 comments:
the average color paint chip is missing for this second picture.
oh and your average color can't be right for the red/yellow picture.
Thanks Mike! I corrected the mistakes. For the average colour of red/yellow, I didn't use the command B=double(A)/255.
Post a Comment