Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!
Image Processing Mini Project
Build a complete image processing pipeline that applies multiple transformations and saves all results for comparison.
15 min•By Priygop Team•Updated 2026
Processing Pipeline Project
Processing Pipeline Project
import cv2
import numpy as np
import os
def full_processing_pipeline(input_path, output_dir="output"):
"""
Apply a full suite of image processing operations.
Saves each result for visual comparison.
"""
os.makedirs(output_dir, exist_ok=True)
image = cv2.imread(input_path)
if image is None:
print(f"Could not load: {input_path}")
return
print(f"Processing: {input_path}")
print(f"Original size: {image.shape[1]}x{image.shape[0]}")
# Resize to standard size
resized = cv2.resize(image, (640, 480), interpolation=cv2.INTER_AREA)
cv2.imwrite(f"{output_dir}/01_resized.jpg", resized)
# Flip horizontally
flipped = cv2.flip(resized, 1)
cv2.imwrite(f"{output_dir}/02_flipped.jpg", flipped)
# Brightness adjustments
brighter = cv2.convertScaleAbs(resized, alpha=1.0, beta=60)
darker = cv2.convertScaleAbs(resized, alpha=1.0, beta=-60)
cv2.imwrite(f"{output_dir}/03_brighter.jpg", brighter)
cv2.imwrite(f"{output_dir}/04_darker.jpg", darker)
# Convert to grayscale
gray = cv2.cvtColor(resized, cv2.COLOR_BGR2GRAY)
cv2.imwrite(f"{output_dir}/05_grayscale.jpg", gray)
# Gaussian blur
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
cv2.imwrite(f"{output_dir}/06_blurred.jpg", blurred)
# Thresholding
_, otsu = cv2.threshold(blurred, 0, 255,
cv2.THRESH_BINARY + cv2.THRESH_OTSU)
cv2.imwrite(f"{output_dir}/07_threshold.jpg", otsu)
# Sharpened
kernel = np.array([[0,-1,0],[-1,5,-1],[0,-1,0]])
sharpened = cv2.filter2D(resized, -1, kernel)
cv2.imwrite(f"{output_dir}/08_sharpened.jpg", sharpened)
print(f"Saved 8 processed images to: {output_dir}/")
print("Operations: resize, flip, brightness, grayscale, blur, threshold, sharpen")
full_processing_pipeline("your_photo.jpg")Diagram
Loading diagram…
Machine Learning follows a structured pipeline from data to deployment
Key Takeaways from Module 3
- Image processing transforms raw images to prepare them for analysis or improve quality
- cv2.resize() changes image dimensions — use INTER_AREA for shrinking, INTER_LINEAR for enlarging
- Cropping uses NumPy slicing: image[y1:y2, x1:x2]
- cv2.flip() with codes 0, 1, -1 creates vertical, horizontal, or combined flips
- cv2.convertScaleAbs(alpha, beta) adjusts contrast (alpha) and brightness (beta) together
- Thresholding converts grayscale to binary — use Otsu's method when unsure of threshold value
- Blurring reduces noise — GaussianBlur is the most widely used pre-processing blur
Key Takeaways
- Build a complete image processing pipeline that applies multiple transformations and saves all results for comparison.
- Image processing transforms raw images to prepare them for analysis or improve quality
- cv2.resize() changes image dimensions — use INTER_AREA for shrinking, INTER_LINEAR for enlarging
- Cropping uses NumPy slicing: image[y1:y2, x1:x2]