Ejemplo n.º 1
0
        public static COMPLEX[,] MultiplyFFTMatrices(COMPLEX [,] A, COMPLEX [,] B)
        {
            int i, j;
            int Width, Height;

            double a, b, c, d;

            Width             = A.GetLength(0);
            Height            = A.GetLength(1);
            COMPLEX[,] Output = new COMPLEX[Width, Height];
            for (i = 0; i <= Width - 1; i++)
            {
                for (j = 0; j <= Height - 1; j++)
                {
                    a = A[i, j].real;
                    b = A[i, j].imag;
                    c = B[i, j].real;
                    d = B[i, j].imag;

                    Output[i, j].real = (a * c - b * d);
                    Output[i, j].imag = (a * d + b * c);
                }
            }


            return(Output);
        }
Ejemplo n.º 2
0
		public override PJ Init()
		{
			// GS50 ellipsoid
			COMPLEX[] ABe=new COMPLEX[]
			{
				new COMPLEX(0.9827497, 0.0),
				new COMPLEX(0.0210669, 0.0053804),
				new COMPLEX(-0.1031415, -0.0571664),
				new COMPLEX(-0.0323337, -0.0322847),
				new COMPLEX(0.0502303, 0.1211983),
				new COMPLEX(0.0251805, 0.0895678),
				new COMPLEX(-0.0012315, -0.1416121),
				new COMPLEX(0.0072202, -0.1317091),
				new COMPLEX(-0.0194029, 0.0759677),
				new COMPLEX(-0.0210072, 0.0834037)
			};

			// GS50 sphere
			COMPLEX[] ABs=new COMPLEX[]
			{
				new COMPLEX(0.9842990, 0.0),
				new COMPLEX(0.0211642, 0.0037608),
				new COMPLEX(-0.1036018, -0.0575102),
				new COMPLEX(-0.0329095, -0.0320119),
				new COMPLEX(0.0499471, 0.1223335),
				new COMPLEX(0.0260460, 0.0899805),
				new COMPLEX(0.0007388, -0.1435792),
				new COMPLEX(0.0075848, -0.1334108),
				new COMPLEX(-0.0216473, 0.0776645),
				new COMPLEX(-0.0225161, 0.0853673)
			};

			n=9;
			lam0=Proj.DEG_TO_RAD*-120.0;
			phi0=Proj.DEG_TO_RAD*45.0;

			if(es!=0)
			{ // fixed ellipsoid/sphere
				zcoeff=ABe;
				a=6378206.4;
				es=0.00676866;
				e=Math.Sqrt(es);
			}
			else
			{
				zcoeff=ABs;
				a=6370997.0;
			}

			return setup();
		}
Ejemplo n.º 3
0
        // ellipsoid
        LP e_inverse(XY xy)
        {
            LP lp;

            lp.lam = lp.phi = 0;

            COMPLEX p;

            p.r = xy.y;
            p.i = xy.x;

            int nn;

            for (nn = 20; nn > 0; nn--)
            {
                COMPLEX fp;
                COMPLEX f = p.pj_zpolyd1(bf, bf.Length - 1, out fp);
                f.r -= xy.y;
                f.i -= xy.x;
                double  den = fp.r * fp.r + fp.i * fp.i;
                COMPLEX dp;
                dp.r = -(f.r * fp.r + f.i * fp.i) / den;
                dp.i = -(f.i * fp.r - f.r * fp.i) / den;
                p.r += dp.r;
                p.i += dp.i;
                if ((Math.Abs(dp.r) + Math.Abs(dp.i)) <= EPSLN)
                {
                    break;
                }
            }

            if (nn != 0)
            {
                lp.lam = p.i;
                int i = tphi.Length - 1;
                int C = i;
                for (lp.phi = tphi[C--]; i > 0; i--)
                {
                    lp.phi = tphi[C--] + p.r * lp.phi;
                }

                lp.phi = phi0 + p.r * lp.phi * SEC5_TO_RAD;
            }
            else
            {
                lp.lam = lp.phi = Libc.HUGE_VAL;
            }

            return(lp);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Applies Gaussian Filter on the Image Data
        /// </summary>
        /// <param name="FFTData">FFT of the Image</param>
        /// <param name="rL">Lower Homomrphic Threshold</param>
        /// <param name="rH">Upper Homomrphic Threshold</param>
        /// <param name="Sigma"> Spread of the Gaussian</param>
        /// <param name="Slope">Slope of the Sharpness of the Gaussian Filter</param>
        /// <returns></returns>

        public static COMPLEX[,] ApplyFilterHMMFreqDomain(COMPLEX[,] FFTData, float rH, float rL, float Sigma, float Slope)
        {
            COMPLEX[,] Output = new COMPLEX[FFTData.GetLength(0), FFTData.GetLength(1)];
            int i, j, W, H;

            W = FFTData.GetLength(0);
            H = FFTData.GetLength(1);

            double Weight;

            //Taking FFT of Gaussian HPF
            double[,] GaussianHPF = GenerateGaussianKernelHPF(FFTData.GetLength(0), Sigma, Slope, out Weight);

            //Variables for FFT of Gaussian Filter
            COMPLEX[,] GaussianHPFFFT;
            // FFT GaussianFFTObject;

            for (i = 0; i <= GaussianHPF.GetLength(0) - 1; i++)
            {
                for (j = 0; j <= GaussianHPF.GetLength(1) - 1; j++)
                {
                    GaussianHPF[i, j] = GaussianHPF[i, j];// / Weight;
                }
            }

            FFT GaussianFFTObject = new FFT(GaussianHPF);

            GaussianFFTObject.ForwardFFT(GaussianHPF);
            //Shifting FFT for Filtering
            GaussianFFTObject.FFTShift();


            GaussianHPFFFT = GaussianFFTObject.FFTShifted;
            for (i = 0; i <= GaussianHPF.GetLength(0) - 1; i++)
            {
                for (j = 0; j <= GaussianHPF.GetLength(1) - 1; j++)
                {
                    GaussianHPFFFT[i, j].real = (rH - rL) * GaussianHPFFFT[i, j].real + rL;
                    GaussianHPFFFT[i, j].imag = (rH - rL) * GaussianHPFFFT[i, j].imag + rL;
                }
            }

            // Applying Filter on the FFT of the Log Image by Multiplying in Frequency Domain
            Output = MultiplyFFTMatrices(GaussianHPFFFT, FFTData);


            return(Output);
        }
Ejemplo n.º 5
0
		public override PJ Init()
		{
			// Lee Oblated Stereographic
			COMPLEX[] AB=new COMPLEX[]
			{
				new COMPLEX(0.721316, 0.0),
				new COMPLEX(0.0, 0.0),
				new COMPLEX(-0.0088162, -0.00617325)
			};

			n=2;
			lam0=Proj.DEG_TO_RAD*-165.0;
			phi0=Proj.DEG_TO_RAD*-10.0;
			zcoeff=AB;
			es=0.0;

			return setup();
		}
Ejemplo n.º 6
0
		public override PJ Init()
		{
			// Miller Oblated Stereographic
			COMPLEX[] AB=new COMPLEX[]
			{
				new COMPLEX(0.924500, 0.0),
				new COMPLEX(0.0, 0.0),
				new COMPLEX(0.019430, 0.0)
			};

			n=2;
			lam0=Proj.DEG_TO_RAD*20.0;
			phi0=Proj.DEG_TO_RAD*18.0;
			zcoeff=AB;
			es=0.0;

			return setup();
		}
Ejemplo n.º 7
0
		public override PJ Init()
		{
			// Alaska ellipsoid
			COMPLEX[] ABe=new COMPLEX[]
			{
				new COMPLEX(0.9945303, 0.0),
				new COMPLEX(0.0052083, -0.0027404),
				new COMPLEX(0.0072721, 0.0048181),
				new COMPLEX(-0.0151089, -0.1932526),
				new COMPLEX(0.0642675, -0.1381226),
				new COMPLEX(0.3582802, -0.2884586)
			};

			// Alaska sphere
			COMPLEX[] ABs=new COMPLEX[]
			{
				new COMPLEX(0.9972523, 0.0),
				new COMPLEX(0.0052513, -0.0041175),
				new COMPLEX(0.0074606, 0.0048125),
				new COMPLEX(-0.0153783, -0.1968253),
				new COMPLEX(0.0636871, -0.1408027),
				new COMPLEX(0.3660976, -0.2937382)
			};

			n=5;
			lam0=Proj.DEG_TO_RAD*-152.0;
			phi0=Proj.DEG_TO_RAD*64.0;

			if(es!=0)
			{ // fixed ellipsoid/sphere
				zcoeff=ABe;
				a=6378206.4;
				es=0.00676866;
				e=Math.Sqrt(es);
			}
			else
			{
				zcoeff=ABs;
				a=6370997.0;
			}

			return setup();
		}
Ejemplo n.º 8
0
		// evaluate complex polynomial

		// note: coefficients are always from C_1 to C_n
		// i.e. C_0 == (0., 0)
		// n should always be >= 1 though no checks are made
		public COMPLEX pj_zpoly1(COMPLEX[] C, int n)
		{
			int C_ind=n;
			COMPLEX a=C[C_ind];

			double t;
			while((n--)>0)
			{
				t=a.r;
				a.r=C[--C_ind].r+r*t-i*a.i;
				a.i=C[C_ind].i+r*a.i+i*t;
			}

			t=a.r;
			a.r=r*t-i*a.i;
			a.i=r*a.i+i*t;

			return a;
		}
Ejemplo n.º 9
0
        // evaluate complex polynomial

        // note: coefficients are always from C_1 to C_n
        // i.e. C_0 == (0., 0)
        // n should always be >= 1 though no checks are made
        public COMPLEX pj_zpoly1(COMPLEX[] C, int n)
        {
            int     C_ind = n;
            COMPLEX a     = C[C_ind];

            double t;

            while ((n--) > 0)
            {
                t   = a.r;
                a.r = C[--C_ind].r + r * t - i * a.i;
                a.i = C[C_ind].i + r * a.i + i * t;
            }

            t   = a.r;
            a.r = r * t - i * a.i;
            a.i = r * a.i + i * t;

            return(a);
        }
Ejemplo n.º 10
0
		public override PJ Init()
		{
			// 48 United States
			COMPLEX[] AB=new COMPLEX[]
			{
				new COMPLEX(0.98879, 0.0),
				new COMPLEX(0.0, 0.0),
				new COMPLEX(-0.050909, 0.0),
				new COMPLEX(0.0, 0.0),
				new COMPLEX(0.075528, 0.0)
			};

			n=4;
			lam0=Proj.DEG_TO_RAD*-96.0;
			phi0=Proj.DEG_TO_RAD*-39.0;
			zcoeff=AB;
			es=0.0;
			a=6370997.0;

			return setup();
		}
Ejemplo n.º 11
0
        // evaluate complex polynomial and derivative
        public COMPLEX pj_zpolyd1(COMPLEX[] C, int n, out COMPLEX der)
        {
            int     C_ind = n;
            COMPLEX a = C[C_ind], b = new COMPLEX();
            bool    first = true;

            double t;

            while ((n--) > 0)
            {
                if (first)
                {
                    first = false;
                    b     = a;
                }
                else
                {
                    t = b.r;

                    b.r = a.r + r * t - i * b.i;
                    b.i = a.i + r * b.i + i * t;
                }

                t   = a.r;
                a.r = C[--C_ind].r + r * t - i * a.i;
                a.i = C[C_ind].i + r * a.i + i * t;
            }

            t   = b.r;
            b.r = a.r + r * t - i * b.i;
            b.i = a.i + r * b.i + i * t;

            t   = a.r;
            a.r = r * t - i * a.i;
            a.i = r * a.i + i * t;

            der = b;

            return(a);
        }
Ejemplo n.º 12
0
		// evaluate complex polynomial and derivative
		public COMPLEX pj_zpolyd1(COMPLEX[] C, int n, out COMPLEX der)
		{
			int C_ind=n;
			double t;
			bool first = true;

			COMPLEX a = C[C_ind];
			COMPLEX b = a;
			while ((n--) > 0)
			{
				if(first)
				{
					first=false;
				}
				else
				{
					t=b.r;

					b.r=a.r+r*t-i*b.i;
					b.i=a.i+r*b.i+i*t;
				}

				t=a.r;
				a.r=C[--C_ind].r+r*t-i*a.i;
				a.i=C[C_ind].i+r*a.i+i*t;
			}

			t=b.r;
			b.r=a.r+r*t-i*b.i;
			b.i=a.i+r*b.i+i*t;

			t=a.r;
			a.r=r*t-i*a.i;
			a.i=r*a.i+i*t;

			der=b;

			return a;
		}
Ejemplo n.º 13
0
		// ellipsoid
		LP e_inverse(XY xy)
		{
			LP lp;
			lp.lam=lp.phi=0;

			int nn;

			COMPLEX p;
			p.r=xy.x;
			p.i=xy.y;
			for(nn=20; nn>0; nn--)
			{
				COMPLEX fpxy;
				COMPLEX fxy=p.pj_zpolyd1(zcoeff, n, out fpxy);

				fxy.r-=xy.x;
				fxy.i-=xy.y;
				double den=fpxy.r*fpxy.r+fpxy.i*fpxy.i;

				COMPLEX dp;
				dp.r=-(fxy.r*fpxy.r+fxy.i*fpxy.i)/den;
				dp.i=-(fxy.i*fpxy.r-fxy.r*fpxy.i)/den;

				p.r+=dp.r;
				p.i+=dp.i;
				if((Math.Abs(dp.r)+Math.Abs(dp.i))<=EPSLN) break;
			}

			double rh=0, sinz=0, cosz=0, phi=0;
			if(nn!=0)
			{
				rh=Libc.hypot(p.r, p.i);
				double z=2.0*Math.Atan(0.5*rh);
				sinz=Math.Sin(z);
				cosz=Math.Cos(z);
				lp.lam=lam0;
				if(Math.Abs(rh)<=EPSLN)
				{
					lp.phi=phi0;
					return lp;
				}

				double chi=Proj.aasin(ctx, cosz*schio+p.i*sinz*cchio/rh);
				phi=chi;
				for(nn=20; nn>0; nn--)
				{
					double esphi=e*Math.Sin(phi);
					double dphi=2.0*Math.Atan(Math.Tan((Proj.HALFPI+chi)*0.5)*Math.Pow((1.0+esphi)/(1.0-esphi), e*0.5))-Proj.HALFPI-phi;
					phi+=dphi;
					if(Math.Abs(dphi)<=EPSLN) break;
				}
			}

			if(nn!=0)
			{
				lp.phi=phi;
				lp.lam=Math.Atan2(p.r*sinz, rh*cchio*cosz-p.i*schio*sinz);
			}
			else lp.lam=lp.phi=Libc.HUGE_VAL;

			return lp;
		}