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

📄 main.m

📁 A matlab gui for basic image processing operations
💻 M
📖 第 1 页 / 共 3 页
字号:
% --- Executes during object creation, after setting all properties.function edit_un_alpha_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_un_alpha (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');endfunction edit_edge_threshold_Callback(hObject, eventdata, handles)% hObject    handle to edit_edge_threshold (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 edit_edge_threshold as text%        str2double(get(hObject,'String')) returns contents of edit_edge_threshold as a double% --- Executes during object creation, after setting all properties.function edit_edge_threshold_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_edge_threshold (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');end% --- Executes on button press in pushbutton_filter.function pushbutton_filter_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton_filter (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)global choice;global image;input1=str2num(get(handles.edit_av_rows,'String'));input2=str2num(get(handles.edit_av_col,'String'));input3=str2num(get(handles.edit_disk_radius,'String'));input4=str2num(get(handles.edit_g_rows,'String'));input5=str2num(get(handles.edit_g_col,'String'));input6=str2num(get(handles.edit_g_sigma,'String'));input7=str2num(get(handles.edit_l_alpha,'String'));input8=str2num(get(handles.edit_log_rows,'String'));input9=str2num(get(handles.edit_log_col,'String'));input10=str2num(get(handles.edit_log_sigma,'String'));input11=str2num(get(handles.edit_m_len,'String'));input13=str2num(get(handles.edit_un_alpha,'String'));if (choice==1)        if ((input1<=0)||(input2<=0))            validate(1);        end        rows=str2num(get(handles.edit_av_rows,'String'));        col=str2num(get(handles.edit_av_col,'String'));        H = fspecial('average',[rows col]);        F = imfilter(image,H,'replicate');        cla(handles.axes_edges);        axes(handles.axes_edges);imshow(F);end if (choice==2)        if (input3<=0)            validate(2);        end        radius=str2num(get(handles.edit_disk_radius,'String'));        H = fspecial('disk',radius);        F = imfilter(image,H,'replicate');        cla(handles.axes_edges);        axes(handles.axes_edges);imshow(F);endif (choice==3)        if ((input4<=0) || (input5<=0) || (input6<=0))            validate(3);            return;        end        rows=str2num(get(handles.edit_g_rows,'String'));        col=str2num(get(handles.edit_g_col,'String'));        sigma=str2num(get(handles.edit_g_sigma,'String'));        H = fspecial('gaussian',[rows col],sigma);        F = imfilter(image,H,'replicate');        cla(handles.axes_edges);        axes(handles.axes_edges);imshow(F);  endif (choice==4)        if ((input7<0)||(input7>1))            validate(4);        end        alpha=str2num(get(handles.edit_l_alpha,'String'));        H = fspecial('laplacian',alpha);        F = imfilter(image,H,'replicate');        cla(handles.axes_edges);        axes(handles.axes_edges);imshow(F);  endif (choice==5)       if ((input8<=0)||(input9<=0)||(input10<=0))            validate(5);        end        rows=str2num(get(handles.edit_log_rows,'String'));        col=str2num(get(handles.edit_log_col,'String'));        sigma=str2num(get(handles.edit_log_sigma,'String'));        H = fspecial('log',[rows col],sigma);        F = imfilter(image,H,'replicate');        cla(handles.axes_edges);        axes(handles.axes_edges);imshow(F);  end if (choice==6)        if (input11<=0)            validate(6);        end        len=str2num(get(handles.edit_m_len,'String'));        theta=str2num(get(handles.edit_m_theta,'String'));        H = fspecial('motion',len,theta);        F = imfilter(image,H,'replicate');        cla(handles.axes_edges);        axes(handles.axes_edges);imshow(F);  endif (choice==7)        if (input13<=0 ||(input13>1))            validate(7);        end        alpha=str2num(get(handles.edit_un_alpha,'String'));        H = fspecial('unsharp',alpha);        F = imfilter(image,H,'replicate');        cla(handles.axes_edges);        axes(handles.axes_edges);imshow(F);  endfunction edit_m_len_Callback(hObject, eventdata, handles)% hObject    handle to edit_m_len (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 edit_m_len as text%        str2double(get(hObject,'String')) returns contents of edit_m_len as a double% --- Executes during object creation, after setting all properties.function edit_m_len_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_m_len (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');endfunction edit_m_theta_Callback(hObject, eventdata, handles)% hObject    handle to edit_m_theta (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 edit_m_theta as text%        str2double(get(hObject,'String')) returns contents of edit_m_theta as a double% --- Executes during object creation, after setting all properties.function edit_m_theta_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_m_theta (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');endfunction edit_av_rows_Callback(hObject, eventdata, handles)% hObject    handle to edit_av_rows (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 edit_av_rows as text%        str2double(get(hObject,'String')) returns contents of edit_av_rows as a double% --- Executes during object creation, after setting all properties.function edit_av_rows_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_av_rows (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');endfunction edit_av_col_Callback(hObject, eventdata, handles)% hObject    handle to edit_av_col (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 edit_av_col as text%        str2double(get(hObject,'String')) returns contents of edit_av_col as a double% --- Executes during object creation, after setting all properties.function edit_av_col_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_av_col (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');endfunction edit_thr_Callback(hObject, eventdata, handles)% hObject    handle to edit_thr (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 edit_thr as text%        str2double(get(hObject,'String')) returns contents of edit_thr as a double% --- Executes during object creation, after setting all properties.function edit_thr_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_thr (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');end% --- Executes on button press in pushbutton_edge.function pushbutton_edge_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton_edge (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)global edge_choice;global image_edge;input=str2num(get(handles.edit_thr,'String'));if (isempty(input)) || (input<0) || (input>1)    msgboxText{1} =  'You have tried to input something that is NOT ';     msgboxText{2} = 'a number or a negative number!';    msgboxText{3} =  'Try an input greater than zero and less than 1.';    msgbox(msgboxText,'Incorrect paramenter!', 'warn','modal');    return;endif (edge_choice==1)        BW = edge(image_edge,'sobel',input);    cla(handles.axes_edges);    axes(handles.axes_edges);imshow(BW);endif (edge_choice==2)        BW = edge(image_edge,'prewitt',input);    cla(handles.axes_edges);    axes(handles.axes_edges);imshow(BW);endif (edge_choice==3)       BW = edge(image_edge,'roberts',input);    cla(handles.axes_edges);    axes(handles.axes_edges);imshow(BW);endif (edge_choice==4)        BW = edge(image_edge,'zerocross',input);    cla(handles.axes_edges);    axes(handles.axes_edges);imshow(BW);endif (edge_choice==5)        BW = edge(image_edge,'canny',input);    cla(handles.axes_edges);    axes(handles.axes_edges);imshow(BW);end

⌨️ 快捷键说明

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