Pad array

版本 1.0.0.0 (2.5 KB) 作者: Sergei Koptenko
Pad array or image.
4.0K 次下载
更新时间 2005/5/26

查看许可证

This function is an extension of padarray.m. It allows to pad borders of an array (or an image) with variety of tapering functions to reduce artifacts from median filtering, convolution, hilbert transform calc., etc.. For instance, median filtering with medfilt2.m results in distorted edges since this function pad edges with zeros (thus, creating discontinuity jumps). Also, discontinuities can appear in hilbert transform or convolution, since they use circular padding of edges. Using padarray.m not always produce desired results. The current function array_padd.m allows pad edges with data tapering to zero with some windowing function (gaussian, hamming, etc..). This function also allows easily recover resulting array with the same size as the input array.
EXAMPLES:
data_in = [1 1 1 1 1; 1 2 3 2 1; 1 2 3 2 1; 1 1 1 1 1]
[data_out, indd] = array_padd(data_in, [3, 5])
[data_out, indd] = array_padd(data_in, [3, 5], 5)
[data_out, indd] = array_padd(data_in, [3, 5], 0, 'both')
[data_out, indd] = array_padd(data_in, [3, 5], 0, 'both', 'replicate')
[data_out, indd] = array_padd(data_in, [3, 5], 0, 'both', 'symmetric')
[data_out, indd] = array_padd(data_in, [3, 5], 0, 'both', 'hamming')
imagesc(data_out); colorbar
original array size and position within padded array can be recovered as
data_out = data_out(indd(1):indd(2),indd(3):indd(4));

引用格式

Sergei Koptenko (2024). Pad array (https://www.mathworks.com/matlabcentral/fileexchange/7720-pad-array), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R14SP1
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0