Slicing 3d matrix

asked 2014-02-06 19:03:07 -0600

stbnps gravatar image

updated 2014-02-06 19:03:36 -0600

I have a Mat like this:

int sizes[] = { 5, 5, 5 };
Mat a(3, sizes, CV_8UC1, cv::Scalar(0));

I want to get a sub-matrix in some specified plane (X-Y, X-Z, or Y-Z) and apply a distance transform to that matrix. I tried something like:

Range ranges[] = {Range(0, 1), Range::all(), Range::all()};
Mat b(a, ranges);

But when I perform:

distanceTransform(b, c, CV_DIST_L2, CV_DIST_MASK_PRECISE);

I got this error:

OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type)

I gess that's because the program doesn't slice the 3d matrix properly.

I also looked at NAryMatIterator but it doesnt seem to be what I need.

Thanks!

edit retag flag offensive close merge delete