Using Sobel on label's of DistanceTransform [closed]
I'm trying to use Sobel on the Distance Transform label as a way to only have Voronoi lines in the resulting map.
This is my code so far :
cv::Mat mat_test(heigh,width, CV_8UC3, cv::Scalar(0,0,0));
cv::circle(mat_test, cv::Point2d(0, 0), 1, cv::Scalar(255,255,255), -1);
cv::circle(mat_test, cv::Point2d(9, 9), 1, cv::Scalar(255,255,255), -1);
cv::circle(mat_test, cv::Point2d(0, 9), 1, cv::Scalar(255,255,255), -1);
cv::Mat result_ccomp;
cv::Mat other_result;
cv::Mat label;
cv::Mat label_pixel;
cv::cvtColor(mat_test, mat_test, CV_RGB2GRAY);
cv::threshold(mat_test, mat_test, 10, 255, CV_THRESH_BINARY_INV);
cv::Mat dist;
cv::distanceTransform(mat_test,result_ccomp, label, CV_DIST_L2, CV_DIST_MASK_PRECISE, CV_DIST_LABEL_CCOMP);
cv::distanceTransform(mat_test, other_result, label_pixel, CV_DIST_L2, CV_DIST_MASK_PRECISE, CV_DIST_LABEL_PIXEL);
cv::normalize(result_ccomp, result_ccomp, 0, 1., cv::NORM_MINMAX);
cv::normalize(other_result, other_result, 0, 100, cv::NORM_MINMAX);
cv::Mat sobelX;
cv::Mat sobelY;
cv::Mat sobel;
//int ddepth = CV_16S;
int scale = 1;
int delta = 0;
/// Gradient X
std::cout << "type : " << sobelX.type() << " type label : "<<label.type()<<std::endl;
cv::Sobel( label, sobelX, -1, 1, 0, 3, scale, delta, cv::BORDER_DEFAULT );
But when I try to run this little program I hit this error :
OpenCV Error: The function/feature is not implemented (Unsupported combination of source format (=4), and buffer format (=5)) in getLinearRowFilter, file /builddir/build/BUILD/opencv-2.4.9/modules/imgproc/src/filter.cpp, line 2857
unknown location(0): fatal error in "trying": std::exception: /builddir/build/BUILD/opencv-2.4.9/modules/imgproc/src/filter.cpp:2857: error: (-213) Unsupported combination of source format (=4), and buffer format (=5) in function getLinearRowFilter
I don't really understand what it means and how I got this error... Any help is appreciated.
it means, that the output from
distanceTransform
is not appropriate as input forSobel
.try to convert to float:
label.convertTo(label,CV_23F);
Thanks it solved my problem. But maybe you meant CV_32F ;)
^^ yea, typo, ofc. ;)
You should add your comment as an answer so I can accept it =)