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.

The following diagram shows the directions in which pixels are spread across the X and Y-axis.

bitmap


How it works

howto


Limitations

COLORS

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

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

 

Optical Character Recognition

Author of “PowerShell Guide to Python“, “Windows Subsystem for Linux (WSL)” and currently writing the most awaited book: “PowerShell to C# and Back” !


Subscribe to our mailing list

* indicates required