Accord.Imaging.ComplexFilters.FrequencyFilter.Apply C# (CSharp) Method

Apply() public method

Apply filter to complex image.
The source complex image should be Fourier transformed.
public Apply ( ComplexImage complexImage ) : void
complexImage ComplexImage Complex image to apply filter to.
return void
        public void Apply(ComplexImage complexImage)
        {
            if (!complexImage.FourierTransformed)
            {
                throw new ArgumentException("The source complex image should be Fourier transformed.");
            }

            // get image dimenstion
            int width = complexImage.Width;
            int height = complexImage.Height;

            // half of dimensions
            int hw = width >> 1;
            int hh = height >> 1;

            // min and max frequencies
            int min = frequencyRange.Min;
            int max = frequencyRange.Max;

            // complex data to process
            Complex[,] data = complexImage.Data;

            // process all data
            for (int i = 0; i < height; i++)
            {
                int y = i - hh;

                for (int j = 0; j < width; j++)
                {
                    int x = j - hw;
                    int d = (int)Math.Sqrt(x * x + y * y);

                    // filter values outside the range
                    if ((d > max) || (d < min))
                    {
                        data[i, j] = Complex.Zero;
                    }
                }
            }
        }
    }