120 likes | 339 Views
Combining Multiple Images with Different Focus Depths. Presented by Steven Scher sscher@ucsc.edu UCSC, CS 290b, Fall 2005. Two Images of the same scene focused at different depths. Focused Near Focused Far. Photos from Haeberli’s website.
E N D
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 FrequenciesSubtract Low From Original for High Freq’s Original Low blur Original Low High 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
Finding Focus Image 1 Image 2 Combination 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)
Example from Matlab Code Focused Near Focused Far (My own photos)
Combined Photo keeps some detail at both focus depths Focused Far Focused Near Combined (My own photos)
Papers to Look at • A Multifocus Method for Controlling Depth of Field • Paul Haeberli • http://www.sgi.com/misc/grafica/depth/index.html • Based on a previous paper • “Pyramid-based computer graphics” • Ogden, Adelson, Berger, & Burt • http://citeseer.csail.mit.edu/adelson84pyramid.html • Also discuss interpolation/extrapolation, mosaicing,
Faces (old pictures) Paul Haeberli Edward Adelson Peter Burt James Bergen Joan Ogden