//4.方向滤波器检查边缘------------------------------------------------------------------------------------
cv::Mat imag = cv::imread("../../aTestImage/building2.jpg", 0);
cv::namedWindow("imag", 1);
cv::imshow("imag", imag);//
cv::Mat sobelX, sobelY,sobel;
//(src,result,ddepth,Xorder,Yorder, kernel_size,alpha缩放量,beta偏移)
cv::Sobel(imag, sobelX, CV_8U, 1, 0 , 3 , 0.4 , 128);//计算Sobel范式
cv::Sobel(imag, sobelY, CV_8U, 0, 1 , 3 , 0.4 , 128);
//cv::namedWindow("sobelX", 1);
//cv::imshow("sobelX", sobelX);
//cv::namedWindow("sobelY", 1);
//cv::imshow("sobelY", sobelY);//
sobel =abs(sobelX) +abs (sobelY);//计算L1范式
//cv::namedWindow("sobel", 1);
//cv::imshow("sobel", sobel);//
//搜索Sobel极大值
double sobmin, sobmax;
cv::minMaxLoc(sobel, &sobmin, &sobmax);
// sobelRes=-alpha*sobel+255
cv::Mat sobelRes, sobelThres;
int threshold = 60;
sobel.convertTo(sobelRes, CV_8U, -255.0 / sobmax, 255);//转变成8位图像
cv::namedWindow("sobelRes", 1);
cv::imshow("sobelRes", sobelRes);//
cv::threshold(sobelRes, sobelThres, threshold, 255, cv::THRESH_BINARY);
//cv::namedWindow("sobelThres", 1);
//cv::imshow("sobelThres", sobelThres);//