Wavelet-based background and noise subtraction for fluorescence microscopy images

Fluorescence microscopy images are inevitably contaminated by background intensity contributions. Fluorescence from out-of-focus planes and scattered light are important sources of slowly varying, low spatial frequency background, whereas background varying from pixel to pixel (high frequency noise) is introduced by the detection system. Here we present a powerful, easy-to-use software, wavelet-based background and noise subtraction (WBNS), which effectively removes both of these components. To assess its performance, we apply WBNS to synthetic images and compare the results quantitatively with the ground truth and with images processed by other background removal algorithms. We further evaluate WBNS on real images taken with a light-sheet microscope and a super-resolution stimulated emission depletion microscope. For both cases, we compare the WBNS algorithm with hardware-based background removal techniques and present a quantitative assessment of the results. WBNS shows an excellent performance in all these applications and significantly enhances the visual appearance of fluorescence images. Moreover, it may serve as a pre-processing step for further quantitative analysis.

: Flowchart of the WBS/WBNS algorithm. Shown is a detailed schematic of the wavelet-based background subtraction (WBS) algorithm. If high-frequency noise is removed in addition (steps 9 -12), we denote the method wavelet-based background and noise subtraction (WBNS).
1. The input image (Python: tiff / Fiji: tiff, PNG, JPEG etc.) is loaded and converted to single precision (32 bit). Slices of an image stack are processed individually. Two parameters, the number of levels assigned as noise and the resolution parameter R are requested. R is given by the full width at half maximum of the PSF in pixel units, rounded to the next larger integer. 2. The image is converted to a new representation by decomposition into a set of coefficients using the discrete Haar wavelet transform. By applying a high-pass filter (defined by the Haar wavelet) and subsampling by a factor of two, the so-called "detail coefficients" are obtained, capturing the highest frequencies of the image. Application of a low-pass filter (quadrature mirror filter to high-pass) and subsampling yields the so-called "approximation coefficients" representing the low-frequency content. This procedure describes a single level of decomposition. 3. To extract and distinguish lower frequencies, the decomposition described in step 2 can be applied to the approximation coefficients of step 2. The approximation of level 1 is split into the approximation and details of level 2. 4. This procedure can be applied iteratively log 2 (n) (rounded to the nearest smaller integer) times, where n is the width/height of the input image in pixels, resulting in a multiresolution representation of the input image. In practice, the process is stopped at a level associated with wavelet decomposition on the spatial scale of the signal content, which is roughly given by log 2 (R), rounded to the next larger integer. 5. For (low-frequency) background extraction, the detail coefficients of the levels that contain high frequency information (characteristic length of the PSF or smaller) are set to zero. 6. The image is reconstructed from the modified wavelet coefficients by running the decomposition algorithm in reverse, which means applying the conjugate high-pass and low-pass filters to the approximation and detail coefficients. 7. The reconstructed image is filtered by a Gaussian filter with a standard deviation of 2 m , where m is the number of levels, smoothening discontinuities originating from the use of the (discontinuous) Haar wavelet. 8. The estimated background is subtracted from the input image; negative pixel amplitudes due to Gaussian filtering are set to zero. 9. The wavelet coefficients of the first decomposition level (step 2) are used to reconstruct an image containing only high frequency noise. 10. To this end, the approximation coefficients of the first level are set to one to create a flat background. The reconstructed image contains only high-frequency components, corresponding to spatial scales smaller than the width of PSF. 11. The noise image is corrected for outliers that may appear in bright regions of the image. Pixel values that exceed a threshold of 2σ (twice the standard deviation) are set equal to the threshold; negative numbers are set to zero. 12. The noise image is subtracted from the background-corrected image; negative numbers in the result are set to zero. 13. The pixel intensities are converted to the same precision as the input image before the image is saved.      Consequently, the border between image and background is shifted to lower frequency, so that lower-frequency components are correctly assigned to image content and not removed as background. (j, k, l) Images of the top row processed with WBNS using R = 27. The even lower cut-off retains low-frequency image components in panels (j) and (k) but is no longer effective in background suppression in panel (l). Scale bar, 100 µm.

Supplemental Note 1: Software Guideline for the Python Implementation
System requirements: The software was tested on workstations running under Microsoft Windows 7 and Windows 10. Only standard hardware is required. Adequate random access memory (RAM) is needed to process large data sets. Python version 3.7 was installed and we used the python distribution Anaconda 3 and Spyder 4 as python editor.

Installation:
The software is provided as a python script. Therefore, a python distribution (e.g. Anaconda 3) must be installed on the PC together with the following packages: Using Anaconda, the packages can be installed by typing conda install "package" or pip install "package" into the IPython console. Installation of the packages may take up to 10 min.

Usage:
-Open WBNS.py in your python editor (e.g., Spyder 4) -In the top section of the script, insert file location and file name of the image data (TIFF format). -Input the resolution parameter R (in pixel units).
-Set the noise level parameter (number of levels used to extract noise). The default is "1". However, for low resolution images, "2" may yield better results. -Run the script.
-Processed images will be saved in TIFF format in the same folder as the input data.
The resolution and noise level parameters are given in the "..._INFO.txt" file. Typical execution times for 3D demo data (Simulation_Microtubules_3D.tif) are 7 s on a computer with Intel(R) Core(TM) i7-8700K CPU; 32 GB RAM, and 21 s on a computer with Pentium(R) Dual-Core CPU E5700; 6 GB RAM.