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
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:13| Question number:10.13
All Answers
total answers (1)
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