views:

506

answers:

1

I have some problems with OpenCVs cvCanny(...) and the Image data types it can handle. Well, maybe you guys/gals know a solution.

I have a 32 bit float image and I want to perform cvCanny on it. The problem is cvCanny can only handle "IPL_DEPTH_8S" or U (signed / unsigned short), or at least that's what I suspect. The OpenCV manual does not indicate how much it can handle and this line in cv/cvcanny.cpp didn't raise my hopes:

...
if( CV_MAT_TYPE( src->type ) != CV_8UC1 ||
CV_MAT_TYPE( dst->type ) != CV_8UC1 )
CV_ERROR( CV_StsUnsupportedFormat, "" );
...

The images I have are greyscale / single channel float32 bit and the values in the image are between 0.0 and 16.0. Casting my float32 to unsigned short wouldn't help much since the values would loose their precision and I would miss edges with OpenCVs canny.

Do you guys/gals happen to know a solution for my problem? (besides using ITK :) )

+1  A: 

Sorry, since cvCanny only supports single-channel 8-bit images, the only thing I can think of is to scale each value in your image by 255/16 into a new image of type CV_8UC1 so that it ranges from 0 - 255 to minimize the precision you've lost.

Jacob
OpenCV prides itself as software that sees ... how much can u see with 8bit depth ... i don't get it. Thanks for the scaling tip.
zhengtonic
Jacob