Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

Trouble with editText functions in GUI

2 views (last 30 days)
david Landrith
david Landrith on 1 Apr 2011
Closed: MATLAB Answer Bot on 20 Aug 2021
I have been writing a script that creates a simple GUI for editing images.
The GUI has sliders and editText boxes that adjust HSV and RGB brightness etc. Everything works as intended when you move the sliders or change the data in the text box. However, after the first adjustment has been made in a GUI, that GUI no longer effects the image. The value changes, but the picture looks the same.
I think the problem lies in the Open function at the beginning of the script but I have no idea where to start.
Thanks in advance.
Below are the function lines for the GUIopen the textbox:
TextBox function:
function red_edit_Callback(hObject, eventdata, handles)
%get the string for the editText component
sliderValue = get(handles.red_edit,'String');
%convert from string to number
sliderValue = str2double(sliderValue);
revert_red = handles.new_image(:,:,3);
%if user inputs something is not a number, or if the input is less than 0
%or great than 24, then the slider defaults to 0
if (isempty(sliderValue) || sliderValue < 0 || sliderValue > 24)
set(handles.red_slider,'Value',0);
set(handles.red_edit,'String','0');
else
set(handles.red_slider,'Value',sliderValue);
end
for row = 1 : size(handles.new_image,1) % for every pixel
for col = 1 : size(handles.new_image,2)
handles.new_image(row,col,1) = handles.new_image(row,col,1)*handles.red_edit; %multiply red components by editText value
red_only (row, col) = handles.new_image(row,col,1)*handles.red_edit;
end
end
if(handles.show_original == 1); % displays 1 or 2 pictures based on user imput
subplot(1,2,1), subimage(handles.original_image)
title('Original Image');
subplot(1,2,2), subimage(handles.new_image)
title('New Image');
else
image(handles.new_image);
end
guidata(hObject, handles);
  1 Comment
david Landrith
david Landrith on 1 Apr 2011
woops first time posting on this site.
thanks

Answers (1)

Matt Fig
Matt Fig on 1 Apr 2011
I don't think the problem is in the OpeningFcn of the figure. I don't see where you are updating the value of handles.new_image. Are you altering the image and then re-saving it to the handles structure? Since you are passing in handles, instead of getting the handles every time through GUIDATA or some other means, how is what you are altering being stored? For example:
handles = guidata(gcbf); % Get previously stored GUIDATA
revert_red = handles.new_image(:,:,3); % Get third page.
% Some code that changes revert_red
handles.new_image(:,:,3) = revert_red; %Assign altered data to handles.
guidata(gcbf,handles) % Store altered image for later use, display.

This question is closed.

Community Treasure Hunt

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

Start Hunting!