基于MATLAB的图像平滑处理(完美运行).zip
大小:82.63KB
价格:37积分
下载量:0
评分:
5.0
上传者:2401_86539719
更新日期:2024-08-13

基于MATLAB的图像平滑处理(完美运行)

资源文件列表(大概)

文件名
大小
基于MATLAB的图像平滑处理(完美运行)/
-
基于MATLAB的图像平滑处理(完美运行)/a.jpg
67.38KB
基于MATLAB的图像平滑处理(完美运行)/mainfc.p
202B
基于MATLAB的图像平滑处理(完美运行)/test.fig
10.04KB
基于MATLAB的图像平滑处理(完美运行)/test.m
12.35KB

资源内容介绍

图像平滑处理是一种常用的图像处理方法,用于去除图像中的噪声,使得图像变得更加平滑和清晰。图像平滑处理的目标是在尽量保留图像的细节的同时,去除图像中的噪声。图像平滑处理通常基于图像的局部特征,通过对图像中的像素进行加权平均来实现。常用的图像平滑处理方法有以下几种:1. 均值滤波:将图像中的每个像素替换为其周围像素的平均值。均值滤波可以有效去除图像中的高频噪声,但会导致图像的细节模糊。2. 中值滤波:将图像中的每个像素替换为其周围像素的中值。中值滤波适用于去除图像中的椒盐噪声等脉冲噪声,能够保持图像的边缘和细节。3. 高斯滤波:通过对图像中的像素进行加权平均来平滑图像。高斯滤波可以有效去除图像中的高频噪声,同时保持图像的细节和边缘特征。4. 双边滤波:在进行像素平均时,考虑到图像的空间距离和像素之间的灰度差异。双边滤波可以有效平滑图像,同时保持图像的边缘和纹理细节。图像平滑处理在很多图像处理应用中都有广泛的应用,如图像降噪、图像增强、图像压缩等。通过选择合适的平滑处理方法,可以使得图像在去噪的同时保持更好的视觉效果。
function varargout = test(varargin)% TEST MATLAB code for test.fig% TEST, by itself, creates a new TEST or raises the existing% singleton*.%% H = TEST returns the handle to a new TEST or the handle to% the existing singleton*.%% TEST('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in TEST.M with the given input arguments.%% TEST('Property','Value',...) creates a new TEST or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before test_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to test_OpeningFcn via varargin.%% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one% instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help test% Last Modified by GUIDE v2.5 27-Jun-2023 17:12:12% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @test_OpeningFcn, ... 'gui_OutputFcn', @test_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endmainfc;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 test is made visible.function test_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 test (see VARARGIN)% Choose default command line output for testhandles.output = hObject;mainfc;% Update handles structureguidata(hObject, handles);% UIWAIT makes test wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = test_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 structurevarargout{1} = handles.output;% --- Executes on button press in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles) [filename, pathname] = uigetfile({'*.jpg';'*.bmp';'*.jpeg'},'选择图像'); if isequal(filename,0) | isequal(pathname,0) disp('取消,重选'); else disp(['选择 ', fullfile(pathname, filename)]) endx=imread(filename);axes(handles.axes1)imshow(x)title('原图')handles.x=xguidata(hObject, handles);set(handles.text2,'string','图像选择完毕')% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)set(handles.text2,'string','梯度倒数加权平均平滑算法。。。')pause(1)ticx=handles.xI=x; H=sqrt(double(I));%把数据类型转换成double,然后进行平方根变换H=uint8(H);%sqrt函数不支持uint8类型,把数据类型转换成uint8类型 %对图象p1-03施加高斯噪声和椒盐噪声并实施梯度倒数加权平滑法(公式4.2.3、4.2.4、4.2,利用方差评价空域平滑的效果a=imnoise(I,'salt & pepper'); axes(handles.axes2); imshow(a); title('椒盐噪声图'); a=double(a); [dep,wide]=size(a); new_image=ones(size(a)); r=0.5; for i=2:dep-1 for j=2:wide-1 g=0; for m=-1:1 for n=-1:1 if(a(i+m,j+n)-a(i,j)==0) g(m+2,n+2)=0; else g(m+2,n+2)=1/abs(a(i+m,j+n)-a(i,j)); end end end G=sum(sum(g)); for m=-1:1 for n=-1:1 w(m+2,n+2)=g(m+2,n+2)/G; end end new_image(i,j)=a(i,j)*r+(1-r)*(w(-1+2,-1+2)*a(i-1,j-1)+w(-1+2,0+2)*a(i-1,j)+w(-1+2,1+2)*a(i-1,j+1)+w(0+2,-1+2)*a(i,j-1)+w(0+2,1+2)*a(i,j+1)+w(1+2,-1+2)*a(i+1,j-1)+w(1+2,0+2)*a(i+1,j)+w(1+2,1+2)*a(i+1,j+1)); end end for i=2:dep-1 new_image(i,1)=new_image(i,2); new_image(i,wide)=new_image(i,wide-1); end new_image(1,:)=new_image(2,:); new_image(dep,:)=new_image(dep-1,:); axes(handles.axes3); imshow(x); title('最后梯度倒数加权平滑'); time=tocset(handles.edit1,'string',time)set(handles.text2,'string','梯度倒数加权平均平滑处理完毕')% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton3.function pushbutton3_Callback(hObject, eventdata, handles)set(handles.text2,'string','最大均匀性平滑滤波开始,约需等待95s。。。')pause(1)ticx=handles.x%**********************最大均匀性平滑法滤波*************************%im=x;[m,n]=size(im);noise_pic=imnoise(im,'salt & pepper',0.02); axes(handles.axes2)imshow(noise_pic);title('椒盐噪声图')I=im2double(im) ;for h=1:m X(1,h)=I(1,h); X(2,h)=I(2,h); X(n-1,h)=I(n-1,h); X(n,h)=I(n,h); end for j=1:n X(j,1)=I(j,1); X(j,2)=I(j,2); X(j,m-1)=I(j,m-1); X(j,m)=I(j,m); end for i=3:n-2 for j=3:m-2 F1=[I(i-2,j-2),I(i-2,j-1),I(i-2,j),I(i-1,j-2),I(i-1,j-1),I(i-1,j),I(i,j-2),I(i,j-1),I(i,j)];%取出每个邻域的像素值 F2=[I(i-2,j+1),I(i-2,j-1),I(i-2,j),I(i-1,j+1),I(i-1,j-1),I(i-1,j),I(i,j+1),I(i,j-1),I(i,j)]; F3=[I(i-2,j+1),I(i-2,j+2),I(i-2,j),I(i-1,j+1),I(i-1,j+2),I(i-1,j),I(i,j+1),I(i,j+2),I(i,j)]; F4=[I(i+1,j-2),I(i+1,j-1),I(i+1,j),I(i-1,j-2),I(i-1,j-1),I(i-1,j),I(i,j-2),I(i,j-1),I(i,j)]; F5=[I(i+1,j+1),I(i+1,j-1),I(i+1,j),I(i-1,j+1),I(i-1,j-1),I(i-1,j),I(i,j+1),I(i,j-1),I(i,j)]; F6=[I(i+1,j+1),I(i+1,j+2),I(i+1,j),I(i-1,j+1),I(i-1,j+2),I(i-1,j),I(i,j+1),I(i,j+2),I(i,j)]; F7=[I(i+1,j-2),I(i+1,j-1),I(i+1,j),I(i+2,j-2),I(i+2,j-1),I(i+2,j),I(i,j-2),I(i,j-1),I(i,j)]; F8=[I(i+1,j+1),I(i+1,j-1),I(i+1,j),I(i+2,j+1),I(i+2,j-1),I(i+2,j),I(i,j+1),I(i,j-1),I(i,j)]; F9=[I(i+1,j+1),I(i+1,j+2),I(i+1,j),I(i+2,j+1),I(i+2,j+2),I(i+2,j),I(i,j+1),I(i,j+2),I(i,j)]; I1=var(F1); I2=var(F2); I3=var(F3); I4=var(F4); I5=var(F5); I6=var(F6); I7=var(F7); I8=var(F8); I9=var(F9); %求方差 array=[I1,I2,I3,I4,I5,I6,I7,I8,I9]; %将方差放在一个数组中 A=sort(array); %对方差排序 switch A(1) %判断最小方差属于哪一个邻域 case I1 average=(I(i-2,j-2)+I(i-2,j-1)+I(i-2,j)+I(i-1,j-2)+I(i-1,j-1)+I(i-1,j)+I(i,j-2)+I(i,j-1)+I(i,j))/9; case I2 average=(I(i-2,j+1)+I(i-2,j-1)+I(i-2,j)+I(i-1,j+1)+I(i-1,j-1)+I(i-1,j)+I(i,j+1)+I(i,j-1)+I(i,j))/9; case I3 average=(I(i-2,j+1)+I(i-2,j+2)+I(i-2,j)+I(i-1,j+1)+I(i-1,j+2)+I(i-1,j)+I(i,j+1)+I(i,j+2)+I(i,j))/9; case I4 average=(I(i+1,j-2)+I(i+1,j-1)+I(i+1,j)+I(i-1,j-2)+I(i-1,j-1)+I(i-1,j)+I(i,j-2)+I(i,j-1)+I(i,j))/9; c

用户评论 (0)

发表评论

captcha

相关资源

基于MATLAB的图像去雾源码(完美运行)

图像去雾是一种图像处理技术,用于去除由雾、烟雾或其他大气颗粒引起的图像模糊和降低对比度的效果。这种技术可以通过对图像进行复原和增强来恢复图像的细节和清晰度。图像去雾的方法可以分为基于物理模型和基于数据驱动的方法。基于物理模型的图像去雾方法使用了大气散射模型,该模型描述了雾和烟雾对光的散射和吸收。根据这个模型,可以通过分析图像中的像素值和颜色来推断图像中的雾的浓度和吸收程度,然后使用这些信息来去除图像中的雾。基于数据驱动的图像去雾方法则利用了大量的雾和非雾图像的训练数据,通过学习这些数据的特征和模式来去除图像中的雾。这些方法通常使用机器学习技术,如神经网络或支持向量机,来对图像进行分类和恢复。图像去雾的应用广泛,包括航空、卫星图像处理、视频监控、无人驾驶等领域。通过去除图像中的雾,可以提高图像的清晰度和对比度,从而更好地进行图像分析和识别。

683.42KB45积分

Android Systrace 博客资源

Android Systrace 博客资源

43.79MB19积分

EasyJava代码生成工具_EasyJava源码.zip

EasyJava代码生成工具_EasyJava源码.zip

35.12KB41积分

脚本一键卸载Visual Studio

有时候VS会出现一些难以解决的问题,这时候个人经验之谈就是,别折腾了,直接卸载重装就好。由于直接手动卸载可能会导致一些文件的残留,以至于重新安装也无法解决问题,可以用这个脚本工具进行无残留卸载。如果卸载重装VS也不行,好像只能重装系统了。。(当然了,也要根据具体出现的问题具体解决)

1.66MB45积分