ResizeWithCropOrPadOp

公用類別 ResizeWithCropOrPadOp

做為處理圖片的運算單位,可將圖片調整為預先定義的大小。

並不會拉長或壓縮圖片內容。不過,為了配合新的大小,系統會裁剪或隱藏像素。裁剪圖片時,會執行置中裁剪;在填充像素時,會執行零邊框間距。

公用建構函式

ResizeWithCropOrPadOp(int targetHeight, int targetWidth)
建立 ResizeWithCropOrPadOp,藉此將圖片裁剪/填充成指定大小。

公用方法

TensorImage
apply(TensorImage 圖片)
以裁剪或/和邊框間距為特定圖片套用定義的大小,並傳回結果。
int
getOutputImageHeight(int inputImageHeight, int inputImageWidth)
指定輸入圖片大小時,計算預期輸出圖片的高度。
int
getOutputImageWidth(int inputImageHeight, int inputImageWidth)
指定輸入映像檔大小時,計算預期輸出圖片的寬度。
PointF
inverseTransform(PointF 點、int inputImageHeight、int inputImageWidth)
將結果圖片的座標系統,轉換為其中一張輸入圖片。

繼承的方法

公用建構函式

public ResizeWithCropOrPadOp (int targetHeight, int targetWidth)

建立 ResizeWithCropOrPadOp,藉此將圖片裁剪/填充成指定大小。採用 center-crop 和零邊框間距。

參數
targetHeight 裁剪/填充圖片的預期高度。
targetWidth 經過裁剪/填充圖片的預期寬度。

公用方法

公開 TensorImage 套用 (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)

將結果圖片的座標系統,轉換為其中一張輸入圖片。

參數
擷取自結果座標系統的點。
inputImageHeight 都與輸入圖片的高度有關
inputImageWidth 都與輸入圖片的寬度相等
傳回
  • 帶有輸入圖片座標系統座標的點。