Write a function that creates a GUI with push-buttons which allows the user to d
ID: 3832842 • Letter: W
Question
Write a function that creates a GUI with push-buttons which allows the user to display a specific true color image in four different ways: true color, red channel only, green channel only, and blue channel only. The red channel should be displayed with a hot color map, the green channel with a summer color map, and the blue channel with a winter color map. The image to be displayed is one of the demo pictures in MATLAB: "peppers .png". Importing this image should be the first task in the function. The function will not need input or output parameters; it will just handle the graphic user interface. The GUI should look something like this: Double-check your code for all the problems before submission. Make sure that your script generates the three (3) requested figures, that they are properly labeled, and that the GUI function generates an additional, interactive figure, as displayed above.Explanation / Answer
I have written a function which basically creates a GUI for the changing color over an image.I have attached the program along with the comments for each line of code.
Function:-
% Created the function selectColor
function selectColor
% The FIGURE object consist of both the position and Toolbar controls
clr = figure('Position',[450 350 180 30],'Toolbar','none');
% Set-up a toolbar for handling the color efficiently
toolClr = uitoolbar('Parent',clr);
% The color needs to be pushed once it has been selected
pushColor = uipushtool('Parent',toolClr,'Cdata',rand(70,47,5),'ClickedCallback',@colorRollback);
% Created another function which rollbacks the previous color code
function colorRollback(selObj,eventdata)
% The color will set according to the given user input
color = uisetcolor(clr,'Please Pick any color of your choice.');
% Finally will end the program with end keyword
end
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.