Skip to content Skip to navigation


You are here: Home » Content » Mask Finding and Scaling


Recently Viewed

This feature requires Javascript to be enabled.

Mask Finding and Scaling

Module by: Cathy Huang. E-mail the author

The PSF is effectively the impulse response in the optical domain. If we try to describe a system with an incorrect impulse response, the output is not true. Accordingly, every plane at a particular depth has its own impulse response, or PSF in this case. The size or scale of a PSF corresponds to a particular plane of focus in space and a blurred image is effectively captured when a lens is focused at a depth that does not correspond to the plane in which the object exists. This is the same situation we recreate when we capture our blurred images.

For these reasons it is important that we obtain not only an exact replica of the PSF used to capture the blurred image, but also the exact scale for the depth of the captured image. An incorrect PSF yields less than desirable results and after experimenting with various techniques we developed two methods for generating the PSF for a given mask and depth in MATLAB: manual construction of the matrix and a search algorithm.

Hand Mask

schematics schematics schematics
Original Matrix of Scale 1 is transformed to a Matrix of Scale 2.

When the distance from the camera to the object is unknown, manual construction of a mask is preferred. The small size of this method allows the mask to be scaled easily as shown above so that the appropriate PSF for a given distance can be searched. The masks are represented by an N-by-N matrix, where every black block is marked as a 0 and every transparent block is marked as a 1.

The simplicity of this method is appealing and provides decent results. One of the main drawbacks to creating the matrix manually is that the actual mask hardly ever appears exactly in the image. For example, the corners of our masks are rounded by the camera aperture. We are able to compensate for this by reducing the intensity of the corner entries in our matrix to about 0.5. A second drawback is that rotations in the placement of the mask in the camera reduce the effectiveness of our manually constructed matrix.

Auto Mask

schematics schematics
Captured PSF (Left) and resulting mask (right) using Automask.

After capturing an image of the appropriate PSF for the depth at which our object exists, we isolate the PSF in MATLAB. First the PSF image is converted to black and white. Given the simplicity of our algorithm, it is necessary to apply some smoothing to this black and white image. After, it is cropped and reproduced automatically using a 0-1 search algorithm, yielding a high-resolution matrix of the appropriate PSF. This method eliminates the need for scaling and much of the rigor required to create the PSF manually, such as aligning the mask exactly. Overall the mask that is recovered by this method is truer to the actual mask and results in better deblurring.

Then What?

Once a PSF is obtained, either by Hand Mask or Auto Mask, we can deblur using the blurred image, the PSF, and the Richardson-Lucy Deconvolution Algorithm.

Content actions

Download module as:

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens


A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks