zxing_lib/zxing/common/HybridBinarizer.h@0:2f8d4a574b4e, 2018-01-12 (annotated)
- Committer:
- Osamu Nakamura
- Date:
- Fri Jan 12 15:41:00 2018 +0900
- Revision:
- 0:2f8d4a574b4e
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Osamu Nakamura |
0:2f8d4a574b4e | 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- |
Osamu Nakamura |
0:2f8d4a574b4e | 2 | #ifndef __HYBRIDBINARIZER_H__ |
Osamu Nakamura |
0:2f8d4a574b4e | 3 | #define __HYBRIDBINARIZER_H__ |
Osamu Nakamura |
0:2f8d4a574b4e | 4 | /* |
Osamu Nakamura |
0:2f8d4a574b4e | 5 | * HybridBinarizer.h |
Osamu Nakamura |
0:2f8d4a574b4e | 6 | * zxing |
Osamu Nakamura |
0:2f8d4a574b4e | 7 | * |
Osamu Nakamura |
0:2f8d4a574b4e | 8 | * Copyright 2010 ZXing authors All rights reserved. |
Osamu Nakamura |
0:2f8d4a574b4e | 9 | * |
Osamu Nakamura |
0:2f8d4a574b4e | 10 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Osamu Nakamura |
0:2f8d4a574b4e | 11 | * you may not use this file except in compliance with the License. |
Osamu Nakamura |
0:2f8d4a574b4e | 12 | * You may obtain a copy of the License at |
Osamu Nakamura |
0:2f8d4a574b4e | 13 | * |
Osamu Nakamura |
0:2f8d4a574b4e | 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
Osamu Nakamura |
0:2f8d4a574b4e | 15 | * |
Osamu Nakamura |
0:2f8d4a574b4e | 16 | * Unless required by applicable law or agreed to in writing, software |
Osamu Nakamura |
0:2f8d4a574b4e | 17 | * distributed under the License is distributed on an "AS IS" BASIS, |
Osamu Nakamura |
0:2f8d4a574b4e | 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Osamu Nakamura |
0:2f8d4a574b4e | 19 | * See the License for the specific language governing permissions and |
Osamu Nakamura |
0:2f8d4a574b4e | 20 | * limitations under the License. |
Osamu Nakamura |
0:2f8d4a574b4e | 21 | */ |
Osamu Nakamura |
0:2f8d4a574b4e | 22 | |
Osamu Nakamura |
0:2f8d4a574b4e | 23 | #include <vector> |
Osamu Nakamura |
0:2f8d4a574b4e | 24 | #include <zxing/Binarizer.h> |
Osamu Nakamura |
0:2f8d4a574b4e | 25 | #include <zxing/common/GlobalHistogramBinarizer.h> |
Osamu Nakamura |
0:2f8d4a574b4e | 26 | #include <zxing/common/BitArray.h> |
Osamu Nakamura |
0:2f8d4a574b4e | 27 | #include <zxing/common/BitMatrix.h> |
Osamu Nakamura |
0:2f8d4a574b4e | 28 | |
Osamu Nakamura |
0:2f8d4a574b4e | 29 | namespace zxing { |
Osamu Nakamura |
0:2f8d4a574b4e | 30 | |
Osamu Nakamura |
0:2f8d4a574b4e | 31 | class HybridBinarizer : public GlobalHistogramBinarizer { |
Osamu Nakamura |
0:2f8d4a574b4e | 32 | private: |
Osamu Nakamura |
0:2f8d4a574b4e | 33 | Ref<BitMatrix> matrix_; |
Osamu Nakamura |
0:2f8d4a574b4e | 34 | Ref<BitArray> cached_row_; |
Osamu Nakamura |
0:2f8d4a574b4e | 35 | |
Osamu Nakamura |
0:2f8d4a574b4e | 36 | public: |
Osamu Nakamura |
0:2f8d4a574b4e | 37 | HybridBinarizer(Ref<LuminanceSource> source); |
Osamu Nakamura |
0:2f8d4a574b4e | 38 | virtual ~HybridBinarizer(); |
Osamu Nakamura |
0:2f8d4a574b4e | 39 | |
Osamu Nakamura |
0:2f8d4a574b4e | 40 | virtual Ref<BitMatrix> getBlackMatrix(); |
Osamu Nakamura |
0:2f8d4a574b4e | 41 | Ref<Binarizer> createBinarizer(Ref<LuminanceSource> source); |
Osamu Nakamura |
0:2f8d4a574b4e | 42 | private: |
Osamu Nakamura |
0:2f8d4a574b4e | 43 | // We'll be using one-D arrays because C++ can't dynamically allocate 2D |
Osamu Nakamura |
0:2f8d4a574b4e | 44 | // arrays |
Osamu Nakamura |
0:2f8d4a574b4e | 45 | ArrayRef<int> calculateBlackPoints(ArrayRef<char> luminances, |
Osamu Nakamura |
0:2f8d4a574b4e | 46 | int subWidth, |
Osamu Nakamura |
0:2f8d4a574b4e | 47 | int subHeight, |
Osamu Nakamura |
0:2f8d4a574b4e | 48 | int width, |
Osamu Nakamura |
0:2f8d4a574b4e | 49 | int height); |
Osamu Nakamura |
0:2f8d4a574b4e | 50 | void calculateThresholdForBlock(ArrayRef<char> luminances, |
Osamu Nakamura |
0:2f8d4a574b4e | 51 | int subWidth, |
Osamu Nakamura |
0:2f8d4a574b4e | 52 | int subHeight, |
Osamu Nakamura |
0:2f8d4a574b4e | 53 | int width, |
Osamu Nakamura |
0:2f8d4a574b4e | 54 | int height, |
Osamu Nakamura |
0:2f8d4a574b4e | 55 | ArrayRef<int> blackPoints, |
Osamu Nakamura |
0:2f8d4a574b4e | 56 | Ref<BitMatrix> const& matrix); |
Osamu Nakamura |
0:2f8d4a574b4e | 57 | void thresholdBlock(ArrayRef<char>luminances, |
Osamu Nakamura |
0:2f8d4a574b4e | 58 | int xoffset, |
Osamu Nakamura |
0:2f8d4a574b4e | 59 | int yoffset, |
Osamu Nakamura |
0:2f8d4a574b4e | 60 | int threshold, |
Osamu Nakamura |
0:2f8d4a574b4e | 61 | int stride, |
Osamu Nakamura |
0:2f8d4a574b4e | 62 | Ref<BitMatrix> const& matrix); |
Osamu Nakamura |
0:2f8d4a574b4e | 63 | }; |
Osamu Nakamura |
0:2f8d4a574b4e | 64 | |
Osamu Nakamura |
0:2f8d4a574b4e | 65 | } |
Osamu Nakamura |
0:2f8d4a574b4e | 66 | |
Osamu Nakamura |
0:2f8d4a574b4e | 67 | #endif |