Depth map method, the best 2D to 3D conversion tool!

(For Photoshop users)

By: Shahrokh Dabiri, Tehran, Iran.



Almost all 3D enthusiasts really would like to find an easy and fast
way to convert their ordinary 2D pictures to 3D. I´m one of those
enthusiasts. You may already know that quite few different methods
and software programs have been described which can be used for
conversion of a 2D picture to 3D. I think I have tried almost all of
them. Based on my experience, I believe the most convincing, logical
and easiest one to use is the depth map method that works by using
Photoshop´s `Displace´ tool.

The Displace tool can shift and/or copy any or all of the pixels from
a 2D picture to its left or right side position, based on a
particular depth map. At a first glance, a depth map image looks like
a combination of different shades of grey, but each shade of those
grey colors is a meaningful code for the Displace tool that copies
the related pixels to their left or right with a particular amount of

Here in this article, I want to help you understand the concept of
this amazing depth map method by doing a few simple exercises. I will
describe how I have created simple maps for converting my simple 2D
pictures to 3D. After creating the map, Photoshop will do the
conversion job after a few simple clicks!

Unfortunately you won´t find enough clear information about this
method on the web, simply because this method is a bit hard to
explain only by words, or maybe because few people have discovered
how it works. But if you see the procedure even just once, you will
quickly understand it. Or in other words: you should do it to learn

Now if you really want to learn this wonderful, amazing and powerful
method, please follow me step by step as I explain it in my following
simple three exercises.

Here we go: open your Photoshop software please. 



Exercise 1

a. Create a new square blank file, 1000 x 1000 pixels in size. Then
draw a simple shape like a cross, a spiral or a few circles. Here we
want to convert one of these to look like a cone when viewed from
above and after converting it to 3D.


b. Create three additional duplicates from your original drawing.
Name one as `Circle_Left´, the second one as `Circle_Right´ and the
third as `Circle_Map´. We first need to create the map. Therefore we
begin to change the `Circle_Map´ image to look like a depth map.

c. Find and select the Gradient tool (G) in your Photoshop tool box.
This important tool works in five different ways. For this
conversion, we need to active its "Radial Gradient" form. Select that
option by a click on its small icon (second from left.) Again in your
tool box, select white for foreground color and black for background
color. Since a depth map works only with different shades of grey, we
don´t need any other colors except white, black and shades of grey.
Now click on the center of your image and drag the line toward a
corner of your square image. The result image should look like this:


This is your final depth map for this conversion. Save it as
`Circle_Map.psd´ somewhere on your computer, then close it on your
Photoshop screen. You will need it again later.

Congratulations - you just created your first depth map. And it was
that simple!


d. Get back to the `Circle_Right´ image. We want to add the
"Displace" filter. You should click on the Filter drop-down menu >
Distort > Displace... After clicking on the "Displace..." filter, a
new "Displace" window will pop up. Adjust its parameters as below:

Horizontal Scale = 30 (Its default is 10, but I want more depth
Vertical Scale = 0 (because we don´t need any vertical shift)
Displacement map = click on "Tile"
Undefined Areas: = Repeat edge pixels Now click on OK.


Another new window or Choose a displacement map window will pop up.
This window asks for your depth map image, and therefore you should
select your previously saved `Circle_Map.psd´ file and then click on
"Open". You will see how simple the foreground of your drawing
distorts to the left and its background distorts to the right. The
right eye view of your conversion has been created now. You can save

e. Get back to the `Circle_Left´ image. Do the same procedures as in
the previous step "d" but change the Horizontal Scale number to
negative 30: Horizontal Scale = -30 (Negative numbers do the reverse
distortion or displacement, therefore the foreground of your drawing
will distort to the right and its background will distort to the
left.) After this step, the left eye view of your conversion also has
been created. You can save that too! Your final conversion should
look something like this stereo pair:

Here I didn´t touch the stereo window position,

but I added the frame to show you how one half of
this conversion is coming out through the window and the other half
is located behind the stereo window.


For a little fun, I also applied the same procedure on my passport
picture to see what I get. Again I did use the Radial Gradient tool.
I began from the top of my nose top and dragged the line up to my
hair to convert only my face. Although the result doesn´t look good
to me, I can always fix it later by adding a little proper grey to a
few particular locations on the map. Here you see my portrait
converted in 2 minutes. The stereo window has been corrected.



My original portrait picture was small, only 354 x 472 pixels in size.
Therefore only ±3 was enough for Horizontal Scale on this picture.
According to my experience, bigger size pictures need bigger numbers
for the Horizontal Scale to create enough displacement.

Now let me explain how these fast conversions have been created by
this Photoshop Displace tool. As I pointed out before, this wonderful
tool gets its orders from the location of shades of grey it finds on
the related depth map. This means that for shifting each pixel, this
tool compares the location of that particular pixel on the related
map, and then finds what shade of grey is located there. Next, based
on the shade color, it copies the related pixel to the left or to the
right. The amount of shifting will be determined by the shade of grey
and the Horizontal Scale number. Obviously, higher numbers of
Horizontal Scale will results to more shifting and lower numbers
result in less shifting. Or in other words: a higher Horizontal Scale
number results in more deviation or more depth in the final stereo
pair. Therefore, the Horizontal Scale can also be considered as
`Stereo base´!


In a depth map, pure white (0 % grey) has been considered for
creating the maximum shift in front of the stereo window and black
(100 % grey) results in the maximum shift or deviation deep into the
background. To put it another way: if we paint part of a map with
pure white, the related subject will show up completely in front of
the stereo window and if we map a subject with black, it will be
located far behind the window after the conversion process. 50 % grey
on a map will translate to no pixel shift, therefore the related
pixels won´t move after applying the Displace tool. It means if we
map a subject with 50 % grey then it will stay right on the stereo
window plane after the conversion.

Now look at your drawing´s depth map again.

Notice the center of the drawing has been mapped with pure
white so therefore the center of the drawing shows up completely in
front of the stereo window on the converted image. The lines near the
borders are behind the window because they have been mapped with dark
grey shades or black.

To summarize: if you paint any part of a map
with pure white (0 % grey) then the related subjects will be located
completely in front of the window after the conversion but any
subject will appear far behind the window if you paint its map with
pure black (100 % grey). If you paint any part of a map with 50 %
grey then the related subjects won´t move to the left or right and
they will be located right on the stereo window surface!

In my further exercises, I will help you to learn how to create or
paint the maps for simple pictures.


You can find different shades of grey in the Swatches window.

They are located above on the right in the first and second rows.

Keep your cursor on one of those grey squares and after a few

moments Photoshop will show you the percentage of that grey.


The Color window shows the numeric values of your selected color.

When Red, Green & Blue are equal the result is a grey color.

You can create any shade of grey by moving these three
sliders together.

127 is equal to 50 % grey, white = 255 and black = 0 


Exercise 2

Find a simple landscape like the picture below with 768 pixels in height.


    Like in the previous exercise, we use the Gradient tool (G)
again. But for such a landscape we should activate its "Linear
Gradient" form. Select that option by a click on its small icon
located on the very left. Getting three copies from the original
picture and creating a depth map is almost same as Exercise 1 - but
there are a few minor differences.

Use 50 % grey for foreground color and black for the background color
because there should be nothing in this picture to come out through
the window in the final conversion.

In other words, we don´t need brighter than 50 % grey because depth
should begin at the stereo window position and move back toward
infinity. For applying the Linear Gradient tool, you should put and
click the Gradient cursor on the lower border of the 2D picture copy,
then drag its line toward the upper border. After applying the Linear
Gradient tool, your map will be ready to save in "psd" format (i.e.
you may save it as `SimpleMap. psd´). Your map should look like the
image below:


Like in the previous exercise, apply the Displace tool to the Right
and Left copies that you have duplicated from your original 2D
picture before. Put ±30 for Horizontal Scale numbers, then use the
previously saved `Simple_Map.psd´ as your depth map here. Your final
conversion should look something like the picture below:

This conversion shows a great amount of depth from the close
foreground to infinity. You may agree that taking such a hyperstereo
is almost impossible in reality but in conversions we have no limit
on creating layers of depth. The Gradient tool in its Linear form
created such a map that the foreground color (here 50 % grey) shifts
toward darker shades until the background color (in our example)
reaches black. As you see in the resulting stereo pair, such a
gradient map has bent the 2D picture toward the Z axis (depth axis).
This simple exercise is very important because you may use it as a
base or as a first step in many of your further conversions!

Exercise 3

On this exercise I´ll describe how I have improved my previous simple
depth map for a little more complicated picture.

First look at this conversion:

The result looks almost similar to the previous exercise,
except that I would like the bird and the two boats show up on a
separate layer of depth.


Carefully check the map of this picture -
then compare it with the stereo pair. Now let me explain what I did
on this map.

First note, this picture has been mapped exactly as in the previous
exercise by using the Linear Gradient tool, and the foreground and
background colors have been the same too.

Secondly, you clearly see the bird shadow on the depth map. Since I
would like to show the bird somewhere close to the stereo window, I
used the Eyedropper tool to pick a shade of grey from the Swatches
window that is a little bit darker than 50 % grey. Then I painted the
bird´s position on the map with that color. You may notice that the
bird shadow on this map is a bit bigger than the bird´s size on the
main picture. This is due to the fact that the Displace tool copies
the pixels on its right or left side, but doesn´t cut those
particular pixels. Therefore the original bird image won´t vanish
until a few new pixels from the background cover it. In this case, if
the bird was deeper in the picture, I would have to extend its map
more to right and left. In other words, depending on the subject
deviation or its depth location, you should extend the subject map to
the right and to the left to cover or hide the original image of your
subject. Most often you will find that your map painting doesn´t need
to be too accurate for this reason.


The third consideration: for the boats I had to find the exact shade
of grey to paint on each location on the map.

Finding a related shade is very easy.

You just need to add a new layer on your original picture,

then create a depth scale by using the Linear Gradient tool
on it. Then, using the Eyedropper tool, you can pick the related
shade of grey and paint the related subject that shade. On the
picture above, the white arrow shows where I picked the related shade
for the boat to the right. I moved the depth scale strip toward the
left side boat, then picked and used that shade too!

Finally, I had to paint or correct my map for the position of the
bird and those two boats. I have explained how I found the related
shades for each of those three subjects. For adding the new shades to
the map, I just copied my simple gradient map over the original 2D
picture, then, by reducing its opacity, I could see the position of
the bird and the boats within the map. Next, by using the Brush tool,
I painted over each subject with its particular shade of grey. After
the painting stage, I changed the map layer opacity to 100 % and
saved it as my final map in ".psd" format. 


On three exercises above I explained how the Displace tool works and
the importance of the Gradient tool for creating smooth depth paths.
For sure your 2D pictures won´t be as simple as I showed in my
exercises, but you may already have a general idea about this depth
map method. Most of the time you should use a combination of Gradient
effects and map painting. For example, if I want to map an extended
hand on a picture, I would select it by using the Lasso tool and then
I´ll add Linear Gradient shades to that particular selection with the
proper foreground and background colors. For a convex subject, I´ll
select it and then use the Radial Gradient, and so on.


This method is much better than the pixel shift method because it´s

so much faster and also the Gradient tool helps you to avoid creating

a cardboard effect on your final conversion.


You can find a few of my old conversions and their related maps on my
Flickr page under the "2D-3D conversion" folder.

Hit Counter