Matlab Code Problem 1 10 Points Write a function with the he

Matlab Code

Problem 1: (10 Points) Write a function with the header

function [rIntens, gIntens, bIntens] = myMeanRGB(X)

which calculates mean red, green, and blue intensities of a m x n x 3 matrix X in which X(:, :, 1) is the red layer, X(:, :, 2) is the green layer, and X(:, :, 3) is the blue layer,.

Test Case 1: >> format long >> load(\'Test.mat\'); >> [rm, gm, bm] = myMeanRGB(y)

rm = 0.322348923199152

gm = 0.274674085696741

bm = 0.243236623009579

Solution

Note: Test.mat is not provided. So, please copy Test.mat into workspace and run the program. You can see the result in command window.

Main Program:

y = load (\'Test.mat\');

[rm, gm, bm] = myMeanRGB(y)

disp(\'Mean of RED Layer is:\')

disp(rm)

disp(\'Mean of GREEN Layer is:\')

disp(gm)

disp(\'Mean of BLUE Layer is:\')

disp(bm)

Function Program:

function [rm, gm, bm] = myMeanRGB(y) % Creating Function named \'MyMeanRGB\'

r = y(:,:,1); % Extraction of RED component
g = y(:,:,2); % Extraction of GREEN component
b = y(:,:,3); % Extraction of BLUE component
rm = mean2(r); % Mean of RED image
gm = mean2(g); % Mean of GREEN image
bm =mean2(b); % Mean of BLUE image
end

Matlab Code Problem 1: (10 Points) Write a function with the header function [rIntens, gIntens, bIntens] = myMeanRGB(X) which calculates mean red, green, and bl

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site