您当前的位置: 首页 >  opencv

惊鸿一博

暂无认证

  • 6浏览

    0关注

    535博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

OpenCV_(Based on Sobel Filter to Detect edges) 基于Sobel算子的方向滤波器检查边缘

惊鸿一博 发布时间:2017-03-14 18:57:13 ,浏览量:6

//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);//

 

关注
打赏
1663399408
查看更多评论
立即登录/注册

微信扫码登录

0.0395s