Repository navigation
Expand file tree
/
Copy pathimageprocessor.h
More file actions
69 lines (49 loc) · 2.2 KB
/
Copy pathimageprocessor.h
File metadata and controls
69 lines (49 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef IMAGEPROCESSOR_H
#define IMAGEPROCESSOR_H
#include <QString>
#include <QImage>
#include <QObject>
#ifdef HAVE_OPENCV
#include <opencv2/opencv.hpp>
#endif
// 圖像處理器類 / Image processor class
class ImageProcessor : public QObject
{
Q_OBJECT
public:
explicit ImageProcessor(QObject *parent = nullptr);
#ifdef HAVE_OPENCV
// 載入圖像 / Load image
cv::Mat loadImage(const QString &path);
// 將 cv::Mat 轉換為 QImage / Convert cv::Mat to QImage
static QImage matToQImage(const cv::Mat &mat);
// 將 QImage 轉換為 cv::Mat / Convert QImage to cv::Mat
static cv::Mat qImageToMat(const QImage &image);
// OpenCV 操作函數 / OpenCV operation functions
// 高斯模糊 / Gaussian blur
static cv::Mat applyGaussianBlur(const cv::Mat &input, int ksize, double sigmaX, double sigmaY = 0);
// Canny 邊緣檢測 / Canny edge detection
static cv::Mat applyCanny(const cv::Mat &input, double threshold1, double threshold2, int apertureSize = 3);
// 亮度對比度調整 / Brightness and contrast adjustment
static cv::Mat applyBrightnessContrast(const cv::Mat &input, double alpha, int beta);
// Gamma 校正 / Gamma correction
static cv::Mat applyGamma(const cv::Mat &input, double gamma);
// 顏色空間轉換 / Color space conversion
static cv::Mat convertColor(const cv::Mat &input, int code);
// 調整大小 / Resize
static cv::Mat resize(const cv::Mat &input, int width, int height, int interpolation = cv::INTER_LINEAR);
// 旋轉 / Rotate
static cv::Mat rotate(const cv::Mat &input, double angle);
// 翻轉 / Flip
static cv::Mat flip(const cv::Mat &input, int flipCode);
// 閾值處理 / Threshold
static cv::Mat threshold(const cv::Mat &input, double thresh, double maxval, int type);
// 形態學操作 / Morphological operations
static cv::Mat morphologyEx(const cv::Mat &input, int op, int shape, int ksize);
// 保存圖像 / Save image
static bool saveImage(const cv::Mat &image, const QString &path, const QVector<int> ¶ms = QVector<int>());
private:
cv::Mat currentImage;
#endif
};
#endif // IMAGEPROCESSOR_H