How Image Processing Revolutionizes Data Science (Day -2)

How Image Processing Revolutionizes Data Science (Day -2)

#Day 2:Creation of Shape and Create Text with Vegeta from DragonBallZ!

Ready for a power-up worthy of Vegeta himself? Today, we're leveling up our image processing skills by creating awesome shapes and text directly on images!



Use pip (the Python package installer) to install the following libraries:

pip install pillow matplotlib imageio opencv-python These libraries provide powerful tools for various image processing tasks:

Pillow (PIL Fork): For basic image loading, manipulating pixels, and saving results.

matplotlib: For visualizing images using plots and figures.

imageio: For handling diverse image formats and advanced loading/saving options.

OpenCV (Open Source Computer Vision Library): A comprehensive library for real-time computer vision, offering extensive image processing and manipulation capabilities.

Work Environment is Kaggle you can visit and explore it open source and free!!!!!!

Key Concepts

Calling All Saiyan Warriors!

  1. Drawing Circles of Energy: Harness the power of OpenCV to draw vibrant circles on images. Explore different colors, thicknesses, and even fill them with energy!
import cv2 as cv
import matplotlib.pyplot as plt
img = cv.imread('../input/vegeta/mpmdbz-02_a10.jpg',1)

  • Converts both from OpenCV's default BGR (Blue-Green-Red) color space to RGB (Red-Green-Blue), a more common format for visualization.

  • Draws circles on the two copies:

    • img1: Circle at coordinates (200, 550), radius 150, color (0, 220, 0) (greenish-blue), thickness 50.

    • img2: Circle at (300, 850), radius 150, color (255, 220, 0) (yellowish), thickness -5 (filled circle).

  1. Writing Messages in the Stars: ✨ Use text superimposition to add epic captions, annotations, or even recreate those iconic Dragon Ball Z battle cries!
import cv2 as cv
import matplotlib.pyplot as plt
img = cv.imread('../input/vegeta/mpmdbz-02_a10.jpg',1)
font = cv.FONT_HERSHEY_SIMPLEX #font family
cv.putText(img1,'Go! Go!',(500,500),font,5,(200,10,100),30) #

  • Sets the font to be used for text. cv.FONT_HERSHEY_SIMPLEX is a simple.

  • Draws the text "Go! Go!" on the modified image img1.

  • Arguments:

    • img1: The image to place the text on.

    • 'Go! Go!': The text to write.

    • (500, 500): The coordinates for the bottom-left corner of the text.

    • font: The font selected earlier.

    • 5: Font scale (size).

    • (200, 10, 100): Text color in BGR format (pinkish-purple).

    • 30: Thickness of the text lines.

  1. Pixel Perfect Precision: Master accessing and manipulating individual pixels to create custom effects or highlight specific areas of interest.
import cv2 as cv
import matplotlib.pyplot as plt
img = cv.imread('../input/vegeta/wp4534369.jpg',1)
img1 =cv.cvtColor(img,cv.COLOR_BGR2RGB)
cv.putText(img1,'Go! Go!',(500,200),font,5,(200,10,100),30)

  • Draws two filled rectangles:

    • One in the top-left corner (blue), 250x200 pixels.

    • One in the bottom-right corner (green), 300x280 pixels.

  • Draws a red circle with a radius of 150 pixels, centered at (1160, 650).

  • Draws two thick, yellow lines:

    • One starting at (750, 1000) and ending at (980, 830).

    • One starting at (1290, 830) and ending at (1500, 1000).

Challenges for the Worthy:

  • Experiment with different shapes: Draw rectangles, lines, or even custom shapes using OpenCV's drawing functions.

  • Combine shapes and text: Create dynamic image compositions that tell a story or highlight key features.

  • Apply shape-based techniques: Try out image segmentation, object detection, or creative image manipulation using shapes as tools.

Over 9000 Possibilities!

Whether you're analyzing Vegeta's power levels or creating your own manga-inspired art, the possibilities are limitless!

Stay tuned for Day 3, where we'll explore even more exciting image processing techniques! ⚡️

P.S. Don't forget to share your image creations and any questions in the comments below! Let's build a thriving Saiyan community of image processing enthusiasts!

#ImageProcessing #DataScience #DragonBallZ #Vegeta #OpenCV #Shapes #Text #Day2

Did you find this article valuable?

Support TechLearn India by becoming a sponsor. Any amount is appreciated!