Class CropBackground

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

    public class CropBackground
    extends AbstractCropAlgorithm
    Picks the background at the specified anchor position and crops to the smallest possible rectangle.

    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
        Defines where to pick the background color.
        default: TOP_LEFT
    $Revision: 6652 $
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_Anchor

        protected ImageAnchor m_Anchor
        where to pick the background color.
    • Constructor Detail

      • CropBackground

        public CropBackground()
    • Method Detail

      • setAnchor

        public void setAnchor​(ImageAnchor value)
        Sets where to pick the background color.
        value - the anchor
      • getAnchor

        public ImageAnchor getAnchor()
        Returns where to pick the background color.
        the anchor
      • anchorTipText

        public String anchorTipText()
        Returns the tip text for this property.
        tip text for this property suitable for displaying in the gui
      • scan

        protected int scan​(BufferedImage img,
                           int from,
                           int to,
                           boolean horizontal,
                           int background)
        Scans the images to find the closest x/y to the center that has the same color as the background. Automatically detects if to scan backwards.
        img - the image to scan
        from - the first index (incl)
        to - the second index (incl)
        horizontal - whether to scan row by row or column by column
        background - the background color to match
        the x or y; -1 denotes that no closer position was located