Search Tips

Search is based on keyword.

`Ex: "Procedures"`

Do not search with natural language

`Ex: "How do I write a new procedure?"`

Give Feedback Support Portal

# O_FocusMatcher

O_FocusMatcher attempts to correct subtle focus differences that are typically present between the left and right views of a stereo image. It does this by matching the focus distribution of one view to that of the other, based on the disparity vectors upstream.

# Inputs and Controls

Connection Type | Connection Name | Function
Input | Kernel | An optional input that allows you to change the shape of the deblur kernel. By default, the kernel is a circular disc. If the way your camera lens renders out-of-focus points of light is not circular, you can input another shape here. O_FocusMatcher then uses the luminance of this RGB image to define the kernel shape. The size of this image doesn’t matter, as O_FocusMatcher automatically resizes the image to provide the radius defined by Defocus Size. This input only has an effect if Primary Method is set to Deblur, or Rebuild Method to Rebuild Plus Deblurred.
Source | A stereo pair of images. Note: If disparity channels aren’t embedded in the images, you should add an O_Solver and an O_DisparityGenerator node after the image sequence. If occlusion masks aren’t embedded in the images, you also need an O_OcclusionDetector node after O_DisparityGenerator.

Control (UI) | Knob (Scripting) | Default Value | Function
O_FocusMatcher Tab
Views to Use | viewPair | Dependent on Source | Sets the two views whose focus you want to match. These views will be mapped for the left and right eye.
Match | matchWhat | Left to Right | Sets which view to match to the other’s focus: • Left to Right - deblur or rebuild the left view to match the right. • Right to Left - deblur or rebuild the right view to match the left.
Primary Method | primaryMethod | Rebuild | Sets how to match the focus: • Rebuild - rebuild one view using the pixels from the other. You can use the Rebuild Method control to select how to handle occluded regions where the picture building fails. Choose this method if your input images are heavily blurred or the blur varies across the image. • Deblur - deconvolve one view with the specified kernel. You can use the Deblur Options and the Kernel input to adjust the size and shape of the kernel. Choose this method if your input images are only slightly blurred and the blur is constant across the image.
Rebuild Options
Rebuild Method | rebuildMethod | Rebuild Plus Original | When Primary Method is set to Rebuild, choose how to handle occluded regions where the picture building is likely to fail. Note: You need to use an upstream O_OcclusionDetector node to define which regions are considered occluded. O_OcclusionDetector stores this information in the mask_occlusion channel. • Rebuild Plus Deblurred - use the deblurred image in any occluded regions defined in the mask_occlusion channel. You can use the Deblur Options and the Kernel input to adjust the size and shape of the deblur kernel. • Rebuild Plus Original - use the original image in any occluded regions defined in the mask_occlusion channel. • Rebuild Only - use the rebuilt image in any occluded regions defined in the mask_occlusion channel.
Match Original Colour | matchOriginalColour | enabled | When enabled, the rebuilt view has the colour profile of the original view (for example, a rebuilt right view matches the colours of the original right view). When disabled, the rebuilt view has the colour profile of the view it was rebuilt from (a rebuilt right view matches the colours of the left view).
Deblur Options
Iterations | iterations | 20 | Sets the number of times the deconvolution algorithm is run for. Increasing this value may create a sharper image but potentially at the cost of more artefacts.
Defocus Size | defocusSize | 0 | Sets the size of the kernel the image has been blurred with. This value is in pixels. It’s very important to get it right, so keep adjusting it until you get nice deblurring with sharp edges but no ringing.
Remove Ringing | removeRinging | enabled | When enabled, O_FocusMatcher attempts to reduce ringing artefacts that may appear around the edges in the image.
Ring Range | ringRange | 5 | Sets the distance from an edge (in pixels) to suppress ringing artefacts.
Ring Ratio | ringRatio | 10 | Sets the strength of a strong edge relative to a nearby ringing artefact. Decreasing this value removes more ringing artefacts, but may also stop real edges from being deblurred.

# Video Tutorials

Ocula 3.0 - FocusMatcher

OCULA 3.0 - Focus Matcher from Foundry on Vimeo.

Transcription

Welcome to Ocula from Foundry. My name is Jon and in this tutorial we're taking a look at correcting focus, using the new FocusMatcher with Ocula 3.0. Let’s look at focus matching this footage. If I switch between the left and right view, you can see the main problems are vertical alignment and colour differences. We saw how to correct this footage in the tutorial on the ColorMatcher node. If I zoom in on the background now, you can see there is a difference in focus here. We want to correct the focus of the left, to match the right view. As we saw in the ColorMatcher tutorial, you can render out the disparity and occlusions for use later on. The important thing to remember here is that we want to mark the main occlusions in the shot; you don’t want lots of isolated occlusions that could cause the corrections to flicker. If you want, you can paint in or roto extra occlusion regions.

So, let’s look at how the FocusMatcher works on this shot. You can define the Views to Use, whether to Match the focus Left to Right, or whether to update the right to match the left. You can define how it does the correction, either by rebuilding the appearance by pulling one view across over the other, or by deblurring the original without pulling across the other view. For the rebuild, you can choose how the occluded region is updated. Does it use a deblurred result, does it use the original image, or does it pull across the other view anyway? You can choose to match the rebuild image to the colour of the original view, or simply to keep the updated colour. These parameters deal with the deblurring algorithm so let’s see how deblurring works for this shot.

I am going to go and look at the correction on the background here. The first thing I need to do is find the size of the blur kernel that’s causing the defocus, so I am going to bring up the Defocus Size until the image becomes sharp, but I don’t want to over-sharpen the shot. Now, you will notice that deblurring causes ringing at strong edges. I can switch to remove that ringing (Remove Ringing). I can then set the range to pick up ringing by looking at how far apart it is in the image (Ring Range), and I can remove it by reducing the Ring Ratio until it disappears across the shot. So, here’s the corrected result and you can see the correction is only subtle. It’s still out of focus compared to the right view. Essentially, the best approach for this shot is to copy the appearance from the right onto the left, using the rebuild method. If I switch to look at the rebuild and compare left to right again, you can see that we get a better result. The focus doesn’t match perfectly though, as I am correcting the colour of the rebuild image to match the original view, which is re-introducing some of the blur from my original left view. So, I can switch this off, and now I have a good match between left and right. Now this is pulling the colour from the right to the left as well, so it’s acting as an intelligent new view, correcting colour and focus.

Here we have some nicely matched plates. We can review this using a ReConverge node. With the ReConverge, I can align the views at a particular point to make it easier to see how well the focus matches when I switch between left and right. Alternatively, you can use the StereoReview Gizmo that comes with Ocula. Here I have got it set to the Reveal tool, so I can peep through from one view to the other to see how similar they are. So, here the images look quite well-matched.

Let’s have a look at an example where you would want to use deblurring to correct defocus. If I zoom in and switch between the left and right view on this shot, you will see that the right view is out of focus. I want to correct that to match the left. So, here we have some large depth changes - there are a lot of occlusions. It’s going to be hard to calculate disparity to correctly pull the left view onto the right, to rebuild the focus to the right view. Now, we can tell this upfront by reviewing the input footage. I have got a NewView node, here, set to pull left onto right, and I am going to compare that to the original right view. You can see when we pull the pixels across, they don’t match. So, we can’t rebuild the right from the left to correct the focus.

Let’s see how deblurring works. I am going to zoom in and then I am going to adjust the Defocus Size to sharpen the image. So, this is a bit too much. This looks reasonable and let’s Remove Ringing on that. So, this is the corrected result, compared to the original. We have sharpened the focus, without having to pull the appearance across the disparity. Now, when you deblur, you can also define the shape of the aperture that caused the original defocus. You might be able to measure this, if you can find a bokeh in the shot, and trace it out with a Roto shape. You can then set this in the Kernel input of focus matcher, and it will use this as the blur kernel to deblur the image. So, here’s the deblurred result using that shape.

Let’s look at one final example to compare deblurring and rebuilding to correct focus. In this shot, the left is nicely focused, but the right is out of focus, and I want to correct that. So, first of all, let’s have a look at deblurring. I have already tuned the Defocus Size and you can see it sharpens the numbers on the plinth. If I zoom in though, you will also notice it is also sharpening the noise on the plate, so I want to Denoise first so I’m not sharpening the noise. An important thing here, when you use the NukeX Denoise tool, is to set the blend values to 1 to make sure all the noise is removed and it’s not mixing any back in. So, now I have the corrected, denoised plate, and I am free to merge back the original noise. Here we can see the original and the corrected plate, and it’s gone someway to correcting that mis-focus. However, there is quite a large blur and the best way to correct this is to copy the left view over to match the views exactly. So, let’s look at the rebuild result and you can see that we can update the focus nicely now. It should match much better when we switch between our left and our rebuilt right view, but the letters don't match perfectly. Again, this is because I have chosen to match the colour back to the original right. If I switch that off and update the colour, you can see we can match that focus really quite well. However, if I switch back to the whole image, you can see some of the problems it can introduce. Because you can’t always pull across one view onto another perfectly, you can end up distorting the image in places. So, here you may need to go back and tune the disparity to improve the rebuild, or you may have to comp together the focus correction across the plate.

That wraps up this tutorial on how to use the new FocusMatcher node in Ocula 3.0. We have seen you can render out disparity and occlusions to pull back in for focus matching. You can review with a deblur or rebuild your plate to correct the focus, and whether to pull in the colour to update focus and colour. We have looked at an example where you would use deblurring. because there are large changes in depth, and lots of occlusions, and also that you can define the blur kernel in the shot by roto-ing out the shape of the aperture and the bokeh. Finally, we have looked at comparing, deblurring, and rebuilding, taking out noise to do a deblur, and also potentially only rebuilding part of the shot to correct the focus.