Fourier transform of an image in EmguCV

后端 未结 1 494
孤城傲影
孤城傲影 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 image = new Image(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 dft = new Matrix(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 outReal = new Matrix(image.Size);
    //The imaginary part of the Fourier Transform
    Matrix outIm = new Matrix(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)
提交回复
热议问题