I'm very fascinated by autostereograms, especially single image random dot (auto)stereograms (SIRDS) where no equipment is needed to view a 3d image within a single image by using random dots (pixels).
But only just recently I discovered single image random text (auto)stereograms (SIRTS), which are of course also very fun and nerdy to look at 😉
With the small program aa3d
it's possible to convert 3d txt
files into a SIRTS. A few examples for such txt files are listed
here.
Hint: I created a copy of aa3d
for further
improvements.
But it's quite inconvenient to create these txt files, so I created a
small python script (my first!) based on asciify to convert a
depth map image like dm.png
to a 3d txt map to be used by
aa3d
.
Supported are only Arch Linux (yay
) and Debian/Ubuntu
(apt-get
).
First install aa3d
, python
and
pip
:
yay -S aa3d python python-pip # Arch Linux with yay as AUR helper
apt-get -y install aa3d python3 python3-pip # Debian/Ubuntu
Afterwards install pillow
via pip
:
pip install pillow
With docker
installed, we can use it and the provided
Dockerfile
to install python
, pip
, pillow
, aa3d
and
dm2txt.py
and tag the image with aa3d
.
I used python:buster
(Debian 10 with Python 3) as the base image.
docker build -t aa3d-tools .
Alternatively you can use the provided docker image thanks to this GitHub workflow:
docker pull ghcr.io/tohn/aa3d-tools
Now you can use dm2txt.py
to convert an image (dm.png
) to
a 3d txt map and use aa3d
to convert the map to a SIRTS.
dm2txt.py
expects an image file as the first parameter.
The second parameter can be used to set the width of the resulting "txt image" (in the range of 1-500) since an image with a width of 1920 wouldn't look good on a terminal. The default width is 80.
The third parameter can be used to set the number of layers used by
aa3d
. Only 10 are possible with 0 as the lowest layer (aka the
background) and 9 as the highest one. The input has to be in the range
0-9, the default is 9.
The parameters of aa3d
are described in man 1 aa3d
.
aa3d <heart.txt
./dm2txt.py dm.png | aa3d -d
./dm2txt.py dm.png 80 3 | aa3d -t tohn
With the docker image aa3d-tools
we can now mount our current folder
pwd
(use (pwd)
instead of $(pwd)
in fish
) and run the
same commands as above.
# create a SIRTS from heart.txt with `aa3d`
docker run --rm -v $(pwd):/opt -i ghcr.io/tohn/aa3d-tools aa3d <heart.txt
# show the output of `dm2txt.py`
docker run --rm -v $(pwd):/opt -i ghcr.io/tohn/aa3d-tools dm2txt.py dm.png
# create SIRTS from dm.png with `dm2txt.py` and `aa3d`
docker run --rm -v $(pwd):/opt -i ghcr.io/tohn/aa3d-tools bash -c 'dm2txt.py dm.png | aa3d -d'
docker run --rm -v $(pwd):/opt -i ghcr.io/tohn/aa3d-tools bash -c 'dm2txt.py dm.png 80 3 | aa3d -t tohn'
I wrote another python script after I saw this 3D Stereogram Ascii Movie Generator, which should create a WebM file consisting of some SIRTS showing the movement of a given txt depth map from left to right. More movements are planned in later versions.
The script is included in the aa3d-tools
Dockerfile. If you want
to run it natively, the following programs are necessary:
yay -S aa3d imagemagick ffmpeg # Arch Linux with yay as AUR helper
apt-get -y install aa3d imagemagick ffmpeg # Debian/Ubuntu
Now you can run it with a txt depth map (maybe generated by dm2txt.py
?
:wink:)
docker run --rm -v $(pwd):/opt -i ghcr.io/tohn/aa3d-tools txt2webm.py heart.txt