B=imread('b+lambs.jpeg'); size(B) % B is 490 by 288 by 3. The 490 by 288 represents the number of pixels in % the photo % THink of B as having three layers of 490 by 288 grids. The first layer % represents the amount of red ( a number between 0 and 255) at each pixel, the second the amt. of green, % the third the amount of blue. Varying shades of red, green and blue mixed together %give all possible visible colors. image(B) % The following matrix C picks up the red levels at each pixel C=B(:,:,1); % Equal amounts of red,green,blue mixed together give gray. % By setting G's red, green, and blue components at a given pixel to the % same value we make the picture from G gray. In this case the darker the % gray the less red there is at that pixel in the original photo. G(:,:,1)=0.5*C; G(:,:,2)=C; G(:,:,3)=C; %The next line produces a new figure to put subsequent image in. figure(2) image(G) %Instructions : repeat the above to produce a gray picture representing the %level of green in the original. %Instructions : repeat the above to produce a gray picture representing the %level of blue in the original. %The following shows the negative of the original picture G(:,:,1)=255-B(:,:,1); G(:,:,2)=255-B(:,:,2); G(:,:,3)=255-B(:,:,3); figure(5) image(G) %Instructions: Double the blue in the top 30 lines of the original %Instructions: Add 50 to the red in the lower right hand corner %Instructions: Pick up only certain pixels-every fifth row, every third %column, display result %Instructions: Ask the user to enter the value of the upper left hand %and lower right hand corner of the box they want to crop of the original; %display cropped picture %Instructions: Ask the user top enter the value of the upper left hand %and lower right hand corner of the box they want to manipulate of the original % and the percentage they want to fade the original by; %display faded picture %The following draws a red square in the upper left hand of the black box. %Instructions modify to draw four boxes of different colors P=zeros(100,100,'uint8'); Q(:,:,1)=P; Q(:,:,2)=P; Q(:,:,3)=P; Q([1:50],[1:50], 1)=255; figure(6) image(Q); H0(:,:,1)=Q(:,:,1); H0(:,:,2)=Q(:,:,1); H0(:,:,3)=Q(:,:,1); figure(8) image(H0) %Z is an array of means of the values in the red columns of B Z=mean(B(:,:,1)); n=length(Z) figure(7) plot([1:n],Z,'r') hold on a=mean(Z);%mean of the means b=a*ones(1,n); plot([1:n],b) hold off %Instructions: creat graphs of the mean of the values in the green columns, %the blue columns