The original uploader has been moved from Los Hawlos on German Wikipedia to Commons from de.wikipedia. , CC display-inheritance 3.0, by https://commons.wikimedia.org/w/index.php?curid=1966500
Can you see it? By shifting the focus of the eyes back and forth, pictures and letters emerge (look three-dimensional). I'm sorry for those who are watching from a smartphone. Look from your computer.
I want to make this myself.
There was an implementation example in Python on the following site, so I made an original random dot stereogram by referring to it.
import numpy as np
import matplotlib.pyplot as plt
import cv2
I've been experimenting with Notebook format and used the familiar matplotlib
to display images, but anything is fine as long as you can see the images.
def make_pattern(shape=(16, 16)):
return np.random.uniform(0, 1, shape)
Try to run it.
pattern = make_pattern((400,400))
plt.imshow(pattern, cmap='gray')
Something is already about to emerge.
def make_depthmap(shape=(400, 600)):
depthmap = np.zeros(shape, dtype=np.float)
cv2.circle(depthmap, (int(shape[1]/2), int(shape[0]/2)), 100, (255 ,255, 255), -1)
return depthmap
Try to run it.
depthmap = make_depthmap()
plt.imshow(depthmap, cmap='gray')
This one should come to the fore.
def make_autostereogram(depthmap, pattern, shift_amplitude=0.1, invert=False):
"Creates an autostereogram from depthmap and pattern."
depthmap = normalize(depthmap)
if invert:
depthmap = 1 - depthmap
autostereogram = np.zeros_like(depthmap, dtype=pattern.dtype)
for r in np.arange(autostereogram.shape[0]):
for c in np.arange(autostereogram.shape[1]):
if c < pattern.shape[1]:
autostereogram[r, c] = pattern[r % pattern.shape[0], c]
else:
shift = int(depthmap[r, c] * shift_amplitude * pattern.shape[1])
autostereogram[r, c] = autostereogram[r, c - pattern.shape[1] + shift]
return autostereogram
def normalize(depthmap):
return depthmap/255
The main process is quoted from the reference site mentioned at the beginning. Try to run it.
autostereogram = make_autostereogram(depthmap, pattern, 0.3)
plt.imshow(autostereogram, cmap='gray')
** A circle is clearly visible. ** ** (The circle mark appears to be dented in the crossing method, which brings the focus of the eyes closer.)
I tried to make the text a random dot stereogram.
def make_text_depthmap(shape=(400, 600), text='Q i i t a'):
font = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(depthmap, text, (50, 250), font, 4, (255,255,255), 12, cv2.LINE_AA)
return depthmap
Something that emerges.
depthmap_text = make_text_depthmap()
plt.imshow(depthmap, cmap='gray')
Try to run it.
autostereogram = make_autostereogram(depthmap_text, pattern, 0.05)
plt.imshow(autostereogram, cmap='gray')
It's a little vaguer than the circle, but you can see it.
What is it written on? ?? The text.
Answers are welcome in the comments ^^
I wrote a sequel.
-In search of the best random dot stereogram (RDS).
I wrote a sequel.