Crop and pad a matrix

版本 1.0.2 (4.9 KB) 作者: ytzhak goussha
Crop and pad a 2d matrix or image into a desired width and height
24.0 次下载
更新时间 2021/6/16

查看许可证

CROPANDPADMATRIX pads or crops a matrix into desierd width and height
X = CROPANDPADMATRIX(MAT,OUTWIDTH, OUTHEIGHT) pads MAT, with zeros or crops the matrix,
while keeping the matrix in the middle and outputs a new matrix x with dimention
[outHeightxoutWidth]. MAT may be a cell array of matrecies, in which case,
X will be [h,w,c] array where h is the height, w is width and c is the
number of matrecies in the MAT. If the matrix is empry CropAndPadMatrix(MAT,WIDTH ,HEIGHT)
returns and zero matrix with size [HEIGHT,WIDTH].
Examples
CropAndPadMatrix(rand(5,10), 100, 10)
CropAndPadMatrix(rand(5,50), 10, 10)
CropAndPadMatrix([], 10, 10)
CropAndPadMatrix({rand(5,10),rand(51,12)}, 10, 10)

引用格式

ytzhak goussha (2024). Crop and pad a matrix (https://www.mathworks.com/matlabcentral/fileexchange/94140-crop-and-pad-a-matrix), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2021a
兼容任何版本
平台兼容性
Windows macOS Linux

Community Treasure Hunt

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

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

fixed bug with cell input, the function name was wrong (older name)

1.0.1

Fixed a bug in the validation, added ~ signs

1.0.0