    // This GUI file is generated by guibuilder version 3.0
//////////
function imcontrast(img)


    h = scf(2);

    img = imadjust(im2double(img));
    imshow(img);
    e = h.children.children;
    min_val = double(min(img));
    max_val = double(max(img));
    

    f=figure('figure_position',[400,50],'figure_size',[500,300],'auto_resize','on', "dockable", "off",...
    'figure_name','Image Contrast',"infobar_visible", "off", "menubar_visible", "off", "toolbar", "none", "toolbar_visible", "off");
    //////////
    



    //f = figure("default_axes", "off", "dockable", "off", "figure_name", "Image Contrast", "axes_size", [200 200], ...
    //           "infobar_visible", "off", "menubar_visible", "off", "toolbar", "none", "toolbar_visible", "off"); //, "layout", "gridbag");

    //delmenu(f.figure_id,gettext('File'))
    //delmenu(f.figure_id,gettext('?'))
    //delmenu(f.figure_id,gettext('Tools'))
    //toolbar(f.figure_id,'off')
    handles.dummy = 0;
    xx = 0.18;
    yy = 0.1;
    ww = 0.7;
    hh = 0.5;

    handles.obj1= newaxes();handles.obj1.margins = [ 0 0 0 0];handles.obj1.axes_bounds = [xx,yy,ww,hh];

    handles.sld_left=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','center','ListboxTop',[],'Max',[max_val],'Min',[min_val],'Position',[xx,0.25,ww,0.08],'Relief','default','SliderStep',[0.01,0.1],'String','Left','Style','slider','Value',[min_val],'VerticalAlignment','middle','Visible','on','Tag','sld_left','Callback','sld_left_callback(handles)')

    handles.sld_right=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','center','ListboxTop',[],'Max',[max_val],'Min',[min_val],'Position',[xx,0.1,ww,0.08],'Relief','default','SliderStep',[0.01,0.1],'String','Right','Style','slider','Value',[max_val],'VerticalAlignment','middle','Visible','on','Tag','sld_right','Callback','sld_right_callback(handles)')

    handles.txt_min=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.08,0.2,0.07,0.06],'Relief','default','SliderStep',[0.01,0.1],'String',string(min_val),'Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','txt_min','Callback','')

    handles.txt_max=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.9,0.2,0.07,0.06],'Relief','default','SliderStep',[0.01,0.1],'String',string(max_val),'Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','txt_max','Callback','')

    handles.txt_left=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.45,0.2,0.1,0.06],'Relief','default','SliderStep',[0.01,0.1],'String','0','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','txt_left','Callback','')

    handles.txt_right=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.45,0.03,0.1,0.06],'Relief','default','SliderStep',[0.01,0.1],'String','1','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','txt_right','Callback','')

    handles.pb_export=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.02,0.02,0.2,0.1],'Relief','raised','SliderStep',[0.01,0.1],'String','Export','Style','pushbutton','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','pb_export','Callback','pb_export_callback(handles)')

    sca(handles.obj1);
    h_bin = imhist(img,255,'');
    mtlb_axis([0 1 0 prod(size(img))*0.01]);
    handles.data = e.data;
    handles.buffer = 0;
    handles.e = e;
    handles = resume(handles);
endfunction
//////////
// Callbacks are defined as below. Please do not delete the comments as it will be used in coming version
//////////

function sld_left_callback(handles)
    //Write your callback for  sld_left  here
    //e = handles.e;
    data = handles.data;
    val1 = handles.sld_left.value;
    val2 = handles.sld_right.value;
    if val1 > val2;
        val1 = val2 -1;
        handles.sld_left.value = val1;

    end
    
    handles.txt_left.string = string((val1));
    
    handles.buffer = handles.buffer + 1;
    //disp(handles.buffer);
    if handles.buffer <=1
    val1 = handles.sld_left.value;
    val2 = handles.sld_right.value;
    handles.txt_left.string = string((val1));
        TempImg = imadjust(data,[val1 val2]);
        handles.e.data= TempImg;
        handles.buffer = handles.buffer - 1
    else
        handles.buffer =handles.buffer - 1;
    end
    
    handles = resume(handles);
endfunction


function sld_right_callback(handles)
    //Write your callback for  sld_right  here
    data = handles.data;    
    val2 = handles.sld_right.value;
    val1 = handles.sld_left.value;
    if val2 < val1;
        val2 = val1 +1;
        handles.sld_right.value = val2;
       
    end
    handles.txt_right.string = string((val2));

    
    handles.buffer = handles.buffer + 1;
    //disp(handles.buffer);
    if handles.buffer <=1
    val1 = handles.sld_left.value;        
    val2 = handles.sld_right.value;
    handles.txt_right.string = string((val2));
        TempImg = imadjust(data,[val1 val2]);
        handles.e.data= TempImg;
        handles.buffer = handles.buffer - 1
    else
        handles.buffer =handles.buffer - 1;
    end
    
    handles = resume(handles);

endfunction

function pb_export_callback(handles)
    myexportimg = resume(handles.e.data);
endfunction


