二维数据的平滑

文摘   2024-07-18 17:24   德国  

二维数据的平滑


有时候数据较为粗糙,边缘性较大,需要做个平滑。

一维的平滑,smooth;

二维的平滑,smooth2;


用法介绍:

函数使用方法:

MATRIXOUT=SMOOTH2(MATRIXIN,Nr,Nc);

平滑度的大小设定:

Inputs: matrixIn - original matrix

                  Nr - number of points used to smooth rows

                  Nc - number of points to smooth columns

输出结果:

  Outputs:matrixOut - smoothed version of original matrix

默认选择:

    Remark: By default, if Nc is omitted, Nc = Nr.


函数下载路径:

ww2.mathworks.cn/login/mwa-sso?uri=https%3A%2F%2Fww2.mathworks.cn%2Fmatlabcentral%2Ffileexchange%2F6298-smooth2&tx_id=ggWzuRiuhMx9Yai1ngtN

Cite As

Kelly Hilands (2024). smooth2 (https://www.mathworks.com/matlabcentral/fileexchange/6298-smooth2), MATLAB Central File Exchange. Retrieved .

实例演示:




示例代码:

clear;clc;close all;
% 读取数据load('data.mat')diat_depth = double(diat_depth);% 画图close allfigureset(gcf,'position',[50 50 850 850])pcolor(diat_depth)shading flatcaxis([-20 10])axis off% 读取颜色包cmap = load('colormore_23.txt');colormap(flip(cmap))% 添加标题title('未平滑的图像','fontsize',20)% 保存图像export_fig('未平滑的图像.jpg','-r600')
%% 平滑度的设置for Nc = 1:2:10 Nr = Nc ; matrixOut = smooth2a(diat_depth, Nr, Nc); % MATRIXOUT=SMOOTH2(MATRIXIN,Nr,Nc) smooths the data in MATRIXIN % using a running mean over 2*N+1 successive points, N points on % each side of the current point. At the ends of the series % skewed or one-sided means are used. % % Inputs: matrixIn - original matrix % Nr - number of points used to smooth rows % Nc - number of points to smooth columns % Outputs:matrixOut - smoothed version of original matrix % % Remark: By default, if Nc is omitted, Nc = Nr. % 画图 close all figure set(gcf,'position',[50 50 850 850]) pcolor(matrixOut) shading flat caxis([-20 10]) axis off % 读取颜色包 cmap = load('colormore_23.txt'); colormap(flip(cmap)) % 添加标题 title(['平滑度为',num2str(Nc),'的图像'],'fontsize',20) % 保存图像 export_fig(['平滑度为',num2str(Nc),'的图像.jpg'],'-r600') close allend


海洋与大气科学
海洋与大气科学数据分析,数据可视化分享,可教学。
 最新文章