Image Processing
Image Processing
INTRODUCTION
This project is a Python-based GUI application that allows users to apply various filters to
images. Built using Tkinter, OpenCV, and Pillow (PIL), this lightweight tool provides a user-
friendly interface to process and enhance images with a few clicks. It is designed to offer
essential image processing functionality without requiring complex software or advanced
technical knowledge.
Features
✅ Apply Filters
The app provides four primary filters that users can apply to their images:
• Grayscale – Converts the image into shades of gray by removing color information. This
filter is useful for artistic effects or preparing images for further analysis. The app uses
cv2.cvtColor() with the COLOR_RGB2GRAY flag to achieve this effect.
• Blur – Applies a Gaussian blur to soften the image. This effect helps reduce noise and
details, making it suitable for backgrounds or artistic blurring. The app uses
cv2.GaussianBlur() with a kernel size of 15x15 for optimal balance between smoothness
and performance.
• Sharpen – Enhances image details using a custom convolution kernel. This filter makes
edges more defined and is commonly used to improve photo clarity. The sharpening
effect is applied using cv2.filter2D() with a predefined kernel matrix.
• Edge Detection – Highlights edges within the image using the Canny Edge Detection
algorithm. This filter is useful for detecting object boundaries and performing image
segmentation. The app applies cv2.Canny() with adjustable threshold values of 100 and
200.
✅ User-Friendly GUI
The interface is built with Tkinter, providing an organized layout with interactive buttons for
each action. The app features:
🔹 Undo Functionality
Implementing an undo feature would allow users to revert the last applied filter without needing
to reload the original image.
🔹 Batch Processing
The ability to apply filters to multiple images at once would improve efficiency for users
working with large sets of images.
IMPLEMENTATION
These libraries provide image processing capabilities, GUI components, and numerical
operations.
Example snippet:
self.root = Tk()
self.root.title("Image Filter App")
self.label = Label(self.root)
self.label.pack()
4. Applying Filters
The app provides multiple image filters, each implemented using OpenCV.
✅ Grayscale Conversion
filtered = cv2.cvtColor(self.img_cv, cv2.COLOR_RGB2GRAY)
filtered = cv2.cvtColor(filtered, cv2.COLOR_GRAY2RGB)
Converts an image to grayscale and back to RGB for proper display.
✅ Blurring Effect
filtered = cv2.GaussianBlur(self.img_cv, (15, 15), 0)
Applies Gaussian blur with a 15x15 kernel to smooth the image.
✅ Sharpening Filter
kernel = np.array([[0, -1, 0], [-1, 5, -1], [0, -1, 0]])
filtered = cv2.filter2D(self.img_cv, -1, kernel)
Enhances the image by amplifying edge details.
✅ Edge Detection
filtered = cv2.Canny(self.img_cv, 100, 200)
filtered = cv2.cvtColor(filtered, cv2.COLOR_GRAY2RGB)
Detects edges using the Canny algorithm and converts it back to RGB.
This ensures smooth scaling and proper rendering of the modified image.
6. Saving Images
Users can save processed images in PNG or JPEG format:
save_path = filedialog.asksaveasfilename(defaultextension=".png")
Image.fromarray(self.img_cv).save(save_path)
The image is converted from an array format back into a standard image format before
saving.
if self.img_cv is None:
messagebox.showerror("Error", "No image loaded!")
return
8. Future Enhancements
• Implement Undo functionality using a stack of image states.
• Add Brightness & Contrast adjustments for greater control.
• Enable Batch Processing to apply filters to multiple images simultaneously.
This structured approach ensures a robust and user-friendly image filtering application with
expandable features for future improvements.
PROGRAM
import cv2
import numpy as np
from tkinter import Tk, Button, Label, filedialog, Frame
from PIL import Image, ImageTk
def open_image():
global img, img_cv
file_path = filedialog.askopenfilename()
if file_path:
img_cv = cv2.imread(file_path)
img_cv = cv2.cvtColor(img_cv, cv2.COLOR_BGR2RGB)
img = Image.fromarray(img_cv)
img = img.resize((400, 300))
img_tk = ImageTk.PhotoImage(img)
label.config(image=img_tk)
label.image = img_tk
def apply_filter(filter_type):
global img_cv
if img_cv is None:
return
if filter_type == "grayscale":
filtered = cv2.cvtColor(img_cv, cv2.COLOR_RGB2GRAY)
filtered = cv2.cvtColor(filtered, cv2.COLOR_GRAY2RGB)
elif filter_type == "blur":
filtered = cv2.GaussianBlur(img_cv, (15, 15), 0)
elif filter_type == "sharpen":
kernel = np.array([[0, -1, 0], [-1, 5, -1], [0, -1, 0]])
filtered = cv2.filter2D(img_cv, -1, kernel)
elif filter_type == "edge":
filtered = cv2.Canny(img_cv, 100, 200)
filtered = cv2.cvtColor(filtered, cv2.COLOR_GRAY2RGB)
else:
return
img_filtered = Image.fromarray(filtered)
img_filtered = img_filtered.resize((400, 300))
img_tk = ImageTk.PhotoImage(img_filtered)
label.config(image=img_tk)
label.image = img_tk
def save_image():
# GUI Setup
root = Tk()
root.title("Image Filter App")
root.configure(bg="#2E3B4E")
root.geometry("500x500")
root.mainloop()
OUTPUT
Expected Output
Action Expected Result
Load Image Selected image appears in the GUI.
Apply Grayscale Image is converted to grayscale.
Apply Blur Image becomes softer and less detailed.
Apply Sharpening Image details and edges become more pronounced.
Apply Edge Detect Outlines of objects in the image become visible.
Save Image Processed image is saved in the selected format.
CONCLUSION
The Image Filter App successfully demonstrates how image processing can be simplified
through an interactive GUI using Python, OpenCV, and Tkinter. By allowing users to open,
modify, and save images with just a few clicks, the app provides a practical and user-friendly
approach to basic image editing.
With essential filters such as grayscale conversion, blurring, sharpening, and edge
detection, users can enhance and analyze images efficiently. The structured implementation
ensures smooth functionality, while error handling prevents unexpected issues.
This project serves as a solid foundation for further expansion. Future improvements such as
undo functionality, advanced filters, batch processing, and custom kernel support can
significantly enhance the app’s capabilities. Overall, the Image Filter App is an excellent
tool for beginners and a stepping stone toward more advanced image processing applications.
Conclusion
The Image Filter App successfully demonstrates how fundamental image processing
operations can be implemented through an interactive and user-friendly Graphical User
Interface (GUI) using Python, OpenCV, Tkinter, and Pillow. By allowing users to open,
apply filters, and save images with minimal effort, the application eliminates the need for
complex image editing software while maintaining essential functionalities.
✅ Gaussian Blur – Smooths the image to reduce noise, providing a soft-focus effect useful
for backgrounds or pre-processing before edge detection.
✅ Sharpening – Enhances fine details and increases image clarity, making it valuable for
improving object visibility.
✅ Edge Detection – Identifies significant structural details in the image, often used in
computer vision applications such as object recognition and segmentation.
With a well-structured GUI, the app ensures an intuitive experience where users can
seamlessly navigate through different functionalities. The Tkinter-based layout organizes
the controls efficiently, and automatic image resizing enhances visibility. Additionally, built-
in error handling mechanisms prevent users from performing invalid operations, ensuring a
smooth user experience.
This project serves as a strong foundation for further development in image processing.
Potential enhancements include:
🔹 Custom Kernel Processing – Enabling users to define and apply their own convolution
filters for advanced image effects.
Overall, the Image Filter App is a compact yet powerful tool that bridges the gap between
beginner-friendly applications and professional image processing techniques. It provides an
excellent starting point for those interested in exploring computer vision, GUI development,
and digital image manipulation, making it an ideal project for both learning and practical use.
❖ References
1) www.google.com
2) www.javatpoint.com
3) For type this project we have use a MS-word
4) And we have completed the projects under guidance of Miss. Raskar. P.B