cvCanny and float 32 bit (IPL_DEPTH_32F) problem
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 :) )
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.
精彩评论