Q:

Put a JPEG file in your Current Folder and use imread to load it into a matrix. Calculate and print the mean separately of the red, green, and blue components in the matrix

0

Put a JPEG file in your Current Folder and use imread to load it into a matrix. Calculate and print the mean separately of the red, green, and blue components in the matrix.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Ch13Ex10.m

im = imread('photo1.jpg');

[r c d] = size(im);

red = im(:,:,1);

green = im(:,:,2);

blue = im(:,:,3);

rmean = mean(mean(red));

gmean = mean(mean(green));

bmean = mean(mean(blue));

rstd = std(double(reshape(red,1,r*c)));

gstd = std(double(reshape(green,1,r*c)));

bstd = std(double(reshape(blue,1,r*c)));

fprintf('The mean of the red pixels is %.2f ',rmean) 

fprintf('with a standard deviation of %.2f\n',rstd)

fprintf('The mean of the green pixels is %.2f ',gmean) 

fprintf('with a standard deviation of %.2f\n',gstd)

fprintf('The mean of the blue pixels is %.2f ',bmean) 

fprintf('with a standard deviation of %.2f\n',bstd)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now