fspecial()和imfilter()用法解析

imfilter函数用法及其在边缘检测中的应用详解 其他选项包括 'symmetric', 'circular', 以及默认的 'zero' 等。imfilter 是 MATLAB 中用于图像滤波的函数,可以用于对图像进行卷积操作,从而实现各种滤波效果,如平滑、锐化、边缘检测等。以下是 imfilter 函数的基本使用方法,以及一个具体的滤波后边缘检测实例。B = imfilter(A, h) 使用多维滤波器 h 对多维数组 A 进行滤波,并在 B 中返回结果。%'replicate'数组边界之外的输入数组值假定为等于最近的数组边界值。 阅读详情

这篇blog里简单介绍下空间域滤波的方法,冈萨雷斯书里讲,通常情况下,当滤波器较小时,空间域滤波要比频域滤波更有效。“小”的定义较为复杂,取决于众多因素,如所使用的机器和算法、缓冲器的大小、所处理数据的复杂度等。

fspecial(), 这个函数,百度百科给的很明白,是一个用来定义滤波器的函数,可以定义各种滤波器,包括 'average' 'disk'  'gaussian'  'laplacian'  'log'  'motion' 'prewitt'  'sobel'  'unsharp'。

语法格式为
h = fspecial(type) 或者为
h = fspecial(type,para)
其中type指定算子的类型,para指定相应的参数;各个类型的滤波器写法可以参照百度百科。
现在滤波器是有了,下面需要 imfilter() 登场了。
功能:对任意类型数组或多维图像进行滤波。
用法:B = imfilter(A,H)
   B = imfilter(A,H,option1,option2,...)
   或写作g = imfilter(f, w, filtering_mode, boundary_options, size_options)
其中,f为输入图像,w为滤波器(这里可以使上面用fspecial()生成的滤波器),g为滤波后图像。filtering_mode用于指定在滤波过程中是使用“相关”还是“卷积”。boundary_options用于处理边界充零问题,边界的大小由滤波器的大小确定。具体参数选项见下表:

选项
描述
filtering_mode
‘corr’
通过使用相关来完成,该值为默认。

‘conv’
通过使用卷积来完成
boundary_options
‘X’
输入图像的边界通过用值X(无引号)来填充扩展
其默认值为0

‘replicate’
图像大小通过复制外边界的值来扩展

‘symmetric’
图像大小通过镜像反射其边界来扩展

‘circular’
图像大小通过将图像看成是一个二维周期函数的一个周期来扩展
size_options
‘full’
输出图像的大小与被扩展图像的大小相同

‘same’
输出图像的大小与输入图像的大小相同。这可通过将滤波掩模的中心点的偏移限制到原图像中包含的点来实现,该值为默认值。

下面给一些例子说明这两个函数合在一起用的效果:

用5*5 均值滤波:
w1=fspecial('average',5);
       A=imfilter(RGB,w1,'replicate');
       imshow(A)
结果是:

用sobel 算子提取边缘:
w8=fspecial('sobel');
       H=imfilter(RGB,w8,'replicate');
       imshow(H);
结果是:






关于MATLAB中imfilter函数的说明 1 imfilter函数简介函数名称:imfilter 函数语法:g=imfilter(f,w,filtering_mode,boundary_options,size_optinos) 函数功能:对任意类型数组或多维图像进行滤波 参数介绍:f是输入图像,w为滤波模板,g为滤波结果;表1-1总结了其他参数的含义。 表1-1 imfilter函数的选项 操作说明:在执行线性空间滤波 阅读详情

相关推荐

Matlab fspecial和imfilter对图像进行空间滤波

对图像空间滤波,简单点理解就是通过利用滤波器模板对图像像素进行操作,从而实现滤波功能。 这里介绍matlab中几个相关函数: imnoise(I,type…):为图像I添加type类型的噪声; type有以下一些类型: ‘gaussian’ ‘localvar’ ‘poisson’ ‘salt & pepper’ ‘speckle’ ,各类型都有相关参数;fspec

三哥的博客 4335

imfilter用法以及滤波讲解

【matlab函数描述】 功能:对任意类型数组或多维图像进行滤波。 用法:B = imfilter(A,H)    B = imfilter(A,H,option1,option2,…)    或写作g = imfilter(f, w, filtering_mode, boundary_options, size_options) 其中,f为输入图像,w为滤波掩模,g为滤波后图像。f

CAD之路 3万+

图像处理之matlab中fspecial函数用法详解

'gaussian’表示高斯低通滤波, h = fspecial(‘gaussian’,hsize,sigma生成高斯低通滤波器,参数hsize代表模板尺寸默认为3*3,sigma用于表示滤波器的标准差,单位为像素且默认值为0.5。'log’表示拉普拉斯高斯算子,h = fspecial(‘log’,hsize,sigma)生成拉普拉斯高斯滤波器,参数hsize代表模板尺寸默认为3*3,sigma用于表示滤波器的标准差,单位为像素且默认值为0.5。'sobel’为sobel算子,用于边缘提取,无参数。

qq_44111805的博客 2万+

Matlab的fspecial函数

参考: http://www.ilovematlab.cn/thread-52886-1-1.html 函数原型 h = fspecial(type) h = fspecial(type,para) 根据函数原型对fspecial函数作个说明,fspecial是用来生成滤波器(也叫算子)的函数,使用type参数来指定滤波器的种类,使用para来对具体的滤波器种类添加额外的参数信息。h...

Chaolei3的博客 4万+

阻容降压 vs 开关电源:5V小功率供电方案成本与安全深度对比

本文深度对比了阻容降压电路与开关电源在5V小功率供电方案中的核心差异。重点剖析了二者在成本、体积、效率、温升及安全隔离等方面的优劣,并结合智能温控器、LED驱动等典型应用场景,为硬件工程师提供了清晰的选型决策框架,帮助在成本与安全之间做出最佳权衡。

weixin_29310631的博客 700

ArcGIS基础:CAD数据转换为GIS数据(符号化显示、数据转换、线转面、空间连接)

1、符号化显示: CAD数据加载进来有很多列表,包含了点【point】、线【polyline】、面【polygon】、标注数据【Annotation】等数据,本次实验我们需要用到的是面数据,也就是.dwgPolygong格式的数据。如下图所示: 把数据加载进来,然后在2处打开属性表,查看CAD数据的属性表,打开后可以发现【layer】图层表示就是地块的用地性质,它就是符号化显示的依据。 我们在数据上右键【属性】,打开图层属性,找到【符号系统】,选择类别中的【唯一值】,然后在【值字段】下拉选择【layer】,

yuanYW7556的博客 2万+

数字图像处理(三):函数fspecial

目录1 函数fspecial2 滤波器的种类2.1 高斯滤波器2.2 均值滤波器2.3 圆形均值滤波器2.4 拉普拉斯滤波器2.5 拉普拉斯高斯滤波器2.6 prewitt2.7 sobel2.8 运动模糊(motion)滤波器2.9 unsharp 1 函数fspecial h = fspecial(type) h = fspecial(type,para) 根据函数原型对fspecial函数作...

小P的博客 6708

【PowerBI专栏】PowerBI导入MYSQL数据库

本文介绍了在PowerBI中连接MySQL数据库的方法。首先需要下载并安装MySQL官方.NET连接驱动(推荐8.4.0版本),安装完成后重启PowerBI。连接时需填写服务器IP和数据库名称等必填参数。文章详细说明了连接配置步骤,包括账户设置、数据表选择以及可能遇到的数据格式转换问题处理。最后指导用户完成数据清洗后进入PowerPivot进行后续计算。特别提醒最新9.4版本可能存在兼容性问题,建议使用稳定的8.4版本连接器。

技术与管理的平衡木- 689

MATLAB--数字图像处理 fspecial()与imfilter()的使用

fspecial()与imfilter()的使用 函数说明 fspecial(): h = fspecial(type) h = fspecial(type,para) 根据函数原型对fspecial函数作个说明,fspecial是用来生成滤波器(也叫算子)的函数,使用type参数来指定滤波器的种类,使用para来对具体的滤波器种类添加额外的参数信息。h就是生成的滤波器。 imfilter(): ...

海到无边天作岸 山登绝顶我为峰 7317

(3dnr)多帧视频图像去噪 (一)

视频图像去噪主要利用相邻帧间内容相似性,通过时域帧平均降低随机噪声。为避免运动物体产生"拖尾"现象,可采用运动自适应或运动补偿时域滤波方法。前者根据运动强度动态调整滤波系数,后者通过运动补偿使参考帧更接近当前帧。运动补偿方法虽能更好处理运动区域,但计算复杂度高且对快速运动场景效果有限。相比之下,运动自适应方法在实时视频处理中更具优势,能平衡去噪效果与硬件资源消耗。两种方法可根据场景动态切换以获得最佳去噪效果。

大熊 1867

基石篇:多模态数据工程导论与核心概念

多模态数据工程不是写Python脚本处理几张图片,而是设计并构建一套系统,来规模化地生产高质量、可追溯、符合合规要求的模型就绪数据。本文将为你建立正确的数据工程思维框架,明确其在多模态AI生态中的战略地位,并为后续的深入学习奠定坚实基础。

jiaquan3011的博客 627

matlab imfilter函数,Matlab中fspecial函数 和imfilter函数的用法

fspecial函数用于创建预约义的滤波算子,其语法格式为:h = fspecial(type)h = fspecial(type,para)其中type指定算子的类型,para指定相应的参数;type的类型有:一、'average'averaging filter为均值滤波,参数为hsize表明模板尺寸,默认值为【3,3】。H = FSPECIAL('average',HSIZE) return...

weixin_28864139的博客 1565

新鲜出炉,ECCV2024.9.25 首次提出基于 YOLO 目标检测的无源域自适应

本文提出了首次使用YOLO系列单发探测器的SFDA方法。本文方法采用了一个带有学习的、目标领域特定的增强和一种新的通信机制的师生框架来稳定训练,减少了对模型选择中带注释的目标数据的依赖,这对现实世界的应用至关重要。SF-YOLO 优于所有基于Faster R-CNN的SFDA方法,甚至一些使用源数据的基于UDA yolo的方法。

m0_63294504的博客 2675

Matlab中fspecial函数 和imfilter函数的用法

fspecial函数用于建立预定义的滤波算子,其语法格式为: h = fspecial(type) h = fspecial(type,para) 其中type指定算子的类型,para指定相应的参数; type的类型有: 1、'average' averaging filter 为均值滤波,参数为hsize代表模板尺寸,默认值为【3,3】。 H = FSPECIAL('average',HSIZE...

yqning123的博客 1378

【ARM Trace32(劳特巴赫) 使用介绍 1.3 - ARM 系统调试中常见的挑战】

每一个独立的gust os或者一个OS 内部里面美格独立的进程它使用虚拟地址是可能是重叠的,比如linux中每个用户进程它的运行地址(虚拟地址)都是0x0,这时如果想去同时调试所有进程,那么必须要有个办法把这些进程区分开来,trace32 就在虚拟地址前面加前缀的方法,这个前缀称为space id, 这个space id 实际上就是processor id或者是task id, 这样就可以把一个os内部的不同的进程区分开来。如果工具和内核中的连接是可以建立起来的,那么接下来就是调试工具使用的问题了。

CodingCos的博客 1961

Kriging克里金模型实现数据回归预测Matlab代码

Kriging克里金模型实现数据回归预测Matlab代码

天天酷科研的博客 603

MATLAB中imfilter和fspecial函数用法

1、imfilter N-D filtering of multidimensional image B = imfilter(A,h) B = imfilter(A,h,options,...) B= imfilter(A,h)filters the multidimensional arrayAwith the multidimensional filterh...

~鹏鹏在努力~ 1952

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

fspecial函数_MATLAB--数字图像处理 fspecial()与imfilter()的使用

fspecial()与imfilter()的使用函数说明fspecial():h = fspecial(type)h = fspecial(type,para)根据函数原型对fspecial函数作个说明,fspecial是用来生成滤波器(也叫算子)的函数,使用type参数来指定滤波器的种类,使用para来对具体的滤波器种类添加额外的参数信息。h就是生成的滤波器。imfilter():用法:B = ...

weixin_31043675的博客 1342

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

imfilter与fspecial

功能:对任意类型数组或多维图像进行滤波。 用法:B = imfilter(A,H)    B = imfilter(A,H,option1,option2,...)    或写作g = imfilter(f, w, filtering_mode, boundary_options, size_options) 其中,f为输入图像,w为滤波掩模,g为滤波后图像。filtering_mod...

bailu6536的博客 270

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

matlab imfilter与fft,imfilter与fspecial

用法:B =imfilter(A,H)B =imfilter(A,H,option1,option2,...)或写作g = imfilter(f, w,filtering_mode, boundary_options, size_options)其中,f为输入图像,w为滤波掩模,g为滤波后图像。filtering_mode用于指定在滤波过程中是使用“相关”还是“卷积”。boundary_optio...

weixin_34329350的博客 279

imfilter,conv,fspecial,imgaussfilt的区别

无

m0_61491601的博客 1960

MATLAB中filter2 conv2 imfilter2 fspecial函数用法

-------------------------------------filter2函数---------------------------------------- 1、用法B = filter2(h,A,shape) ; %相关(correlation)滤波 A:输入图像,h:相关核        假设输入图像A大小为ma x na,相关核h大小为mb x nb,则

放飞梦想,展望未来 3690

Matlab圖像濾波imfilter與fspecial

http://blog.youkuaiyun.com/star_gdx/article/details/14523937 imfilter() 功能:對任意類型數組或多維圖像進行濾波。 用法:B = imfilter(A,H)    B = imfilter(A,H,option1,option2,...)    或寫作g = imfilter(f, w, filtering_mod

I am Rocky 9861

fspecial,imfilter

一、fspecial函数用于建立预定义的滤波算子,其语法格式为: h = fspecial(type) h = fspecial(type,para) 其中type指定算子的类型,para指定相应的参数; type的类型有: 1、'average' averaging filter 为均值滤波,参数为hsize代表模板尺寸,默认值为【3,3】。 H = FSPECIAL('av

魂的专栏 2020
上一篇: c++数组
下一篇: 图像matlab 频域处理
PParis
博客等级 码龄13年 20粉丝 32原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值