Исправь код. private void gaussImage() { if (image != null) { for (int i = 1; i <= 3;…
- User
Исправь код. private void gaussImage() { if (image != null) { for (int i = 1; i <= 3; i++) { try { String inputMask = JOptionPane.showInputDialog(this, “Enter a mask size (odd number):”); int maskSize = Integer.parseInt(inputMask); if (maskSize >= 1 && maskSize <= 60 && maskSize % 2 != 0) { float[][] mask = gaussianMask(maskSize, maskSize / 2); BufferedImage gaussImage = applyMask(image, mask); setImageIcon(gaussImage); saveImage(gaussImage); createTransformedHistogram(gaussImage); // добавляем создание гистограммы break; } else { throw new NumberFormatException(); } } catch (NumberFormatException e) { if (i == 3) { JOptionPane.showMessageDialog(this, “Invalid input. Please enter an odd number between 1 and 60.”); break; } else { continue; } }
- Assistant
private void gaussImage() { if (image != null) { for (int i = 1; i <= 3; i++) { try { String inputMask = JOptionPane.showInputDialog(this, "Enter a mask size (odd number):"); int maskSize = Integer.parseInt(inputMask); if (maskSize >= 1 && maskSize <= 60 && maskSize % 2 != 0) { float[][] mask = gaussianMask(maskSize, maskSize / 2); BufferedImage gaussImage = applyMask(image, mask); setImageIcon(gaussImage); saveImage(gaussImage); createTransformedHistogram(gaussImage); // добавляем создание гистограммы break; } else { throw new NumberFormatException(); } } catch (NumberFormatException e) { if (i == 3) { JOptionPane.showMessageDialog(this, "Invalid input. Please enter an odd number between 1 and 60."); break; } } } } }
- User
сделай исключение при выходе за диапазон от 1 до 60. private void cannyImage() { if (image != null) { String inputMask = JOptionPane.showInputDialog(this, "Enter a mask size (odd number):"); int maskSize = Integer.parseInt(inputMask); BufferedImage cannyImage = cannyDetector(image, maskSize); setImageIcon(cannyImage); saveImage(cannyImage); createTransformedHistogram(cannyImage); // добавляем создание гистограммы } }
- Assistant
private void cannyImage() { if (image != null) { try { String inputMask = JOptionPane.showInputDialog(this, "Enter a mask size (odd number between 1 and 60):"); int maskSize = Integer.parseInt(inputMask); if (maskSize >= 1 && maskSize <=60 && maskSize % 2 != 0) { BufferedImage cannyImage = cannyDetector(image, maskSize); setImageIcon(cannyImage); saveImage(cannyImage); createTransformedHistogram(cannyImage); // добавляем создание гистограммы } else { throw new NumberFormatException(); } } catch (NumberFormatException e) { JOptionPane.showMessageDialog(this, "Invalid input. Please enter an odd number between 1 and 60."); } } }