[PYTHON] In search of the best random dot stereogram (RDS).

In the previous article, I tried to create an original random dot stereogram using Python.

-Create an original random dot stereogram (RDS) with Python

I was able to see stereoscopically safely, but I was satisfied just by looking at the circles and texts in 3D. This time I will make something a little cooler.

Change color

Last time, the random dot stereogram was displayed in grayscale. This is kind of scary like an old TV sandstorm.

Since Matplotlib has various color maps other than grayscale, I changed it.

plt.imshow(stereogram, cmap='spring')

1207_1.png The feeling of Sadako disappeared and it became a lot of POP. Good.

depth

Last time, I created a depth map of a 3D pattern with 2 values. This is not deep in many ways. By making the depth map a continuous numerical value, it is possible to adjust the degree to which the solid emerges.

I prepared the following pattern as a trial.

def make_depthmap(shape=(400, 600)):
    depthmap = np.zeros(shape, dtype=np.float)
    cv2.circle(depthmap, (200, 100), 50, (255 ,255, 255), -1)
    cv2.circle(depthmap, (400, 100), 50, (200 ,200, 200), -1)
    cv2.circle(depthmap, (300, 200), 50, (155 ,155, 155), -1)
    cv2.circle(depthmap, (200, 300), 50, (100 ,100, 100), -1)
    cv2.circle(depthmap, (400, 300), 50, (55 ,55, 55), -1)
    return depthmap

1207_2.png

A pattern that darkens in order of Z from the upper left. Now let's create an RDS.

1207_3.png

It's amazing. The degree of popping out changes depending on the darkness of the depth map. I also tried this pattern.

def make_rectangle_depthmap(shape=(400, 600)):
    depthmap = np.zeros(shape, dtype=np.float)
    for i in range(16):
        c = 255 - i * 16
        cv2.rectangle(depthmap, (100+i*25, 100), (125+i*25, 300), (c, c, c), -1)
    return depthmap

1209_1.png

Click here for results

1209_2.png

It looks like a staircase. Good.

end

Next time, I would like to create a depth map from a photo (2D image) so that a normal photo can be viewed stereoscopically. I want to be a random dot stereo glamor.

Postscript

I wrote a sequel.

-Create an original random dot stereogram (RDS) from 2D photos with depth estimation by machine learning

Recommended Posts

In search of the best random dot stereogram (RDS).
Create your own Random Dot Stereogram (RDS) in Python.
In search of the fastest FizzBuzz in Python
Search by the value of the instance in the list
Google search for the last line of the file in Python
The story of participating in AtCoder
The story of the "hole" in the file
The meaning of ".object" in Django
[Python] Explore the characteristics of the titles of the top sites in Google search results
The google search console sitemap api client is in webmasters instead of search console
[Understanding in 3 minutes] The beginning of Linux
Check the behavior of destructor in Python
The story of an error in PyOCR
Implement part of the process in C ++
The result of installing python in Anaconda
Let's claim the possibility of pyenv-virtualenv in 2021
The basics of running NoxPlayer in Python
[Reinforcement learning] Search for the best route
Output the number of CPU cores in Python
The meaning of {version-number} in the mysql rpm package
[Python] Sort the list of pathlib.Path in natural sort
Change the font size of the legend in df.plot
Get the caller of a function in Python
Match the distribution of each group in Python
View the result of geometry processing in Python
Make a copy of the list in Python
Find the number of days in a month
Read the output of subprocess.Popen in real time
Find the divisor of the value entered in python
The story of finding the optimal n in N fist
Fix the argument of the function used in map
[At Coder] Solve the problem of binary search
Find the solution of the nth-order equation in python
The story of reading HSPICE data in Python
[Note] About the role of underscore "_" in Python
Put the second axis in 2dhistgram of matplotlib
About the behavior of Model.get_or_create () of peewee in Python
Solving the equation of motion in Python (odeint)
Visualized the usage status of the sink in the company
Output in the form of a python array
The story of viewing media files in Django
Make progress of dd visible in the progress bar
Factfulness of the new coronavirus seen in Splunk
Get the tag search results of Nico Nico Douga in XML format. (No login required)
I investigated the calculation time of "X in list" (linear search / binary search) and "X in set"