Professional Documents
Culture Documents
Lab 13
Lab 13
Lab 13
Intelligence
7th Semester Institute of Industrial Electronics Engineering LAB 13
Objective:
The objective of this lab is to introduce undergraduate students to image processing techniques using
Python and OpenCV. Students will learn to perform tasks such as image loading, resizing, and applying
basic filters. By the end of the lab, students should be able to understand the fundamentals of image
processing and build a simple image processing application.
Description:
Image processing is a crucial aspect of computer vision. In this lab, students will develop an image
processing application that allows them to load images, resize them, and apply basic filters such as
grayscale conversion and edge detection.
Steps:
1. Introduction to Image Processing:
• Brief overview of image processing and its applications.
4. Resizing Images:
• Learn to resize images using OpenCV.
5. Grayscale Conversion:
• Implement grayscale conversion of the loaded image.
6. Edge Detection:
• Apply edge detection filters to identify prominent edges in the image.
• Discuss the significance of edge detection in image analysis.
7. Interactive Application:
• Create a simple interface allowing users to load an image, resize it, convert it to grayscale,
and apply edge detection.
import cv2
def load_and_display_image(image_path):
img = cv2.imread(image_path)
plt.imshow(img_rgb)
plt.title("Original Image")
plt.axis('off')
plt.show()
img = cv2.imread(image_path)
plt.imshow(resized_img)
plt.title("Resized Image")
plt.axis('off')
plt.show()
plt.imshow(img, cmap='gray')
plt.title("Grayscale Image")
plt.axis('off')
plt.show()
def edge_detection(image_path):
plt.imshow(edges, cmap='gray')
plt.title("Edge Detection")
plt.axis('off')
plt.show()
# Example usage
image_path = 'path/to/your/image.jpg'
load_and_display_image(image_path)
resize_image(image_path, 50)
convert_to_grayscale(image_path)
edge_detection(image_path)
Note: Replace 'path/to/your/image.jpg' with the actual path to your image file.
This lab is designed to provide students with a practical understanding of basic image processing
techniques using Python and OpenCV. The interactive application allows students to experiment with
different image processing tasks and observe the effects in real-time.