public class GThresholdImageOps
extends java.lang.Object
ThresholdImageOps.| Constructor and Description |
|---|
GThresholdImageOps() |
| Modifier and Type | Method and Description |
|---|---|
static int |
computeEntropy(ImageSingleBand input,
int minValue,
int maxValue)
Computes a threshold which maximizes the entropy between the foreground and background regions.
|
static int |
computeEntropy(int[] histogram,
int length,
int totalPixels)
Computes a threshold which maximizes the entropy between the foreground and background regions.
|
static int |
computeOtsu(ImageSingleBand input,
int minValue,
int maxValue)
Computes the variance based threshold using Otsu's method from an input image.
|
static int |
computeOtsu(int[] histogram,
int length,
int totalPixels)
Computes the variance based Otsu threshold from a histogram directly.
|
static <T extends ImageSingleBand> |
localBlockMinMax(T input,
ImageUInt8 output,
int radius,
double scale,
boolean down,
double textureThreshold)
Applies a threshold to an image by computing the min and max values in a regular grid across
the input image.
|
static <T extends ImageSingleBand> |
localGaussian(T input,
ImageUInt8 output,
int radius,
double scale,
boolean down,
T work1,
ImageSingleBand work2)
Thresholds the image using a locally adaptive threshold that is computed using a local square region centered
on each pixel.
|
static <T extends ImageSingleBand> |
localSauvola(T input,
ImageUInt8 output,
int radius,
float k,
boolean down)
Applies
Sauvola thresholding to the input image. |
static <T extends ImageSingleBand> |
localSquare(T input,
ImageUInt8 output,
int radius,
double scale,
boolean down,
T work1,
T work2)
Thresholds the image using a locally adaptive threshold that is computed using a local square region centered
on each pixel.
|
static <T extends ImageSingleBand> |
threshold(T input,
ImageUInt8 output,
double threshold,
boolean down)
Applies a global threshold across the whole image.
|
public static int computeOtsu(ImageSingleBand input, int minValue, int maxValue)
Computes the variance based threshold using Otsu's method from an input image. Internally it uses
computeOtsu(int[], int, int) and GImageStatistics.histogram(boofcv.struct.image.ImageSingleBand, int, int[])
input - Input gray-scale imageminValue - The minimum value of a pixel in the image. (inclusive)maxValue - The maximum value of a pixel in the image. (inclusive)public static int computeOtsu(int[] histogram,
int length,
int totalPixels)
histogram - Histogram of pixel intensities.length - Number of elements in the histogram.totalPixels - Total pixels in the imagepublic static int computeEntropy(ImageSingleBand input, int minValue, int maxValue)
Computes a threshold which maximizes the entropy between the foreground and background regions. See
computeEntropy(int[], int, int) for more details.
input - Input gray-scale imageminValue - The minimum value of a pixel in the image. (inclusive)maxValue - The maximum value of a pixel in the image. (inclusive)GImageStatistics.histogram(boofcv.struct.image.ImageSingleBand, int, int[])public static int computeEntropy(int[] histogram,
int length,
int totalPixels)
Computes a threshold which maximizes the entropy between the foreground and background regions. See [1] for algorithmic details, which cites [2].
[1] E.R. Davies "Machine Vision Theory Algorithms Practicalities" 3rd Ed. 2005. pg. 124
[2] Hannah, Ian, Devesh Patel, and Roy Davies. "The use of variance and entropic thresholding methods
for image segmentation." Pattern Recognition 28.8 (1995): 1135-1143.
histogram - Histogram of pixel intensities.length - Number of elements in the histogram.totalPixels - Total pixels in the imagepublic static <T extends ImageSingleBand> ImageUInt8 threshold(T input, ImageUInt8 output, double threshold, boolean down)
input - Input image. Not modified.output - (Optional) Binary output image. If null a new image will be declared. Modified.threshold - threshold value.down - If true then the inequality ≤ is used, otherwise if false then > is used.public static <T extends ImageSingleBand> ImageUInt8 localSquare(T input, ImageUInt8 output, int radius, double scale, boolean down, T work1, T work2)
Thresholds the image using a locally adaptive threshold that is computed using a local square region centered on each pixel. The threshold is equal to the average value of the surrounding pixels times the scale. If down is true then b(x,y) = I(x,y) ≤ T(x,y) * scale ? 1 : 0. Otherwise b(x,y) = I(x,y) > T(x,y) * scale ? 0 : 1
NOTE: Internally, images are declared to store intermediate results. If more control is needed over memory call the type specific function.
input - Input image.output - (optional) Output binary image. If null it will be declared internally.radius - Radius of square region.scale - Scale factor used to adjust thresholddown - Should it threshold up or down.work1 - (Optional) Internal workspace. Can be nullwork2 - (Optional) Internal workspace. Can be nullpublic static <T extends ImageSingleBand> ImageUInt8 localGaussian(T input, ImageUInt8 output, int radius, double scale, boolean down, T work1, ImageSingleBand work2)
Thresholds the image using a locally adaptive threshold that is computed using a local square region centered on each pixel. The threshold is equal to the gaussian weighted sum of the surrounding pixels times the scale. If down is true then b(x,y) = I(x,y) ≤ T(x,y) * scale ? 1 : 0. Otherwise b(x,y) = I(x,y) > T(x,y) * scale ? 0 : 1
NOTE: Internally, images are declared to store intermediate results. If more control is needed over memory call the type specific function.
input - Input image.output - (optional) Output binary image. If null it will be declared internally.radius - Radius of square region.scale - Scale factor used to adjust thresholddown - Should it threshold up or down.work1 - (Optional) Internal workspace. Can be nullwork2 - (Optional) Internal workspace. Can be nullpublic static <T extends ImageSingleBand> ImageUInt8 localSauvola(T input, ImageUInt8 output, int radius, float k, boolean down)
Sauvola thresholding to the input image.
Intended for use with text image.input - Input image.output - (optional) Output binary image. If null it will be declared internally.radius - Radius of local region. Try 15k - Positive parameter used to tune threshold. Try 0.3down - Should it threshold up or down.ThresholdSauvolapublic static <T extends ImageSingleBand> ImageUInt8 localBlockMinMax(T input, ImageUInt8 output, int radius, double scale, boolean down, double textureThreshold)
ThresholdSquareBlockMinMax for the details.input - Input image.output - (optional) Output binary image. If null it will be declared internally.radius - Radius of square region.scale - Scale factor used to adjust thresholddown - Should it threshold up or down.textureThreshold - If the min and max values are within this threshold the pixel will be set to 1.