Matlab padarray函数详解
2016-03-24 00:46
796 查看
在MATLAB中可以很方便的使用padarray函数进行图像的填充。
padarray函数可以有两个至四个参数,以下是官方文档介绍
padsize给出了给出了填充的行数和列数,通常用[r c]来表示。
padval表示填充方法。它的具体值和描述如下:
padval: ‘symmetric’表示图像大小通过围绕边界进行镜像反射来扩展;
‘replicate’表示图像大小通过复制外边界中的值来扩展;
‘circular’图像大小通过将图像看成是一个二维周期函数的一个周期来进行扩展。
direction表示填充的方向。它的具体值和描述如下:
direction : ‘pre’表示在每一维的第一个元素前填充;
‘post’表示在每一维的最后一个元素后填充;
‘both’表示在每一维的第一个元素前和最后一个元素后填充,此项为默认值。
下面举个栗子:
结果为
fp =
一.更改direction
1.把’post’换成’pre’
结果为
fp =
2.再换成’both’
fp =
二,更改padval
1.把’replicate’改为’symmetric’
结果为
fp =
2.改为’circular’
结果为
fp =
padarray函数可以有两个至四个参数,以下是官方文档介绍
B = padarray(A,PADSIZE) pads array A with PADSIZE(k) number of zeros along the k-th dimension of A. PADSIZE should be a vector of nonnegative integers. B = padarray(A,PADSIZE,PADVAL) pads array A with PADVAL (a scalar) instead of with zeros. B = padarray(A,PADSIZE,PADVAL,DIRECTION) pads A in the direction specified by the string DIRECTION. DIRECTION can be one of the following strings. String values for DIRECTION 'pre' Pads before the first array element along each dimension . 'post' Pads after the last array element along each dimension. 'both' Pads before the first array element and after the last array element along each dimension. By default, DIRECTION is 'both'. B = padarray(A,PADSIZE,METHOD,DIRECTION) pads array A using the specified METHOD. METHOD can be one of these strings: String values for METHOD 'circular' Pads with circular repetition of elements. 'replicate' Repeats border elements of A. 'symmetric' Pads array with mirror reflections of itself.
padsize给出了给出了填充的行数和列数,通常用[r c]来表示。
padval表示填充方法。它的具体值和描述如下:
padval: ‘symmetric’表示图像大小通过围绕边界进行镜像反射来扩展;
‘replicate’表示图像大小通过复制外边界中的值来扩展;
‘circular’图像大小通过将图像看成是一个二维周期函数的一个周期来进行扩展。
direction表示填充的方向。它的具体值和描述如下:
direction : ‘pre’表示在每一维的第一个元素前填充;
‘post’表示在每一维的最后一个元素后填充;
‘both’表示在每一维的第一个元素前和最后一个元素后填充,此项为默认值。
下面举个栗子:
>>f=[1 2;3 4]; >> fp=padarray(f,[3 2],'replicate','post'); >> fp
结果为
fp =
1 2 2 2 3 4 4 4 3 4 4 4 3 4 4 4 3 4 4 4
一.更改direction
1.把’post’换成’pre’
>>f=[1 2;3 4]; >> fp=padarray(f,[3 2],'replicate','pre'); >> fp
结果为
fp =
1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 2 3 3 3 4
2.再换成’both’
fp =
1 1 1 2 2 2 1 1 1 2 2 2 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 4 4 4 3 3 3 4 4 4 3 3 3 4 4 4 3 3 3 4 4 4
二,更改padval
1.把’replicate’改为’symmetric’
结果为
fp =
1 2 2 1 3 4 4 3 3 4 4 3 1 2 2 1 1 2 2 1
2.改为’circular’
结果为
fp =
1 2 1 2 3 4 3 4 1 2 1 2 3 4 3 4 1 2 1 2
相关文章推荐
- matlab ompbox安装教程
- Matlab 2015a 安装libsvm 3.21 步骤
- C/C++下调用matlab函数操作说明
- 绘制二元函数z=f(x,y)=(x^2-2*x)*exp(-x^2-y^2-x*y)的曲线及其三视图和三维表面图形
- 用鼠标左键绘制折线,利用鼠标中键或右键终止绘制
- 利用MATLAB绘制隐函数f(x,y)=x^2 * sin(x+y^2)+y^2 * exp(x+y)+5 * cos(x^2+y)=0的曲线
- 张量的展开与matlab下的工具包操作
- Matlab diff std setdiff exist
- MATLAB-Direct access of structure fields returned by a function call is not allowed 的解决方法~
- MATLAB中添加新的工具箱
- Matlab 2014a添加桌面快捷方式(ubuntu14.04 kylin)
- LIBSVM在MATLAB中的使用及SVM最优参数选取示例代码
- 每天学一点MATLAB函数——软件操作函数
- Matlab中保存图像时,图形窗口大小的控制
- 每天学一点MATLAB函数——文件编程函数
- Matlab中存储及读取数据
- matlab中textread 函数
- matlab中读取txt数据文件(txt文本文档)
- matlab 读取txt文件数据
- matlab中循环保存数据