I am creating a GUI for my final project in my MATLAB programming class

3 visualizaciones (últimos 30 días)
I am creating a GUI for my final project in my MATLAB pogramming course
Program requirements: Your program should include the five features listed below. However, the implementations are suggestions. You can provide your own solutions. 1. Use “Load Image” button to load a JPEG file to a variable ‘pic’ and display it in the axes area. a. Functions used: uigetfile, fullfile, imread 2. Use handles structure to store the image for future use. E.g: a. handles.pic = pic b. guidata(hObject,handles) 3. Use slider red, green and blue to adjust the three colors. In the corresponding call back function, a. Retrieve the values of slider bars as variable scales to all basic colors. b. Retrieve the image data using handles.pic c. Adjust the color by adding the value with a scale*128. This applies to all colors. E.g. the red color is affected by the red slider bar and the brightness bar. d. Show the modified image 4. Use slider contrast to adjust the brightness. In the call back function, a. Retrieve the values of slider bars as variable scales to all basic colors. b. Retrieve the image data using handles.pic c. Adjust the color by adding the value with a scale*128. This applies to all colors. E.g. the red color is affected by the red slider bar and the brightness bar. d. Show the modified image 5. Exit button: when the button is push, close the GUI interface. Use Google search to find the solution.
I have started the slider bar first because I believe it is the hardest but I need suggestions and help with all of the other parts. below is my code for which I am getting errors. If someone could help me make this GUI work that would be awesome! Thanks so much!
function redbar_Callback(hObject, eventdata, handles)
% hObject handle to redbar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% Retrieve original image
pic = handles.picture;
contrastlocation = get(handles.contrast,'Value');
% Change redbar color
redlocation = get(handles.redbar,'Value');
pic(:,:,1)= pic(:,:,1)+128*redlocation+128*contrastlocation;
% Change bluebar color
bluelocation = get(handels.bluebar,'Value');
pic(:,:,3) = pic(:,:,3)+128*bluelocation+128*contrastlocation;
%Change greenbar color
greenlocation = get(handels.greenbar,'Value');
pic(:,:,2) = pic(:,:,2)+128*greenlocation+128*contrastlocation;
% Make it easier to read
% Show the image
image(pic,'Parent',handles.picture);
  1 comentario
Walter Roberson
Walter Roberson el 27 de Abr. de 2019
Editada: Walter Roberson el 27 de Abr. de 2019
What error are you observing?
... Other than the fact that you use handels instead of handles in some places ?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by