function getdata

    f = figure('Visible','off','Position',[1,1,1000,1005]);
    
    hopen= uicontrol('Style','pushbutton','String','Open','Position',[900,340,70,25],'Callback',{@openbutton_Callback});

    htext1  = uicontrol('Style','text','String','Xmin','Position',[900,300,35,15]);
    htext2  = uicontrol('Style','text','String','Xmax','Position',[935,300,35,15]);
    hedit1= uicontrol('Style','edit','Position',[900,285,35,15],'Callback',{@edit1_Callback});
    hedit2= uicontrol('Style','edit','Position',[935,285,35,15],'Callback',{@edit2_Callback});
    htext3  = uicontrol('Style','text','String','ymin','Position',[900,270,35,15]);
    htext4  = uicontrol('Style','text','String','ymax','Position',[935,270,35,15]);
    hedit3= uicontrol('Style','edit','Position',[900,255,35,15],'Callback',{@edit3_Callback});
    hedit4= uicontrol('Style','edit','Position',[935,255,35,15],'Callback',{@edit4_Callback});
    htext5=uicontrol('Style','text','String','initiate xmin,xmax,ymin,ymax position on picture','Position',[900,220,150,25]);
    hinitiation=uicontrol('Style','pushbutton','String','Initiation ','Position',[900,185,70,25],'Callback',{@initiationbutton_Callback});
    
    
    htextx  = uicontrol('Style','text','String','x scale','Position',[900,145,35,15]);
    
    hscalex= uicontrol('Style','popupmenu', 'String',{'please select','linear','log'},'Position',[900,115,70,25],'Callback',{@scalex_menu_Callback});
    
    htexty  = uicontrol('Style','text','String','y scale','Position',[900,85,35,15]);
    
    hscaley= uicontrol('Style','popupmenu', 'String',{'please select','linear','log'},'Position',[900,65,70,25],'Callback',{@scaley_menu_Callback});
    
    
    
    
    hgetdata=uicontrol('Style','pushbutton','String','Getdata','Position',[900,45,70,25],'Callback',{@getdatabutton_Callback});
    hsave=uicontrol('Style','pushbutton','String','save','Position',[900,10,70,25],'Callback',{@savebutton_Callback});
    
    ha = axes('Units','pixels','Position',[1,1,900,905]);
    %align([hopen,hrun,hpause,hsave],'Center','None');
    set(f,'Visible','on')
   global a xmin xmax ymin ymax xstep ystep init d data1 strx valx stry valy;
    
    
    
   function openbutton_Callback(source,eventdata) 
        [FileName,PathName] = uigetfile('*.jpg','Select the picture from paper');
        a=imread([PathName,FileName]);
        
        imshow(a);
   end


  
   function edit1_Callback(hObject, eventdata, handles)
        xmin = str2num(get(hObject,'string'));
   end
   
   function edit2_Callback(hObject, eventdata, handles)
        xmax = str2num(get(hObject,'string'));
   end
   
   function edit3_Callback(hObject, eventdata, handles)
        ymin = str2num(get(hObject,'string'));
   end
   
   function edit4_Callback(hObject, eventdata, handles)
        ymax = str2num(get(hObject,'string'));
   end


 
   function initiationbutton_Callback(source,eventdata)
        init=ginput;
        
        xstep=(xmax-xmin)./(init(2,1)-init(1,1));
        ystep=(ymax-ymin)./(init(4,2)-init(3,2));
        
   end


   function scalex_menu_Callback(source,eventdata) 
         % Determine the selected data set.
         strx = get(source, 'String');
         valx = get(source,'Value');
         % Set current data to the selected data set.
         switch strx{valx};
             
         case 'linear' % User selects Peaks.
            xxscale = 0;
            xstep=(xmax-xmin)./(init(2,1)-init(1,1));
         case 'log' % User selects Membrane.
            xxscale = 1;
            xstep=(log10(xmax)-log10(xmin))./(init(2,1)-init(1,1));
       
         end
   end


   function scaley_menu_Callback(source,eventdata) 
         % Determine the selected data set.
         stry = get(source, 'String');
         valy = get(source,'Value');
         % Set current data to the selected data set.
         switch stry{valy};
             
         case 'linear' % User selects Peaks.
            yyscale = 0;
            ystep=(ymax-ymin)./(init(4,2)-init(3,2));
         case 'log' % User selects Membrane.
            yyscale = 1;
            ystep=(log10(ymax)-log10(ymin))./(init(4,2)-init(3,2));
       
         end
    end


    function getdatabutton_Callback(hObject,source,eventdata)
        clear data1;
        d=ginput;
        
        switch strx{valx};
            case 'linear'
                data1(:,1)=(d(:,1)-init(1,1)).*xstep+xmin;
            case 'log'
                data1(:,1)=10.^((d(:,1)-init(1,1)).*xstep+log10(xmin));
        end;
        
        switch stry{valy}
            case 'linear'
                data1(:,2)=(d(:,2)-init(3,2)).*ystep+ymin;
            case 'log'
                data1(:,2)=10.^((d(:,2)-init(3,2)).*ystep+log10(ymin));
        end;
        
    end

    function savebutton_Callback(source,eventdata)
        [filename, pathname] = uiputfile('*.txt','Write to txt');
        save([pathname,filename],'data1','-ascii');
        clear;
    end

    
        
        

end
