pic2ascii | magically enhances photos into ASCII!!!
kandi X-RAY | pic2ascii Summary
kandi X-RAY | pic2ascii Summary
magically enhances photos into ASCII!!!
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Creates an image .
- Create the ascii string .
- Initialize the widget .
- Prepare image .
- Argument parser .
- String representation of the object .
pic2ascii Key Features
pic2ascii Examples and Code Snippets
Community Discussions
Trending Discussions on pic2ascii
QUESTION
ANSWER
Answered 2020-Jul-31 at 16:12Interseting problem its basically vector form of Image to ASCII art conversion... I managed to do this with this algorithm:
preprocess image
You gave us JPG which has lossy compresion meaning your image contain much more than just 2 colors. So there are shades and artifacts which will screw things up. So first we must get rid of those by thresholding and recoloring. So we can have 2D BW image (no grayscales)
vectorize
Your maze is axis aligned so it contains only horizontal and vertical (
h
,v
) lines. So simply scan each line of image find first starting wall pixel then its ending pixel and store somewhere... repeat until whole line is processed and do this for all lines. Again do the same for rows of image. As your image has thick walls ignore lines sorter than thickness threshold and remove adjacent (duplicates) line that are (almost) the same.get list of possible grid coordinates from h,v lines
simply make a list of all x and y (separately) coordinates from lines start and end points. Then sort them and remove too close coordinates (duplicates).
Now the min and max values gives you AABB of your maze and GCD of all the
coordinate-lowest coordinate
will give you grid size.align h,v lines to grid
simply round all start/end points to nearest grid position ...
create text buffer for maze
AABB along with grid size will give you resolution of your maz in cells so simply create 2D text buffer where each cell has
NxN
characters. I am using6x3
cells which looks nice enough (square and with enough space inside).renmder h,v lines into text
simply loop through all lines and render
-
or|
instead of pixels... I am using also+
if the target position does not contain ' '.convert 2D text array into wanted text output
simply copy the lines into single text ... or if you clever enough you can have 1D and 2D at the same memory place with
eol
encoded between lines.
Here simple example in C++/VCL I made from the exampe in the link above:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pic2ascii
You can use pic2ascii like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page