Help to subtract two images with gui

1 view (last 30 days)
Sophie
Sophie on 31 May 2012
Hello. I need help with gui. 1) I have 2 pictures that I want to subtract and do not know how to code. The two images are open in two axes. The subtract will appear in a third axes. 2)have to move from string to double?
thank you very much!

Answers (2)

Image Analyst
Image Analyst on 31 May 2012
String to double??? No. Just cast to floating point (so you won't get clipping at 0) and subtract:
diffImage = double(image1) - double(image2);
Of course you already have image1 and image2 or else you wouldn't have been able to display them in their axes.

Sophie
Sophie on 31 May 2012
I have this:
% --- Executes on button press in psr. psr_Callback function (hObject, eventdata, handles) diffImage = double (img0) - double (img90); axes (handles.ps1) image (diffImage)
There is an error that says:
?? Undefined function or variable 'img0'.
Error in ==> entornografico2> psr_Callback at 233 diffImage = double (img0) - double (img90);
Error in ==> gui_mainfcn at 96 feval (varargin {:});
Error in ==> entornografico2 at 42 gui_mainfcn (gui_State, varargin {:});
Error in ==> @ (hObject, eventdata) gui1 ('psr_Callback', hObject, eventdata, guidata (hObject))
?? Error while uicontrol Callback Evaluating
Thank you.
  1 Comment
Image Analyst
Image Analyst on 31 May 2012
img0 is not in scope. You need to make it in scope - make it so that your callback can see it. See the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
Please post comments/follow-up questions as comments to my Answer, not as Answers to your questions.

Sign in to comment.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!