#include<opencv2\opencv.hpp>
#include<iostream>
#include<math.h>
using namespace cv;
int main()
{
Mat src = imread("C:/Users/asus/Desktop/tupian/1.jpg");
if (src.empty())
{
printf("could not load image...\n");
return -1;
}
namedWindow("opencv setup demo", WINDOW_AUTOSIZE);
imshow("opencv setup demo", src);
namedWindow("output window", WINDOW_AUTOSIZE);
Mat dst;
Mat kernel_x = (Mat_<int>(2, 2) << 1, 0, 0, -1);
filter2D(src, dst, -1, kernel_x, Point(-1, -1), 0, 0);
imshow("output window", dst);
Mat kernel_y = (Mat_<int>(2, 2) << 0,1,-1,0);
filter2D(src, dst, -1, kernel_y, Point(-1, -1), 0, 0);
imshow("output robart_y", dst);
waitKey(0);
return 0;
}
#include<opencv2\opencv.hpp>
#include<iostream>
#include<math.h>
using namespace cv;
int main()
{
Mat src = imread("C:/Users/asus/Desktop/tupian/1.jpg");
if (src.empty())
{
printf("could not load image...\n");
return -1;
}
namedWindow("opencv setup demo", WINDOW_AUTOSIZE);
imshow("opencv setup demo", src);
namedWindow("output window", WINDOW_AUTOSIZE);
Mat dst;
Mat kernel_x = (Mat_<int>(3, 3) << -1,0,1,-2,0,2,-1,0,1);
filter2D(src, dst, -1, kernel_x, Point(-1, -1), 0, 0);
imshow("output window", dst);
Mat kernel_y = (Mat_<int>(3, 3) << -1,-2,-1,0,0,0,1,2,1);
filter2D(src, dst, -1, kernel_y, Point(-1, -1), 0, 0);
imshow("output y", dst);
waitKey(0);
return 0;
}
#include<opencv2\opencv.hpp>
#include<iostream>
#include<math.h>
using namespace cv;
int main()
{
Mat src = imread("C:/Users/asus/Desktop/tupian/1.jpg");
if (src.empty())
{
printf("could not load image...\n");
return -1;
}
namedWindow("opencv setup demo", WINDOW_AUTOSIZE);
imshow("opencv setup demo", src);
namedWindow("output window", WINDOW_AUTOSIZE);
Mat dst;
Mat kernel_x = (Mat_<int>(3, 3) << 0,-1,0,-1,4,-1,0,-1,0);
filter2D(src, dst, -1, kernel_x, Point(-1, -1), 0, 0);
imshow("output window", dst);
waitKey(0);
return 0;
}
#include<opencv2\opencv.hpp>
#include<iostream>
#include<math.h>
using namespace cv;
int main()
{
Mat src = imread("C:/Users/asus/Desktop/tupian/1.jpg");
if (src.empty())
{
printf("could not load image...\n");
return -1;
}
namedWindow("opencv setup demo", WINDOW_AUTOSIZE);
imshow("opencv setup demo", src);
namedWindow("output window", WINDOW_AUTOSIZE);
Mat dst;
int c = 0;
int index = 0;
int kzize = 3;
while (true)
{
c = waitKey(500);
if((char)c==27)
{
break;
}
kzize = 4 + (index % 5) * 2 + 1;
Mat kernel = Mat::ones(Size(kzize, kzize), CV_32F) / (float)(kzize*kzize);
filter2D(src, dst, -1, kernel, Point(-1, -1), 0, 0);
index++;
imshow("output window", dst);
}
waitKey(0);
return 0;
}