无法使用 cvMerge、DFT 进行转换
我正在尝试制作一个单通道图像的 dft,并且由于 cvDft 期望复数值,因此建议我将原始图像与另一幅全 0 的图像合并,因此最后一个将被视为虚部。
我的问题出现在使用 cvmerge 函数时,
Mat tmp = imread(filename,0);
if( tmp.empty() )
{cout << "Usage: dft <image_name>" << endl;
return -1;}
Mat Result(tmp.rows,tmp.cols,CV_64F,2);
Mat tmp1(tmp.rows,tmp.cols,CV_64F, 0);
Mat image(tmp.rows,tmp.cols,CV_64F,2);
cvMerge(tmp,tmp1,image);`
它给了我下一个错误:无法将 cvMAt 转换为 cvArr
有人可以帮助我吗?谢谢!
I am trying to make the dft of one single channeled image, and as cvDft is expecting complex values, I was adviced to merge the original image with another image with all 0's so this last one will be considered as imaginary part.
My problem comes when using cvmerge function,
Mat tmp = imread(filename,0);
if( tmp.empty() )
{cout << "Usage: dft <image_name>" << endl;
return -1;}
Mat Result(tmp.rows,tmp.cols,CV_64F,2);
Mat tmp1(tmp.rows,tmp.cols,CV_64F, 0);
Mat image(tmp.rows,tmp.cols,CV_64F,2);
cvMerge(tmp,tmp1,image);`
It gives me the next error: can not convert cvMAt to cvArr
Anyone could help me? thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1)看起来你正在混合两种不同风格的opencv代码
cv::Mat
(- Mat)是新版本opencv中的c++类,cvMerge
是旧版本opencv中的c函数。而不是使用
cvmerge
使用 合并2) 您正在尝试将
CV_8U
类型的矩阵 (tmp
)(可能)与CV_64F
合并使用 convertTo 将 tmp 获取为 CV_64F
3)为什么是您的
结果
&image
垫(目标垫)是否初始化为cv::Scalar(2)
?我认为您滥用了承包商参数。请参阅此处了解更多信息。4)你的
image
垫是一个单通道垫,你希望它作为一个2通道垫(如问题中提到的),将声明更改为1) it seems like you're mixing up 2 different styles of opencv code
cv::Mat
(- Mat) is a c++ class from the new version of opencv,cvMerge
is a c function from the old version of opencv.instead of using
cvmerge
use merge2) you're trying to merge a matrix (
tmp
) of typeCV_8U
(probably) with aCV_64F
use convertTo to get tmp as CV_64F
3) why is your
Result
&image
mats (the destination mat) are initializes tocv::Scalar(2)
? i think you're misusing the constractor parameters. see here for more info.4) you're
image
mat is a single channel mat and you wanted it as a 2 channel mat (as mentioned in the question), change the declaration to