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
49 static void adaptThreshold(cv::Mat &image,
50 bool isMorphOp = false,
51 uint8_t morphKernel = 3,
52 uint8_t blurValue = 3);
53 static cv::Mat adjustBrightness(cv::Mat &in, int value, cv::Rect rect);
54 static cv::Mat adjustContrast(cv::Mat &in, int beta);
55 static cv::Mat manualThreshold(cv::Mat &image, int threshValue = 128, uint8_t blurValue = 3);
56 static cv::Mat adjustSaturation(cv::Mat &in, int value);
57
58 static cv::Mat dilate(cv::Mat &in);
59 static cv::Mat canny(cv::Mat &in);
60 static cv::Mat warp(cv::Mat &in);
61 static cv::Mat medianBlur(cv::Mat &in);
62 static cv::Mat gaussianBlur(cv::Mat &in);
63 static cv::Mat hue(cv::Mat matrix, int h_shift);
64
65 static cv::Mat sharpness(cv::Mat matrix, double beta);
66 static cv::Mat gamma(cv::Mat matrix, double gamma);
67 static void hedEdgeDetectDNN(cv::Mat &image,
68 std::string &prototxt,
69 std::string &caffemodel,
70 int size);
71 static bool compareContourAreas(std::vector<cv::Point> &contour1,
72 std::vector<cv::Point> &contour2);
73 static bool compareXCords(cv::Point &p1, cv::Point &p2);
74 static bool compareYCords(cv::Point &p1, cv::Point &p2);
75 static bool compareDistance(std::pair<cv::Point, cv::Point> &p1,
76 std::pair<cv::Point, cv::Point> &p2);
77 static double _distance(cv::Point &p1, cv::Point &p2);
78 static void resizeToHeight(cv::Mat &src, cv::Mat &dst, int height);
79 static void orderPoints(std::vector<cv::Point> &inpts, std::vector<cv::Point> &ordered);
80 static void fourPointTransform(cv::Mat &src, cv::Mat &dst, std::vector<cv::Point> &pts);
81 static double computeSkew(cv::Mat src);
82 static void CalcBlockMeanVariance(cv::Mat& Img, cv::Mat& Res,float blockSide = 21);
83
84private:
85 static std::vector<cv::Point> poi;
86};
87
88#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 Apr 11 2025 11:57:09 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.