-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCH5_spatial_domain_image_enhancement.h
33 lines (29 loc) · 1.13 KB
/
CH5_spatial_domain_image_enhancement.h
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
#include <opencv2/opencv.hpp>
#include <opencv2/core/types.hpp>
#include <opencv2/imgproc.hpp> //line
#include <opencv2/imgcodecs.hpp>
#include <opencv2/core/hal/interface.h> //CV_8UC3
#include <iostream>
#include <map>
#include <cmath> //M_PI
#include "utility.h"
using namespace std;
struct Kernel{
string name;
int kernelHeight;
int kernelWidth;
int kernelMiddleY;
int kernelMiddleX;
vector<float> arr;
float coef;
bool isGradient; //if its gradient, take abs() and then normalize the range to [0,255]
Kernel(string n, vector<float> a, float c, bool g = false) : name(n), arr(a), coef(c), isGradient(g){
kernelHeight = kernelWidth = (int)(sqrt(a.size()));
kernelMiddleY = kernelMiddleX = kernelHeight/2;
};
};
void FilterOp(cv::Mat& img, vector<Kernel*> kernels, bool padding = false, float adaptiveThreshold = 0.0,
float mixRatio = 0.0);
void MedianFilterOp(cv::Mat& img, int kernelHeight, int kernelWidth,
int kernelMiddleY, int kernelMiddleX, bool padding = false, bool adaptive = false);
void addNoise(cv::Mat& img, string mode = "gaussian", double mean = 0.0, double stddev = 0.0);