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

📄 guidegrade.m

📁 dip函数 hough houghpeaks
💻 M
📖 第 1 页 / 共 3 页
字号:
% 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.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 chknoise.
function chknoise_Callback(hObject, eventdata, handles)
% hObject    handle to chknoise (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 chknoise

if get(handles.chknoise, 'Value')
    %Enabling the popup menu for noise type
    set(handles.popnoisetype, 'Enable', 'on');
    popnoisetype_Callback(hObject, eventdata, handles);
else
    %Disabling popup menu for noise type
    set(handles.popnoisetype, 'Enable', 'off');
    
    %Disabling all the sliders
    set(handles.sldnoisedensity, 'Enable', 'off');
    set(handles.sldmean, 'Enable', 'off');
    set(handles.sldvariance, 'Enable', 'off');

    %Resetting all the labels
    set(handles.lblnoisedensityval, 'String', 0);
    set(handles.lblmeanval, 'String', 0);
    set(handles.lblvarianceval, 'String', 0);
end


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

% Hint: popupmenu 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


% --- Executes on selection change in popnoisetype.
function popnoisetype_Callback(hObject, eventdata, handles)
% hObject    handle to popnoisetype (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popnoisetype contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popnoisetype

%Disabling all the sliders
set(handles.sldnoisedensity, 'Enable', 'off');
set(handles.sldmean, 'Enable', 'off');
set(handles.sldvariance, 'Enable', 'off');

%Resetting all the labels
set(handles.lblnoisedensityval, 'String', 0);
set(handles.lblmeanval, 'String', 0);
set(handles.lblvarianceval, 'String', 0);

% 1: salt & pepper
% 2: gaussian
% 3: poisson
% 4: speckle
switch get(handles.popnoisetype, 'Value')
    case 1,
        set(handles.sldnoisedensity, 'Enable', 'on', 'Value', 0.05);
        set(handles.lblnoisedensityval, 'String', 0.05);
    case 2,
        set(handles.sldmean, 'Enable', 'on', 'Value', 0);
        set(handles.lblmeanval, 'String', 0);
        set(handles.sldvariance, 'Enable', 'on', 'Value', 0.01);
        set(handles.lblvarianceval, 'String', 0.01);
    case 4,
        set(handles.sldvariance, 'Enable', 'on', 'Value', 0.04);
        set(handles.lblvarianceval, 'String', 0.04);
end


% --- Executes during object creation, after setting all properties.
function sldmean_CreateFcn(hObject, eventdata, handles)
% hObject    handle to sldmean (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 sldmean_Callback(hObject, eventdata, handles)
% hObject    handle to sldmean (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
value = sprintf('%.2f', get(handles.sldmean, 'Value'));
set(handles.lblmeanval, 'String', value);


% --- Executes during object creation, after setting all properties.
function sldvariance_CreateFcn(hObject, eventdata, handles)
% hObject    handle to sldvariance (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 sldvariance_Callback(hObject, eventdata, handles)
% hObject    handle to sldvariance (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
value = sprintf('%.2f', get(handles.sldvariance, 'Value'));
set(handles.lblvarianceval, 'String', value);


% --- Executes during object creation, after setting all properties.
function sldnoisedensity_CreateFcn(hObject, eventdata, handles)
% hObject    handle to sldnoisedensity (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 sldnoisedensity_Callback(hObject, eventdata, handles)
% hObject    handle to sldnoisedensity (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
value = sprintf('%.2f', get(handles.sldnoisedensity, 'Value'));
set(handles.lblnoisedensityval, 'String', value);

% --- Executes on button press in pbdegradeimg.function pbdegradeimg_Callback(hObject, eventdata, handles)% hObject    handle to pbdegradeimg (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', 'degimstatus') >= 1 & comein >= 1
    %Reading original image from base workspace
    originalimg = evalin('base', 'originalimg');
    LEN         = str2num(get(handles.txtlength, 'String'));
    THETA       = str2num(get(handles.txttheta, 'String'));

    %If noise is checked
    if get(handles.chknoise, 'Value')
        switch get(handles.popnoisetype, 'Value')
            case 1 %salt & pepper
                d = str2num(get(handles.lblnoisedensityval, 'String'));
                degradedimg = degrade(originalimg, LEN, THETA, 'salt & pepper', d);
            case 2 %gaussian
                m = str2num(get(handles.lblmeanval, 'String'));
                v = str2num(get(handles.lblvarianceval, 'String'));
                degradedimg = degrade(originalimg, LEN, THETA, 'gaussian', m, v);
            case 3 %poisson
                degradedimg = degrade(originalimg, LEN, THETA, 'poisson');
            case 4 %speckle
                v = str2num(get(handles.lblvarianceval, 'String'));
                degradedimg = degrade(originalimg, LEN, THETA, 'speckle', v);
        end
    else %noise is not checked
        degradedimg = degrade(originalimg, LEN, THETA);
    end

    %Make the axisdegradedimg the current axes
    axes(handles.axisdegradedimg);
    imshow(real(degradedimg));

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

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

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

    %Enabling the File->LoadDegraded & Save
    set(handles.FileSave, 'Enable', 'on');
    set(handles.FileLoadDegraded, '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\Degrade.html'], '-browser');
set(gcf,'pointer','arrow');
set(handles.lblstatus, 'String', 'Status: Ready', 'Foregroundcolor', 'Black');

⌨️ 快捷键说明

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