
This is my picture 2 in the centre and on the right corner is its average color.

The code for the average color of picture 2isas follows:
octave-3.0.1.exe:39> cd c:\
octave-3.0.1.exe:40> G=imread("p2.jpg");
octave-3.0.1.exe:41> H=double(G)/255;
octave-3.0.1.exe:42> size(H)
ans =
640 480 3
octave-3.0.1.exe:43> averagecolor=sum(sum(H))/(640*480)
averagecolor =
ans(:,:,1) = 0.31509
ans(:,:,2) = 0.38258
ans(:,:,3) = 0.20739
octave-3.0.1.exe:44> I=ones(256);
octave-3.0.1.exe:45> I(:,:,1)=0.31509*ones(256);
octave-3.0.1.exe:46> I(:,:,2)=0.38258*ones(256);
octave-3.0.1.exe:47> I(:,:,3)=0.20739*ones(256);
octave-3.0.1.exe:48> cd c:\users\public\documents
octave-3.0.1.exe:49> imwrite("p2out.jpg",I(:,:,1),I(:,:,2),I(:,:,3));
No comments:
Post a Comment