Exemple #1
0
        private void Lab2Form_Load(object sender, EventArgs e)
        {
            RGBImage = new Bitmap(source);
            YUVImage = new Bitmap(source.Width, source.Height);
            for (int i = 0; i < source.Width; i++)
            {
                for (int j = 0; j < source.Height; j++)
                {
                    Color  color = source.GetPixel(i, j);
                    double Y, U, V;
                    ModelSettingsChooser.ColorToYUV(color, out Y, out U, out V);
                    YUVImage.SetPixel(i, j, Color.FromArgb((int)Y, (int)U, (int)V));
                }
            }

            PictureBox.Image        = RGBImage;
            originalImage           = new Bitmap(RGBImage);
            comboBox1.SelectedIndex = 0;
        }
Exemple #2
0
        public void CountHystograms(string mode, out double[] R, out double[] G, out double[] B, out string rName, out string gName, out string bName)
        {
            //int[] points = new int[100];
            R     = new double[256];
            G     = new double[256];
            B     = new double[256];
            rName = "Red";
            gName = "Green";
            bName = "Blue";
            Color color;

            for (int i = 0; i < localImage.Width; i++)
            {
                for (int j = 0; j < localImage.Height; j++)
                {
                    color = localImage.GetPixel(i, j);
                    if (mode == "RGB")
                    {
                        rName = "Red";
                        gName = "Green";
                        bName = "Blue";
                        ++R[color.R];
                        ++G[color.G];
                        ++B[color.B];
                    }
                    else if (mode == "YUV")
                    {
                        double Y, U, V;
                        ModelSettingsChooser.ColorToYUV(color, out Y, out U, out V);
                        rName = "Y";
                        gName = "U";
                        bName = "V";
                        ++R[(int)Y];
                        ++G[(int)U];
                        ++B[(int)V];
                    }
                    else if (mode == "HSL")
                    {
                        double H, S, L;
                        ModelSettingsChooser.ColorToHSL(color, out H, out S, out L);
                        rName = "Hue";
                        gName = "Saturation";
                        bName = "Brightness";
                        ++R[(int)(H * 255)];
                        ++G[(int)(S * 255)];
                        ++B[(int)(L * 255)];
                    }
                    else if (mode == "HSV")
                    {
                        double H, S, V;
                        ModelSettingsChooser.ColorToHSV(color, out H, out S, out V);
                        rName = "Hue";
                        gName = "Saturation";
                        bName = "Value";
                        ++R[(int)(H / 360 * 255)];
                        ++G[(int)(S * 255)];
                        ++B[(int)(V * 255)];
                    }
                }
            }
            //double maxValue = 0;
            //for (int i = 0; i < 256; ++i)
            //{
            //    if (R[i] > maxValue)
            //        maxValue = R[i];
            //    if (G[i] > maxValue)
            //        maxValue = G[i];
            //    if (B[i] > maxValue)
            //        maxValue = B[i];
            //}
        }