一个简单的matlab图形界面程序GUI(4)

function sliderObj_CreateFcn(hObject, eventdata, handles)
% hObject    handle to sliderObj (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
    if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor',[.9 .9 .9]);
    end
    set(hObject, 'Visible', 'off');
    guidata(hObject, handles);

function imageName = gui_get_imageName(no)
% get the imagename with order no
    namelist = ['/home/aborn/research/code/SalDef/dataset/' ...
                'voc2012imglist.txt'];
    fid = fopen(namelist);
    C  = textscan(fid,'%s');
    fclose(fid);
    name = C{1,1};
    clear C;
    imageName = name{no,1}(1,1:end-4);

function gui_contents_update(handles, cur_img_no)
    cur_img_no = floor(cur_img_no);
    mapsdir    = '/media/research/mapsCIKM/maps/';
    set(handles.imgNo,'String',num2str(cur_img_no));
    set(handles.sliderImageNo, 'Value', cur_img_no);
    imageName  = gui_get_imageName(cur_img_no);     
    info      = getVOC2012ImgInfo(imageName);
    imageName  = [mapsdir,imageName, '.jpg'];
   
    contents  = cellstr(get(handles.nbs, 'String'));
    cur_conts  = contents{get(handles.nbs, 'Value')};
    segmapName = [imageName(1,1:end-4),'_segmap_', cur_conts, '.mat'];
    if file_check(segmapName) == -1
        return;
    end
    load(segmapName);
    rgbSeg      = segmap.rgbSeg;
    if (get(handles.rdch, 'Value') == get(handles.rdch, 'Max')) 
        % if the rdch radio button has been chosen, update test results
        if (gui_contents_update_test(handles, cur_img_no, rgbSeg) == -1)
            return;
        end
    else
        salmapName = [imageName(1,1:end-4),'_salmap.mat'];
        load(salmapName);
        defmapName = [imageName(1,1:end-4),'_defmap.mat'];
        load(defmapName);
        gui_update_axes(imageName, 11, handles);
        gui_update_axes(salmap, 21, handles, 'im');
        gui_update_axes(defmap, 12, handles, 'im');
        gui_update_axes(rgbSeg, 22, handles, 'im');
       
        set(handles.percent, 'String', '');
        set(handles.objNo, 'String', '');
        set(handles.sliderObj, 'Visible', 'off');
        set(handles.currentMsg, 'String', '');
        change_objdet_panel(handles, 'maps');
        gui_update_names(handles, 'maps');
    end
    gui_update_msg(cur_img_no, handles);
   
function st = gui_contents_update_test(handles, cur_img_no, rgbSeg)
% if the rdch be chosen
%    show the test result.
    objno = floor(get(handles.sliderObj, 'Value'));
    runNo = floor(str2double(get(handles.beginValue, 'String')));
    if runtime_number_check(handles, runNo) == -1
        nmr = 1;
        set(handles.beginValue, 'String', '1');
    else
        nmr = runNo;
    end
    set(handles.beginValue, 'String', num2str(nmr));
    imageName = gui_get_imageName(cur_img_no);
    info      = getVOC2012ImgInfo(imageName);
    set(handles.sliderObj, 'Max', info.objno);
   
    contents  = cellstr(get(handles.nbs, 'String'));
    cur_conts = contents{get(handles.nbs, 'Value')};
    set(handles.sliderObj, 'Visible', 'off');
    testRS    = gui_obtain_testRS(imageName, str2num(cur_conts), objno, nmr);
    if (testRS.st == -1)
        tmsg  = 'runing test before this action!';
        msg  = sprintf('Can not find the image %s \n %s', imageName, tmsg);
        msgbox(msg,'FileReadError', 'modal');
        st    = -1;
        return;
    end
   
    maxV      = get(handles.sliderObj, 'Max');
    minV      = get(handles.sliderObj, 'Min');
    if maxV > minV
        set(handles.sliderObj, 'Visible', 'on');
        step  = 1/(maxV-minV);
        set(handles.sliderObj, 'SliderStep', [step, 0.1]);
    elseif maxV == minV
        set(handles.sliderObj, 'Visible', 'off');
    end
    if objno > maxV
        set(handles.sliderObj, 'Value', minV);
        objno = minV;
    end

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/80870949e2c8b65d9c1641a4b17a3f93.html