Class 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.
    - 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
    $Revision: 8487 $
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_NoiseLevel

        protected double m_NoiseLevel
        the noise level in percent (0-1).
    • Constructor Detail

      • ThresholdedCrop

        public ThresholdedCrop()
    • Method Detail

      • setNoiseLevel

        public void setNoiseLevel​(double value)
        Sets the noise level.
        value - the noise level (0-1)
      • getNoiseLevel

        public double getNoiseLevel()
        Returns the noise level.
        the noise level (0-1)
      • noiseLevelTipText

        public String noiseLevelTipText()
        Returns the tip text for this property.
        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.
        img - the image to use
        the threshold byte