Tesseract-android-tools  1.0
 Todo Clases Namespaces Archivos Funciones Variables
AdaptiveMap.java
Ir a la documentación de este archivo.
00001 /*
00002  * Copyright (C) 2011 Google Inc.
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
00005  * use this file except in compliance with the License. You may obtain a copy of
00006  * the License at
00007  * 
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00012  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
00013  * License for the specific language governing permissions and limitations under
00014  * the License.
00015  */
00016 
00025 package com.googlecode.leptonica.android;
00026 
00031 public class AdaptiveMap {
00032         static {
00033                 System.loadLibrary("lept");
00034         }
00035 
00036         // Background normalization constants
00037 
00039         private final static int NORM_REDUCTION = 16;
00040 
00042         private final static int NORM_SIZE = 3;
00043 
00047         private final static int NORM_BG_VALUE = 200;
00048 
00056         public static Pix backgroundNormMorph(Pix pixs) {
00057                 return backgroundNormMorph(pixs, NORM_REDUCTION, NORM_SIZE,
00058                                 NORM_BG_VALUE);
00059         }
00060 
00102         public static Pix backgroundNormMorph(Pix pixs, int normReduction,
00103                         int normSize, int normBgValue) {
00104                 if (pixs == null)
00105                         throw new IllegalArgumentException("Source pix must be non-null");
00106 
00107                 int nativePix = nativeBackgroundNormMorph(pixs.mNativePix,
00108                                 normReduction, normSize, normBgValue);
00109 
00110                 if (nativePix == 0)
00111                         throw new RuntimeException("Failed to normalize image background");
00112 
00113                 return new Pix(nativePix);
00114         }
00115 
00116         // ***************
00117         // * NATIVE CODE *
00118         // ***************
00119 
00120         private static native int nativeBackgroundNormMorph(int nativePix,
00121                         int reduction, int size, int bgval);
00122 }
 Todo Clases Namespaces Archivos Funciones Variables