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