File Exchange

## Extended depth-of-field

version 1.0.0.0 (5.51 MB) by
Generate low-noise extended depth-of-field image from focus sequence

Updated 27 Jan 2016

This function generates an extended depth-of-field image (also referred to as all-in-focus image) from a focus sequence using the noise-robust selective all-in-focus algorithm [1]. Input images may be grayscale or color. For color images, the algorithm is applied to each color plane independently. For a demo, just type 'fstackdemo' at the matlab prompt.
References:
[1] Pertuz et. al. "Generation of all-in-focus images by noise-robust selective fusion of limited depth-of-field
images" IEEE Trans. Image Process, 22(3):1242 - 1251, 2013.

### Cite As

Said Pertuz (2021). Extended depth-of-field (https://www.mathworks.com/matlabcentral/fileexchange/55115-extended-depth-of-field), MATLAB Central File Exchange. Retrieved .

Z Hu

@S Pertuz Thank you very much for the reply. Got it. However, after those two lines Index1 is the same as Index3.
Should it be
Index1(I(:)<=STEP) = Index3(I(:)<=STEP);
Index3(I(:)>=P- STEP) = Index1(I(:)>=P-STEP)? Or it doesn't matter? I see no big changes before or after I changed the line.

Said Pertuz

Hi, @z hu, those steps are necessary to account for extreme points, for instance when the peak is too close to the beggining or the end of the sequence we simply mirror the values around the peak.

Z Hu

Thank you for sharing. Learned a lot. The focused image quality is really great. Two lines I don't understand
Index1(I(:)<=STEP) = Index3(I(:)<=STEP);
Index3(I(:)>=STEP) = Index1(I(:)>=STEP);

This make s Index1 == Index3;
Although I commented those two lines, the quality in some area is bad.
could you let me know the reason of using the two lines ?

Takuji Fukumoto

Robert Klose

Ilya Belevich

Said Pertuz

The focus parameter can be either a set of values corresponding to the focus distance of each image or a dummy variable with sequential number (e.g., [1,2,3,...])

harjatin baweja

Thank you for this implementation. I had a quick question. If I just have the focal lengths at which images were collected. Can I still use the 'focus' parameter ?

David Niles

##### MATLAB Release Compatibility
Created with R2015a
Compatible with any release
##### Platform Compatibility
Windows macOS Linux