Class ThresholdedCrop
- 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.ThresholdedCrop
-
- All Implemented Interfaces:
Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,SizeOfHandler,CropAlgorithm<BufferedImage>,Serializable
public class ThresholdedCrop extends AbstractCropAlgorithm
Simple cropping algorithm that assumes a good contrast between background and foreground.
Algorithm:
- create histogram of grayscale image
- remove counts from histogram that fall below noise-level
- determine left-most (L) and right-most (R) non-zero count
- divide region between L and R into two and determine highest peak in each (LP and RP)
- 8-bit threshold is halfway between LP and RP
- determine first pixel that is above threshold from top, bottom, left and right, which is used for the crop
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-noise-level <double> (property: noiseLevel) The noise level in percent (0-1). default: 0.05 minimum: 0.0 maximum: 1.0
- Version:
- $Revision: 8487 $
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected doublem_NoiseLevelthe noise level in percent (0-1).-
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 ThresholdedCrop()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddefineOptions()Adds options to the internal list of options.protected BufferedImagedoCrop(BufferedImage img)Performs the actual cropping.protected intfindThreshold(BufferedImage img)Calculates the threshold 8-bit value to distinguish between background and foreground.doublegetNoiseLevel()Returns the noise level.StringglobalInfo()Returns a string describing the object.StringnoiseLevelTipText()Returns the tip text for this property.voidsetNoiseLevel(double value)Sets the noise level.-
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
-
-
-
-
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
-
setNoiseLevel
public void setNoiseLevel(double value)
Sets the noise level.- Parameters:
value- the noise level (0-1)
-
getNoiseLevel
public double getNoiseLevel()
Returns the noise level.- Returns:
- the noise level (0-1)
-
noiseLevelTipText
public String noiseLevelTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
findThreshold
protected int findThreshold(BufferedImage img)
Calculates the threshold 8-bit value to distinguish between background and foreground.- Parameters:
img- the image to use- Returns:
- the threshold byte
-
doCrop
protected BufferedImage doCrop(BufferedImage img)
Performs the actual cropping.- Specified by:
doCropin classAbstractCropAlgorithm- Parameters:
img- the image to crop- Returns:
- the (potentially) cropped image
-
-