static public Image Vylf(ObjectAPI picture, double k, int a, ref Stopwatch st2) { ObjectAPI pic = picture.Clone() as ObjectAPI; ObjectAPI pic2 = picture.Clone() as ObjectAPI; double R = 0; for (int i = 0; i < pic.Height; i++) { for (int j = 0; j < pic.Width; j++) { var r = ConvertMatrixVylf2(pic, a, i, j); if (R < r) { R = r; } } } for (int i = 0; i < pic.Height; i++) { for (int j = 0; j < pic.Width; j++) { var t = ConvertMatrixVylf(pic, a, i, j, k, pic.MinPix, R); if (pic.Rmatrix[j, i] <= t) { pic2.Rmatrix[j, i] = 0; } if (pic.Rmatrix[j, i] > t) { pic2.Rmatrix[j, i] = 255; } } } st2.Stop(); return(pic2.Show()); }
static public Image Niblek(ObjectAPI picture, double k, int a, ref Stopwatch st2) { ObjectAPI pic = new ObjectAPI(); pic = picture.Clone() as ObjectAPI; ObjectAPI pic2 = new ObjectAPI(); pic2 = picture.Clone() as ObjectAPI; for (int i = 0; i < pic.Height; i++) { for (int j = 0; j < pic.Width; j++) { var t = ConvertMatrixNiblek(pic, a, i, j, k); if (pic.Rmatrix[j, i] <= t) { pic2.Rmatrix[j, i] = 0; } if (pic.Rmatrix[j, i] > t) { pic2.Rmatrix[j, i] = 255; } } } st2.Stop(); return(pic2.Show()); }
static public Image Otcu(ObjectAPI picture, ref Stopwatch st2) { ObjectAPI pic = new ObjectAPI(); pic = picture.Clone() as ObjectAPI; var w = pic.Width; var h = pic.Height; double[] I = new double[256]; for (int i = 0; i < pic.Height; i++) { for (int j = 0; j < pic.Width; j++) { ++I[pic.Rmatrix[j, i]]; } } for (int i = 0; i < I.Count(); i++) { I[i] = I[i] / (w * h); } double deltaDef = 0; int tDef = 0; for (int t = 0; t < pic.MaxPix; t++) { CalcOtcu(I, t, pic.MaxPix, ref deltaDef, ref tDef); } //throw new Exception(); for (int i = 0; i < pic.Height; i++) { for (int j = 0; j < pic.Width; j++) { if (pic.Rmatrix[j, i] <= tDef) { pic.Rmatrix[j, i] = 0; } if (pic.Rmatrix[j, i] > tDef) { pic.Rmatrix[j, i] = 255; } } } st2.Stop(); return(pic.Show()); }
static public Image Bredly(ObjectAPI picture, double k, int a, ref Stopwatch st2) { ObjectAPI pic = picture.Clone() as ObjectAPI; ObjectAPI pic2 = picture.Clone() as ObjectAPI; for (int i = 0; i < pic.Height; i++) { for (int j = 0; j < pic.Width; j++) { var t = ConvertMatrixBredly(pic, a, i, j); if (pic.Rmatrix[j, i] * t[1] < t[0] * (1 - k)) { pic2.Rmatrix[j, i] = 0; } if (pic.Rmatrix[j, i] * t[1] >= t[0] * (1 - k)) { pic2.Rmatrix[j, i] = 255; } } } st2.Stop(); return(pic2.Show()); }
static public Image Gavr(ObjectAPI picture, ref Stopwatch st2) { ObjectAPI pic = new ObjectAPI(); pic = picture.Clone() as ObjectAPI; double sum = 0; var w = pic.Width; var h = pic.Height; for (int i = 0; i < pic.Height; i++) { for (int j = 0; j < pic.Width; j++) { sum += pic.Rmatrix[j, i]; } } var t = sum / (w * h); for (int i = 0; i < pic.Height; i++) { for (int j = 0; j < pic.Width; j++) { if (pic.Rmatrix[j, i] <= t) { pic.Rmatrix[j, i] = 0; } if (pic.Rmatrix[j, i] > t) { pic.Rmatrix[j, i] = 255; } } } st2.Stop(); return(pic.Show()); }
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(); } }
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); } }