/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. #include "common.h"
  17. #include "thresholder.h"
  18. #include "utilities.h"
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif /* __cplusplus */
  22. jint Java_com_googlecode_eyesfree_textdetect_Thresholder_nativeSobelEdgeThreshold(JNIEnv *env,
  23. jclass clazz,
  24. jint nativePix,
  25. jint threshold) {
  26. LOGV(__FUNCTION__);
  27. PIX *pixs = (PIX *) nativePix;
  28. PIX *pixd = pixThreshedSobelEdgeFilter(pixs, (l_int32) threshold);
  29. return (jint) pixd;
  30. }
  31. jint Java_com_googlecode_eyesfree_textdetect_Thresholder_nativeEdgeAdaptiveThreshold(
  32. JNIEnv *env,
  33. jclass clazz,
  34. jint nativePix,
  35. jint tileX,
  36. jint tileY,
  37. jint threshold,
  38. jint average) {
  39. LOGV(__FUNCTION__);
  40. PIX *pixs = (PIX *) nativePix;
  41. PIX *pixd;
  42. if (pixEdgeAdaptiveThreshold(pixs, &pixd, (l_int32) tileX, (l_int32) tileY, (l_int32) threshold,
  43. (l_int32) average)) {
  44. return (jint) 0;
  45. }
  46. return (jint) pixd;
  47. }
  48. jint Java_com_googlecode_eyesfree_textdetect_Thresholder_nativeFisherAdaptiveThreshold(
  49. JNIEnv *env,
  50. jclass clazz,
  51. jint nativePix,
  52. jint tileX,
  53. jint tileY,
  54. jfloat scoreFract,
  55. jfloat thresh) {
  56. LOGV(__FUNCTION__);
  57. PIX *pixs = (PIX *) nativePix;
  58. PIX *pixd;
  59. if (pixFisherAdaptiveThreshold(pixs, &pixd, (l_int32) tileX, (l_int32) tileY,
  60. (l_float32) scoreFract, (l_float32) thresh)) {
  61. return (jint) 0;
  62. }
  63. return (jint) pixd;
  64. }
  65. #ifdef __cplusplus
  66. }
  67. #endif /* __cplusplus */