/** * <p> * Computes the variance based threshold using a modified Otsu method from an input image. Internally it uses * {@link #computeOtsu2(int[], int, int)} and {@link boofcv.alg.misc.GImageStatistics#histogram(ImageGray, double, int[])} * </p> * * @param input Input gray-scale image * @param minValue The minimum value of a pixel in the image. (inclusive) * @param maxValue The maximum value of a pixel in the image. (inclusive) * @return Selected threshold. */ public static int computeOtsu2(ImageGray input , int minValue , int maxValue ) { int range = 1+maxValue - minValue; int histogram[] = new int[ range ]; GImageStatistics.histogram(input,minValue,histogram); // Total number of pixels int total = input.width*input.height; return computeOtsu2(histogram,range,total)+minValue; }
/** * <p> * Computes the variance based threshold using Otsu's method from an input image. Internally it uses * {@link #computeOtsu(int[], int, int)} and {@link boofcv.alg.misc.GImageStatistics#histogram(ImageGray, double, int[])} * </p> * * @param input Input gray-scale image * @param minValue The minimum value of a pixel in the image. (inclusive) * @param maxValue The maximum value of a pixel in the image. (inclusive) * @return Selected threshold. */ public static double computeOtsu(ImageGray input , double minValue , double maxValue ) { int range = (int)(1+maxValue - minValue); int histogram[] = new int[ range ]; GImageStatistics.histogram(input,minValue,histogram); // Total number of pixels int total = input.width*input.height; return computeOtsu(histogram,range,total)+minValue; }
/** * <p> * Computes a threshold which maximizes the entropy between the foreground and background regions. See * {@link #computeEntropy(int[], int, int)} for more details. * </p> * * @see boofcv.alg.misc.GImageStatistics#histogram(ImageGray, double, int[]) * * @param input Input gray-scale image * @param minValue The minimum value of a pixel in the image. (inclusive) * @param maxValue The maximum value of a pixel in the image. (inclusive) * @return Selected threshold. */ public static double computeEntropy(ImageGray input , double minValue , double maxValue ) { int range = (int)(1 + maxValue - minValue); int histogram[] = new int[ range ]; GImageStatistics.histogram(input,minValue,histogram); // Total number of pixels int total = input.width*input.height; return computeEntropy(histogram, range, total)+minValue; }