Class ImageResizeOptions

java.lang.Object
com.itextpdf.pdfocr.onnx.ImageResizeOptions

public class ImageResizeOptions extends Object
Options, that describe the way an image will be resized before being converted to a tensor for an ML model input.

At the moment only ratio-preserving resizing is supported.

  • Constructor Details

    • ImageResizeOptions

      public ImageResizeOptions (ImageChannelConfiguration channelConfiguration, int minWidth, int minHeight, int maxWidth, int maxHeight, int widthMultiple, int heightMultiple, PaddingStrategy paddingStrategy)
      Creates image resize options.
      Parameters:
      channelConfiguration - channel configuration, that will be used, when passing the image to the ML model
      minWidth - minimum width the image should be after resizing. Should be a positive value
      minHeight - minimum height the image should be after resizing. Should be a positive value
      maxWidth - maximum width the image should be after resizing. Should not be less than minWidth. Should be a multiple of widthMultiple
      maxHeight - maximum height the image should be after resizing. Should not be less than minHeight. Should be a multiple of heightMultiple
      widthMultiple - after resizing, the width of the image should be a multiple of this value
      heightMultiple - after resizing, the height of the image should be a multiple of this value
      paddingStrategy - padding strategy to be used
    • ImageResizeOptions

      public ImageResizeOptions (ImageChannelConfiguration channelConfiguration, int minWidth, int minHeight, int maxWidth, int maxHeight, PaddingStrategy paddingStrategy)
      Creates image resize options.

      With this constructor variant output image dimensions are not bumped up to be a multiple of some integer value.

      Parameters:
      channelConfiguration - channel configuration, that will be used, when passing the image to the ML model
      minWidth - minimum width the image should be after resizing. Should be a positive value
      minHeight - minimum height the image should be after resizing. Should be a positive value
      maxWidth - maximum width the image should be after resizing. Should not be less than minWidth
      maxHeight - maximum height the image should be after resizing. Should not be less than minHeight
      paddingStrategy - padding strategy to be used
    • ImageResizeOptions

      public ImageResizeOptions (ImageChannelConfiguration channelConfiguration, int minWidth, int minHeight, int maxWidth, int maxHeight)
      Creates image resize options.

      With this constructor variant output image dimensions are not bumped up to be a multiple of some integer value and a default black padding is added at the bottom-right of the image.

      Parameters:
      channelConfiguration - channel configuration, that will be used, when passing the image to the ML model
      minWidth - minimum width the image should be after resizing. Should be a positive value
      minHeight - minimum height the image should be after resizing. Should be a positive value
      maxWidth - maximum width the image should be after resizing. Should not be less than minWidth
      maxHeight - maximum height the image should be after resizing. Should not be less than minHeight
    • ImageResizeOptions

      public ImageResizeOptions (ImageChannelConfiguration channelConfiguration, int targetWidth, int targetHeight, PaddingStrategy paddingStrategy)
      Creates image resize options.

      With this constructor variant output image dimensions are fixed to the provided values.

      Parameters:
      channelConfiguration - channel configuration, that will be used, when passing the image to the ML model
      targetWidth - width the image should be after resizing. Should be a positive value
      targetHeight - height the image should be after resizing. Should be a positive value
      paddingStrategy - padding strategy to be used
    • ImageResizeOptions

      public ImageResizeOptions (ImageChannelConfiguration channelConfiguration, int targetWidth, int targetHeight)
      Creates image resize options.

      With this constructor variant output image dimensions are fixed to the provided values and a default black padding is added at the bottom-right of the image.

      Parameters:
      channelConfiguration - channel configuration, that will be used, when passing the image to the ML model
      targetWidth - width the image should be after resizing. Should be a positive value
      targetHeight - height the image should be after resizing. Should be a positive value
  • Method Details

    • getChannelConfiguration

      public ImageChannelConfiguration getChannelConfiguration()
      Returns the image channel configuration, that will be used when passing the image to the ML model.
      Returns:
      the image channel configuration
    • getMinWidth

      public int getMinWidth()
      Returns the minimum width the image should be after resizing.
      Returns:
      the minimum width the image should be after resizing
    • getMinHeight

      public int getMinHeight()
      Returns the minimum height the image should be after resizing.
      Returns:
      the minimum height the image should be after resizing
    • getMaxWidth

      public int getMaxWidth()
      Returns the maximum width the image should be after resizing.
      Returns:
      the maximum width the image should be after resizing
    • getMaxHeight

      public int getMaxHeight()
      Returns the maximum height the image should be after resizing.
      Returns:
      the maximum height the image should be after resizing
    • getWidthMultiple

      public int getWidthMultiple()
      Returns the width multiple.

      After resizing, the width of the image should be a multiple of this value.

      Returns:
      the width multiple
    • getHeightMultiple

      public int getHeightMultiple()
      Returns the height multiple.

      After resizing, the height of the image should be a multiple of this value.

      Returns:
      the height multiple
    • getPaddingStrategy

      public PaddingStrategy getPaddingStrategy()
      Returns the padding strategy.
      Returns:
      the padding strategy
    • isFixedSize

      public boolean isFixedSize()
      Returns whether the target size is fixed.
      Returns:
      whether the target size is fixed.
    • equals

      public boolean equals (Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object