Drawing Image Pixels to Powershell Console


Being honest, I’m not very proud of this script 🙂 , but I like the Beauty how “Thoughts become Things” ( Idea -> Script )

INTRODUCTION AND DEFINITIONS : 

Yesterday,  I was thinking about my graduation days how Image Processing in MatLab used to fascinate me! So I thought giving Images a try in Powershell.

Just to see if an Image can be drawn in the Powershell console I did some (A lot!) research and ended up with this script, but before we delve into it its time for some definitions which are following –

WHAT IS A PIXEL ? 

A Pixel (a word invented from “Picture Element“) is the basic unit of programmable color on a computer display or in a computer image.

Pixels indicates a color for each image unit along the horizontal axis or row (called the x coordinate) and a color for each Image unit along the vertical axis (called the y coordinate).

pixel

WHAT IS A BITMAP ?

A bit map (often spelled “bitmap”) defines a display space and the color for each pixel or “bit” in the display space.

A Graphics Interchange Format (GIF) and a JPEG are examples of graphic image file types that contain bit maps. Pixels are nothing but color information spread on X, Y coordinates.

Following diagram show the directions in which pixels are spread across X and Y axis.

bitmap

HOW IT WORKS :

howto

LIMITATIONS : 

  1. COLORS :

    Console is limited to only 16 colors leaving us with less choices. Hence, I have to write a small algorithm to find the Closest console color matching the color in a Pixel.
    So you want find the Image in the console very beautiful, but good part is it at least works 😉

  2. SPEED : 

    Speed of drawing Image in a console depends heavily on the number of Pixels in the Image that is width multiplied by the height, so I would recommend that your image size doesn’t cross 150X150 otherwise image will be drawn a pretty slow pace, since the number of iterations will increase drastically for larger images.

    NumberOfPixels  = Width  * Height of the Image

 

HOW TO RUN : 

*This animation is a high speed version of the Original

g

GET THE SCRIPT :

Grab the script from my GitHub Repo Here

 

Hoping you’ll find it fun!! 🙂

Prateek Singh

Advertisements

6 thoughts on “Drawing Image Pixels to Powershell Console

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s