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
| bool Operation::op_blur(cv::Mat& img, cv::Mat& blur)
{
//blur an image with a convolution(gaussian kernel)
/// Declare variables
Mat src, dst, kernel;
Mat img_blur(height, width, CV_8UC1, Scalar(0, 0, 0));
Point anchor;
double delta;
int ddepth, kernel_size;
/// Initialize arguments for the filter
anchor = Point(-1, -1);
delta = 0;
ddepth = -1;
kernel_size = 5;
kernel = 1.0f/159.0f*(Mat_<double>(5, 5) << 2, 4, 5, 4, 2,
4, 9, 12, 9, 4,
5, 12, 15, 12, 5,
4, 9, 12, 9, 4,
2, 4, 5, 4, 2);
/// Apply filter
filter2D(img, img_blur, ddepth, kernel, anchor, delta, BORDER_DEFAULT);
blur = img_blur; //a revoir car copie de matrice
opimg = img_blur; //a revoir car copie de matrice
return true;
} |
Partager