⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guirestore.m

📁 dip函数 hough houghpeaks
💻 M
📖 第 1 页 / 共 3 页
字号:
if ispc    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction txttheta_Callback(hObject, eventdata, handles)% hObject    handle to txttheta (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of txttheta as text%        str2double(get(hObject,'String')) returns contents of txttheta as a doublestr = str2num(get(handles.txttheta,'String'));
if str<0 || str>180
    uiwait(errordlg('Please enter blur angle in the range 0 to 180.', 'Invalid Theta', 'modal'));
    
    %Resetting theta
    str = sprintf('%.0f', get(handles.sldtheta, 'Value'));
    set(handles.txttheta, 'String', str);
else
    set(handles.sldtheta,'Value', str);
end

% --- Executes on button press in angleexpert.
function angleexpert_Callback(hObject, eventdata, handles)
% hObject    handle to angleexpert (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of angleexpert


% --- Executes on button press in lengthexpert.
function lengthexpert_Callback(hObject, eventdata, handles)
% hObject    handle to lengthexpert (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of lengthexpert


function setAngle(hObject, eventdata, handles, THETA)
%This function sets the value of theta on GUI
global anglecount noofest;
if THETA<0 || THETA>180
    msg = ['The estimated blur angle value is invalid. '...
           'Please select a value manually.'];
    uiwait(errordlg(msg, 'Error', 'modal'));
    THETA = 0;
else
    set(handles.sldtheta, 'Value', THETA);
    set(handles.txttheta, 'String', THETA);
end
anglenexttip = [num2str(noofest-anglecount) ' estimates remaining...'];
set(handles.pbanglenext, 'Tooltipstring', anglenexttip);

%Disable the next angle estimate button once all the values are over
if noofest-anglecount <= 0
    set(handles.pbanglenext, 'Enable', 'off');
end


% --- Executes on button press in pbestimateangle.
function pbestimateangle_Callback(hObject, eventdata, handles)
% hObject    handle to pbestimateangle (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.lblstatus, 'Foregroundcolor', 'Red');
set(handles.lblstatus, 'String', 'Status: Busy');
set(gcf,'pointer','watch');
global comein;
global anglecount THETAarr noofest;
noofest = size(THETAarr, 2);
anglecount = 0;

%Enter only if image is opened first
if evalin('base', 'resimstatus') >= 1 & comein >= 1
    %Reading the degraded image from the base workspace
    degradedimg = evalin('base', 'degradedimg');
    expertstatus = get(handles.angleexpert, 'Value');

    %Enabling the Next Button for angle
    set(handles.pbanglenext, 'Enable', 'on');

    %Start the waitbar
    handle = waitbar(0,'Please wait...');

    %Estimating blur angle
    [THETAarr] = EstAngle(degradedimg, expertstatus, handle);

    %Close the waitbar
    close(handle);

    anglecount = anglecount + 1;
    setAngle(hObject, eventdata, handles, THETAarr(anglecount));
else
    uiwait(errordlg('Please open a file first.', 'Error', 'modal'));
end
set(handles.GUIRestore,'pointer','arrow');
set(handles.lblstatus, 'String', 'Status: Ready', 'Foregroundcolor', 'Black');

% --- Executes on button press in pbanglenext.
function pbanglenext_Callback(hObject, eventdata, handles)
% hObject    handle to pbanglenext (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global anglecount THETAarr;
anglecount = anglecount + 1;
setAngle(hObject, eventdata, handles, THETAarr(anglecount));


% --- Executes on button press in pbestimatelen.function pbestimatelen_Callback(hObject, eventdata, handles)% hObject    handle to pbestimatelen (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)set(handles.lblstatus, 'Foregroundcolor', 'Red');
set(handles.lblstatus, 'String', 'Status: Busy');
set(gcf,'pointer','watch');
global comein;

%Enter only if image is opened first
if evalin('base', 'resimstatus') >= 1 & comein >= 1
    %Reading the degraded image from the base workspace
    degradedimg = evalin('base', 'degradedimg');
    THETA = str2num(get(handles.txttheta, 'String'));
    expertstatus = get(handles.lengthexpert, 'Value');

    %Start the waitbar
    handle = waitbar(0,'Please wait...');

    %Estimating blur length
    LEN = EstLen(degradedimg, THETA, expertstatus, handle);

    %Close the waitbar
    close(handle);

    if LEN<1 || LEN>100
        msg = ['The estimated blur length value is invalid. '...
                'Please select a value manually.'];
        uiwait(errordlg(msg, 'Error', 'modal'));
    else
        set(handles.sldlength, 'Value', LEN);
        set(handles.txtlength, 'String', LEN);
    end
else
    uiwait(errordlg('Please open a file first.', 'Error', 'modal'));
end
set(handles.GUIRestore,'pointer','arrow');
set(handles.lblstatus, 'String', 'Status: Ready', 'Foregroundcolor', 'Black');


% --- Executes during object creation, after setting all properties.
function slditerations_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slditerations (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background, change
%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
    set(hObject,'BackgroundColor',[.9 .9 .9]);
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on slider movement.
function slditerations_Callback(hObject, eventdata, handles)
% hObject    handle to slditerations (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
str = sprintf('%.0f', get(handles.slditerations, 'Value'));
set(handles.txtiterations, 'String', str);


% --- Executes during object creation, after setting all properties.
function txtiterations_CreateFcn(hObject, eventdata, handles)
% hObject    handle to txtiterations (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


function txtiterations_Callback(hObject, eventdata, handles)
% hObject    handle to txtiterations (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of txtiterations as text
%        str2double(get(hObject,'String')) returns contents of txtiterations as a double
str = str2num(get(handles.txtiterations,'String'));
if str<1 || str>1000
    uiwait(errordlg('Please enter no. of iterations in the range 1 to 1000', 'Invalid Iterations', 'modal'));

    %Resetting iterations
    str = sprintf('%.0f', get(handles.slditerations, 'Value'));
    set(handles.txtiterations, 'String', str);
else
    set(handles.slditerations,'Value', str);
end


% --- Executes during object creation, after setting all properties.
function sldsnr_CreateFcn(hObject, eventdata, handles)
% hObject    handle to sldsnr (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background, change
%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
    set(hObject,'BackgroundColor',[.9 .9 .9]);
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on slider movement.
function sldsnr_Callback(hObject, eventdata, handles)
% hObject    handle to sldsnr (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
str = sprintf('%.4f', get(handles.sldsnr, 'Value'));
set(handles.txtsnr, 'String', str);


% --- Executes during object creation, after setting all properties.
function txtsnr_CreateFcn(hObject, eventdata, handles)
% hObject    handle to txtsnr (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


function txtsnr_Callback(hObject, eventdata, handles)
% hObject    handle to txtsnr (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of txtsnr as text
%        str2double(get(hObject,'String')) returns contents of txtsnr as a double
str = str2num(get(handles.txtsnr,'String'));
if str<0.0001 || str>1
    uiwait(errordlg('Please enter Signal to Noise Ratio (SNR) in the range 0.0001 to 1', 'Invalid SNR', 'modal'));

    %Resetting iterations
    str = sprintf('%.4f', get(handles.sldsnr, 'Value'));
    set(handles.txtsnr, 'String', str);
else
    set(handles.sldsnr,'Value', str);
end


% --- Executes on button press in pbestimatesnr.
function pbestimatesnr_Callback(hObject, eventdata, handles)
% hObject    handle to pbestimatesnr (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.lblstatus, 'Foregroundcolor', 'Red');
set(handles.lblstatus, 'String', 'Status: Busy');
set(gcf,'pointer','watch');
global comein;

%Enter only if image is opened first
if evalin('base', 'resimstatus') >= 1 & comein >= 1
    degradedimg = evalin('base', 'degradedimg');
    R = str2num(sprintf('%.4f', 1/size(degradedimg, 2)));
    set(handles.txtsnr, 'String', R);
    set(handles.sldsnr, 'Value', R);
else
    uiwait(errordlg('Please open a file first.', 'Error', 'modal'));
end
set(gcf,'pointer','arrow');
set(handles.lblstatus, 'String', 'Status: Ready', 'Foregroundcolor', 'Black');

% --- Executes on button press in pbrestoreimg.function pbrestoreimg_Callback(hObject, eventdata, handles)% hObject    handle to pbrestoreimg (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)set(handles.lblstatus, 'Foregroundcolor', 'Red');
set(handles.lblstatus, 'String', 'Status: Busy');
set(gcf,'pointer','watch');
global comein zoompoint;

%Enter only if image is opened first
if evalin('base', 'resimstatus') >= 1 & comein >= 1
    %Reading the degraded image from the base workspace
    degradedimg = evalin('base', 'degradedimg');
    LEN         = str2num(get(handles.txtlength, 'String'));
    THETA       = str2num(get(handles.txttheta, 'String'));

    %Start the waitbar
    handle = waitbar(0,'Please wait...');
    switch evalin('base', 'algo')
        case 1 %Inverse filter
            restoredimg = Inverse(degradedimg, LEN, THETA, handle);
        case 2 %Wiener filter
            SNR = get(handles.sldsnr, 'Value');
            restoredimg = Wiener(degradedimg, LEN, THETA, SNR, handle);
        case 3 %Lucy-Richardson
            iterations = round(get(handles.slditerations, 'Value'));
            restoredimg = Lucy(degradedimg, LEN, THETA, iterations, handle);
    end

    %Close the waitbar
    close(handle);

    %Make the axisrestoredimg the current axes
    axes(handles.axisrestoredimg);
    imshow(real(restoredimg));

    %Storing the degraded image in the base workspace
    assignin('base','restoredimg',restoredimg);

    %Setting resimstatus to 2 signifying image can be saved now
    assignin('base', 'resimstatus', 2); comein = 2;

    %Hiding the frame
    set(handles.frmrestoredimg, 'Visible', 'off');

    %Enabling the Zoom menu item
    set(handles.EditZoom, 'Enable', 'on');
    set(handles.sldzoomfactor, 'Enable', 'on');
    zoompoint(1) = size(restoredimg, 2)/2;
    zoompoint(2) = size(restoredimg, 1)/2;
    zoomimage(hObject, eventdata, handles);
    set(handles.frmzoom, 'Visible', 'off');

    %Enabling the File->LoadRestored & Save
    set(handles.FileSave, 'Enable', 'on');
    set(handles.FileLoadRestored, 'Enable', 'on');
else
    uiwait(errordlg('Please open a file first.', 'Error', 'modal'));
end
set(gcf,'pointer','arrow');
set(handles.lblstatus, 'String', 'Status: Ready', 'Foregroundcolor', 'Black');
% --- Executes on button press in pbhelp.function pbhelp_Callback(hObject, eventdata, handles)% hObject    handle to pbhelp (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)set(handles.lblstatus, 'Foregroundcolor', 'Red');
set(handles.lblstatus, 'String', 'Status: Busy');
set(gcf,'pointer','watch');
web ([cd '\Help\Restore.html'], '-browser');
set(gcf,'pointer','arrow');
set(handles.lblstatus, 'String', 'Status: Ready', 'Foregroundcolor', 'Black');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -