コード例 #1
0
        public static Complex[,] GetSquaredDerectionField(double[,] img, double Sigma1)
        {
            var kernelX = KernelHelper.MakeKernel((x, y) => Gaussian.Gaussian2D(x, y, Sigma1) * x, KernelHelper.GetKernelSizeForGaussianSigma(Sigma1));
            var resultX = ConvolutionHelper.Convolve(img, kernelX);
            var kernelY = KernelHelper.MakeKernel((x, y) => Gaussian.Gaussian2D(x, y, Sigma1) * -y, KernelHelper.GetKernelSizeForGaussianSigma(Sigma1));
            var resultY = ConvolutionHelper.Convolve(img, kernelY);

            var preZ = KernelHelper.MakeComplexFromDouble(resultX, resultY);

            var z = preZ.Select2D(x => x * x);

            return(z);
        }
コード例 #2
0
        public static Complex[,] ComplexConvolve(Complex[,] data, Complex[,] kernel)
        {
            var dataReal      = data.Select2D(x => x.Real);
            var dataImaginary = data.Select2D(x => x.Imaginary);

            var kernelReal      = kernel.Select2D(x => x.Real);
            var kernelImaginary = kernel.Select2D(x => x.Imaginary);

            var resultRealPart1 = Convolve(dataReal, kernelReal);
            var resultRealPart2 = Convolve(dataImaginary, kernelImaginary);

            var resultImaginaryPart1 = Convolve(dataReal, kernelImaginary);
            var resultImaginaryPart2 = Convolve(dataImaginary, kernelReal);

            return(KernelHelper.MakeComplexFromDouble(
                       KernelHelper.Subtract(resultRealPart1, resultRealPart2),
                       KernelHelper.Add(resultImaginaryPart1, resultImaginaryPart2)));
        }
コード例 #3
0
        public static Complex[,] EstimateLS(double[,] l1, double Sigma1, double Sigma2)
        {
            var kernelX = KernelHelper.MakeKernel((x, y) => Gaussian.Gaussian2D(x, y, Sigma1) * x, KernelHelper.GetKernelSizeForGaussianSigma(Sigma1));
            var resultX = ConvolutionHelper.Convolve(l1, kernelX);
            var kernelY = KernelHelper.MakeKernel((x, y) => Gaussian.Gaussian2D(x, y, Sigma1) * -y, KernelHelper.GetKernelSizeForGaussianSigma(Sigma1));
            var resultY = ConvolutionHelper.Convolve(l1, kernelY);


            var preZ = KernelHelper.MakeComplexFromDouble(resultX, resultY);

            var z = preZ.Select2D(x => x * x);

            var kernel2 = KernelHelper.MakeComplexKernel((x, y) => Gaussian.Gaussian2D(x, y, Sigma2), (x, y) => 0,
                                                         KernelHelper.GetKernelSizeForGaussianSigma(Sigma2));

            var I20 = ConvolutionHelper.ComplexConvolve(z, kernel2);

            var I11 = ConvolutionHelper.Convolve(z.Select2D(x => x.Magnitude), kernel2.Select2D(x => x.Real));

            Complex[,] LS = KernelHelper.Zip2D(I20, I11, (x, y) => x / y);

            return(LS);
        }