protected override STuple <float, float> Modulate(float x, float y)
        {
            STuple <float, float> pair = AcuityEngine.ConvertZeroOneToNegOneOne(x, y);

            pair = InternalModulate(pair);

            return(AcuityEngine.ConvertNegOneOneToZeroOne(pair.Value1, pair.Value2));
        }
Ejemplo n.º 2
0
        protected override STuple <float, float> InternalModulate(STuple <float, float> pair)
        {
            STuple <float, float> pair2 = AcuityEngine.ConvertEuclideanToPolar(pair.Value1, pair.Value2);

            if (!CheckCoordinates(pair2))
            {
                return(pair);
            }

            pair2 = InternalModulate2(pair2);

            return(AcuityEngine.ConvertPolarToEuclidean(pair2.Value1, pair2.Value2));
        }
        public static Matrix IntervalFit(Matrix input, float min, float max)
        {
            int i;
            int j;

            Matrix output = input.CloneSize();

            for (i = 0; i < input.RowCount; i++)
            {
                for (j = 0; j < input.ColumnCount; j++)
                {
                    float value = input[i, j];
                    if (float.IsNaN(value))
                    {
                        value = min;
                    }
                    output[i, j] = AcuityEngine.IntervalFit(value, min, max);
                }
            }

            return(output);
        }
Ejemplo n.º 4
0
        protected override float CalculateFinalValue(Matrix input, int row, int column, float signalMean, float ratio)
        {
            float value = input[row, column];
            int   rejectionWindowSize = 3;

            List <float> measures   = new List <float>(rejectionWindowSize * rejectionWindowSize);
            int          alphaCount = (int)Math.Ceiling(rejectionWindowSize * rejectionWindowSize * AlphaForRejection / 2);

            DoWindowPass(input, row, column, rejectionWindowSize, AddValueToMeasures, measures);
            measures.Sort(Compare);

            bool doAtm = false;

            if (value > measures[measures.Count / 2])
            {
                //white impulse?
                if (measures.GetRange(measures.Count - alphaCount, alphaCount).Contains(value))
                {
                    //yes, replace mmse calc with atm
                    doAtm = true;
                }
            }
            else
            {
                //black impulse?
                if (measures.GetRange(0, alphaCount).Contains(value))
                {
                    //yes, replace mmse calc with atm
                    doAtm = true;
                }
            }

            if (doAtm)
            {
                if (measures.Count > alphaCount)
                {
                    measures.RemoveRange(0, alphaCount);
                }
                if (measures.Count > alphaCount)
                {
                    measures.RemoveRange(measures.Count - alphaCount, alphaCount);
                }

                if (measures.Count > 0)
                {
                    //float sum = 0;
                    //foreach (float measure in measures)
                    //{
                    //    sum += measure;
                    //}
                    //value = sum / measures.Count;
                    value = AcuityEngine.CalculateMean(measures);
                }
                else
                {
                    value = 0;
                }

                return(value);
            }

            return(base.CalculateFinalValue(input, row, column, signalMean, ratio));
        }
        //public DualBellEdgeDetectorMatrixFilter(int windowSize, float gamma)
        //    : base(windowSize)
        //{
        //    _gamma = gamma;
        //}

        //private float _gamma;
        //public float Gamma
        //{
        //    get { return _gamma; }
        //    set { _gamma = value; }
        //}


        protected override float SelectValueFromOrderedMeasures(List <float> measures)
        {
            if (measures.Count < 1)
            {
                return(0);
            }

            int splitIndex = 0;

            float signalMean     = AcuityEngine.CalculateMean(measures);
            float signalVariance = AcuityEngine.CalculateVariance(measures, signalMean);
            float signalStdev    = (float)Math.Sqrt(signalVariance);

            int i;
            int start = -1;
            int count = 1;

            for (i = 0; i < measures.Count; i++)
            {
                if (measures[i] == signalMean)
                {
                    if (start < 0)
                    {
                        start = i;
                    }
                    else
                    {
                        count++;
                    }
                }
                else if (measures[i] > signalMean)
                {
                    if (start < 0)
                    {
                        start = i;
                    }

                    break;
                }
            }

            if (start < 0)
            {
                start = measures.Count - 1;
            }

            splitIndex = start + count / 2;

            float value;

            if (splitIndex < 1)
            {
                value = 0;
            }
            else
            {
                //List<float> lower = measures.GetRange(0, splitIndex);
                //List<float> higher = measures.GetRange(splitIndex, measures.Count - splitIndex);

                float lowerMean;
                //float lowerVariance;
                float higherMean;
                //float higherVariance;

                //if (lower.Count < 1 || higher.Count < 1)
                //{
                //    value = 0;
                //}
                //else
                if (signalVariance == 0)
                {
                    value = 0;
                }
                else
                {
                    lowerMean = AcuityEngine.CalculateMean(measures, 0, splitIndex);
                    //lowerVariance = SolusEngine.CalculateVariance(measures, lowerMean, 0, splitIndex);
                    higherMean = AcuityEngine.CalculateMean(measures, splitIndex, measures.Count - splitIndex);
                    //higherVariance = SolusEngine.CalculateVariance(measures, higherMean, splitIndex, measures.Count - splitIndex);

                    value = higherMean - lowerMean;
                    //value = Math.Abs((lowerMean - higherMean)) / Math.Sqrt(lowerVariance * higherVariance);
                    //value = 1 - higherVariance * lowerVariance / (signalVariance * signalVariance);
                    //value = (higherMean - lowerMean) / signalStdev;
                    //value = Math.Sqrt(higherMean - lowerMean);

                    //value = 1 - SolusEngine.CalculateNormalDistributionOverlap(lowerMean, lowerVariance, higherMean, higherVariance);
                    //value = 1 - Math.Sqrt(lowerVariance * higherVariance) / signalVariance;
                }

                if (float.IsNaN(value))
                {
                    value = 0;
                }
            }

            return(value);// Math.Pow(value, Gamma);
        }