📄 guirestore.m
字号:
%Storing the start and the end points irrespective of the
%actual positions on the image
startx = min(point1(2), point2(2));
endx = max(point1(2), point2(2));
starty = min(point1(1), point2(1));
endy = max(point1(1), point2(1));
%Cropping the image
croppedimg = degradedimg(startx:endx, starty:endy);
%Backingup the old degraded image for Undo
assignin('base', 'degradedimgundo', degradedimg);
%Storing the cropped image
assignin('base', 'degradedimg', croppedimg);
imshow(real(croppedimg));
%Enabling the Undo menu item
set(handles.EditUndo, 'Enable', 'on');
%Estimating SNR for the new image
pbestimatesnr_Callback(hObject, eventdata, handles);
end
end
else
uiwait(errordlg('Please open a file first.', 'Error', 'modal'));
end
set(handles.lbleditstatus, 'Visible', 'off');
set(gcf,'pointer','arrow');
set(handles.lblstatus, 'String', 'Status: Ready', 'Foregroundcolor', 'Black');
% ----------------------
function EditZoom_Callback(hObject, eventdata, handles)
% hObject handle to EditCrop (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axisrestoredimg);
global comein zoompoint;
%Enter only if image is opened first
if evalin('base', 'resimstatus') >= 1 & comein >= 1
%Reading the restored image
restoredimg = evalin('base', 'restoredimg');
set(handles.lbleditstatus, 'Visible', 'on');
set(gcf,'pointer','circle');
set(handles.lblstatus, 'Foregroundcolor', 'Red');
set(handles.lblstatus, 'String', 'Status: Select Point');
status = waitforbuttonpress;
while status==0
zoompoint = get(gca, 'CurrentPoint');
zoompoint = round(zoompoint(1,1:2)); % extract x1 and y1
set(handles.lblstatus, 'String', 'Status: Busy');
set(gcf,'pointer','watch');
%Calling the zoomimage function to zoom and display the image
zoomimage(hObject, eventdata, handles);
set(gcf,'pointer','circle');
set(handles.lblstatus, 'String', 'Status: Select Point');
status = waitforbuttonpress;
end
else
uiwait(errordlg('Please open a file first.', 'Error', 'modal'));
end
set(handles.lbleditstatus, 'Visible', 'off');
set(gcf,'pointer','arrow');
set(handles.lblstatus, 'String', 'Status: Ready', 'Foregroundcolor', 'Black');
% ----------------------
function Filter_Callback(hObject, eventdata, handles)% hObject handle to Filter (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% ----------------------
function FilterDegrade_Callback(hObject, eventdata, handles)% hObject handle to FilterDegrade (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%Closing the Restore GUI & Opening the Degrade GUI
delete(gcf);
GUIDegrade;
% ----------------------
function FilterRestore_Callback(hObject, eventdata, handles)% hObject handle to FilterRestore (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% ----------------------
function RestoreInverse_Callback(hObject, eventdata, handles)% hObject handle to RestoreInverse (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');
assignin('base', 'algo', 1);
settingAlgo(handles, 1);
set(gcf,'pointer','arrow');
set(handles.lblstatus, 'String', 'Status: Ready', 'Foregroundcolor', 'Black');
% ----------------------
function RestoreWiener_Callback(hObject, eventdata, handles)% hObject handle to RestoreWiener (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');
assignin('base', 'algo', 2);
settingAlgo(handles, 2);
set(gcf,'pointer','arrow');
set(handles.lblstatus, 'String', 'Status: Ready', 'Foregroundcolor', 'Black');
% ----------------------
function RestoreLucyRichardson_Callback(hObject, eventdata, handles)% hObject handle to RestoreLucyRichardson (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');
assignin('base', 'algo', 3);
settingAlgo(handles, 3);
set(gcf,'pointer','arrow');
set(handles.lblstatus, 'String', 'Status: Ready', 'Foregroundcolor', 'Black');
% ----------------------
function RestoreCompare_Callback(hObject, eventdata, handles)
% hObject handle to RestoreCompare (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%Closing the Restore GUI & Opening the Compare GUI
delete(gcf);
GUICompare;
% ----------------------
function Help_Callback(hObject, eventdata, handles)% hObject handle to Help (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% ----------------------
function HelpHelp_Callback(hObject, eventdata, handles)% hObject handle to HelpHelp (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\Home.html'], '-browser');
set(gcf,'pointer','arrow');
set(handles.lblstatus, 'String', 'Status: Ready', 'Foregroundcolor', 'Black');
% ----------------------
function HelpAboutUs_Callback(hObject, eventdata, handles)% hObject handle to HelpAboutUs (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\About Us.html'], '-browser');
set(gcf,'pointer','arrow');
set(handles.lblstatus, 'String', 'Status: Ready', 'Foregroundcolor', 'Black');
% ----------------------- End of GUIRestore --------------------------
function zoomimage(hObject, eventdata, handles, restoredimg, pix)
%Function to zoom an image and display it on the zoom axis
global zoompoint;
pix = floor(get(handles.sldzoomfactor, 'Value'));
zoompoint = floor(zoompoint);
restoredimg = evalin('base', 'restoredimg');
%Calculating the limits from the selected point
Xmin = zoompoint(2) - pix;
Xmax = zoompoint(2) + pix;
if Xmin<1
Xmin = 1;
end
if Xmax>size(restoredimg, 1)
Xmax = size(restoredimg, 1);
end
Ymin = zoompoint(1) - pix;
Ymax = zoompoint(1) + pix;
if Ymin<1
Ymin = 1;
end
if Ymax>size(restoredimg, 2)
Ymax = size(restoredimg, 2);
end
%Reading the zoomed region from the image
zoomedimg = restoredimg(Xmin:Xmax, Ymin:Ymax);
%Displaying the zoomed image
axes(handles.axiszoom);
imshow(real(zoomedimg));
% --- Executes during object creation, after setting all properties.
function sldzoomfactor_CreateFcn(hObject, eventdata, handles)
% hObject handle to sldzoomfactor (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 sldzoomfactor_Callback(hObject, eventdata, handles)
% hObject handle to sldzoomfactor (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
zoomimage(hObject, eventdata, handles);
function settingAlgo(handles, algo)
%This function sets the menu and the GUI for the respective algorithm
%Reset all the menu items
set(handles.RestoreInverse, 'Checked', 'off');
set(handles.RestoreWiener, 'Checked', 'off');
set(handles.RestoreLucyRichardson, 'Checked', 'off');
%Disabling the GUI Components
set(handles.slditerations, 'Enable', 'off');
set(handles.txtiterations, 'Enable', 'off');
set(handles.sldsnr, 'Enable', 'off');
set(handles.txtsnr, 'Enable', 'off');
set(handles.pbestimatesnr, 'Enable', 'off');
%Setting the menu item & gui properties
switch algo
case 1
set(handles.RestoreInverse, 'Checked', 'on');
set(handles.lbltitle, 'String', 'Inverse Filter');
case 2
set(handles.RestoreWiener, 'Checked', 'on');
set(handles.lbltitle, 'String', 'Wiener Filter');
set(handles.sldsnr, 'Enable', 'on');
set(handles.txtsnr, 'Enable', 'on');
set(handles.pbestimatesnr, 'Enable', 'on');
case 3
set(handles.slditerations, 'Enable', 'on');
set(handles.txtiterations, 'Enable', 'on');
set(handles.RestoreLucyRichardson, 'Checked', 'on');
set(handles.lbltitle, 'String', 'Lucy-Richardson');
end
% --- Executes during object creation, after setting all properties.function sldlength_CreateFcn(hObject, eventdata, handles)% hObject handle to sldlength (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 sldlength_Callback(hObject, eventdata, handles)% hObject handle to sldlength (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 sliderstr = sprintf('%.0f', get(handles.sldlength, 'Value'));
set(handles.txtlength, 'String', str);
% --- Executes during object creation, after setting all properties.function sldtheta_CreateFcn(hObject, eventdata, handles)% hObject handle to sldtheta (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 sldtheta_Callback(hObject, eventdata, handles)% hObject handle to sldtheta (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 sliderstr = sprintf('%.0f', get(handles.sldtheta, 'Value'));
set(handles.txttheta, 'String', str);
% --- Executes during object creation, after setting all properties.function txtlength_CreateFcn(hObject, eventdata, handles)% hObject handle to txtlength (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'));endfunction txtlength_Callback(hObject, eventdata, handles)% hObject handle to txtlength (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 txtlength as text% str2double(get(hObject,'String')) returns contents of txtlength as a doublestr = str2num(get(handles.txtlength,'String'));
if str<1 || str>100
uiwait(errordlg('Please enter blur length in the range 1 to 100.', 'Invalid Length', 'modal'));
%Resetting length
str = sprintf('%.0f', get(handles.sldlength, 'Value'));
set(handles.txtlength, 'String', str);
else
set(handles.sldlength,'Value', str);
end
% --- Executes during object creation, after setting all properties.function txttheta_CreateFcn(hObject, eventdata, handles)% hObject handle to txttheta (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.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -