PageRenderTime 15ms CodeModel.GetById 9ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/ocr/ocrservice/jni/hydrogen/jni/thresholder.cpp

http://eyes-free.googlecode.com/
C++ | 81 lines | 52 code | 14 blank | 15 comment | 2 complexity | fadd43b560c1870144100710ff721a26 MD5 | raw file
 1/*
 2 * Copyright 2011, Google Inc.
 3 *
 4 * Licensed under the Apache License, Version 2.0 (the "License");
 5 * you may not use this file except in compliance with the License.
 6 * You may obtain a copy of the License at
 7 *
 8 *     http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "common.h"
18#include "thresholder.h"
19#include "utilities.h"
20
21#ifdef __cplusplus
22extern "C" {
23#endif  /* __cplusplus */
24
25jint Java_com_googlecode_eyesfree_textdetect_Thresholder_nativeSobelEdgeThreshold(JNIEnv *env,
26                                                                                  jclass clazz,
27                                                                                  jint nativePix,
28                                                                                  jint threshold) {
29  LOGV(__FUNCTION__);
30
31  PIX *pixs = (PIX *) nativePix;
32  PIX *pixd = pixThreshedSobelEdgeFilter(pixs, (l_int32) threshold);
33
34  return (jint) pixd;
35}
36
37jint Java_com_googlecode_eyesfree_textdetect_Thresholder_nativeEdgeAdaptiveThreshold(
38                                                                                     JNIEnv *env,
39                                                                                     jclass clazz,
40                                                                                     jint nativePix,
41                                                                                     jint tileX,
42                                                                                     jint tileY,
43                                                                                     jint threshold,
44                                                                                     jint average) {
45  LOGV(__FUNCTION__);
46
47  PIX *pixs = (PIX *) nativePix;
48  PIX *pixd;
49
50  if (pixEdgeAdaptiveThreshold(pixs, &pixd, (l_int32) tileX, (l_int32) tileY, (l_int32) threshold,
51                               (l_int32) average)) {
52    return (jint) 0;
53  }
54
55  return (jint) pixd;
56}
57
58jint Java_com_googlecode_eyesfree_textdetect_Thresholder_nativeFisherAdaptiveThreshold(
59                                                                                       JNIEnv *env,
60                                                                                       jclass clazz,
61                                                                                       jint nativePix,
62                                                                                       jint tileX,
63                                                                                       jint tileY,
64                                                                                       jfloat scoreFract,
65                                                                                       jfloat thresh) {
66  LOGV(__FUNCTION__);
67
68  PIX *pixs = (PIX *) nativePix;
69  PIX *pixd;
70
71  if (pixFisherAdaptiveThreshold(pixs, &pixd, (l_int32) tileX, (l_int32) tileY,
72                                 (l_float32) scoreFract, (l_float32) thresh)) {
73    return (jint) 0;
74  }
75
76  return (jint) pixd;
77}
78
79#ifdef __cplusplus
80}
81#endif  /* __cplusplus */