private double plotGaussianX() { double[] GuessParameterArray = new double[4]; GaussianFit fit = new GaussianFit(); int m = 0; int xrange; SetDefault(out xrange); double[] arrayX = new double[xrange + 1]; double[] arrayB = new double[xrange + 1]; double brightness = 0; int xstart = HelperClass.brightest_x - xrange / 2; int xend = HelperClass.brightest_x + xrange / 2; Bitmap mybitmap = new Bitmap(ImagePanel.Image); //Feeding in array X and array Y data points (Y: brightness) for (int i = xstart; i <= xend; i++) { Color pixel = mybitmap.GetPixel(i, HelperClass.brightest_y); brightness = (double)pixel.B * 0.33 + pixel.G * 0.33 + pixel.R * (1 - 0.33 * 2); arrayX[m] = i; arrayB[m] = brightness; m++; } double[] arrayparameters = new double[4]; GuessParameterArray = fit.SuggestParameters(arrayX, arrayB); arrayparameters[0] = GuessParameterArray[0]; arrayparameters[1] = GuessParameterArray[1]; arrayparameters[2] = GuessParameterArray[2]; arrayparameters[3] = GuessParameterArray[3]; fit.Fit(arrayX, arrayB, arrayparameters); double[] fittedY = fit.FittedValues; //Y HERE REFERS TO BRIGHTNESS for (int j = 0; j < m; j++) { PlotXYAppend(this.chart1, this.chart1.Series[0], arrayX[j], fittedY[j]); PlotXYAppend(this.chart1, this.chart1.Series[1], arrayX[j], arrayB[j]); } return(fit.FittedParameters[3]); }
private double plotGaussianY() { double[] GuessParameterArray = new double[4]; GaussianFit fit = new GaussianFit(); int m = 0; int yrange; SetDefault(out yrange); double[] arrayY = new double[yrange + 1]; double[] arrayB = new double[yrange + 1]; double brightness = 0; int ystart = HelperClass.brightest_y - yrange / 2; int yend = HelperClass.brightest_y + yrange / 2; Bitmap mybitmap = new Bitmap(ImagePanel.Image); //Feeding in array X and array Y data points (Y: brightness) for (int i = ystart; i <= yend; i++) { Color pixel = mybitmap.GetPixel(HelperClass.brightest_x, i); brightness = (double)pixel.B * 0.33 + pixel.G * 0.33 + pixel.R * (1 - 0.33 * 2); arrayY[m] = i; arrayB[m] = brightness; m++; } double[] arrayparameters = new double[4]; GuessParameterArray = fit.SuggestParameters(arrayY, arrayB); arrayparameters[0] = GuessParameterArray[0]; arrayparameters[1] = GuessParameterArray[1]; arrayparameters[2] = GuessParameterArray[2]; arrayparameters[3] = GuessParameterArray[3]; fit.Fit(arrayY, arrayB, arrayparameters); double[] fittedB = fit.FittedValues; for (int j = 0; j < m; j++) { PlotXYAppend(this.chart2, this.chart2.Series[0], arrayY[j], fittedB[j]); PlotXYAppend(this.chart2, this.chart2.Series[1], arrayY[j], arrayB[j]); } return(fit.FittedParameters[3]); }
private double plotGaussianY() { double[] GuessParameterArray = new double[4]; GaussianFit fit = new GaussianFit(); int m = 0; int yrange; SetDefault(out yrange); double[] arrayY = new double[yrange + 1]; double[] arrayB = new double[yrange + 1]; double brightness = 0; int ystart = HelperClass.brightest_y - yrange / 2; int yend = HelperClass.brightest_y + yrange / 2; Bitmap mybitmap = new Bitmap(ImagePanel.Image); //Feeding in array X and array Y data points (Y: brightness) for (int i = ystart; i <= yend; i++) { Color pixel = mybitmap.GetPixel(HelperClass.brightest_x, i); brightness = (double)pixel.B * 0.33 + pixel.G * 0.33 + pixel.R * (1 - 0.33 * 2); arrayY[m] = i; arrayB[m] = brightness; m++; } double[] arrayparameters = new double[4]; GuessParameterArray = fit.SuggestParameters(arrayY, arrayB); arrayparameters[0] = GuessParameterArray[0]; arrayparameters[1] = GuessParameterArray[1]; arrayparameters[2] = GuessParameterArray[2]; arrayparameters[3] = GuessParameterArray[3]; fit.Fit(arrayY, arrayB, arrayparameters); double[] fittedB = fit.FittedValues; for (int j = 0; j < m; j++) { PlotXYAppend(this.chart2, this.chart2.Series[0], arrayY[j], fittedB[j]); PlotXYAppend(this.chart2, this.chart2.Series[1], arrayY[j], arrayB[j]); } return fit.FittedParameters[3]; }
private double plotGaussianX() { double[] GuessParameterArray = new double[4]; GaussianFit fit = new GaussianFit(); int m = 0; int xrange; SetDefault(out xrange); double[] arrayX = new double[xrange + 1]; double[] arrayB = new double[xrange + 1]; double brightness = 0; int xstart = HelperClass.brightest_x - xrange / 2; int xend = HelperClass.brightest_x + xrange / 2; Bitmap mybitmap = new Bitmap(ImagePanel.Image); //Feeding in array X and array Y data points (Y: brightness) for (int i = xstart; i <= xend; i++) { Color pixel = mybitmap.GetPixel(i, HelperClass.brightest_y); brightness = (double)pixel.B * 0.33 + pixel.G * 0.33 + pixel.R * (1 - 0.33 * 2); arrayX[m] = i; arrayB[m] = brightness; m++; } double[] arrayparameters = new double[4]; GuessParameterArray = fit.SuggestParameters(arrayX, arrayB); arrayparameters[0] = GuessParameterArray[0]; arrayparameters[1] = GuessParameterArray[1]; arrayparameters[2] = GuessParameterArray[2]; arrayparameters[3] = GuessParameterArray[3]; fit.Fit(arrayX, arrayB, arrayparameters); double[] fittedY = fit.FittedValues; //Y HERE REFERS TO BRIGHTNESS for (int j = 0; j < m; j++) { PlotXYAppend(this.chart1, this.chart1.Series[0], arrayX[j], fittedY[j]); PlotXYAppend(this.chart1, this.chart1.Series[1], arrayX[j], arrayB[j]); } return fit.FittedParameters[3]; }