MauiKit Image Tools

preprocessimage.hpp
1/*****************************************************************************
2 * preprocessimage.hpp
3 *
4 * Created: 5/28/2020 2020 by mguludag
5 *
6 * Copyright 2020 mguludag. All rights reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining
9 * a copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 *****************************************************************************/
27#ifndef PREPROCESSIMAGE_HPP
28#define PREPROCESSIMAGE_HPP
29
30#include "convertimage.hpp"
31#include "mycroplayer.hpp"
32#include <opencv2/core/core.hpp>
33#include <opencv2/imgproc.hpp>
34#include <vector>
35
36#include "opencvlib_export.h"
37
38
39class OPENCVLIB_EXPORT PreprocessImage
40{
41public:
42 PreprocessImage();
43 static cv::Mat deskewRotate(cv::Mat &image);
44 static void setPoints(std::vector<cv::Point2f> pt);
45 static std::vector<cv::Point2f> getPoints(cv::Mat &src);
46 static void preProcess(cv::Mat &src, cv::Mat &dst);
47 static void toGray(cv::Mat &image, uint8_t blurValue = 3);
48 static cv::Mat grayscale(cv::Mat matrix);
49
50 static void adaptThreshold(cv::Mat &image,
51 bool isMorphOp = false,
52 uint8_t morphKernel = 3,
53 uint8_t blurValue = 3);
54 static cv::Mat adjustBrightness(cv::Mat &in, int value, cv::Rect rect = cv::Rect());
55 static cv::Mat adjustContrast(cv::Mat &in, int beta);
56 static cv::Mat manualThreshold(cv::Mat &image, int threshValue = 128, uint8_t blurValue = 3);
57 static cv::Mat adjustSaturation(cv::Mat &in, int value);
58
59 static cv::Mat dilate(cv::Mat &in);
60 static cv::Mat canny(cv::Mat &in);
61 static cv::Mat warp(cv::Mat &in);
62 static cv::Mat hue(cv::Mat matrix, int h_shift);
63
64 static cv::Mat sharpness(cv::Mat matrix, double beta);
65 static cv::Mat gamma(cv::Mat matrix, double gamma);
66 static void hedEdgeDetectDNN(cv::Mat &image,
67 std::string &prototxt,
68 std::string &caffemodel,
69 int size);
70 static bool compareContourAreas(std::vector<cv::Point> &contour1,
71 std::vector<cv::Point> &contour2);
72 static bool compareXCords(cv::Point &p1, cv::Point &p2);
73 static bool compareYCords(cv::Point &p1, cv::Point &p2);
74 static bool compareDistance(std::pair<cv::Point, cv::Point> &p1,
75 std::pair<cv::Point, cv::Point> &p2);
76 static double _distance(cv::Point &p1, cv::Point &p2);
77 static void resizeToHeight(cv::Mat &src, cv::Mat &dst, int height);
78 static void orderPoints(std::vector<cv::Point> &inpts, std::vector<cv::Point> &ordered);
79 static void fourPointTransform(cv::Mat &src, cv::Mat &dst, std::vector<cv::Point> &pts);
80 static double computeSkew(cv::Mat src);
81 static void CalcBlockMeanVariance(cv::Mat& Img, cv::Mat& Res,float blockSide = 21);
82
83private:
84 static std::vector<cv::Point> poi;
85};
86
87#endif // PREPROCESSIMAGE_HPP
KGUIADDONS_EXPORT qreal hue(const QColor &)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri May 2 2025 11:56:08 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.