#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main(){
Mat src_img = imread("../assets/zqbb.jpg",IMREAD_COLOR);
namedWindow("src",CV_WINDOW_AUTOSIZE);
imshow("src",src_img);
Mat gray;
cvtColor(src_img,gray,COLOR_BGR2GRAY);
GaussianBlur(gray,gray,Size(3,3),0);
// sobel
Mat xgray,ygray;
// Sobel(gray,xgray,CV_16S,1,0);
// Sobel(gray,ygray,CV_16S,0,1);
Scharr(gray,xgray,CV_16S,1,0);
Scharr(gray,ygray,CV_16S,0,1);
convertScaleAbs(xgray,xgray);
convertScaleAbs(ygray,ygray);
imshow("xgray",xgray);
imshow("ygray",ygray);
//将两张图片融合在一起
const Size size = gray.size();
int height = size.height;
int width = size.width;
Mat result = Mat::zeros(gray.size(),gray.type());
//
// for(int row=0;row<height;row++){
// for(int col=0;col<width;col++){
// int xv = xgray.at<uchar>(row,col);
// int yv = ygray.at<uchar>(row,col);
// result.at<uchar>(row,col) = xv + yv;
// }
// }
add(xgray,ygray,result);
imshow("result",result);
waitKey(0);
destroyAllWindows();
return 0;
}