public class GThresholdImageOps
extends java.lang.Object
ThresholdImageOps.| Constructor and Description |
|---|
GThresholdImageOps() |
| Modifier and Type | Method and Description |
|---|---|
static <T extends ImageGray<T>> |
blockMean(T input,
GrayU8 output,
ConfigLength width,
double scale,
boolean down)
Applies a threshold to an image by computing the mean values in a regular grid across
the input image.
|
static <T extends ImageGray<T>> |
blockMinMax(T input,
GrayU8 output,
ConfigLength width,
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 ImageGray<T>> |
blockOtsu(T input,
GrayU8 output,
boolean otsu2,
ConfigLength width,
double tuning,
double scale,
boolean down)
Applies a threshold to an image by computing the Otsu threshold in a regular grid across
the input image.
|
static double |
computeEntropy(ImageGray input,
double minValue,
double 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 double |
computeOtsu(ImageGray input,
double minValue,
double 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 int |
computeOtsu2(ImageGray input,
int minValue,
int maxValue)
Computes the variance based threshold using a modified Otsu method from an input image.
|
static int |
computeOtsu2(int[] histogram,
int length,
int totalPixels)
Computes a modified modified Otsu threshold which maximizes the distance from the distributions means.
|
static <T extends ImageGray<T>> |
localGaussian(T input,
GrayU8 output,
ConfigLength width,
double scale,
boolean down,
T work1,
ImageGray work2)
Thresholds the image using a locally adaptive threshold that is computed using a local square region centered
on each pixel.
|
static <T extends ImageGray<T>> |
localMean(T input,
GrayU8 output,
ConfigLength width,
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 ImageGray<T>> |
localNick(T input,
GrayU8 output,
ConfigLength width,
float k,
boolean down)
Applies
NICK thresholding to the input image. |
static <T extends ImageGray<T>> |
localOtsu(T input,
GrayU8 output,
boolean otsu2,
ConfigLength width,
double tuning,
double scale,
boolean down) |
static <T extends ImageGray<T>> |
localSauvola(T input,
GrayU8 output,
ConfigLength width,
float k,
boolean down)
Applies
Sauvola thresholding to the input image. |
static <T extends ImageGray<T>> |
threshold(T input,
GrayU8 output,
double threshold,
boolean down)
Applies a global threshold across the whole image.
|
public static double computeOtsu(ImageGray input, double minValue, double maxValue)
Computes the variance based threshold using Otsu's method from an input image. Internally it uses
computeOtsu(int[], int, int) and GImageStatistics.histogram(ImageGray, double, 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 computeOtsu2(ImageGray input, int minValue, int maxValue)
Computes the variance based threshold using a modified Otsu method from an input image. Internally it uses
computeOtsu2(int[], int, int) and GImageStatistics.histogram(ImageGray, double, 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 computeOtsu2(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 double computeEntropy(ImageGray input, double minValue, double 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(ImageGray, double, 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 ImageGray<T>> GrayU8 threshold(T input, GrayU8 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 ImageGray<T>> GrayU8 localMean(T input, GrayU8 output, ConfigLength width, 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.width - Width 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 ImageGray<T>> GrayU8 localGaussian(T input, GrayU8 output, ConfigLength width, double scale, boolean down, T work1, ImageGray 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.width - Width 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 ImageGray<T>> GrayU8 localOtsu(T input, GrayU8 output, boolean otsu2, ConfigLength width, double tuning, double scale, boolean down)
public static <T extends ImageGray<T>> GrayU8 localSauvola(T input, GrayU8 output, ConfigLength width, 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.width - Width of square region.k - Positive parameter used to tune threshold. Try 0.3down - Should it threshold up or down.ThresholdSauvolapublic static <T extends ImageGray<T>> GrayU8 localNick(T input, GrayU8 output, ConfigLength width, float k, boolean down)
NICK 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.width - Width of square region.k - Positive parameter used to tune threshold. Try -0.1 to -0.2down - Should it threshold up or down.ThresholdNickpublic static <T extends ImageGray<T>> GrayU8 blockMinMax(T input, GrayU8 output, ConfigLength width, double scale, boolean down, double textureThreshold)
ThresholdBlockMinMax for the details.input - Input image.output - (optional) Output binary image. If null it will be declared internally.width - Width 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.public static <T extends ImageGray<T>> GrayU8 blockMean(T input, GrayU8 output, ConfigLength width, double scale, boolean down)
ThresholdBlockMean for the details.input - Input image.output - (optional) Output binary image. If null it will be declared internally.width - Width of square region.scale - Scale factor used to adjust thresholddown - Should it threshold up or down.public static <T extends ImageGray<T>> GrayU8 blockOtsu(T input, GrayU8 output, boolean otsu2, ConfigLength width, double tuning, double scale, boolean down)
ThresholdBlockOtsu for the details.input - Input image.output - (optional) Output binary image. If null it will be declared internally.width - Width of square region.tuning - Tuning parameter. 0 = regular Otsudown - Should it threshold up or down.