Fix the code. 	}
			private void brightnessImage() {
				if (image != null) {
				int minBrightness = 50;
				int maxBrightness = 50;

				// Create panels for min and max brightness thresholds
				JPanel minBrightnessPanel = new JPanel(new GridLayout(1, 2));
				JPanel maxBrightnessPanel = new JPanel(new GridLayout(1, 2));

				// Create text fields for threshold values
				JTextField minBrightnessField = new JTextField(Integer.toString(minBrightness));
				JTextField maxBrightnessField = new JTextField(Integer.toString(maxBrightness));
				minBrightnessPanel.add(new JLabel("Min threshold: "));
				maxBrightnessPanel.add(new JLabel("Max threshold: "));
				minBrightnessPanel.add(minBrightnessField);
				maxBrightnessPanel.add(maxBrightnessField);

				// Create window for inputting thresholds
				int result = JOptionPane.showConfirmDialog(null, new Object[] { minBrightnessPanel, maxBrightnessPanel },
				"Enter Threshold Values", JOptionPane.OK_CANCEL_OPTION);

				if (result == JOptionPane.OK_OPTION) {
				// Update threshold values
				minBrightness = Integer.parseInt(minBrightnessField.getText());
				maxBrightness = Integer.parseInt(maxBrightnessField.getText());

				BufferedImage binarizedImage = binarizeImage(image, minBrightness, maxBrightness);
				if (binarizedImage != null) {
				setImageIcon(binarizedImage);
				saveImage(binarizedImage);

				// Create histogram for original image
				int[] histogram = new int[256];
				for (int i = 0; i < image.getWidth(); i++) {
				for (int j = 0; j < image.getHeight(); j++) {
				int pixel = image.getRGB(i, j);
				int red = (pixel >> 16) & 0xff;
				int green = (pixel >> 8) & 0xff;
				int blue = pixel & 0xff;
				int brightness = (int) (0.2126 * red + 0.7152 * green + 0.0722 * blue);
				histogram[brightness]++;
				}
				}

				// Create histogram for binarized image
				int[] binarizedHistogram = new int[256];
				for (int i = 0; i < binarizedImage.getWidth(); i++) {
				for (int j = 0; j < binarizedImage.getHeight(); j++) {
				int pixel = binarizedImage.getRGB(i, j);
				int red = (pixel >> 16) & 0xff;
				int green = (pixel >> 8) & 0xff;
				int blue = pixel & 0xff;
				int brightness = (int) (0.2126 * red + 0.7152 * green + 0.0722 * blue);
				binarizedHistogram[brightness]++;
				}
				}

				// Create window for displaying histograms
				JFrame histogramFrame = new JFrame("Histograms");
				histogramFrame.setLayout(new GridLayout(2, 2, 10, 10));

				// Panel for original image histogram
				JPanel histogramPanel = new JPanel() {
				@Override
				protected void paintComponent(Graphics g) {
				super.paintComponent(g);
				int max = Arrays.stream(histogram).max().getAsInt();
				for (int i = 0; i < 256; i++) {
				int height = (int) (300.0 * histogram[i] / max);
				g.fillRect(i, 300 - height, 1, height);
				}
				}
				};
				histogramPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
				histogramPanel.setPreferredSize(new Dimension(256, 300));
				histogramFrame.add(new JLabel("Original Image"));
				histogramFrame.add(histogramPanel);

				// Panel for binarized image histogram
				JPanel binarizedHistogramPanel = new JPanel() {
				@Override
				protected void paintComponent(Graphics g) {
				super.paintComponent(g);
				int max = Arrays.stream(binarizedHistogram).max().getAsInt();
				for (int i = 0; i < 256; i++) {
				int height = (int) (300.0 * binarizedHistogram[i] / max);
				g.fillRect(i, 300 - height, 1, height);
				}
				}
				};
				binarizedHistogramPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
				binarizedHistogramPanel.setPreferredSize(new Dimension(256, 300));
				histogramFrame.add(new JLabel("Binarized Image"));
				histogramFrame.add(binarizedHistogramPanel);

				histogramFrame.pack();
				histogramFrame.setLocationRelativeTo(null);
				histogramFrame.setVisible(true);
				}
				}
				}
				}

		 private BufferedImage brightnessSlice(BufferedImage image, int minBrightness, int maxBrightness) {
			 BufferedImage brightnessSliceImage = new BufferedImage(image.getWidth(), image.getHeight(),
			 BufferedImage.TYPE_INT_RGB);
			 for (int i = 0; i < image.getWidth(); i++) {
			 for (int j = 0; j < image.getHeight(); j++) {
			 int rgb = image.getRGB(i, j);
			 int r = (rgb & 0x00ff0000) >> 16;
			 int g = (rgb & 0x0000ff00) >> 8;
			 int b = rgb & 0x000000ff;
			 int brightness = (int) (0.2126 * r + 0.7152 * g + 0.0722 * b); // расчет яркости пикселя
			 if (brightness >= minBrightness && brightness <= maxBrightness) {
			 brightnessSliceImage.setRGB(i, j, Color.WHITE.getRGB());
			 } else {
			 brightnessSliceImage.setRGB(i, j, Color.BLACK.getRGB());
			 }
			 }
			 }
			 return brightnessSliceImage;
			 }