用法:
mxnet.image.center_crop(src, size, interp=2)
- src:(
NDArray
) - 二進製源圖像數據。 - size:(
list
or
tuple of int
) - 所需的輸出圖像大小。 - interp:(
int
,
optional
,
default=2
) - 插值方法。有關詳細信息,請參閱resize_short。
- src:(
NDArray
- 裁剪後的圖像。Tuple
- (x, y, width, height) 其中 x, y 是原始圖像中裁剪的位置,寬度、高度是裁剪的尺寸。
參數:
返回:
通過修剪所有四個邊並保留圖像的中心,將圖像
src
裁剪為給定的size
。如果src
小於size
則上采樣。注意:
這需要使用USE_OPENCV 編譯 MXNet。
示例:
>>> with open("flower.jpg", 'rb') as fp: ... str_image = fp.read() ... >>> image = mx.image.imdecode(str_image) >>> image <NDArray 2321x3482x3 @cpu(0)> >>> cropped_image, (x, y, width, height) = mx.image.center_crop(image, (1000, 500)) >>> cropped_image <NDArray 500x1000x3 @cpu(0)> >>> x, y, width, height (1241, 910, 1000, 500)
相關用法
- Python mxnet.image.resize_short用法及代碼示例
- Python mxnet.image.random_crop用法及代碼示例
- Python mxnet.image.imresize用法及代碼示例
- Python mxnet.image.CreateAugmenter用法及代碼示例
- Python mxnet.image.ImageIter.read_image用法及代碼示例
- Python mxnet.image.CreateMultiRandCropAugmenter用法及代碼示例
- Python mxnet.image.imread用法及代碼示例
- Python mxnet.image.CreateDetAugmenter用法及代碼示例
- Python mxnet.image.ImageDetIter.sync_label_shape用法及代碼示例
- Python mxnet.image.ImageDetIter.draw_next用法及代碼示例
- Python mxnet.image.imdecode用法及代碼示例
- Python mxnet.image.scale_down用法及代碼示例
- Python mxnet.io.PrefetchingIter用法及代碼示例
- Python mxnet.initializer.register用法及代碼示例
- Python mxnet.initializer.One用法及代碼示例
- Python mxnet.io.NDArrayIter用法及代碼示例
- Python mxnet.io.ResizeIter用法及代碼示例
- Python mxnet.initializer.Constant.dumps用法及代碼示例
- Python mxnet.initializer.Mixed用法及代碼示例
- Python mxnet.initializer.Zero用法及代碼示例
注:本文由純淨天空篩選整理自apache.org大神的英文原創作品 mxnet.image.center_crop。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。