void Sobel(Mat &img)
{
Mat bmp = img.clone();
Sobel( img, bmp ,CV_8U ,0, 1);
Sobel( img, img, CV_8U, 1, 0);
//整合到一幅圖
img = img | bmp;
bmp.release();
threshold(img, img, 0, 255, CV_THRESH_OTSU);
}
void Sobel(Mat &img)
{
Mat bmp = img.clone();
Sobel( img, img, CV_8U, 1, 0);
Sobel( bmp, bmp, CV_8U, 0, 1);
//整合到一幅圖
addWeighted( img, 0.5, bmp, 0.5, 0, img );
bmp.release();
threshold(img, img, 0, 255, CV_THRESH_OTSU);
}
兩種整合方式 結果差別不大