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
     
    -anchor <TOP_LEFT|TOP_CENTER|TOP_RIGHT|MIDDLE_LEFT|MIDDLE_CENTER|MIDDLE_RIGHT|BOTTOM_LEFT|BOTTOM_CENTER|BOTTOM_RIGHT> (property: anchor)
        Defines where to pick the background color.
        default: TOP_LEFT
     
    Version:
    $Revision: 6652 $
    Author:
    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.
        Parameters:
        value - the anchor
      • getAnchor

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

        public String anchorTipText()
        Returns the tip text for this property.
        Returns:
        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.
        Parameters:
        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
        Returns:
        the x or y; -1 denotes that no closer position was located