Class CropBackground
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.image.transformer.crop.AbstractCropAlgorithm
-
- adams.data.image.transformer.crop.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 Summary
Fields Modifier and Type Field Description protected ImageAnchorm_Anchorwhere to pick the background color.-
Fields inherited from class adams.data.image.transformer.crop.AbstractCropAlgorithm
m_BottomRight, m_TopLeft
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.data.image.CropAlgorithm
CROP_BOTTOM, CROP_LEFT, CROP_RIGHT, CROP_TOP
-
-
Constructor Summary
Constructors Constructor Description CropBackground()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringanchorTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.protected BufferedImagedoCrop(BufferedImage img)Simply returns the original image.ImageAnchorgetAnchor()Returns where to pick the background color.StringglobalInfo()Returns a string describing the object.protected intscan(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.voidsetAnchor(ImageAnchor value)Sets where to pick the background color.-
Methods inherited from class adams.data.image.transformer.crop.AbstractCropAlgorithm
check, crop, getBottomRight, getTopLeft, postCrop, preCrop
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Anchor
protected ImageAnchor m_Anchor
where to pick the background color.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractOptionHandler
-
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 scanfrom- the first index (incl)to- the second index (incl)horizontal- whether to scan row by row or column by columnbackground- the background color to match- Returns:
- the x or y; -1 denotes that no closer position was located
-
doCrop
protected BufferedImage doCrop(BufferedImage img)
Simply returns the original image.- Specified by:
doCropin classAbstractCropAlgorithm- Parameters:
img- the image to crop- Returns:
- the (potentially) cropped image
-
-