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).
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.
How it works
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
GET THE SCRIPT :
Grab the script from my GitHub Repo Here
Author of “PowerShell Guide to Python“, “Windows Subsystem for Linux (WSL)” and currently writing the most awaited book: “PowerShell to C# and Back” !
Prateek Singh
Related posts
0 Comments
Leave a ReplyCancel reply
Categories
Author of Books
Awards
Open Sourced Projects
Author at
Blog Roll
Mike F RobbinsDamien Van Robaeys
Stéphane van Gulick
Kevin Marquette
Adam Bertram
Stephanos Constantinou
Francois-Xavier Cat
Ravikanth Chaganti
Roman Levchenko
Blog Stats
- 1,132,982 People Reached
This is really awesome……
Thank you !
That’s fun!
Thank you JSnover 🙂
[…] on July 20, 2016 submitted by /u/Prateeksingh1590 [link] [comments] Leave a […]
U RLZ! ^^
true ART of scripting
[…] function/script from Prateek Singh called Write-Pixel. You can find it over at his awesome blog here. Its limited to 16 collors, but within that frame it finds the closest collor to each pixel in a […]