Fourier transform of an image in EmguCV

后端 未结 1 485
孤城傲影
孤城傲影 2021-01-21 23:43

Can anyone tell me if there is an inbuilt function present in emgucv 2.3 for finding out fourier transform of images ?

Thanks in advance

相关标签:
1条回答
  • 2021-01-22 00:37

    From my answer Fourier Transform + emgucv

    The function you are after is CvInvoke.cvDFT it is technically calling the opencv method but it should be what your after

    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);
    

    Cheers,

    Chris

    0 讨论(0)
提交回复
热议问题