переделать код, чтобы  значение , которое не входит в порог.  Не изменялось. А то, что входит в порог изменялось. 
			private void brightness1Image() {
				if (image != null) {
				int minThreshold = 50;
				int maxThreshold = 50;

				// Create panels for min and max threshold values
				JPanel minThresholdPanel = new JPanel(new GridLayout(1, 2));
				JPanel maxThresholdPanel = new JPanel(new GridLayout(1, 2));

				// Create text fields for threshold values
				JTextField minThresholdField = new JTextField(Integer.toString(minThreshold));
				JTextField maxThresholdField = new JTextField(Integer.toString(maxThreshold));
				minThresholdPanel.add(new JLabel("Min threshold: "));
				maxThresholdPanel.add(new JLabel("Max threshold: "));
				minThresholdPanel.add(minThresholdField);
				maxThresholdPanel.add(maxThresholdField);

				// Create window for inputting threshold values
				int result = JOptionPane.showConfirmDialog(null, new Object[]{minThresholdPanel, maxThresholdPanel},
				"Enter Threshold Values", JOptionPane.OK_CANCEL_OPTION);

				if (result == JOptionPane.OK_OPTION) {
				// Update threshold values
				minThreshold = Integer.parseInt(minThresholdField.getText());
				maxThreshold = Integer.parseInt(maxThresholdField.getText());

				// Create new image for modified image
				BufferedImage modifiedImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB);

				// Create color for black pixels
				Color black = Color.BLACK;

				for (int i = 0; i < image.getWidth(); i++) {
				for (int j = 0; j < image.getHeight(); j++) {
				// Get pixel and extract RGB values
				int pixel = image.getRGB(i, j);
				int red = (pixel >> 16) & 0xff;
				int green = (pixel >> 8) & 0xff;
				int blue = pixel & 0xff;

				// Calculate brightness of pixel
				int brightness = (int) (0.2126 * red + 0.7152 * green + 0.0722 * blue);

				// Check if brightness value falls within threshold range
				if (brightness >= minThreshold && brightness <= maxThreshold) {
				Color c = new Color(red, green, blue);
				modifiedImage.setRGB(i, j, c.getRGB());
				} else {
				modifiedImage.setRGB(i, j, black.getRGB());
				}
				}
				}

				if (modifiedImage != null) {
				setImageIcon(modifiedImage);
				saveImage(modifiedImage);

				// Create histogram for original image
				int[] originalHistogram = new int[256];
				for (int i = 0; i < image.getWidth(); i++) {
				for (int j = 0; j < image.getHeight(); j++) {
				// Get pixel and extract RGB values
				int pixel = image.getRGB(i, j);
				int red = (pixel >> 16) & 0xff;
				int green = (pixel >> 8) & 0xff;
				int blue = pixel & 0xff;

				// Calculate brightness of pixel
				int brightness = (int) (0.2126 * red + 0.7152 * green + 0.0722 * blue);

				originalHistogram[brightness]++;
				}
				}

				// Create histogram for modified image
				int[] modifiedHistogram = new int[256];
				for (int i = 0; i < modifiedImage.getWidth(); i++) {
				for (int j = 0; j < modifiedImage.getHeight(); j++) {
				// Get pixel and extract RGB values
				int pixel = modifiedImage.getRGB(i, j);
				int red = (pixel >> 16) & 0xff;
				int green = (pixel >> 8) & 0xff;
				int blue = pixel & 0xff;

				// Calculate brightness of pixel
				int brightness = (int) (0.2126 * red + 0.7152 * green + 0.0722 * blue);

				modifiedHistogram[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 originalHistogramPanel = new JPanel() {
				@Override
				protected void paintComponent(Graphics g) {
				super.paintComponent(g);
				int max = Arrays.stream(originalHistogram).max().getAsInt();
				for (int i = 0; i < 256; i++) {
				int height = (int) (300.0 * originalHistogram[i] / max);
				g.fillRect(i, 300 - height, 1, height);
				}
				}
				};
				originalHistogramPanel.setBorder(BorderFactory.createLineBorder(Color.GRAY));
				originalHistogramPanel.setPreferredSize(new Dimension(256, 300));
				histogramFrame.add(new JLabel("Original Image"));
				histogramFrame.add(originalHistogramPanel);

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

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