public static double[] DoTheAnalysis(double sigma, double bottomThresholdCanny, double upperThresholdCanny, int waveletLength, double bottomThresholdHaar, double upperThresholdHaar, int widthOfBrightnessDiffer, double snr = -1) { decimal[,] origImage = MakeOriginImArr(widthOfBrightnessDiffer); decimal[,] origImageCopyForHaar = MakeOriginImArr(widthOfBrightnessDiffer); double[,] perfectEdgeImage = MakePerfectEdgeImArr(); Bitmap bmpToSaveForTest = new Bitmap(origImage.GetLength(1), origImage.GetLength(0)); for (int i = 0; i < origImage.GetLength(0); i++) { for (int j = 0; j < origImage.GetLength(1); j++) { bmpToSaveForTest.SetPixel(j, i, Color.FromArgb((int)Math.Ceiling(origImage[i, j]), (int)Math.Ceiling(origImage[i, j]), (int)Math.Ceiling(origImage[i, j]))); } } if (snr > -1) { origImage = AddGausNoise(origImage, snr);// зашумляем изображение origImageCopyForHaar = AddGausNoise(origImageCopyForHaar, snr); } CannyForm = new CannyForm(sigma, bottomThresholdCanny, upperThresholdCanny, bmp: null, imageArray: origImage); //создаем окно для вывода результатов метода Канни, передавая путь к выбранному файлу double[,] cannyResult = new double[CannyForm.cannyResult.Height, CannyForm.cannyResult.Width]; for (int i = 0; i < cannyResult.GetLength(0); i++) { for (int j = 0; j < cannyResult.GetLength(1); j++) { cannyResult[i, j] = CannyForm.cannyResult.GetPixel(j, i).R; } } HaarForm = new HaarForm(waveletLength, bottomThresholdHaar, upperThresholdHaar, bmp: null, imageArray: origImageCopyForHaar); //создаем окно для вывода результатов метода Хаара, передавая путь к выбранному файлу double[,] haarResult = new double[HaarForm.resultBmp.Height, HaarForm.resultBmp.Width]; for (int i = 0; i < haarResult.GetLength(0); i++) { for (int j = 0; j < haarResult.GetLength(1); j++) { haarResult[i, j] = HaarForm.resultBmp.GetPixel(j, i).R; } } double cannyPrettCrit = CountPrettCriteriaWithoutBorderPixels(perfectEdgeImage, cannyResult, waveletLength); double haarPrettCrit = CountPrettCriteriaWithoutBorderPixels(perfectEdgeImage, haarResult, waveletLength); double[] prettCrit = new double[2]; prettCrit[0] = cannyPrettCrit; prettCrit[1] = haarPrettCrit; return(prettCrit); }
private void useCannyMethod_button_Click(object sender, EventArgs e) { CannyForm CannyForm = new CannyForm(filePath, Convert.ToDouble(sigma_textBox.Text), Convert.ToDouble(bottomThreshold_textBox.Text), Convert.ToDouble(upperThreshold_textBox.Text)); //создаем окно для вывода результатов метода Канни, передавая путь к выбранному файлу CannyForm.Show(); }