private void button8_Click(object sender, EventArgs e) //степень { if (!CheckSourceImage()) { return; } var str = textBoxPower.Text.Split(' '); if (str.Length != 2) { MessageBox.Show("Для степени введены неверные значения"); return; } double power; double coef; try { power = double.Parse(str[0]); coef = double.Parse(str[1]); } catch { MessageBox.Show("Неверный ввод"); return; } editImage = checkBoxAnti.Checked ? LuminanceConversions.GetAntiPower(editImage, power, coef) : LuminanceConversions.GetPowerImage(editImage, power, coef); pictureBoxImage.Image = editImage; editImage.Save(@"Power.jpg"); if (editImage != null) { label5TypeImage.Text = "Степень"; } }
private void button11_Click(object sender, EventArgs e) // полутоновое изображение { if (!CheckSourceImage()) { return; } grayImage = new Bitmap(sourceImage.Width, sourceImage.Height); grayImage = LuminanceConversions.GetGrayScaleImage(editImage); pictureBoxImage.Image = grayImage; label5TypeImage.Text = "Полутоновое изображение"; }
private void button6_Click(object sender, EventArgs e) // негатив { if (!CheckSourceImage()) { return; } editImage = LuminanceConversions.GetNegative(editImage); pictureBoxImage.Image = editImage; editImage.Save(@"Negative.jpg"); if (editImage != null) { label5TypeImage.Text = "Негатив"; } }
private void button5_Click(object sender, EventArgs e) //серый мир { if (!CheckSourceImage()) { return; } editImage = LuminanceConversions.GetGrayWorld(editImage); pictureBoxImage.Image = editImage; editImage.Save(@"GrayWorld.jpg"); if (editImage != null) { label5TypeImage.Text = "Серый мир"; } }
private void button3_Click(object sender, EventArgs e) //коррекция с опорным цветом //286 124 54 59 { if (!CheckSourceImage()) { return; } Bitmap palitre = new Bitmap(pictureBoxColorPalitre.Image); Color destinationColor, sourceColor; int coordinateX = 0, coordinateY = 0; if (labelRGBcolorPalitre.Text != "-" && labelCoordinatesPixel.Text != "-") { var strSrc = labelCoordinatesPixel.Text.Split(' '); var strDst = labelRGBcolorPalitre.Text.Split(' '); sourceColor = editImage.GetPixel(int.Parse(strSrc[0]), int.Parse(strSrc[1])); destinationColor = palitre.GetPixel(int.Parse(strDst[0]), int.Parse(strDst[1])); } else { try { destinationColor = StringColor[textBoxSupportingColor.Text.ToLower()]; } catch { MessageBox.Show("Реализованы не все цвета :)"); return; } var str = textBoxCoordinatesPixel.Text.Split(' ', ','); if (str.Length != 2) { MessageBox.Show("Неверно введены координаты"); return; } coordinateX = int.Parse(str[0]); coordinateY = int.Parse(str[1]); sourceColor = editImage.GetPixel(coordinateX, coordinateY); } if (coordinateX >= sourceImage.Width || coordinateY >= sourceImage.Height) { MessageBox.Show("Вне границ изображения"); return; } editImage = LuminanceConversions.GetCorrectionImageBasedColor(editImage, destinationColor, sourceColor); pictureBoxImage.Image = editImage; editImage.Save(@"CorrectionBasedOnColor.jpg"); label5TypeImage.Text = "Коррекция с опорным цветом"; }
private void button10_Click(object sender, EventArgs e) //эквализация гистограммы { if (!CheckSourceImage() || grayImage == null) { return; } editImage = LuminanceConversions.GetEqualizationImage(grayImage); double[] array = new double[256]; for (int y = 0; y < editImage.Height; y++) { for (int x = 0; x < editImage.Width; x++) { array[editImage.GetPixel(x, y).R]++; } } pictureBoxImage.Image = editImage; pictureBoxHystogram.Image = GetHystogram(array); label5TypeImage.Text = "Эквализированное изображение"; editImage.Save("Equalization.jpg"); }
private void button7_Click(object sender, EventArgs e) // логарифм { if (!CheckSourceImage()) { return; } var str = textBoxBaseLog.Text.Split(' ', ','); if (str.Length != 2) { MessageBox.Show("Для логарифма неверно введены основание и коэффициент"); return; } int coef = 41; int baseLog; try { baseLog = int.Parse(str[0]); coef = int.Parse(str[1]); } catch { MessageBox.Show("Неверный ввод"); return; } if (checkBoxAnti.Checked) { editImage = LuminanceConversions.GetAntiLogarithm(editImage, baseLog, coef); } else { editImage = LuminanceConversions.GetLogarithmImage(editImage, baseLog, coef); } pictureBoxImage.Image = editImage; editImage.Save(@"Logarithm.jpg"); if (editImage != null) { label5TypeImage.Text = "Логарифм"; } }