コード例 #1
0
        public void mLineAutoSpectr(double[] temparr, int imgW, int imgH)
        {
            Random r       = new Random();
            int    lineInd = r.Next(0, imgH);

            double[] line    = temparr.Skip(lineInd * imgW).Take(imgW).ToArray <double>();
            double[] dLineDt = new double[imgW];
            for (int i = 0; i < imgW - 2; i++)
            {
                dLineDt[i] = line[i] - line[i + 1];
            }
            ComplexNum[] lineAutocor = new ComplexNum[imgW];
            for (int i = 0; i < imgW; i++)
            {
                lineAutocor[i] = new ComplexNum(Statistics.Crosscorrelation(dLineDt, dLineDt, i));
            }

            FourierTransfom ft     = new FourierTransfom();
            double          Fgr    = 1.0 / 1;
            double          Fdelta = Fgr / lineAutocor.Length;

            ComplexNum[] res = ft.mTransform(lineAutocor);
            for (int i = 0; i < mCount; i++)
            {
                mArguments[i] = i * Fdelta;
            }
            mFunc = t => res[t].abs;
        }
コード例 #2
0
ファイル: ComplexNum.cs プロジェクト: clevermx/imgProc
        public static ComplexNum operator *(ComplexNum a, ComplexNum b)
        {
            ComplexNum result = new ComplexNum();

            result.Re = (a.Re * b.Re - a.Im * b.Im);
            result.Im = (b.Re * a.Im + a.Re * b.Im);
            return(result);
        }
コード例 #3
0
ファイル: ComplexNum.cs プロジェクト: clevermx/imgProc
 public static ComplexNum[] CompArrOfDoble(double[] tempArr)
 {
     ComplexNum[] result = new ComplexNum[tempArr.Length];
     for (int i = 0; i < tempArr.Length; i++)
     {
         result[i] = new ComplexNum(tempArr[i]);
     }
     return(result);
 }
コード例 #4
0
ファイル: FourierTransfom.cs プロジェクト: clevermx/imgProc
        public ComplexNum[] mTransform(ComplexNum[] tempArr, double Fgr, double df)
        {
            int N = tempArr.Length;

            mCount      = (int)(Fgr / df);
            mCompResult = new ComplexNum[mCount];
            for (int k = 0; k < mCount; k++)
            {
                ComplexNum result = new ComplexNum();
                result.Re = 0;
                result.Im = 0;
                for (int i = 0; i < N; i++)
                {
                    result.Re = result.Re + tempArr[i].Re * Math.Cos(-(2 * Math.PI * k * i) / N) - tempArr[i].Im * Math.Sin(-(2 * Math.PI * k * i) / N);
                    result.Im = result.Im + tempArr[i].Re * Math.Sin(-(2 * Math.PI * k * i) / N) + tempArr[i].Im * Math.Cos(-(2 * Math.PI * k * i) / N);
                }
                mCompResult[k] = result;
            }
            return(mCompResult);
        }
コード例 #5
0
        public virtual void pSetObrFurie(double[] tempArr)
        {
            int N = tempArr.Length;

            mArguments = new double[N];
            mValues    = new double[N];
            for (int i = 0; i < mCount; i++)
            {
                mArguments[i] = i;
            }
            mLeftBorder  = 0;
            mRightBorder = N - 1;
            FourierTransfom fs = new FourierTransfom();

            ComplexNum[]       lFurieResult = fs.mObrTransform(ComplexNum.CompArrOfDoble(tempArr));
            Func <int, double> temp         = (k =>
            {
                return(lFurieResult[k].RePlusIm);
            });

            mFunc = temp;
        }
コード例 #6
0
ファイル: FourierTransfom.cs プロジェクト: clevermx/imgProc
        public ComplexNum[] mObrTransform(ComplexNum[] tempArr)
        {
            int N = tempArr.Length;

            mCount      = N;
            mCompResult = new ComplexNum[mCount];
            for (int k = 0; k < mCount; k++)
            {
                ComplexNum result = new ComplexNum();
                result.Re = 0;
                result.Im = 0;
                for (int i = 0; i < N; i++)
                {
                    result.Re = result.Re + tempArr[i].Re * Math.Cos((2 * Math.PI * k * i) / N) - tempArr[i].Im * Math.Sin((2 * Math.PI * k * i) / N);
                    result.Im = result.Im + tempArr[i].Re * Math.Sin((2 * Math.PI * k * i) / N) + tempArr[i].Im * Math.Cos((2 * Math.PI * k * i) / N);
                }
                result.Re      = result.Re / N;
                result.Im      = result.Im / N;
                mCompResult[k] = result;
            }
            return(mCompResult);
        }
コード例 #7
0
        public void mLineSpectr(double[] temparr, int imgW, int imgH)
        {
            Random r       = new Random();
            int    lineInd = r.Next(0, imgH);

            double[] line = temparr.Skip(lineInd * imgW).Take(imgW).ToArray <double>();

            FourierTransfom ft     = new FourierTransfom();
            double          Fgr    = 1.0 / (1 * 2);
            double          Fdelta = 2 * Fgr / line.Length;

            mCount       = (int)(Fgr / Fdelta);
            mDelta       = Fdelta;
            mRightBorder = Fgr;
            mLeftBorder  = 0;
            mValues      = new double[mCount];
            ComplexNum[] res = ft.mTransform(ComplexNum.CompArrOfDoble(line), Fgr, Fdelta);
            mArguments = new double[mCount];
            for (int i = 0; i < mCount; i++)
            {
                mArguments[i] = i * Fdelta;
            }
            mFunc = t => res[t].abs;
        }