且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

傅里叶变换+ emgucv

更新时间:2022-06-12 15:51:01

好吧,我已经遍历了您的代码并对其进行调试,问题所在的是这里:

Well I've gone over your code and debugged it the problem line is here:

imageMat.CopyTo( GreyFourierImage );

您正在尝试将float []数组中的imageMat复制到图像float [,*]中,我敢肯定,您会发现只是不起作用,这就是程序挂起的原因.

You are trying to copy imageMat which is a float[,] array to an image float[,,*] I'm sure you can figure out that this just doesn't work and is why the program hangs.

这是将cvDFT中的虚部和实部分开的代码:

Here is the code that splits the Imaginary and Real parts from cvDFT:

Image<Gray, float> image = new Image<Gray, float>(open.FileName);
IntPtr complexImage = CvInvoke.cvCreateImage(image.Size, Emgu.CV.CvEnum.IPL_DEPTH.IPL_DEPTH_32F, 2);

CvInvoke.cvSetZero(complexImage);  // Initialize all elements to Zero
CvInvoke.cvSetImageCOI(complexImage, 1);
CvInvoke.cvCopy(image, complexImage, IntPtr.Zero);
CvInvoke.cvSetImageCOI(complexImage, 0);

Matrix<float> dft = new Matrix<float>(image.Rows, image.Cols, 2);
CvInvoke.cvDFT(complexImage, dft, Emgu.CV.CvEnum.CV_DXT.CV_DXT_FORWARD, 0);

//The Real part of the Fourier Transform
Matrix<float> outReal = new Matrix<float>(image.Size);
//The imaginary part of the Fourier Transform
Matrix<float> outIm = new Matrix<float>(image.Size);
CvInvoke.cvSplit(dft, outReal, outIm, IntPtr.Zero, IntPtr.Zero);

//Show The Data       
CvInvoke.cvShowImage("Real", outReal);
CvInvoke.cvShowImage("Imaginary ", outIm);

干杯

克里斯