Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opencv 2.4.3如何将IPL_DEPTH_8U转换为IPL_DEPTH_32F?_Opencv - Fatal编程技术网

Opencv 2.4.3如何将IPL_DEPTH_8U转换为IPL_DEPTH_32F?

Opencv 2.4.3如何将IPL_DEPTH_8U转换为IPL_DEPTH_32F?,opencv,Opencv,始终失败,表示“未知函数中的断言失败(src.size==dst.size&&dst.type()==CV_8UC(src.channels())” 我搜索了很多方法,但似乎没有一种有效?这里有一个简单的函数,可以将任何IplImage转换为32位浮点 char* filename1="1.bmp"; IplImage* greyLeftImg= cvLoadImage(filename1,0); char* filename2="2.bmp"; IplImage* greyRightImg

始终失败,表示“未知函数中的断言失败(src.size==dst.size&&dst.type()==CV_8UC(src.channels())”


我搜索了很多方法,但似乎没有一种有效?

这里有一个简单的函数,可以将任何
IplImage
转换为32位浮点

char* filename1="1.bmp";  
IplImage* greyLeftImg= cvLoadImage(filename1,0);
char* filename2="2.bmp";
IplImage* greyRightImg= cvLoadImage(filename2,0); 

IplImage* greyLeftImg32=cvCreateImage(cvSize(width,height),32,greyLeftImg->nChannels);//IPL_DEPTH_32F 
IplImage* greyRightImg32=cvCreateImage(cvSize(width,height),32,greyRightImg->nChannels);

将opencv中的任何灰度8位或16位uint图像转换为32位浮动类型的简单步骤如下

IplImage* img8u = cvLoadImage(filename1,0);

IplImage* img32f = convert_to_float32(img8u);

cvShowImage("float image",img32f); //Image will not be shown correctly
cvWaitKey(0);

cvScale(img32f, img32f, 1.0/255.0);

cvShowImage("float image normalized",img32f); //Image will be shown correctly now 
cvWaitKey(0);
希望这是一个简单的方法

IplImage* img8u = cvLoadImage(filename1,0);

IplImage* img32f = convert_to_float32(img8u);

cvShowImage("float image",img32f); //Image will not be shown correctly
cvWaitKey(0);

cvScale(img32f, img32f, 1.0/255.0);

cvShowImage("float image normalized",img32f); //Image will be shown correctly now 
cvWaitKey(0);
IplImage* img = cvLoadImage( "E:\\Work_DataBase\\earth.jpg",0);
IplImage* out = cvCreateImage( cvGetSize(img), IPL_DEPTH_32F, img->nChannels);

double min,max;

cvMinMaxLoc(img,&min,&max);

// Remember values of the floating point image are in the range of 0 to 1, which u 
// can't visualize by cvShowImage().......
cvCvtScale(img,out,1/ max,0);