Class BinaryCrop

  • All Implemented Interfaces:
    Destroyable, GlobalInfoSupporter, LoggingLevelHandler, LoggingSupporter, OptionHandler, SizeOfHandler, CropAlgorithm<BufferedImage>, Serializable

    public class BinaryCrop
    extends AbstractCropAlgorithm
    Turns image into binary (ie black and white) image and determines the largest rectangle encompassing a (white) object in the middle to crop to.
    When looking for a black object, check the 'invert' option.

    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
     
    -image-transformer <adams.data.image.transformer.AbstractBufferedImageTransformer> (property: imageTransformer)
        The image transformer to apply to the image copy before further binarizing
        and determining the crop.
        default: adams.data.image.transformer.PassThrough
     
    -num-check-points <int> (property: numCheckPoints)
        The number of check points (evenly distributed across width/height) to use 
        for locating the smallest rectangle in the middle.
        default: 1
        minimum: 1
     
    -invert <boolean> (property: invert)
        If enabled, the algorithm looks for a black rectangle rather than a white 
        one.
        default: false
     
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_NumCheckPoints

        protected int m_NumCheckPoints
        the number of checkpoints to use for determining minimum rectangle.
      • m_Invert

        protected boolean m_Invert
        whether to invert the check (ie look for black rectangle).
    • Constructor Detail

      • BinaryCrop

        public BinaryCrop()
    • Method Detail

      • setImageTransformer

        public void setImageTransformer​(AbstractBufferedImageTransformer value)
        Sets the image transformer to apply to the image copy before further binarizing and determining the crop.
        Parameters:
        value - the transformer
      • getImageTransformer

        public AbstractBufferedImageTransformer getImageTransformer()
        Returns the image transformer to apply to the image copy before further binarizing and determining the crop.
        Returns:
        the transformer
      • imageTransformerTipText

        public String imageTransformerTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the gui
      • setNumCheckPoints

        public void setNumCheckPoints​(int value)
        Sets the number of check points to use for determining smallest rectangle in the middle.
        Parameters:
        value - the number
      • getNumCheckPoints

        public int getNumCheckPoints()
        Returns the number of check points to use for determining smallest rectangle in the middle.
        Returns:
        the number
      • numCheckPointsTipText

        public String numCheckPointsTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the gui
      • setInvert

        public void setInvert​(boolean value)
        Sets whether to look for black rectangle (true) rather than white (false).
        Parameters:
        value - true if to look for black rectangle
      • getInvert

        public boolean getInvert()
        Returns whether to look for black rectangle (true) rather than white (false).
        Returns:
        true if to look for black rectangle
      • invertTipText

        public String invertTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the gui
      • min

        protected int min​(int[] values,
                          int lowerBound)
        Finds the smallest value that is greater than the specified lower bound.
        Parameters:
        values - the values to search
        lowerBound - the lower bound to use
        Returns:
        the value, lower bound if failed to locate a value of at greater than lowerBound
      • max

        protected int max​(int[] values,
                          int upperBound)
        Finds the largest value that is smaller than the specified upper bound.
        Parameters:
        values - the values to search
        upperBound - the upper bound to use
        Returns:
        the value, defValue if failed to locate a value of smaller than upperBound