コード例 #1
0
 private void btnGist_Click(object sender, EventArgs e)
 {
     if (_currentImage == null)
     {
         return;
     }
     new HistoryForm(_histogramGenerator.Generate(_currentImage)).Show();
 }
コード例 #2
0
        private void ShowOnHistogram(bool isInputImage)
        {
            List <int[]>    histogram = HistogramGenerator.Generate(isInputImage ? input : output);
            SolidColorBrush redColor, greenColor, blueColor;
            string          redTitle, greenTitle, blueTitle;

            if (ImageHelper.GetBitsPerPixel(isInputImage ? input.PixelFormat : output.PixelFormat) > 8)
            {
                redColor   = System.Windows.Media.Brushes.Red;
                greenColor = System.Windows.Media.Brushes.Green;
                blueColor  = System.Windows.Media.Brushes.Blue;
                redTitle   = "Red";
                greenTitle = "Green";
                blueTitle  = "Blue";
            }
            else
            {
                redColor   = System.Windows.Media.Brushes.Gray;
                greenColor = System.Windows.Media.Brushes.Gray;
                blueColor  = System.Windows.Media.Brushes.Gray;
                redTitle   = "Gray";
                greenTitle = "Gray";
                blueTitle  = "Gray";
            }

            SeriesCollection red = new SeriesCollection
            {
                new ColumnSeries
                {
                    Title         = redTitle,
                    Values        = new ChartValues <double> {
                    },
                    ColumnPadding = 0,
                    Fill          = redColor
                }
            };
            SeriesCollection green = new SeriesCollection
            {
                new ColumnSeries
                {
                    Title         = greenTitle,
                    Values        = new ChartValues <double> {
                    },
                    ColumnPadding = 0,
                    Fill          = greenColor
                }
            };
            SeriesCollection blue = new SeriesCollection
            {
                new ColumnSeries
                {
                    Title         = blueTitle,
                    Values        = new ChartValues <double> {
                    },
                    ColumnPadding = 0,
                    Fill          = blueColor
                }
            };

            for (int i = 0; i < histogram[0].Length; i++)
            {
                red[0].Values.Add((double)histogram[0][i]);
                green[0].Values.Add((double)histogram[1][i]);
                blue[0].Values.Add((double)histogram[2][i]);
            }

            if (isInputImage)
            {
                ChartsUserControl.InputRed   = red;
                ChartsUserControl.InputGreen = green;
                ChartsUserControl.InputBlue  = blue;
            }
            else
            {
                ChartsUserControl.OutputRed   = red;
                ChartsUserControl.OutputGreen = green;
                ChartsUserControl.OutputBlue  = blue;
            }
        }