1 /*
2 Scan Tailor - Interactive post-processing tool for scanned pages.
3 Copyright (C) Joseph Artsimovich <joseph.artsimovich@gmail.com>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "MorphGradientDetect.h"
20 #include "GrayRasterOp.h"
21 #include "Grayscale.h"
22 #include "Morphology.h"
23
24 namespace imageproc {
morphGradientDetectDarkSide(const GrayImage & image,const QSize & area)25 GrayImage morphGradientDetectDarkSide(const GrayImage& image, const QSize& area) {
26 GrayImage lighter(erodeGray(image, area, 0x00));
27 grayRasterOp<GRopUnclippedSubtract<GRopDst, GRopSrc>>(lighter, image);
28
29 return lighter;
30 }
31
morphGradientDetectLightSide(const GrayImage & image,const QSize & area)32 GrayImage morphGradientDetectLightSide(const GrayImage& image, const QSize& area) {
33 GrayImage darker(dilateGray(image, area, 0xff));
34 grayRasterOp<GRopUnclippedSubtract<GRopSrc, GRopDst>>(darker, image);
35
36 return darker;
37 }
38 } // namespace imageproc
39