Bme Final
Bme Final
5/6/2022
BME 120
The purpose of this project is to make a GUI where the user can upload an image from the
computer into the app. From there, the user can interact with the application by adjusting the
different bars in the app that changes the contrast, and the color by changing the amount of the 3
primary colors red, blue and green that is displayed by the image. The user can also leave the app
Images in MATLAB are made up of 3 dimensional arrays of byte which make up the total
images. The first 2 dimension of the array would specify a specific pixel at a location on the
image indicated by the numbers in the first 2 dimension, while the third dimension gives one of
the 3 primary colors. Putting an index of 1 in the third index would be modifying the amount of
red, index of 2 would be blue, index of 3 is green. Knowing this, by creating a callback function
that adjusts the amount of these colors in response to changing a slider on the app, therefore
In order to create this GUI, it is important to create the layout of the app first to make it easy to
use. First, an axis would be created and put on the app display, which would take up most of the
design view. Next, 4 sliders would be placed along the side of the axes, which would later be
used to adjust the contrast and color of the image. Finally, two push buttons are added outside
the axes, one is for loading the image and the other is for exiting the application. All these
objects can be accessed and added in the component library on the left side of the app designer.
Next in the code view, callback functions can be added by clicking the green plus sign in the
callback browser, and the popup will allow you to associate a callback function with the desired
object. The properties of the objects can also be edited by clicking on them in the design view.
Once an object is clicked on in the design view, the name of the object, the label of the object on
the design view, and the limits for the slider’s values can be adjusted through the component
browser on the right. What happens in the application after interacting with the objects are
First to create a GUI, a private property for the data of our picture needs to be created. First the
callback function associated with pushing the load button is made. The callback function consists
of the functions uigetfile, fullfile, imread, and imshow in that order. Function uigetfile will allow
the user to select a file from their computer in the Matlab search path. Fullfile will get the full
name of the file including its path and name, where imread will read the file and allows the
information of that selected picture to be stored in our private property of the picture data. From
there, imshow would be used to display the selected picture in the axes. From there, a callback
function for the red, green, blue, and contrast slider will be created. In the callback function, the
value of each slide bar is retrieved and is used in a function called ModifyImage which would
change the image based off the value of each slider. In the private function ModifyImage which
is accessed in the code view, a variable NewPicture is used to hold in data for the default image
uploaded. Individual colors of red, blue, and green are targeted by modifying the indexes of the
third dimension of the picture data, which mentioned before is responsible for the color of the
image. The amount of the corresponding color is then changed by adding the original value with
the value from the corresponding color slider times 128 and the contrast slider times 128.
Imshow is used again at the end of function ModifyImage to display the edited variation of the
original photo. Lastly, a callback function for the exit button is created, which only contains the
function app.delete(). This is a MATLAB function that allows the user to close out of the