简体   繁体   English

为什么在FFT自相关的情况下AForge.net提供不同的输出?

[英]Why is AForge.net giving a different output in case of FFT Auto-correlation?

See this related question . 请参阅此相关问题

I want to obtain the same outcome using AForge.net framework. 我想使用AForge.net框架获得相同的结果。 The output should match the following: 输出应匹配以下内容:

在此处输入图片说明

The output seems to be not coming as expected: 输出似乎没有达到预期的效果:

Why is the output different in AForge.net? 为什么在AForge.net中输出不同?

.

Source Code 源代码

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();

        Bitmap image = (Bitmap)Bitmap.FromFile(@"StandardImage\\lena.png");
        Bitmap conv = new Bitmap(image.Width, image.Height, image.PixelFormat);

        ComplexImage cImage = ComplexImage.FromBitmap(image);
        cImage.ForwardFourierTransform();

        ComplexImage cKernel = ComplexImage.FromBitmap(image);
        cImage.ForwardFourierTransform();

        ComplexImage convOut = ComplexImage.FromBitmap(conv);
        convOut.ForwardFourierTransform();

        for (int y = 0; y < cImage.Height; y++)
        {
            for (int x = 0; x < cImage.Width; x++)
            {
                convOut.Data[x, y] = cImage.Data[x, y] * cKernel.Data[x, y];
            }
        }

        convOut.BackwardFourierTransform();

        Bitmap bbbb = convOut.ToBitmap();

        pictureBox1.Image = bbbb;

    }
}

The main problem is 主要的问题是

    ComplexImage cKernel = ComplexImage.FromBitmap(image);
    //cImage.ForwardFourierTransform(); //<--- This line should be FFT of cKernel
    cKernel.ForwardFourierTransform();

This would solve the problem you mentioned in the resulting image, but if you want to get an image similar to the bottom right image you need to do some normalization to increase the intensity of pixels. 这样可以解决您在生成的图像中提到的问题,但是如果要获得与右下角图像相似的图像,则需要进行一些归一化处理以增加像素强度。


update: The bottom right image is actually a Fourier image so I think we should remove the BFF. 更新:右下方的图像实际上是傅立叶图像,所以我认为我们应该删除BFF。

 
 
 
  
  //convOut.BackwardFourierTransform();
 
  

It is seems like you are not using a gaussian kernel with Aforge, Anyway, the library has a method for convolution with gaussian: 似乎您没有在Aforge中使用高斯内核,无论如何,该库提供了一种与高斯卷积的方法:

int w=4,h=11;
GaussianBlur filter = new GaussianBlur( w, h );
// apply the filter
filter.ApplyInPlace( image );

Try it and the output should be the same as the others. 试试看,其输出应与其他输出相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM