Breaking

Thursday, February 16, 2023

SHAH RUKH KHAN LINE ART DRAWING 💥

Introduction

Line art, characterized by distinct straight lines or curves placed on a usually plain background without gradations in shadow or hue, is a captivating and artistic form of expression. In this blog post, we will explore how to create line art of the iconic Bollywood actor Shah Rukh Khan using Python, the turtle graphics library, and the OpenCV package. You don't need to be an experienced artist to achieve this; a few lines of code will suffice. We will guide you through the process step by step..

Understanding Line Art

Line art, often monochrome, relies on the clever use of lines and curves to convey a visual representation. While it's typically black and white, line art can also incorporate colored lines to add depth and dimension. This art form is particularly appealing due to its simplicity and ability to capture intricate details with just a few strokes.

Shah Rukh Khan: The Icon

Shah Rukh Khan, often referred to as the "King of Bollywood," is one of India's most renowned actors. His charismatic presence and iconic smile have won the hearts of millions worldwide. Capturing his essence in line art is not just an artistic endeavor but also a tribute to his remarkable career.

Getting Started

Before we dive into the creative process, you'll need to download an image of Shah Rukh Khan to use as a reference. This image will serve as the basis for our line art. You can easily find high-quality images of the actor on the internet, or you can use the image provided in this blog post.

The Process

The line art creation process involves two primary steps: outlining and shading. We'll use the turtle graphics library for outlining and the OpenCV package for shading. Let's break down the process further.

Outlining with Turtle Graphics

Turtle graphics is a Python library that allows for easy drawing. We'll use it to outline Shah Rukh Khan's image. Here's an overview of how we achieve this:
  • Import Turtle Graphics: To get started, we import the turtle graphics library. This library provides us with a turtle that can move around the canvas and draw lines.
  • Load the Image: We load the Shah Rukh Khan image using the OpenCV package. OpenCV is a powerful computer vision library that helps us manipulate and work with images.
  • Initialize the Turtle: We initialize the turtle, setting its speed, position, and other attributes to prepare it for drawing.
  • Trace the Edges: With the turtle in place, we trace the edges of Shah Rukh Khan's image. This step involves carefully following the contours of his face, hair, and features.
  • Complete the Outline: Gradually, the outline of Shah Rukh Khan's image takes shape as we continue tracing. Attention to detail is crucial to capture the actor's likeness accurately.
  • Saving the Outline:Once we've completed the outline, we save it as a line art image.

Shading with OpenCV

To add depth and dimension to our line art, we use the OpenCV package for shading. Here's how we achieve this:
  • Import OpenCV: We import the OpenCV package, a versatile tool for image processing.
  • Load the Outline: We load the previously created outline of Shah Rukh Khan.
  • Apply Shading: Using OpenCV, we apply shading techniques to the outline. This step involves adding gradients and varying line thickness to create a 3D effect.
  • Enhance Details: We pay attention to specific details, such as shadows and highlights, to make the line art more lifelike.
  • Finalize the Artwork: After shading, we save the final line art image, now with depth and dimension..

Implementation

For the script mentioned below You need to download the above image . You can download the above image from here
Source Code
import cv2 import turtle import numpy as np from matplotlib import pyplot as plt import time image ='your image path' def find_closest(p): if len(positions) > 0: nodes = np.array(positions) distances = np.sum((nodes - p) ** 2, axis=1) i_min = np.argmin(distances) return positions[i_min] else: return None def outline(): src_image = cv2.imread(image, 0) th3 = cv2.adaptiveThreshold(src_image, maxValue=255, adaptiveMethod=cv2.ADAPTIVE_THRESH_GAUSSIAN_C, thresholdType=cv2.THRESH_BINARY, blockSize=51, C=50) return th3 im = cv2.imread(image, 0) th3 = outline() WIDTH = im.shape[1] HEIGHT = im.shape[0] print(WIDTH, HEIGHT) CUTOFF_LEN = ((WIDTH + HEIGHT) / 2) / 60 # 60 threshold value iH, iW = np.where(th3 == [0]) iW = iW - WIDTH / 2 iH = -1 * (iH - HEIGHT / 2) positions = [list(iwh) for iwh in zip(iW, iH)] turtle.setup(WIDTH+150, HEIGHT+150,startx=10,starty=10) turtle.shapesize(1) turtle.tracer(10) turtle.penup() turtle.goto(positions[0]) turtle.pendown() time.sleep(3) p = positions[0] while (p): p = find_closest(p) if p: current_pos = np.asarray(turtle.pos()) new_pos = np.asarray(p) length = np.linalg.norm(new_pos - current_pos) if length < CUTOFF_LEN: turtle.goto(p) turtle.update() else: turtle.penup() turtle.goto(p) turtle.pendown() positions.remove(p) else: p = None turtle.hideturtle() turtle.penup() turtle.done()

Exploring the Creative Process

Creating line art is not just about replicating an image; it's about understanding the subject's nuances and translating them into a unique artistic representation. As you embark on this journey to create Shah Rukh Khan's line art, take a moment to appreciate the beauty of merging technology with artistry.

Reference Image Selection

The choice of a reference image is crucial. It serves as the canvas for your digital brushstrokes. When selecting an image, consider factors like clarity, composition, and the distinctive features of the subject. Shah Rukh Khan's iconic smile and charismatic presence make for an excellent subject.

Turtle Graphics: The Art of Outlining

The outlining phase with Turtle Graphics is where you breathe life into your canvas. It's a meticulous process of following the contours, shapes, and proportions of the subject. Every line you draw is a stroke of creativity, bringing you closer to capturing the essence of Shah Rukh Khan's image.

OpenCV Shading: Adding Depth

OpenCV, the magic wand in your artistic toolkit, adds depth and dimension to your line art. It's akin to adding shades and highlights to a traditional artwork, making it visually compelling. Pay attention to the subtleties of shading, as they can transform a flat image into a three-dimensional masterpiece.

The Joy of Art and Code Fusion

The process of creating line art is not just a technical exercise; it's a fusion of art and code. It's a journey where pixels and algorithms blend seamlessly to create something visually captivating. This project allows you to explore the intersection of technology and artistic expression.

A Tribute to Shah Rukh Khan

Beyond the technical aspects, remember that this line art is a tribute to the legendary Shah Rukh Khan. It's an artistic homage to his remarkable career and magnetic persona. By the end of this project, you'll have a unique piece of artwork that celebrates his iconic presence.

Conclusion

Creating line art of iconic figures like Shah Rukh Khan using Python and the turtle graphics library, along with the OpenCV package, is not just a technical process; it's a creative endeavor that combines art and technology. Line art allows you to capture the essence of a subject with a unique and visually appealing approach. Whether you're an aspiring artist or a programming enthusiast, this project provides an exciting opportunity to explore the intersection of art and code.

With a reference image, some Python code, and a touch of creativity, you can embark on your journey to create impressive line art that pays homage to the charisma of Shah Rukh Khan and the artistry of line drawings.


Stay up-to-date with our latest content by subscribing to our channel! Don't miss out on our next video - make sure to subscribe today.



No comments: