Ivánovick
Ivánovick

Reputation: 267

Can not convert with cvMerge,DFT

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!

Upvotes: 0

Views: 703

Answers (1)

Boaz
Boaz

Reputation: 4669

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 merge

2) you're trying to merge a matrix (tmp) of type CV_8U (probably) with a CV_64F use convertTo to get tmp as CV_64F

3) why is your Result & image mats (the destination mat) are initializes to cv::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

Mat image(tmp.rows,tmp.cols,CV_64FC2);

Upvotes: 1

Related Questions