Post on 21-Dec-2015
Combining Multiple Imageswith Different Focus Depths
Presented by Steven Scher
sscher@ucsc.edu
UCSC, CS 290b, Fall 2005
Two Images of the same scenefocused at different depths
Focused Near Focused Far
Photos from Haeberli’s website
Divide Image into High-Frequency & Low-Frequency Components
Low-Frequency (Blurry)
High-Frequency (Edges)
Photos from Haeberli’s website
Quick Way:Blur Each Image for Low Frequencies
Subtract Low From Original for High Freq’s
blur
Original Low High
Original Low
Photos from Haeberli’s website
Finding Focus
• For Each Pixel in the Final Image– Compare the magnitude of each High-Frequency Component
– Take the original pixel value from the image whose High-Frequency Component was higher
Photos from Haeberli’s website
Advantage of Simple Algorithm:Short Code (Matlab)
• img_names = {‘near’,’far’};• filt = fspecial('gaussian',20,1); % Make blurring filter• for i = 1:length(img_names)• img_rgb{i} = imread(img_names{i}); % Read
Images• img_gray{i} = rgb2gray(img_rgb{i}); % Make
Gray• img_blurred = imfilter(img_gray{i}, filt); % Blur• img_edges(:,:,i)= abs(double(img_gray{i}) - double(img_blurred));• end• [temp, index] = max(img_edges,[],3); % Find biggest high-freq mag• best_gray = img_gray{1}; % Combine• for i = 2:length(img_gray)• best_gray(index==i) = img_gray{i}(index==i);• end
(My own code)
Combined Photo keeps some detail at both focus depths
(My own photos)
Focused NearFocused Far Combined
Papers to Look at
• A Multifocus Method for Controlling Depth of Field– Paul Haeberli– http://www.sgi.com/misc/grafic
a/depth/index.html
• Based on a previous paper– “Pyramid-based computer
graphics”– Ogden, Adelson, Berger, &
Burt– http://citeseer.csail.mit.edu/ad
elson84pyramid.html– Also discuss
interpolation/extrapolation, mosaicing,