0% found this document useful (0 votes)
8 views3 pages

Out Put Code

The document contains a Java program that implements an image enhancement application using Swing for the GUI. It allows users to adjust brightness, contrast, sharpness, and color of an image through sliders, and displays the modified image in a JFrame. The program includes methods for enhancing the image properties, although the actual enhancement logic is not implemented in the provided code.

Uploaded by

akshj838
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Out Put Code

The document contains a Java program that implements an image enhancement application using Swing for the GUI. It allows users to adjust brightness, contrast, sharpness, and color of an image through sliders, and displays the modified image in a JFrame. The program includes methods for enhancing the image properties, although the actual enhancement logic is not implemented in the provided code.

Uploaded by

akshj838
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

import java.awt.

Image;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class ImageEnhancer {


private static BufferedImage img;
private static BufferedImage outputImage;
private static JLabel panel;

public static void main(String[] args) {


JFrame frame = new JFrame("Image Enhancer");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

panel = new JLabel();


frame.getContentPane().add(panel);

JSlider brightnessSlider = new JSlider(0, 100, 50);


brightnessSlider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
float brightnessPos = (float) brightnessSlider.getValue() / 50;
enhanceBrightness(brightnessPos);
}
});

JSlider contrastSlider = new JSlider(0, 100, 50);


contrastSlider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
float contrastPos = (float) contrastSlider.getValue() / 50;
enhanceContrast(contrastPos);
}
});

JSlider sharpnessSlider = new JSlider(0, 100, 50);


sharpnessSlider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
float sharpnessPos = (float) sharpnessSlider.getValue() / 50;
enhanceSharpness(sharpnessPos);
}
});

JSlider colorSlider = new JSlider(0, 100, 50);


colorSlider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
float colorPos = (float) colorSlider.getValue() / 50;
enhanceColor(colorPos);
}
});

JPanel sliderPanel = new JPanel();


sliderPanel.add(brightnessSlider);
sliderPanel.add(contrastSlider);
sliderPanel.add(sharpnessSlider);
sliderPanel.add(colorSlider);
frame.getContentPane().add(sliderPanel, BorderLayout.SOUTH);

JFileChooser fileChooser = new JFileChooser();


int result = fileChooser.showOpenDialog(frame);
if (result == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile();
try {
img = ImageIO.read(selectedFile);
displayImage(img);
} catch (Exception ex) {
ex.printStackTrace();
}
}

frame.pack();
frame.setVisible(true);
}

private static void displayImage(BufferedImage img) {


ImageIcon icon = new ImageIcon(img);
panel.setIcon(icon);
}

private static void enhanceBrightness(float brightnessPos) {


ImageEnhancer enhancer = new ImageEnhancer(img);
outputImage = enhancer.enhanceBrightness(brightnessPos);
displayImage(outputImage);
}

private static void enhanceContrast(float contrastPos) {


ImageEnhancer enhancer = new ImageEnhancer(img);
outputImage = enhancer.enhanceContrast(contrastPos);
displayImage(outputImage);
}

private static void enhanceSharpness(float sharpnessPos) {


ImageEnhancer enhancer = new ImageEnhancer(img);
outputImage = enhancer.enhanceSharpness(sharpnessPos);
displayImage(outputImage);
}

private static void enhanceColor(float colorPos) {


ImageEnhancer enhancer = new ImageEnhancer(img);
outputImage = enhancer.enhanceColor(colorPos);
displayImage(outputImage);
}
}

class ImageEnhancer {
private BufferedImage img;

public ImageEnhancer(BufferedImage img) {


this.img = img;
}

public BufferedImage enhanceBrightness(float brightnessPos) {


// Enhance brightness
}

public BufferedImage enhanceContrast(float contrastPos) {


// Enhance contrast
}

public BufferedImage enhanceSharpness(float sharpnessPos) {


// Enhance sharpness
}

public BufferedImage enhanceColor(float colorPos) {


// Enhance color
}
}

You might also like