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

📄 guirestore.m

📁 dip函数 hough houghpeaks
💻 M
📖 第 1 页 / 共 3 页
字号:
function varargout = GUIRestore(varargin)
% GUIRESTORE M-file for GUIRestore.fig
%      GUIRESTORE, by itself, creates a new GUIRESTORE or raises the existing
%      singleton*.
%
%      H = GUIRESTORE returns the handle to a new GUIRESTORE or the handle to
%      the existing singleton*.
%
%      GUIRESTORE('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUIRESTORE.M with the given input arguments.
%
%      GUIRESTORE('Property','Value',...) creates a new GUIRESTORE or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before GUIRestore_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to GUIRestore_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools guirestore.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help GUIRestore

% Last Modified by GUIDE v2.5 16-Apr-2005 21:35:52
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @GUIRestore_OpeningFcn, ...
                   'gui_OutputFcn',  @GUIRestore_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before GUIRestore is made visible.
function GUIRestore_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to GUIRestore (see VARARGIN)

% Choose default command line output for GUIRestore
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% Hiding the axis
set(handles.axisdegradedimg, 'Visible', 'off');
set(handles.axisrestoredimg, 'Visible', 'off');
set(handles.axiszoom, 'Visible', 'off');

%Disabling File->LoadDegraded, LoadRestored & Save menu items
set(handles.FileSave, 'Enable', 'off');
set(handles.FileLoadDegraded, 'Enable', 'off');
set(handles.FileLoadRestored, 'Enable', 'off');

%Disabling the Edit menu item
set(handles.EditUndo, 'Enable', 'off');
set(handles.EditRedo, 'Enable', 'off');
set(handles.EditCrop, 'Enable', 'off');
set(handles.EditZoom, 'Enable', 'off');

%Enabling the menu item to load recently degraded image
if evalin('base', 'degimstatus') == 2
    set(handles.FileLoadDegraded, 'Enable', 'on');
end

%Enabling the menu item to load recently restored image
if evalin('base', 'resimstatus') == 2
    set(handles.FileLoadRestored, 'Enable', 'on');
end

%Setting the Filter->Restore menu item
set(handles.FilterRestore, 'Checked', 'on');

%Setting the Algorithm
settingAlgo(handles, evalin('base', 'algo'));

%Initialising global variable to 0 to signify that GUI is freshly opened
global comein; comein = 0;

%Setting the close function
set(gcf, 'CloseRequestFcn', 'my_closereq');

% UIWAIT makes GUIRestore wait for user response (see UIRESUME)
% uiwait(handles.GUIRestore);


% --- Outputs from this function are returned to the command line.
function varargout = GUIRestore_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;

% -------------------Start of GUIRestore ----------------------function File_Callback(hObject, eventdata, handles)% hObject    handle to File (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)
% ----------------------
function FileLoadDegraded_Callback(hObject, eventdata, handles)
% hObject    handle to FileLoadDegraded (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;

%Loading the degraded image from the base workspace
degradedimg = evalin('base', 'degradedimg');

%Displaying on the axis
axes(handles.axisdegradedimg);
imshow(real(degradedimg));

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

%Setting image status to signify that image is opened
if evalin('base', 'resimstatus') < 1
    assignin('base', 'resimstatus', 1);
end

%Initialising comein to 1 to signify that image is opened
comein = 1;

%Enabling the crop menu item
set(handles.EditCrop, 'Enable', 'on');

pbestimatesnr_Callback(hObject, eventdata, handles);
set(gcf,'pointer','arrow');
set(handles.lblstatus, 'String', 'Status: Ready', 'Foregroundcolor', 'Black');


% ----------------------
function FileLoadRestored_Callback(hObject, eventdata, handles)
% hObject    handle to FileLoadRestored (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;

%Loading the degraded image from the base workspace
degradedimg = evalin('base', 'restoredimg');

%Displaying on the axis
axes(handles.axisdegradedimg);
imshow(real(degradedimg));

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

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

%Setting image status to signify that image is opened
if evalin('base', 'resimstatus') < 1
    assignin('base', 'resimstatus', 1);
end

%Initialising comein to 1 to signify that image is opened
comein = 1;

%Enabling the crop menu item
set(handles.EditCrop, 'Enable', 'on');

pbestimatesnr_Callback(hObject, eventdata, handles);
set(gcf,'pointer','arrow');
set(handles.lblstatus, 'String', 'Status: Ready', 'Foregroundcolor', 'Black');


% ----------------------function FileOpen_Callback(hObject, eventdata, handles)% hObject    handle to FileOpen (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;
[filename, pathname] = uigetfile('*.bmp;*.jpg;*.tif;', 'Open input image');

if filename ~= 0
    %Displaying the degraded image
    file = [pathname filename];
    degradedimg = imread(file);

    %Converting to double
    degradedimg = im2double(degradedimg);

    %Converting the image to grayshade
    if size(degradedimg, 3) == 3,
        degradedimg = rgb2gray(degradedimg);
    end

    %Setting axisdegradedimg as the current axis
    axes(handles.axisdegradedimg);
    imshow(real(degradedimg));
    
    %Storing the image in the base workspace
    assignin('base','degradedimg',degradedimg);
    
    %Setting start to 1 signifying that image is opened
    assignin('base', 'resimstatus', 1);

    %Initialising comein to 1 to signify that image is opened
    comein = 1;

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

    %Enabling the crop menu item
    set(handles.EditCrop, 'Enable', 'on');

    pbestimatesnr_Callback(hObject, eventdata, handles);
end
set(gcf,'pointer','arrow');
set(handles.lblstatus, 'String', 'Status: Ready', 'Foregroundcolor', 'Black');
% ----------------------
function FileSave_Callback(hObject, eventdata, handles)% hObject    handle to FileSave (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');

restoredimg = evalin('base', 'restoredimg');
[filename, pathname] = uiputfile('*.bmp', 'Save image');

if filename ~= 0
    file = [pathname, filename, '.bmp'];

    %Saving the degraded image
    imwrite(restoredimg, file, 'bmp');
end
set(gcf,'pointer','arrow');
set(handles.lblstatus, 'String', 'Status: Ready', 'Foregroundcolor', 'Black');
% ----------------------
function FileExit_Callback(hObject, eventdata, handles)% hObject    handle to FileExit (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)close;


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


% ----------------------
function EditUndo_Callback(hObject, eventdata, handles)
% hObject    handle to EditUndo (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');

%Reading the old image for undo
degradedimgundo = evalin('base', 'degradedimgundo');

%Reading the modified image for redo
degradedimgredo = evalin('base', 'degradedimg');

%Storing the modified image for redo
assignin('base', 'degradedimgredo', degradedimgredo);

%Storing the old image as current image
assignin('base', 'degradedimg', degradedimgundo);

%Displaying the old image
axes(handles.axisdegradedimg);
imshow(real(degradedimgundo));

%Estimating SNR for the new image
pbestimatesnr_Callback(hObject, eventdata, handles);

%Enabling the Redo & Disabling Undo menu item
set(handles.EditRedo, 'Enable', 'on');
set(handles.EditUndo, 'Enable', 'off');

set(gcf,'pointer','arrow');
set(handles.lblstatus, 'String', 'Status: Ready', 'Foregroundcolor', 'Black');


% ----------------------
function EditRedo_Callback(hObject, eventdata, handles)
% hObject    handle to EditRedo (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');

%Reading the old image for redo
degradedimgredo = evalin('base', 'degradedimgredo');

%Storing the modified image as current image
assignin('base', 'degradedimg', degradedimgredo);

%Displaying the old image
axes(handles.axisdegradedimg);
imshow(real(degradedimgredo));

%Estimating SNR for the new image
pbestimatesnr_Callback(hObject, eventdata, handles);

%Diabling the Redo & Enabling Undo menu item
set(handles.EditRedo, 'Enable', 'off');
set(handles.EditUndo, 'Enable', 'on');

set(gcf,'pointer','arrow');
set(handles.lblstatus, 'String', 'Status: Ready', 'Foregroundcolor', 'Black');


% ----------------------
function EditCrop_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.axisdegradedimg);
global comein;

%Enter only if image is opened first
if evalin('base', 'resimstatus') >= 1 & comein >= 1
    set(handles.lbleditstatus, 'Visible', 'on');
    set(gcf,'pointer','crosshair');
    set(handles.lblstatus, 'Foregroundcolor', 'Red');
    set(handles.lblstatus, 'String', 'Status: Starting Point');
    status = waitforbuttonpress;
    if status==0
        point1 = get(gca, 'CurrentPoint');
        point1 = round(point1(1,1:2)); % extract x1 and y1
        
        set(handles.lblstatus, 'String', 'Status: Ending Point');
        status = waitforbuttonpress;
        if status==0
            point2 = get(gca, 'CurrentPoint');
            point2 = round(point2(1,1:2)); % extract x2 and y2

            set(handles.lblstatus, 'String', 'Status: Busy');
            set(gcf,'pointer','watch');

            %Reading the degraded image
            degradedimg = evalin('base', 'degradedimg');

⌨️ 快捷键说明

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