Ir a la documentación de este archivo.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00026 package com.googlecode.leptonica.android;
00027
00032 public class Binarize {
00033 static {
00034 System.loadLibrary("lept");
00035 }
00036
00037
00038
00040 public final static int OTSU_SIZE_X = 32;
00041
00043 public final static int OTSU_SIZE_Y = 32;
00044
00046 public final static int OTSU_SMOOTH_X = 2;
00047
00049 public final static int OTSU_SMOOTH_Y = 2;
00050
00052 public final static float OTSU_SCORE_FRACTION = 0.1f;
00053
00062 public static Pix otsuAdaptiveThreshold(Pix pixs) {
00063 return otsuAdaptiveThreshold(pixs, OTSU_SIZE_X, OTSU_SIZE_Y,
00064 OTSU_SMOOTH_X, OTSU_SMOOTH_Y, OTSU_SCORE_FRACTION);
00065 }
00066
00123 public static Pix otsuAdaptiveThreshold(Pix pixs, int sizeX, int sizeY,
00124 int smoothX, int smoothY, float scoreFraction) {
00125 if (pixs == null)
00126 throw new IllegalArgumentException("Source pix must be non-null");
00127 if (pixs.getDepth() != 8)
00128 throw new IllegalArgumentException("Source pix depth must be 8bpp");
00129
00130 int nativePix = nativeOtsuAdaptiveThreshold(pixs.mNativePix, sizeX,
00131 sizeY, smoothX, smoothY, scoreFraction);
00132
00133 if (nativePix == 0)
00134 throw new RuntimeException(
00135 "Failed to perform Otsu adaptive threshold on image");
00136
00137 return new Pix(nativePix);
00138 }
00139
00140
00141
00142
00143
00144 private static native int nativeOtsuAdaptiveThreshold(int nativePix,
00145 int sizeX, int sizeY, int smoothX, int smoothY, float scoreFract);
00146 }