필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Trouble with editText functions in GUI

조회 수: 2 (최근 30일)
david Landrith
david Landrith 2011년 4월 1일
마감: MATLAB Answer Bot 2021년 8월 20일
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
david Landrith
david Landrith 2011년 4월 1일
woops first time posting on this site.
thanks

답변 (1개)

Matt Fig
Matt Fig 2011년 4월 1일
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.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by