Exemplo n.º 1
0
 public static double getLabb(Color c, LabMode m)
 {
     if (m == LabMode.CIE)
     {
         return(new LColor(c).CIELab_b);
     }
     return(new LColor(c).PhotoShopLab_b);
 }
Exemplo n.º 2
0
 public double getb(LabMode m)
 {
     if (m == LabMode.Photoshop)
     {
         return(PhotoShopLab_b);
     }
     return(CIELab_b);
 }
Exemplo n.º 3
0
        private void setParams(int cntBlock, int cntTrial, int cntRepetition, int cntS1Pos, int cntS2Pos,
                               int cntPosture, int cntAngle, int cntOrientation)
        {
            totalBlockCount = cntBlock;
            totalTrialCount = cntTrial;
            labMode         = LabMode.Full;
            repetitionCount = cntRepetition;
            s1PositionCount = cntS1Pos;
            s2PositionCount = cntS2Pos;

            postureCount     = cntPosture;
            angleCount       = cntAngle;
            orientationCount = cntOrientation;
        }
Exemplo n.º 4
0
        public void setTotalTrialCount(bool isFullMode)
        {
            switch (labName)
            {
            case LabScene.Lab0_tap_5_5:
                labMode         = isFullMode ? LabMode.Full : LabMode.Test;
                totalTrialCount = isFullMode ? Lab0_tap_55.fullTrialCount : Lab0_tap_55.testTrialCount;
                break;

            case LabScene.Lab1_tap_33_33:
                labMode         = isFullMode ? LabMode.Full : LabMode.Test;
                totalTrialCount = isFullMode ? Lab1_tap_99.fullTrialCount : Lab1_tap_99.testTrialCount;
                break;
            }
        }
Exemplo n.º 5
0
        public void setColorByLab(double l, double a, double b, LabMode m)
        {
            if (l < 0)
            {
                l = 0;
            }
            if (l > 100)
            {
                l = 100;
            }
            if (a < -128)
            {
                a = -128;
            }
            if (a > 127)
            {
                a = 127;
            }
            if (b < -128)
            {
                b = -128;
            }
            if (b > 127)
            {
                b = 127;
            }
            if (m == LabMode.CIE)
            {
                CIELab_L = l;
                CIELab_a = a;
                CIELab_b = b;
                CalculateCIELab2XYZ();
                CalculateXYZ2RGB();
                CalculateRGB2PhotoShopLab();
            }
            else
            {
                PhotoShopLab_L = l;
                PhotoShopLab_a = a;
                PhotoShopLab_b = b;
                CalculatePhotoShopLab2XYZ();
                CalculateXYZ2RGB();
                CalculateXYZ2CIELab();
            }

            CalculateRGB2HSB();
            CalculateRGB2HSL();
        }
Exemplo n.º 6
0
        public double?getSNR(Dictionary <TimeSpan, WriteableBitmap> sl, LabMode CurrentLabMode)
        {
            SnapList = sl;
            if (!CharkSnapList())
            {
                return(null);
            }
            double AllAve   = 0; //总平均
            double FrameAve = 0; //帧平均
            Dictionary <TimeSpan, double> FrameAveList = new Dictionary <TimeSpan, double>();
            long tp = 0;

            List <double> PixAveList = new List <double>();//空间平均的列表

            if (SignValue == null)
            {
                foreach (KeyValuePair <TimeSpan, WriteableBitmap> tb in sl)
                {
                    tp = tp + tb.Value.PixelBuffer.Length;
                    for (int i = 0; i < tb.Value.PixelBuffer.Length; i++)
                    {
                        FrameAve = 0;
                        byte[] components = new byte[4];
                        components = BitConverter.GetBytes(tb.Value.PixelBuffer.ToArray()[i]);
                        double v = 0;

                        if (currentNoiseType == SignNoiseType.Gray)
                        {
                            v = .299 * components[2] + .587 * components[1] + .114 * components[0];
                        }
                        if (currentNoiseType == SignNoiseType.L)
                        {
                            v = ColorManager.getLabL(Color.FromArgb(255, components[2], components[1], components[0]), CurrentLabMode);
                        }
                        if (currentNoiseType == SignNoiseType.R)
                        {
                            v = components[2];
                        }
                        if (currentNoiseType == SignNoiseType.G)
                        {
                            v = components[1];
                        }
                        if (currentNoiseType == SignNoiseType.B)
                        {
                            v = components[0];
                        }
                        AllAve   = AllAve + v;
                        FrameAve = FrameAve + v;
                        if (i >= PixAveList.Count)
                        {
                            PixAveList.Add(v);
                        }
                        else
                        {
                            PixAveList[i] = PixAveList[i] + v;
                        }
                    }
                    FrameAve = FrameAve / tb.Value.PixelBuffer.ToArray().Length;
                    FrameAveList.Add(tb.Key, FrameAve);
                }
                AllAve = AllAve / tp;//获取所有帧的平均值
            }
            else
            {
                foreach (KeyValuePair <TimeSpan, WriteableBitmap> tb in sl)
                {
                    tp = tp + tb.Value.PixelBuffer.ToArray().Length;
                    for (int i = 0; i < tb.Value.PixelBuffer.ToArray().Length; i++)
                    {
                        if (i >= PixAveList.Count)
                        {
                            PixAveList.Add(SignValue.Value);
                        }
                        else
                        {
                            PixAveList[i] = PixAveList[i] + SignValue.Value;
                        }
                    }
                    FrameAve = SignValue.Value;
                    FrameAveList.Add(tb.Key, FrameAve);
                }
                AllAve = SignValue.Value;
            }
            double s1 = 0, s2 = 0;

            foreach (KeyValuePair <TimeSpan, WriteableBitmap> tb in sl)
            {
                s1 = s1 + (FrameAveList[tb.Key] - AllAve) * (FrameAveList[tb.Key] - AllAve);
                for (int i = 0; i < tb.Value.PixelBuffer.ToArray().Length; i++)
                {
                    byte[] components = new byte[4];
                    components = BitConverter.GetBytes(tb.Value.PixelBuffer.ToArray()[i]);
                    double v = 0;

                    if (currentNoiseType == SignNoiseType.Gray)
                    {
                        v = .299 * components[2] + .587 * components[1] + .114 * components[0];
                    }
                    if (currentNoiseType == SignNoiseType.L)
                    {
                        v = ColorManager.getLabL(Color.FromArgb(255, components[2], components[1], components[0]), CurrentLabMode);
                    }
                    if (currentNoiseType == SignNoiseType.R)
                    {
                        v = components[2];
                    }
                    if (currentNoiseType == SignNoiseType.G)
                    {
                        v = components[1];
                    }
                    if (currentNoiseType == SignNoiseType.B)
                    {
                        v = components[0];
                    }
                    s2 = s2 + (PixAveList[i] / sl.Count - v) * (PixAveList[i] / sl.Count - v);
                }
            }
            s1 = s1 / FrameAveList.Count;
            s2 = s2 / FrameAveList.Count / PixAveList.Count;
            return(20 * Math.Log10(AllAve / Math.Sqrt(s1 + s2)));
        }