예제 #1
0
        static public Image LinFilter(ObjectAPI pic, int a, double[,] filterMatrix, ref Stopwatch st)
        {
            ObjectAPI pic2 = new ObjectAPI();

            pic2 = pic.Clone() as ObjectAPI;
            for (int i = 0; i < pic.Height; i++)
            {
                for (int j = 0; j < pic.Width; j++)
                {
                    int[,] R            = FilterArray(CreateMatrix(pic, a, i, j, 'R'), a);
                    int[,] G            = FilterArray(CreateMatrix(pic, a, i, j, 'G'), a);
                    int[,] B            = FilterArray(CreateMatrix(pic, a, i, j, 'B'), a);
                    pic2.matrix[j, i].R = GetReadyLinFilter(R, filterMatrix, a);
                    pic2.matrix[j, i].G = GetReadyLinFilter(G, filterMatrix, a);
                    pic2.matrix[j, i].B = GetReadyLinFilter(B, filterMatrix, a);
                }
            }

            st.Stop();
            return(pic2.ShowRGB());
        }
예제 #2
0
        static public Image MedianaFilter(ObjectAPI pic, int a, ref Stopwatch st)
        {
            ObjectAPI pic2 = new ObjectAPI();

            pic2 = pic.Clone() as ObjectAPI;
            for (int i = 0; i < pic.Height; i++)
            {
                for (int j = 0; j < pic.Width; j++)
                {
                    byte[] R = FilterMedianaArray(CreateMatrix(pic, a, i, j, 'R'), a);
                    byte[] G = FilterMedianaArray(CreateMatrix(pic, a, i, j, 'G'), a);
                    byte[] B = FilterMedianaArray(CreateMatrix(pic, a, i, j, 'B'), a);
                    pic2.matrix[j, i].R = Math_Methods.QuickSelect_median(R);
                    pic2.matrix[j, i].G = Math_Methods.QuickSelect_median(G);
                    pic2.matrix[j, i].B = Math_Methods.QuickSelect_median(B);
                }
            }

            st.Stop();
            return(pic2.ShowRGB());
        }
예제 #3
0
        private void MainChart_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button.HasFlag(MouseButtons.Right))
            {
                double    X  = Convert.ToDouble(Lx.Text);
                double    Y  = Convert.ToDouble(Ly.Text);
                DataPoint dp = new DataPoint(X, Y);

                dp.MarkerStyle = MarkerStyle.Square;
                dp.MarkerColor = Color.Red;

                var mass = MainChart.Series[str].Points.ToArray();
                for (int i = 0; i < mass.Count(); i++)
                {
                    if ((int)X == (int)mass[i].XValue)
                    {
                        return;
                    }
                }
                MainChart.Series[str].Points.Add(dp);
                MainChart.Series[str].Sort(PointSortOrder.Ascending);
                ObjectAPI pic2 = pic.Clone() as ObjectAPI;
                //pic2.ChangeGist(MainChart,str);
                Gist.Series[str2].Points.Clear();

                if (flag == false)
                {
                    Parallel.Invoke(() => Gist = Curve.loadGist(Gist, pic2, str2), () => pic2.ChangeGist(MainChart, str), () => MainPic.Image = pic2.ShowRGB());
                }
                //MainPic.Image = pic2.ShowRGB();
                else
                {
                    Parallel.Invoke(() => Gist = Curve.loadGist(Gist, pic2, str2), () => pic2.ChangeGist(MainChart, str), () => MainPic.Image = pic2.Show());
                }
                //MainPic.Image = pic2.Show();
                //Gist = Curve.loadGist(Gist, pic2, str2);
                MainPic.Refresh();
            }
        }
예제 #4
0
        private void MainChart_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button.HasFlag(MouseButtons.Left))
            {
                ChartArea     ca = MainChart.ChartAreas[0];
                Axis          ax = ca.AxisX;
                Axis          ay = ca.AxisY;
                int           X = e.X, Y = e.Y;
                HitTestResult hit = MainChart.HitTest(e.X, e.Y);
                if (hit.PointIndex > 0)
                {
                    curPoint = hit.Series.Points[hit.PointIndex];
                }

                //if (curPoint != null)
                //{
                //    if (curPoint.XValue == 255 && curPoint.YValues[0] == 255) curPoint = null;
                //    if (curPoint.XValue == 0 && curPoint.YValues[0] == 0) curPoint = null;
                //    if (MainChart.Series[0].Points[MainChart.Series[0].Points.Count() - 1] == curPoint) curPoint = null;
                //    if (MainChart.Series[0].Points[0] == curPoint) curPoint = null;

                //}
                if (curPoint != null)
                {
                    Series s  = hit.Series;
                    double dx = ax.PixelPositionToValue(e.X);
                    double dy = ay.PixelPositionToValue(e.Y);

                    curPoint.XValue     = dx;
                    curPoint.YValues[0] = dy;
                }


                ObjectAPI pic2 = pic.Clone() as ObjectAPI;
                //pic2.ChangeGist(MainChart,str);
                Gist.Series[str2].Points.Clear();

                if (flag == false)
                {
                    Parallel.Invoke(() => Gist = Curve.loadGist(Gist, pic2, str2), () => pic2.ChangeGist(MainChart, str), () => MainPic.Image = pic2.ShowRGB());
                }
                //MainPic.Image = pic2.ShowRGB();
                else
                {
                    Parallel.Invoke(() => Gist = Curve.loadGist(Gist, pic2, str2), () => pic2.ChangeGist(MainChart, str), () => MainPic.Image = pic2.Show());
                }
                //MainPic.Image = pic2.Show();
                MainPic.Refresh();
                Gist = Curve.loadGist(Gist, pic2, str2);
            }
        }