Example #1
0
        private void btn_savedata_Click(object sender, EventArgs e)
        {
            byte[] imgdata = System.IO.File.ReadAllBytes(@"c:\v1colorimeter\src\x2displaytest\bin\Debug\temp\12345620160209232604_cropped.bmp");

            Bitmap myBitmap = new Bitmap(@"c:\v1colorimeter\src\x2displaytest\bin\Debug\temp\12345620160209232604_cropped.bmp");
            int    height   = myBitmap.Height;
            int    width    = myBitmap.Width;

            double[, ,] rgbstr = new double[width, height, 3];

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    rgbstr[i, j, 0] = myBitmap.GetPixel(i, j).R;
                    rgbstr[i, j, 1] = myBitmap.GetPixel(i, j).G;
                    rgbstr[i, j, 2] = myBitmap.GetPixel(i, j).B;
                }
            }
            XYZ = ip.rgb2xyz(rgbstr);

            double sum  = 0;
            double mean = 0;
            double w    = XYZ.GetLength(0);
            double h    = XYZ.GetLength(1);

            for (int r = 0; r < w; r++)
            {
                for (int c = 0; c < h; c++)
                {
                    sum += XYZ[r, c, 2];
                }
            }
            mean = sum / (w * h);
        }
Example #2
0
        public void Analysis()
        {
            if (m_bitmap != null)
            {
                double[, ,] rgb = m_pipeline.bmp2rgb(m_bitmap);
                double[, ,] XYZ = m_pipeline.rgb2xyz(rgb);

                switch (m_panel)
                {
                case ColorPanel.White:
                case ColorPanel.Black:
                    this.Luminance   = m_pipeline.getlv(XYZ);
                    this.Uniformity5 = m_pipeline.getuniformity(XYZ);
                    this.Mura        = m_pipeline.getmura(XYZ);
                    break;

                case ColorPanel.Red:
                case ColorPanel.Green:
                case ColorPanel.Blue:
                {
                    double[] xyY = m_pipeline.getxyY(XYZ);
                    CIE1931xyY.x = xyY[0];
                    CIE1931xyY.y = xyY[1];
                    CIE1931xyY.Y = xyY[2];
                }
                break;
                }
            }
        }