Focus on Miniatures

Algorithm

In order to be as general as possible, I chose to design my miniaturization function around an algorithm which accepts an image, a depth map, and a maximum blur radius and outputs the blurred image. The value 0.5 in the depth map will be completely focused while 0.0 and 10 blur by the maximum radius. The distinction is important, as a focused object in front of a blurred one should have hard edges while a blurred object in front of a focused one should have soft edges. (Of course, the portion of the background revealed by the blur cannot actually be recovered.)

The depth map to mask out portions of the image from back to front. At each level, it progressively blurs either the background or the foreground depending on the current depth value. When blurring the background, the foreground is masked prior to blurring and then the background is masked one again after blurring. The foreground is then added back in. When blurring the foreground, the mask itself is blurred and then used to weight the addition of a blurred copy of the image and an unmodified copy. This creates a soft edge on objects in the foreground, and simulated revealing the background by simply blurring it around the object. In order to preserve image intensity at the borders and at borders of foreground and background, a white image is also blurred and used to normalize the results for each color channel.

Defining DOF

As a basic method of defining the depth of field, I allow the user to select two horizon points and a third point indicating the extent of the focused region. When selected from left to right, the portion below the points is considered to be in the foreground, though this doesn't make much difference without a complex depth map. As there are other tools which allow one to outline objects much more easily than Matlab's roipoly command, I decided not to implement the creation of complex depth maps in Matlab and instead created an option to read the depth map from a file.

Images


Original Depth Map

Original

Original

My Images


Original Depth Map

Original Depth Map

Other Images


Original Source

Original Source