Convert float array image to a format usable for opencv

匿名 (未验证) 提交于 2019-12-03 02:52:02

问题:

i wonder if there is a easy way to convert my float array image to iplimage, which can be handled by opencv. Of course i could create an empty iplimage with the same size and just copy ever pixel from my float array image to the emplty iplimage, but is there more elegant solution to this. Maybe a faster less memory consuming method, since the source images are pretty large and the copy process would take a while.

Best regards,

Zhengtonic

回答1:

You can do something like this (assuming 32 bit floats):

float* my_float_image_data;  CvSize size; size.height = height ; size.width = width; IplImage* ipl_image_p = cvCreateImageHeader(size, IPL_DEPTH_32F, 1); ipl_image_p->imageData = my_float_image_data; ipl_image_p->imageDataOrigin = ipl_image_p->imageData; 


回答2:

You can fill an iplimage structure 'by hand' to describe your array following the comments here.

The field imageData will point to your original array.

But then don't use deallocation functions on it. Just delete the structure in the end.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!