gpt-3.5-turbo-0301· OpenAI
WildChat-4.8M (AI2)
Используя этот код. private static void nine(Mat image, int t1, int t2) { for (int i =…
- User
Используя этот код. private static void nine(Mat image, int t1, int t2) { for (int i = 0; i < image.rows(); i++) for (int j = 0; j < image.cols(); j++) { double[] data = image.get(i, j);
codefor (int p = 0; p < image.channels(); p++) { int cell = (int) (255 * (data[p] - (double) t1) / ((double) t2 - (double) t1)); if ((double) t2 >= data[p] && data[p] >= (double) t1) data[p] = cell; else data[p] = data[p]; } image.put(i, j, data); } Переделай другой код. // Гистограмма для sawtooth4Image() private void zigzagContrastImage() { if (image != null) { // Запрос значений порогов у пользователя int t1 = (int) userInput("Введите значение порога 1: ", 0, 255); int t2 = (int) userInput("Введите значение порога 2: ", 0, 255); // Проверка правильности введенных значений порогов if (t2 <= t1) { JOptionPane.showMessageDialog(null, “Значение порога 2 должно быть больше порога 1”); return; } int teeth = (int) userInput("Введите количество зубьев: ", 2, 10); // Запрос значения количества зубьев List<BufferedImage> zigzagContrastImages = new ArrayList<>(); for (int i = 0; i < teeth; i++) { BufferedImage zigzagContrastImage = zigzagContrast(image, t1, t2, teeth, i); zigzagContrastImages.add(zigzagContrastImage); } histogramFrame.pack(); histogramFrame.setLocationRelativeTo(null); histogramFrame.setVisible(true); } } private BufferedImage zigzagContrast(BufferedImage image, int t1, int t2, int teeth, int index) { int width = image.getWidth(); int height = image.getHeight(); BufferedImage resultImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); int step = 255 / teeth; // Calculate step size based on the number of teeth for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { Color c = new Color(image.getRGB(x, y)); int grey = (int) (0.299 * c.getRed() + 0.587 * c.getGreen() + 0.114 * c.getBlue()); int cell = (int) (255 * (grey - t1) / (t2 - t1)); if (t2 >= grey && grey >= t1) { cell = (int) (((double) cell) / step); if (cell <= index) { resultImage.setRGB(x, y, Color.BLACK.getRGB()); } else { resultImage.setRGB(x, y, Color.WHITE.getRGB()); } } else if (grey < t1) { resultImage.setRGB(x, y, Color.BLACK.getRGB()); } else { resultImage.setRGB(x, y, Color.WHITE.getRGB()); } } } return resultImage; } - Assistant
private static void nine(Mat image, int t1, int t2) { for (int i = 0; i < image.rows(); i++) { for (int j = 0; j < image.cols(); j++) { double[] pixel = image.get(i, j);
codefor (int k = 0; k < pixel.length; k++) { double pixelValue = (pixel[k] - t1) * 255.0 / (t2 - t1); pixel[k] = (pixelValue > 0 && pixelValue < 255) ? pixelValue : pixel[k]; } image.put(i, j, pixel); } }}
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.