0% found this document useful (0 votes)
3 views

AI Project

The document outlines ten different projects involving data analysis and image processing using Python libraries such as Pandas, Matplotlib, and OpenCV. Each project includes objectives, sample code, and visualizations for tasks like temperature data analysis, creating bar charts, image conversions, and applying filters. The projects demonstrate various techniques for data visualization and image manipulation.

Uploaded by

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

AI Project

The document outlines ten different projects involving data analysis and image processing using Python libraries such as Pandas, Matplotlib, and OpenCV. Each project includes objectives, sample code, and visualizations for tasks like temperature data analysis, creating bar charts, image conversions, and applying filters. The projects demonstrate various techniques for data visualization and image manipulation.

Uploaded by

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

Project 1: Temperature Data Analysis

Objective: Analyze temperature data using Pandas and visualize it with Matplotlib.

import pandas as pd
import matplotlib.pyplot as plt

# Create a sample dataset


data = {
"Day": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
"Temperature": [30, 32, 33, 31, 29]
}

# Convert to DataFrame
df = pd.DataFrame(data)

# Plot the temperature data


plt.figure(figsize=(8, 5))
plt.plot(df["Day"], df["Temperature"], marker='o', color='blue',
label="Temperature")
plt.title("Temperature Over Days")
plt.xlabel("Day")
plt.ylabel("Temperature (°C)")
plt.legend()
plt.grid()
plt.show()

Project 2: Simple Bar Chart with Matplotlib


Objective: Create a bar chart to display sales data.
import matplotlib.pyplot as plt

# Sales data
products = ["Product A", "Product B", "Product C", "Product D"]
sales = [100, 150, 200, 80]

# Create a bar chart


plt.figure(figsize=(8, 5))
plt.bar(products, sales, color='orange')
plt.title("Sales Data")
plt.xlabel("Products")
plt.ylabel("Sales (Units)")
plt.show()
Project 3: Grayscale Image to Binary Image Converter

Objective: Convert a grayscale image into a binary image using a threshold value.

Step 1 : Upload an image in co-lab

from google.colab import files


uploaded = files.upload() # Opens a file upload dialog
Upload an image in Google Colab and use the name of the file with
extension.

Step 2 : Project code

import cv2
import matplotlib.pyplot as plt

# Load a grayscale image


image_path = "Vaibhav Kumar.jpeg" # Replace with your image path
image = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)

# Apply thresholding
threshold = 128
_, binary_image = cv2.threshold(image, threshold, 255, cv2.THRESH_BINARY)

# Display original and binary images


plt.figure(figsize=(10, 5))
plt.subplot(1, 2, 1)
plt.title("Original Grayscale Image")
plt.imshow(image, cmap='gray')
plt.axis('off')

plt.subplot(1, 2, 2)
plt.title("Binary Image")
plt.imshow(binary_image, cmap='gray')
plt.axis('off')

plt.show()
Project 4: Simple Image Blurring

Objective: Apply a blur effect to an image using OpenCV.

Step 1 : Upload an image in co-lab

from google.colab import files


uploaded = files.upload() # Opens a file upload dialog
Upload an image in Google Colab and use the name of the file with
extension.

Step 2 : Project code

import cv2
import matplotlib.pyplot as plt

# Load the image


image_path = "Vaibhav Kumar.jpeg" # Replace with your image path
image = cv2.imread(image_path)

# Convert to RGB for display


image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

# Apply a blur filter


blurred_image = cv2.GaussianBlur(image_rgb, (15, 15), 0)

# Display original and blurred images


plt.figure(figsize=(10, 5))
plt.subplot(1, 2, 1)
plt.title("Original Image")
plt.imshow(image_rgb)
plt.axis('off')

plt.subplot(1, 2, 2)
plt.title("Blurred Image")
plt.imshow(blurred_image)
plt.axis('off')

plt.show()
Project 5: Edge Detection in an Image

Objective: Detect edges in an image using the Canny Edge Detection algorithm.

Step 1 : Upload an image in co-lab

from google.colab import files


uploaded = files.upload() # Opens a file upload dialog
Upload an image in Google Colab and use the name of the file with
extension.

Step 2 : Project code

import cv2
import matplotlib.pyplot as plt

# Load an image
image_path = "Vaibhav Kumar.jpeg" # Replace with your image path
image = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)

# Apply Canny edge detection


edges = cv2.Canny(image, 100, 200)

# Display the original and edge-detected images


plt.figure(figsize=(10, 5))
plt.subplot(1, 2, 1)
plt.title("Original Image")
plt.imshow(image, cmap='gray')
plt.axis('off')

plt.subplot(1, 2, 2)
plt.title("Edge Detection")
plt.imshow(edges, cmap='gray')
plt.axis('off')

plt.show()
Project 6: Face Detection Using OpenCV

Objective: Detect faces in an image using OpenCV's Haar Cascade.

Step 1 : Upload an image in co-lab

from google.colab import files


uploaded = files.upload() # Opens a file upload dialog
Upload an image in Google Colab and use the name of the file with
extension.

Step 2 : Project code

import cv2
import matplotlib.pyplot as plt

# Load Haar Cascade for face detection


face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades +
"haarcascade_frontalface_default.xml")

# Load the image


image_path = "Vaibhav Kumar.jpeg" # Replace with your image path
image = cv2.imread(image_path)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

# Detect faces
faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1,
minNeighbors=5)

# Draw rectangles around faces


for (x, y, w, h) in faces:
cv2.rectangle(image, (x, y), (x + w, y + h), (255, 0, 0), 2)

# Convert BGR to RGB for display


image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

# Show the image


plt.imshow(image_rgb)
plt.axis('off')
plt.title("Face Detection")
plt.show()
Project 7: Image Color Channels Split
Objective: Split an image into its RGB (Red, Green, Blue) color channels.
Step 1 : Upload an image in co-lab
from google.colab import files
uploaded = files.upload() # Opens a file upload dialog
Upload an image in Google Colab and use the name of the file with
extension.

Step 2 : Project code

import cv2
import matplotlib.pyplot as plt

# Load the image


image_path = "Vaibhav Kumar.jpeg" # Replace with your image path
image = cv2.imread(image_path)

# Split into channels


blue, green, red = cv2.split(image)

# Plot the original image and the channels


plt.figure(figsize=(10, 8))

plt.subplot(2, 2, 1)
plt.title("Original Image")
plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
plt.axis('off')

plt.subplot(2, 2, 2)
plt.title("Red Channel")
plt.imshow(red, cmap='Reds')
plt.axis('off')

plt.subplot(2, 2, 3)
plt.title("Green Channel")
plt.imshow(green, cmap='Greens')
plt.axis('off')

plt.subplot(2, 2, 4)
plt.title("Blue Channel")
plt.imshow(blue, cmap='Blues')
plt.axis('off')

plt.tight_layout()
plt.show()
Project 8: Create a Scatter Plot

Objective: Visualize the relationship between two variables in a dataset.

Code:

import pandas as pd
import matplotlib.pyplot as plt

# Create a sample dataset


data = {
"Age": [15, 16, 17, 18, 19],
"Marks": [75, 80, 85, 90, 95]
}

# Convert to DataFrame
df = pd.DataFrame(data)

# Scatter plot
plt.figure(figsize=(8, 5))
plt.scatter(df["Age"], df["Marks"], color='purple', label="Marks vs Age")
plt.title("Age vs Marks Scatter Plot")
plt.xlabel("Age")
plt.ylabel("Marks")
plt.legend()
plt.grid()
plt.show()
Project 9: Create a Line Plot of Population Growth

Objective: Visualize population growth over years using Matplotlib.

Code:

import matplotlib.pyplot as plt

# Population data
years = [2000, 2005, 2010, 2015, 2020]
population = [6, 6.5, 7, 7.5, 8] # In billions

# Create a line plot


plt.figure(figsize=(8, 5))
plt.plot(years, population, marker='o', linestyle='--', color='green',
label="Population Growth")
plt.title("World Population Growth")
plt.xlabel("Year")
plt.ylabel("Population (Billions)")
plt.legend()
plt.grid()
plt.show()
Project 10: Image Rotation
Objective: Rotate an image by 90 degrees using OpenCV.
Step 1 : Upload an image in co-lab
from google.colab import files
uploaded = files.upload() # Opens a file upload dialog
Upload an image in Google Colab and use the name of the file with
extension.

Step 2 : Project code

import cv2
import matplotlib.pyplot as plt

# Load the image


image_path = "Vaibhav Kumar.jpeg" # Replace with your image path
image = cv2.imread(image_path)

# Rotate the image by 90 degrees


rotated_image = cv2.rotate(image, cv2.ROTATE_90_CLOCKWISE)

# Convert to RGB for display


image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
rotated_rgb = cv2.cvtColor(rotated_image, cv2.COLOR_BGR2RGB)

# Display the images


plt.figure(figsize=(10, 5))
plt.subplot(1, 2, 1)
plt.title("Original Image")
plt.imshow(image_rgb)
plt.axis('off')

plt.subplot(1, 2, 2)
plt.title("Rotated Image (90° Clockwise)")
plt.imshow(rotated_rgb)
plt.axis('off')

plt.show()

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy