公共类 ResizeWithCropOrPadOp
作为处理图片的计算单元,它可以将图片大小调整为预定义的大小。
它不会拉伸或压缩图片内容。不过,为了适应新尺寸,它会剪裁或填充像素。在剪裁图片时,它会执行中心剪裁;在填充像素时,它会执行零内边距。
公共构造函数
ResizeWithCropOrPadOp(int targetHeight, int targetWidth)
创建一个 ResizeWithCropOrPadOp,它可以将图片剪裁/填充为指定尺寸。
|
公共方法
TensorImage | |
整型 |
getOutputImageHeight(int inputImageHeight, int inputImageWidth)
指定输入图片大小时,计算预期输出图片的高度。
|
整型 |
getOutputImageWidth(int inputImageHeight, int inputImageWidth)
给定输入图片大小时,计算预期输出图片的宽度。
|
PointF |
inverseTransform(PointF point, int inputImageHeight, int inputImageWidth)
将点从结果图片的坐标系转换回某张输入图片。
|
继承的方法
公共构造函数
public ResizeWithCropOrPadOp (int targetHeight, int targetWidth)
创建一个 ResizeWithCropOrPadOp,它可以将图片剪裁/填充为指定尺寸。它采用中心剪裁和零内边距。
参数
targetHeight | 剪裁后/含内边距的图片的预期高度。 |
---|---|
targetWidth | 剪裁后/含内边距的图片的预期宽度。 |
公共方法
public TensorImage apply (TensorImage 映像)
对给定的图片应用定义的调整大小以及剪裁或/和内边距,并返回结果。
注意:输入 image
的内容会发生变化,并且 image
是输出的同一实例。
参数
图片 | 输入图像。 |
---|
返回
- 输出图像。
public int getOutputImageHeight (int inputImageHeight, int inputImageWidth)
指定输入图片大小时,计算预期输出图片的高度。
参数
inputImageHeight | |
---|---|
inputImageWidth |
public int getOutputImageWidth (int inputImageHeight, int inputImageWidth)
给定输入图片大小时,计算预期输出图片的宽度。
参数
inputImageHeight | |
---|---|
inputImageWidth |
public PointF inverseTransform (PointF point, int inputImageHeight, int inputImageWidth)
将点从结果图片的坐标系转换回某张输入图片。
参数
point | 结果坐标系中的点。 |
---|---|
inputImageHeight | 输入图片的高度。 |
inputImageWidth | 输入图像的宽度。 |
返回
- 与输入图片坐标系中的坐标相对应的点。