How to get a picture(memory a picture) froma an axes to another axes of a form?

Discussion in 'MATLAB' started by Sprinceana, Mar 31, 2009.

  1. Sprinceana

    Sprinceana Guest

    So I have 2 forms(form1.fig and form2.fig. On first I have a pushbutton1 where I store my photo using uigetfile this is working and a pushbutton2 to make link with the second form form2.fig. On second form I have an axes component where I want to store the image loaded in axes1 from the first form form1.

    I'm using guide

    The thing I want is to memorize using gca function the photo I select and load in my axes1 on first form on the single axes that I have on form2.fig(form2.fig has only 1 axes component).

    Here is the callbacks I did for the two buttons that I have on form1.fig

    function pushbutton1_callback
    [filename,pathname] = uigetfile({'*.jpg';'*.png';'*.bmp'}); %selection of the file

    if ~ischar(filename) %on cancel press OK
    errordlg('Error!','Any file selected!'); cancel
    return;
    end

    img = imread(fullfile(pathname,filename)); %reading the image from the path
    imshow(img); %displaying on screen
    set(handles.text1,'string',fullfile(pathname,filename)); %storing the path of image loaded in a static text component OK

    pushbutton1_callback it's functioning

    %Now I want to get the current image loaded in axes1 for form1.fig and to set that image loaded in axes1 of form2.fig

    function_pushbutton2_callback(hObject, eventdata, handles)

    h=gcbo %returns the handle of the graphics object whose callback is executing.
    h=get(gca,handles.axes1) % Get handle to current axes so I get the image stored in axes1 component
    set(gca,handles.axes1) % put the image I loaded in axes1 of form1.fig in axes1 of form2.fig

    I'm stuck using the use of gca and gcbo functiones in pushbutton2_callback.
    Pushbutton1_callback it's functionning correctly.

    Can you help with an exemple please?

    I didn't found any in the documentation so I can understand the main idea.
     
    Sprinceana, Mar 31, 2009
    #1
    1. Advertisements

  2. Sprinceana

    Sprinceana Guest

    function_pushbutton2_callback(hObject, eventdata, handles)
    I try also with this but isn't working:(with set and get) in callback pushbutton2:

    a=get(handles.axes1); %get the image I stored in form1.fig on component axes1
    set(handles.axes2,a); %set the image on axes2 which is the single component on form2.fig -but it loads me only the photo in axes1 not making the setting for the same picture in the second form(forrm2.fig)
     
    Sprinceana, Mar 31, 2009
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.