Question
MATLAB Problem 3 : (7 Points). Write a function with the header function [newX] = myAdjustRGB(X, rgb) which takes - (m,n,3) matrix X. Red components
MATLAB Problem 3: (7 Points). Write a function with the header function [newX] = myAdjustRGB(X, rgb) which takes - (m,n,3) matrix X. Red components are stored in X(:,:,1). Green components are stored in X(:, :, 2). Blue components are stored in X(:, :, 3). Each component is limited to values between 0 and 1. (As in the file Test.mat). - A 3 element vector rgb whose values are between 0 and 1. rgb(1) is a percent increase in red intensity, rgb(2) is a percent increase in green intensity, and rgb(3) is a percent increase in blue intensity. For example, o Suppose X(14,42,1) has a value of 0.325 (its red intensity is 32.5% of maximum red), then adding (1 0.325) to X(14,42,1) would saturate the red value (make it maximum red) of that pixel. X(14,42,1) would then have a value of 1. o If rgb(1) is 0.5, then X(14, 42, 1) would go from 0.325 to 0.325 + 0.5*(1 0.325) = 0.6625. This is 66.25% of red saturation for that element. This function allows the user to increase each color channel from its current value up to 1. To do this, I used the following approach: 1) Calculate the differences between 1 and all the elements in the red level. Multiply these differences by rgb(1). Add these values to the original red layer of X. 2) Calculate the difference between 1 and all the elements in the green level. Multiply these differences by rgb(2). Add these values to the original green layer of X. 3) Calculate the difference between 1 and all the elements in the blue level. Multiply these differences by rgb(3). Add these values to the original blue layer of X.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started