Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(a) Read a JPG image into Matlab, display that image with the imshow function. (

ID: 3561226 • Letter: #

Question

(a) Read a JPG image into Matlab, display that image with the imshow function.
(b) Decrease the red and green color values in the image to one-half the original values, and display the
modified image.
(c) Plot, using the plot function, the three original color values vs. horizontal position across your
image at some vertical location in the image that you pick. The colors on the lines in the plot should
match the color value being plotted.

i am having trouble with problem (c)

what i have got so fat is

x=imread(image);
figure(1);
imshow(x)
title('original image')
[r, c, p]=size(x);
z=0.5*(x(r,c));
xred=x;
xred(:,:,1)=z;
xred(:,:,2)=z;
figure(2)
xcomp = xred;
imshow(xcomp)
title('half of red and green with normal blue')

Explanation / Answer

c)

function(Vertical_axis)%vertical_axis is the position of vertical row

[r c p]=size(x);%p will be 3 as it is colored

Horizontal_axis=[1:c];

red_values=x(Vertical_axis,:,1);

green_values=x(Vertical_axis,:,2);

blue_values=x(Vertical_axis,:,3);

figure(1);

plot(Horizontal_axis,red_values);

figure(2);

plot(Horizontal_axis,green_values);

figure(3);

plot(Horizontal_axis,blue_values);