How to use LeiaPix with Photoshop

Share this tutorial:

Overview

Made with LeiaPix Depth Map in Photoshop

In addition to merely viewing animated images within LeiaPix you can leverage its feature-rich sharing and exporting capabilities. This guide will focus on one of these, demonstrating how to effectively integrate depth maps generated in LeiaPix with Adobe Photoshop. In photoshop you can use depth maps for various effects such as:

  • Segmentation - removing parts of the image based on depth (background, foreground and even objects in between)
  • Bokeh and Blur effects - adding blur based on depth. This simulates lens blur to produce a bokeh effect. Other blur effects can also be produced such as motion blur if we know an object at a certain distance is in motion.
  • Relighting - depth data provides valuable insights into the contours and surfaces of objects, enabling the manipulation of lighting effects. This capability can be harnessed, for instance, to replicate the play of light on a person's face from an alternative angle or to create intriguing effects like the glistening of hair through backlighting

LeiaPix

It all starts in LeiaPix.

LeiaPix Web Application

To use the content from LeiaPix in Photoshop, we need to first upload it and then export it as a depth map. To do this follow these simple steps:

1. Log in on LeiaPix

Leia Inc.
LeiaPix | Depth Animations

2. Upload an image from your device either by drag & drop or by pressing the upload button
3. Wait for image processing. Once complete a 3D animation will appear
4. Set Edge Dilation to zero:

5. Optional: Perform any depth map edits.
6. Export the Depth Map.

Hint: don’t worry about any other settings such as animation style, length, motion settings, focus at this stage as they relate to the animation you see on the screen. Feel free to play around with them, but be aware that information will be lost when exporting to a depth map and will not be relevant to our import into Photoshop.
Additional Info: To learn how to make adjustments to your depth maps prior to exporting see the General instructions for LeiaPix:
Leia Inc.
How to Use LeiaPix Features

Segmentation

The first effect we will explore is to isolate parts of the image based on distance.

Segmentation on hand of Depth Map in Photoshop

Here the depth map is used to create a mask that then allows you to selectively include and exclude items based on depth.

Step 1
Place Images
Place the base RGB image and the depth map image into Photoshop as separate layers in order shown:
Hint: you can drag and drop the images into photoshop to create these layers by dragging into the canvas area. Don’t drag into layers pane as this creates a new tab. Acknowledge each placement by clicking the apply button with checkmark symbol.
Step 2
Threshold Adjustment Layer
1. On top of the Depth Mask Image layer place a Threshold Adjustment Layer. Adjust the Threshold level. White areas will be retained in steps to follow, and black areas will be removed. This will keep items in the foreground and gradually remove items from the background with with increasing threshold values.
Hint: place a invert adjustment layer if you want to keep items in the background and remove items gradually from the foreground with increasing threshold values.
2. Create Clipping Mask for this layer so that it only applies to the layer below it. Right click on the layer and select “Create Clipping Mask”
With this we create a view that in the next step we will use to create a mask where we only retain the white areas:
View on Canvas at end of this step
Step 3
(Optional)
Guided Adjusting
It is sometimes hard to align the mask you are generating with the objects in the image unless you overlay them and view them simultaneously. To do this you can change the blending opacity to reveal some of the underlying RGB image:
1. Right click on the Depth Map Image Layer to bring up the context menu
2. Select “Blending Options…” to bring up the “Layer Style” dialogue box
3. Change the Opacity Slider to reveal as much of the underlying image as needed.
Result:
View whilst adjusting threshold value
4. Continue making adjustments as per step 2 to the threshold to align mask with desired parts of the underlying image.
5. Once you are happy with the mask outline, set opacity back to 100% to hide the underlying RGB image completely. This is important otherwise the copy paste we are about to perform in Step 4 will not work.
Step 4
Create Mask
Copy and paste this view into a new mask on the original RGB image layer
1. Select all of canvas: Menu > Select > All
2. Copy contents of canvas: Menu > Edit > Copy Merged
3. Select RGB Image layer and create Mask: Menu > Layer > Layer Mask > Reveal All
4. Select the Mask and bring it on canvas by pressing alt key and right clicking on mask thumbnail at same time.
5. Paste the contents: Menu > Edit > Paste
6. Hide Depth Map and Adjustment layer by deselecting the eye icon
Result:
View on Canvas at end of this step
Step 5
Add Background
The mask removes parts of the image and we are left with transparency. The checkerboard pattern represents the areas of transparency. We can now replace these areas with other content by placing another image or color as a layer underneath the RGB Image layer. In our example here I will simply add a white fill layer to fill the space with white, since that is what the background was originally.
1. Add a Solid Color Fill Layer: Menu > Layer > New Fill Layer > Solid Color and press okay.
2. Select the color you want and press okay
3. Move the layer to the bottom by dragging and dropping in the Layers pane
Result:
Final View in Canvas

Bokeh and Blur Effects

Next let’s explore how we can create blur in images based on distance from camera. This is of course what naturally happens with a camera lens and creates the bokeh effect. During shooting we have control of this by adjusting the aperture of the camera on location, but would it not be nice if we could adjust this retrospectively.

Method 1 - Lens Blur

Step 1
Place Images
Place the base RGB image and the depth map image into Photoshop as separate layers in order shown:
Step 2
Depth Map Channel
Create a new channel that contains the contents of the depth map:
1. Select the Depth map layer on the Layers pane
2. Select Channels Tab
3. Select and Left click any of the channels (Red, Green or Blue) and select “Duplicate Channel…” from the context menu.
3. In the Duplicate Channel Dialogue name the new channel “Depth Map Channel” and press OK.
4. Hide the new Depth Map Channel and make Red, Green and Blue visible if not already
5. Click back on the Layers Tab and hide the Depth Map Layer and select the RGB Image layer
Step 3
Lens Blur Filter
1. Create Lens Blur Filter: Menu > Filters > Blur > Lens Blur…
Hint: You can’t apply a Lens Blur to a Smart Object. If your RGB Image is a Smart Object you will need to Rasterize Layer first.
  • Blur Focal Distance: This is the distance at which you want things to be in focus based on the provided depth map. Note that you can set the focal distance automatically by clicking anywhere on the image using the Set Focal Point target tool:
  • Radius: This is the strength of blur
  • Invert: Also try with invert box ticked, as this may yield better results with Leia Depth Maps.
Feel free to experiment with other settings also.
We can also create blur effects with another camera feature - the exposure. By using long exposure we can create motion blur. Again, usually real-time decisions need to me made to get this right. What if you could also adjust this afterwards. With this technique you can.

Method 2 - Motion Blur

Step 1 - 4
Preparation
To prepare this, follow exactly the same steps to start with as outlined in Segmentation section Method 1 - Steps 1 to 4 above. Segment a part of the image you don’t want to blur.
Result:
Step 5
Blur Original Image
Now instead of placing a solid color behind the layer, we will place the original behind the layer and apply motion blur to it.
1. Select the RGB Image layer and duplicate it. Right click on the layer and from the context menu select “Duplicate Layer…”.
2. Delete the mask from the lower layer. Left click on the mask and press delete key.
3. Select the lower of the two RGB Image layers (from which you just deleted the mask) and add a motion blur filter. Menu > Filter > Blur > Motion Blur…
4. Make adjustments:
  • Angle: The direction of motion
  • Distance: The strength of blur
5. Press OK once you are happy with the adjustments you have made.
Hint: If you convert the layer to a smart object then the blur filter will not be destructive, and you can make further adjustments to the angle and distance later if you are not happy with them.

Relighting

Finally let’s explore relighting an image using depth maps. There are a number of different ways to do this but we’ll cover here one of the more impacting ways using backlighting with the associated glistening from thin hair like structures.

Method 1 - Using Emboss Filter

Step 1
Place Images
1. Place the base RGB image and the depth map image into Photoshop as separate layers in order shown below.
Hint: If your imported layer appears as “Background” you may need to untick the lock on the “Background” in order to be able to move the layer - since otherwise the background will always remain as the lowest layer and you can’t move it.
2. Ensure Depth Map Layer is a smart object. If not already you can convert it to a Smart Object by left clicking on the layer and selecting “Convert to Smart Object” in the context menu.
3. Select the RGB Image Layer and right click and select “Blending Options…” from context menu.
4. Set Blending Mode to “Screen”
Result - looks overexposed, but don’t worry, we’ll fix that:
View on Canvas at end of this step
Step 2
Emboss Filter
Add a Emboss filter to the Depth Map:
1. Select the Depth map and select Emboss filter: Menu > Filter > Stylize > Emboss…
2. Make adjustments
  • Amount: This is the strength of the embossing. The higher the value, the more the edges will emit light.
  • Height: this is the effect of widening the edges. Keep this value small to keep edges sharp.
  • Angle: this is the direction from which the light shines in the scene.
3. Press OK once you are happy with the adjustments you have made.
Step 3
Curves Adjustment Layer
1. On top of the Depth Mask Image layer place a Curves Adjustment Layer. Adjust the Curve Such that only the brightest lines remain by moving the handle at the bottom to the right as shown below.
2. Make fine adjustments by moving the handle used in step 1 above slightly left and right whilst viewing the effect on the canvas until you are happy with the result.
Result:
Share this tutorial: