From: Robert Berry on 25 Nov 2009 11:23 I'm having a problem similar to the user that started this thread. In my GUI, the user presses a pushbutton and selects an image (.bin format) which is displayed in an axis (image_display). No problems there. Pushbutton Callback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % PUSH BUTTON TO LOAD IMAGE FROM FILE % --- Executes on button press in load_image. function load_image_Callback(hObject, eventdata, handles) % hObject handle to load_image (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) [filename, pathname] = uigetfile('*.*','Select an file to Process'); image_path=(strcat(pathname,filename)); %Location of the image % open file in binary read mode fid = fopen(image_path,'r'); framenumber=2; columns=1315; % read image for n=1:framenumber frame=fread(fid,[columns 480],'int16'); end frame=frame'; set(handles.image_display,'UserData',frame); %Passes the image data to the image_display 'UserData' property imagesc(frame,'Parent',handles.image_display); %Displays the image in the axis %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% I confirmed that frame (image data) was stored in handles.image_display 'UserData' using breakpoints within the pushbotton callback. I then want the user to be able to adjust a slider (GainControl) that updates the image by adding contrast. But when I try to perform operations on the data in the slider callback by getting 'UserData', the field is empty. Somehow the data I'm trying to pass to the slider callback isn't getting displayed. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % --- Executes on slider movement. function GainControl_Callback(hObject, eventdata, handles) % hObject handle to GainControl (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) %obtains the slider value from the slider component GainControl = get(hObject,'Value'); %Slider controls GainControl (contrast) GainControl = round(GainControl); %The contrast should be an integer %puts the slider value into the edit text component set(handles.GainControlDisplay,'String', num2str(GainControl)); frame = get(handles.image_display,'UserData'); %Gets image data stored in the axis 'UserData' property frame = frame*GainControl; %Scales image values (adjust contrast?) imagesc(frame,'Parent',handles.image_display); %Display the image in the axis %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Please help!!! Also, generally speaking: I'm clueless as to -how to best display images that update in a GUI -pass data between callbacks Can someone help me with my specific issue in my code and help me understand my general questions above. Thanks! Robert
|
Pages: 1 Prev: Copy & Paste a GEOSHOW Figure Next: how to use ndgrid with N dimensions |