private void executeButton_Click(object sender, EventArgs e) { if (bitmap == null) { return; } executeButton.Enabled = false; bitmapRes = null; byte treshold; bool isSuccess = byte.TryParse(textBox_threshold.Text, out treshold); if (isSuccess == false) { MessageBox.Show("Порог - число от 0 до 255"); return; } int medianKernelSize = 3; isSuccess = int.TryParse(textBox_median.Text, out medianKernelSize); if (isSuccess == false || medianKernelSize % 2 == 0 || medianKernelSize == 1) { MessageBox.Show("Размер ядра медианного фильтра - нечётное число большее либо равное 3."); return; } int clustNum = 0; isSuccess = int.TryParse(textBox_clustNumber.Text, out clustNum); if (isSuccess == false || clustNum <= 0) { MessageBox.Show("Количество кластеров должно быть больше нуля."); return; } bitmapRes = bitmap; if (checkBox_medianFilter.Checked) { bitmapRes = ImageProcessing.MedianFilter_unsafe(bitmapRes, medianKernelSize); } bitmapRes = ImageProcessing.GrayscaleAndBinarization_unsafe(bitmapRes, treshold); //pictureBox_intermediate.Image = bitmapRes; СlusterАnalysis clustInfo = new СlusterАnalysis(bitmapRes, clustNum); bitmapRes = clustInfo.GetClusteredBitmap(); //label_objectCount.Text = "Количество значимых объектов: " + clustInfo.GetGoodObjectsCount(); pictureBox_result.Image = bitmapRes; //pixelFormat_label2.Text = bitmapRes.PixelFormat.ToString(); executeButton.Enabled = true; }
private void executeButton_Click(object sender, EventArgs e) { if (bitmap == null) return; executeButton.Enabled = false; bitmapRes = null; byte treshold; bool isSuccess = byte.TryParse(textBox_threshold.Text, out treshold); if (isSuccess == false) { MessageBox.Show("Порог - число от 0 до 255"); return; } int medianKernelSize = 3; isSuccess = int.TryParse(textBox_median.Text, out medianKernelSize); if (isSuccess == false || medianKernelSize%2 == 0 || medianKernelSize == 1) { MessageBox.Show("Размер ядра медианного фильтра - нечётное число большее либо равное 3."); return; } int clustNum = 0; isSuccess = int.TryParse(textBox_clustNumber.Text, out clustNum); if (isSuccess == false || clustNum <= 0) { MessageBox.Show("Количество кластеров должно быть больше нуля."); return; } bitmapRes = bitmap; if(checkBox_medianFilter.Checked) bitmapRes = ImageProcessing.MedianFilter_unsafe(bitmapRes, medianKernelSize); bitmapRes = ImageProcessing.GrayscaleAndBinarization_unsafe(bitmapRes, treshold); //pictureBox_intermediate.Image = bitmapRes; СlusterАnalysis clustInfo = new СlusterАnalysis(bitmapRes, clustNum); bitmapRes = clustInfo.GetClusteredBitmap(); //label_objectCount.Text = "Количество значимых объектов: " + clustInfo.GetGoodObjectsCount(); pictureBox_result.Image = bitmapRes; //pixelFormat_label2.Text = bitmapRes.PixelFormat.ToString(); executeButton.Enabled = true; }