Пример #1
0
        private void DrawGraph(FFTService.FFTImageDataModel data)
        {
            for (int i = 0; i < data.R.frequency.Count; ++i)
            {
                chart1.Series["SeriesR"].Points.AddXY
                    (data.R.frequency[i], data.G.magnitude[i]);
                chart1.Series["SeriesG"].Points.AddXY
                    (data.G.frequency[i], data.G.magnitude[i]);
                chart1.Series["SeriesB"].Points.AddXY
                    (data.B.frequency[i], data.B.magnitude[i]);
            }

            chart1.Series["SeriesR"].ChartType  = SeriesChartType.Line;
            chart1.Series["SeriesR"].Color      = Color.Red;
            chart1.Series["SeriesR"].LegendText = "Channel R";
            chart1.ChartAreas["R"].AxisX.Title  = "Frequency [ju]";
            chart1.ChartAreas["R"].AxisY.Title  = "Magnitude [ju]";


            chart1.Series["SeriesG"].ChartType  = SeriesChartType.Line;
            chart1.Series["SeriesG"].Color      = Color.Green;
            chart1.Series["SeriesG"].LegendText = "Channel G";
            chart1.ChartAreas["G"].AxisX.Title  = "Frequency [ju]";
            chart1.ChartAreas["G"].AxisY.Title  = "Magnitude [ju]";

            chart1.Series["SeriesB"].ChartType  = SeriesChartType.Line;
            chart1.Series["SeriesB"].Color      = Color.Blue;
            chart1.Series["SeriesB"].LegendText = "Channel B";
            chart1.ChartAreas["B"].AxisX.Title  = "Frequency [ju]";
            chart1.ChartAreas["B"].AxisY.Title  = "Magnitude [ju]";
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Stream myStream = null;

            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            JpegModel      jpegModel;
            JpegReader     jpegReader = new JpegReader();

            openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonPictures);
            openFileDialog1.Filter           = "images (*.jpg)|*.jpg";
            openFileDialog1.FilterIndex      = 2;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try {
                    if ((myStream = openFileDialog1.OpenFile()) != null)
                    {
                        using (myStream) {
                            // Insert code to read the stream here.
                            jpegModel      = jpegReader.ReadImage(myStream);
                            jpegModel.file = (myStream as FileStream).Name;
                            FFTService.FFTImageDataModel fftImageDataModel = FFTService.FFT(jpegModel);
                            SetImageDetails(jpegModel);
                            ClearGraph();
                            DrawGraph(fftImageDataModel);
                        }
                    }
                }
                catch (Exception ex) {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }