Optics and Lasers in Engineering

We report on a novel computational technique for automatic numerical refocusing in digital in-line holographic microscopy. It is based on the adaptive ﬁltering of the recorded on-axis hologram to eliminate its background term and extract interference intensity-component connected with light scattered on the sample (interference fringes). Numerical propagation of such ﬁltered hologram yields the computationally generated dark-ﬁeld imaging coming from the amplitude part of the complex ﬁeld. We propose a simple measure in the form of the variance of the dark-ﬁeld gradient, which attains its maximum value in the focal planes for all types of objects (phase, amplitude and mixed phase-amplitude), as a robust indicator of overall sharpness and in-focus quality. Demonstrated novel autofocusing technique is positively validated using experimental data exhibiting signiﬁcant variation of the magniﬁcation factor for both single and double focal plane scenarios. It compares favorably with other well-established automatic numerical refocusing techniques based on the high-pass ﬁltered complex amplitude and edge sparsity, mainly in terms of higher axial resolution and better robustness to hologram low signal-to-noise ratio.


Introduction
Digital holography (DH) enables capturing and analyzing 3D object information [1][2][3] . DH is a central aspect of a myriad of modern optical examination techniques employed for, e.g., high-contrast imaging of biological samples [4][5][6][7][8] , nano-particle tracking [ 9 , 10 ], sperm cell analysis [ 11 , 12 ] and microfluidics [ 13 , 14 ], among many others. Numerical propagation of the complex optical field grants the access to the different planes of interest within the imaged volume, both in the amplitude and phase imaging. Automatic selection of the object in-focus plane in terms of determination of the propagation distance from the hologram plane is therefore of crucial importance. Thus, autofocusing techniques [15] play a pivotal role in digital holography, especially in the in-line architectures [16] as the twin image severely complicates the object volume analysis. In off-axis digital holography [17] the cross-correlation complex term (carrying object information) can be dissected in the Fourier domain [18] facilitating further calculations but, nonetheless, autofocusing methods are still vital [19] in the off-axis hologram analysis. In this contribution, without the loss of generality and versatility, we will focus on the digital in-line holography for micro-specimen examination A well-established autofocusing procedure comprises the numerical refocusing (propagation) of the recorded hologram to a set of distances and evaluating the quality ('sharpness') of the propagated field using so-called focus metrics. The distance corresponding to the maximum or minimum of the focus criterion evaluation curve is considered as the indicator of the focal plane (distance from the hologram plane to the object plane). One can distinguish several important features of the autofocusing criterion: (1) accuracy, understood as the general capacity to precisely determine the refocusing distance; (2) polarity, defined from the relation between the type of the local extremum (minimum or maximum) indicating the focal plane and the nature of the imaged object: phase or amplitude or mixed phase and amplitude. Unipolar techniques are based on searching for the single type of extremum (maximum/minimum) regardless the nature of the object (refracting and/or absorbing) and are considered as favorable because they avoid possible ambiguity in the mixed phase-amplitude sample analysis; (3) versatility, understood as the ability to correctly determine the focal plane regardless the sample nature, magnification factor (from Ozcan close-contact configuration [21][22][23][24] to Kreuzer highly-magnified setup [ 20 , 26 ]) and without the precisely selected region of interest; (4) robustness, related with the immunity to the diminished hologram signal to noise ratio (SNR). Decreased SNR can have different origins: inhomogeneous complex patterns of the coherent diffraction, speckle noise, multiple-reflection-related interference artifacts, twin-image influence, pixel saturation and underexposure etc. Hence, the spatial high-frequency content of a holographic reconstruction can be mixed with noise and might not necessarily reduce with defocusing. In this contribution we are highlighting two additional features, of crucial importance upon the numerical automatic refocusing of the experimental holograms, which are (5) axial resolution, understood as the capability to differentiate between two (or more) focal planes closely place with respect to each other (e.g., both walls of micro-chamber); (6) confluence, understood as the local density of the sample, where the low confluence indicates sparse sample and the high confluence denotes dense sample. Spatial variation of the confluence within a single focal plane can be especially cumbersome, while capacity to estimate the relative level of the confluence in several focal planes determined within the image volume stems as the particularly attractive feature of the automatic numerical refocusing method.
Hence, the impactful numerical autofocusing technique would be accurate, unipolar, versatile, robust, would exhibit high axial resolution and high degree of acceptable spatial variation of sample density, and finally would indicate on an estimate of sample relative confluence in several detected focal planes. Achieving all these attractive features with a single hologram (single-shot single-wavelength) operation while keeping the computational load and processing time at reasonably low level is a challenging task of great importance in the digital holography and DIHM.

The review of the numerical autofocusing techniques
As digital holography plays a crucial role in nowadays noninvasive 3D capturing, analysis and displaying of the information a vast number of application-specific autofocusing criteria has been already reported  . Selected ones will be briefly reviewed here; although not all methods were proposed (and applied) for DIHM they are considered here due to their capacity and impact on the digital holography, and to allow better understanding of working principle behind the different class of the numerical autofocusing schemes. Gillespie and King demonstrated autofocusing based on self-entropy of intensity valid only for amplitude objects [33] . Ferraro et al. [34] have proposed an autofocus algorithm for the digital in-line holography that tracks the axial displacement of the sample in the real time by measuring the phase shift of the hologram fringes. It is point-wise and therefore has limited robustness and versatility. Liebling and Unser [35] implemented a criterion based on the sparsity of the Fresnelet coefficients and positively verified it using the amplitude test targets. Dubois et al. employed the total (integrated) amplitude measure for pure amplitude and pure phase objects [36] . Due to the high-polarity of this approach an advancement in terms of the high-pass filtered complex-field total amplitude criterion was proposed by the same group in [37] achieving very good results. A fast method using the spectral norm was proposed by Li et al. to determine the focus plane directly in the Fourier domain of the highly magnified amplitude objects [38] . Yang et al. proposed a scanning method based on the correlation coefficient computed between two planes (with fixed separation) for the amplitude objects autofocusing [39] . Langehanenberg et al. tested four different criteria for pure-phase object study: weighted power spectrum, variance, summed gradient, and summed Laplacian [40] . Refocusing of the tilted objects, as particularly interesting case of the autofocusing with propagation distance spatially varying over the hologram area, was studied by Paturzo and Ferraro [41] and Kostencka et al. [42] . Memmolo et al. proposed to use a sparsity metric called the Tamura coefficient as an autofocusing criterion and demonstrated successful results based on the off-axis holography using macroscopic objects [43] . Following this, Memmolo et al. employed a second sparsity measure denoted as the Gini index (GI) [44] . Both metrics assume sparsity of the sample, hence can stumble upon problems while analyzing multi-focal-plane volumes of samples with locally varying confluence. Guo et al. demonstrated the setup-specific methods for automated focusing when two nonparallel beams illuminate the sample [45] and exploiting the diffraction dependence on the wavelength [46] . Other group of criteria is based on the multi-wavelength approach, taking advantage of the increased RGB information content and the synthetic wavelength approaches, e.g., works of Xu et al. [47] , Dohet-Eraly et al. [48] and Liu et al. [49] . Su et al. proposed a dual-view (dual-angle and dual-color illumination) on-chip imaging platform for the lens-free 3D tracking of sperm cells with improved axial (sub-micron localization) accuracy [50][51][52] . Trujillo and Garcia-Sucerquia developed an autofocusing method employing the enclosed energy measure for the observation of the biological specimens by the DIHM [53] with indicated ability to detect and discern more than one focal plane within the imaged volume with high axial resolution. Another method to accelerate the focus detection was presented by Toy et al. [54] for the off-axis digital holography by cropping in the Fourier domain before the reconstruction. Recently, Lyu et al. used the axial magnitude differential as another autofocusing criterion and discussed its applicability to amplitude-contrast and phase-contrast samples [55] . Zhang et al. proposed two robust autofocusing criteria based on the sparsity of the gradient -the Tamura of gradient and the Gini of gradient [56] . Moreover, approaches utilizing the notion of the deep learning for the holographic remote numerical refocusing emerged recently [57][58][59][60][61][62] , with the different level of robustness and learning needed. In our analysis we focus on the learning-free deterministic and versatile approaches, however.

The aim of the research work
In this contribution we propose the DarkFocus method -a novel scheme for an unsupervised estimation of the focal plane in the digital in-line holographic microscopy using a single-wavelength singlehologram acquisition, which exhibits all of the following advantages: (1) it is accurate, (2) unipolar, (3) versatile, (4) robust, (5) has high axial accuracy enabling multiple focal planes detection, especially under noisy conditions and spatially varying sample density, and (6) can qualitatively indicate on a relative confluence level of in focus object fraction in multi-focal-plane regime (for comparison of the sample density in different focal plane). For benchmarking we have selected two very capable reference metrics: the high-pass filtered complex amplitude [37] referred to as the Dubois method and the Tamura of Gradient referred to as the ToG method [56] . Both methods were proved superior over a great majority of the other reviewed methods in [37] and [56] , and can be advocated as the state-of-the-art, promoting the recently proposed ToG [56] . We therefore purposely resigned from considering a larger number of techniques, as it tends to blur the analysis, and adds no new information with respect to the previous works [ 37 , 56 ].
In a very informative comparative study presented in [19] two offaxis autofocusing metrics were corroborated as the most accurate and robust: the cross correlation (CC) [39] and the ratio between variances of the real and the imaginary parts (RC) [63] . They stay out of the scope of our study, however, not only due to the off-axis application. This is also because of the fact that the CC needs two images, is time consuming and has the polarity problem, whereas the RC requires two wavelengths, exhibits periodic misleading profile on a wide range of the propagation distances and most importantly is not versatile as it works well only for precisely selected region of interest (e.g., tightly enclosing single particle).
The paper is structured as follows: in Section 2 the experimental setup is described, in Section 3 we carefully introduce the novel DarkFocus metric for the automated digital refocusing in the DIHM, in Section 4 the comprehensive experimental evaluation is provided, while Section 5 discusses and concludes the paper.

Experimental setup
The experimental setup utilized for validating the proposed numerical refocusing algorithm is presented in Fig. 1 . We have used the blue (450 nm) illumination of a 4-wavelength source of the fiber-optic coupled diodes (Blue Sky Research, SpectraTec 4 STEC4-405/450/532/635nm, NA = 0.12). As an imaging sensor, a monochrome camera (Ximea USB3.0 Model MQ042MG-CM, 2048 × 2048 pixels, 5.5 μm pixel size) is employed. The digital sensor is placed at z 1 + z 2 = 300 mm away from the illumination source in order to provide uniform illumination over the whole sensor area. The magnification (M) in the DIHM is given by the following formula: We will study the polystyrene microbeads -standard monodispersive polystyrene microspheres immersed in an aqueous medium -as the calibration samples under varying experimental conditions to highlight the wide-spreading applicability of the proposed DIHM autofocusing. We selected the microbeads as technical mixed phase-amplitude samples as they do mainly refract the light just like phase objects but due to the high numerical aperture and the local field obscurity they act also like an amplitude sample.
In order to validate the approach, we have considered two different sizes of the static microbeads (Polybead Microspheres, either 45 μm or 90 μm in diameter). The beads are introduced in sparse (not clustered) mode into a counting chamber of 100 μm thickness by micro pipetting. We will not pursue high magnifications since the beads are quite large in diameter.
Single plane scenario: Two planes scenario includes two cases: Variable separation between planes: 45 μm (mean diameter) spheres are employed. The microsphere samples are placed in two different counting chambers of 100 μm thickness each one where the distance between both chambers is changed. We have considered a separation of 50 mm and 30 mm for the two studied cases. Both chambers are imaged simultaneously in the in-line configuration.
Close planes: In this case, 45 μm (mean diameter) spheres are sandwiched between coverslip-microscope slide-coverslip, so the distance between planes is around 1.1 mm, according to the thickness of the microscope slide. Distances between the sample and the CCD (z 2 ) were equal to 150 mm (M = 3X) and 100 mm (M = 1.5X).

Portrayal of the proposed DarkFocus method
The proposed novel technique for the numerical autofocusing -the DarkFocus -contains the following structure of the algorithmic procedure: (A) hologram filtering, (B) filtered hologram numerical propagation along the optical axis direction to a given z distance and calculation of the amplitude of the propagated complex field, (C) computing the focus metric DarkFocus(z) as the variance of the amplitude gradient -generally the higher the metric value the better the focus, (D) repeating steps (A)-(C) for all predefined propagation distances z deriving the automatic focusing curve.
Each step will be carefully described in the following subsections employing illustrative examples for clear demonstration of the working principle behind the devised DarkFocus autofocusing framework.

Hologram filtering
Recorded in-line hologram -intensity pattern consisting of incoherent background, coherent interference fringes and noise -is adaptively filtered by image-domain decomposition. The hologram is decoupled into several bidimensional intrinsic mode functions (BIMFs) using the enhanced and fast empirical mode decomposition (EFEMD) algorithm [64] . The EFEMD technique is based on the notion of the one-dimensional empirical mode decomposition, originally proposed by Huang et al. [65] as a capable tool for the adaptive analysis of nonstationary and nonlinear signals, later extended to 2D by Nunes et al. [66] and simplified in terms of the iteration number by Bhuyian et al. [67] . The EFEMD method adaptively dissects the multi-scale image components using the decomposition filters of varying size determined by the image local extrema distribution (data-driven approach). The EFEMD technique is applied here to decompose the in-line holograms based on the previous success in interferogram [68][69][70][71] , specklegram [72] and moiregram [73] fringe pattern analysis with specified applications in the fringe projection profilometry [74] , quantitative phase imaging [75] and interference microscopy [76] , to name only some of them. It is to be noted that, although the algorithms based on the EMD concept were already applied to the in-line particle tracking [ 77 , 78 ] (employing 1D signal processing approach [77] and the noise reduction [78] ) our contribution is the first one, to the best of our knowledge, to propose the (EF)EMD-generated computational dark-field of the in-line hologram and its application for the autofocusing.
The hologram filtering process is demonstrated utilizing an exemplifying in-line intensity distribution, Fig. 2 (a), recorded by the CCD camera after illuminating the polystyrene micro-beads with blue light. The decomposition residue (low frequency component) and two first BIMFs are presented in Figs 2 (b)-2(d), respectively. First two BIMFs are added to form the adaptively filtered background-free interference term of the in-line hologram and presented in Fig. 2 (e). We recommend, after large ensemble of trials, to extract only two first BIMFs within the filtering process, as summing up three first modes generate similar outcomes, while computation time is elongating considerably. Further increase of the number of the summed modes is risky also due to the background term leakage. Throughout this study the two mode (BIMFs) filtering will be employed, therefore, as we aim at focusing on the interference fringes coming from the optical field scattered on object to yield the dark-field upon propagation of filtered hologram. The question about the number of BIMFs to be extracted and added upon filtering can be answered in a tailored manual fashion, simply selecting the right number of modes after few trials. Other approaches offering so-called sparse decomposition can be also utilized where no decision on the number of components is needed (total fringe term is dissected as first component), e.g., the morphological operation based BEMD [79] or the Variational Image Decomposition [ 80 , 81 ]. The computation time can be severely increased up to several minutes, however, which promotes the EFEMD technique as it finished the exemplifying decomposition presented in Fig. 2 in just 0.8 s (Matlab implementation on CPU 2.6 GHz, RAM 16 GB), which is a very favorable result for 2040 × 2040px intensity pattern processing.

Numerical propagation of the hologram
The recorded and filtered in-line hologram must be numerically processed to achieve the imaging conditions by back-propagating the optical field. There are different numerical methods for the digital hologram reconstruction, mainly by solving the diffraction integral of the field propagation. Rigorous optical field propagation methods are based on the Rayleigh-Sommerfeld integral (RS) or the angular spectrum (AS) method [82] , which are efficiently numerically solved using fast Fourier transform (FFT). Both methods are well-established as properties of the RS and the AS have been thoroughly investigated in the literature [82][83][84][85] . In our study we decided to employ the angular spectrum propagation routine as it is already corroborated in lensless digital in-line holographic microscopy regime [86] . The AS is advantageous in terms of straightforward processing path resulting in low computational load and short calculation time, high efficiency especially in paraxial regime, high fidelity and good discretization.

Novel DarkFocus metric calculation
The proposed autofocusing scheme is based on calculating the amplitude of the propagated complex field yielding the computational darkfield, and then computing the variance of the dark-field gradient. Hologram pre-filtering, with the goal of generating the dark-field, augments the impact of the object-scattered interference component. This object information needs now to be brought into the plane of focus where the 'sharpness' is maximized. Gradient operation amplifies high frequency components connected with dark-field object sharpness and variance is an appropriate measure to quantitatively encapsulate them into a single value. In this spirit the DarkFocus metric (DF) is defined as: where U(z) is the complex optical field calculated after propagating the filtered hologram to the distance z, abs(U(z)) is the computational darkfield, grad is the gradient operator described below. Presented scheme ensures maximization of the DF value in the refocusing distance, indicating the plane of focus, regardless the type of specimen (phase, amplitude, mixed) as every object related interference component adds to the overall metric upon focusing. The dark-field gradient is calculated using the following basic Matlab function [ gxgy ] = gradient ( abs ( U ( z ) ) ) .
We have therefore access to the two maps of the orthogonal spatial derivatives of the computational dark-field. As dark-field itself is a single all-positive field and its two gradient maps have both negative and positive values we impose here a non-negativity constraint in terms of calculating the sum of squares of the partial spatial derivatives to obtain We finish the procedure with the variance calculation to determine the DarkFocus metric. Squaring is a nonlinear operation and this fact further increases the DarkFocus edge sharpness sensitivity and calculated variance robustness. One can also implement the L1 norm in terms of summing the absolute values of two orthogonal spatial derivatives or L2 norm in terms of the gradient modulus calculation. We tested these approaches comprehensively and cannot make a positive recommendation as they produce much noisier focus metric data.
The dark-field calculation as a part of the autofocusing metric pipeline has been proposed by Dubois et al. [37] , however the filtering was performed using the arbitrary selected complex high pass Gaussian kernel applied to the propagated complex amplitude. As emphasized in [37] the complex amplitudes need prior adequate processing to flatten the phase background and to remove the permanent defects in the field of view. This metric, termed as Dubois here and in the literature, is designed for all amplitude, phase and mixed samples yielding always minimum focus curve value in the refocusing distance. Axial-resolution can be often impeded, however, when the crucial background and defects correction is not properly applied. In comparison with the Dubois metric, our proposed DarkFocus works in the hologram domain and is robust to the not-flat phase background and defects present in the FOV. One does not need to apply any additional advanced defect removal procedure. It suggests higher robustness, versatility and accuracy of the presented DarkFocus metric in comparison with the Dubois one.
The calculation of the variance of the amplitude term of the complex field has been reported for the autofocusing purpose [40] . The goal was to minimize it in the phase object automatic focusing and to maximize it in the amplitude object focusing. Inherent polarity of this approach was cumbersome. Recently the Tamura coefficient, based on the variance and the mean value, was proposed as a sparsity measure and applied in autofocusing [43] . To enhance its performance it was merged with gradient computation prior to the Tamura coefficient evaluation, yielding the so-called Tamura of Gradient (ToG) autofocusing metric [56] . It is to be emphasized that the ToG is based on the amplitude of the complex optical field (no hologram filtering applied therefore bright field mode is explored) and it is inherently sensitive to the sharp edges assuming their sparsity [56] . The axial-resolution can be often impeded, therefore, in case of dense objects where the sparsity is limited. In comparison with the ToG metric, our proposed DarkFocus applies hologram filtering to computationally generate propagated dark-field and makes no assumptions regarding the sparsity of the focused objects. Problems of the ToG related to the confluence are envisioned. It suggests higher robustness, versatility and accuracy of the presented DarkFocus in comparison with the ToG to be verified in the following Sections and Figures.
Exemplifying dark-field distributions for the hologram ( Fig. 2 )   Visual verification positively corroborated numerical automatic calculations. Graph illustrating three autofocusing metric curves (Duboisin black, ToG -in red, and DarkFocus -in blue) is presented in Fig. 3 (g), with additional inserts facilitating qualitative evaluation of the numerical focusing accuracy. Region of interest for the inserts was selected to enclose single bead and single dust particle. Please note erroneous result of the Dubois metric clearly indicated in the misfocused insert at propagation distance 102.7 mm. The Dubois metric has problems with parasitic fringes (generated by multiple reflection based spurious interference) and big FOV analyzed in Fig. 3 encapsulating large number of microspheres and dust particles. The proposed DarkFocus and reference ToG metrics exhibit robustness to mentioned error sources providing high accuracy.
Visualizations 1, 2 and 3 appended to Fig. 3 present dynamic image sequences of the numerical refocusing of the selected region of interest in amplitude mode, darkfield mode, and gradient of darkfield mode (DarkFocus), respectively, showcasing micro-spheres and dust particles refocusing. Additionally, Visualization4 is included to present different automatic numerical refocusing of region of interest highlighting multiple beads and dust particles.
All data presented in Fig. 3 corroborate both the ToG and DarkFocus metrics and highlight inherent features of newly proposed automatic focusing evaluation scheme. The Dubois method is proved to be less accurate, however. To sum up this part of the analysis we present in Fig. 4 a block diagram for calculating the DarkFocus metric for a given propagation distance z. Please note that the procedure described in the diagram is repeated for all preselected z distances. Hologram filtering is performed only once, however.

The DarkFocus algorithm evaluation: single focal plane
The first part of the comprehensive evaluation comprises a single focal plane case. To evaluate the versatility of the proposed DarkFocus metric and compare it with the reference Dubois and ToG solutions we have recorded in-line holograms varying the sample-CCD distance in a wide range. For the presentation of the results we have chosen the following sample-CCD distances: 20mm, 50mm, 100mm, and 150mm, without the loss of generality to other "in-between " cases. Any encountered deviation between autofocusing result and precisely set manual refocusing distance can be therefore accounted for the lack of versatility and accuracy of the method -see the Dubois case already discussed in Fig. 3 . Moreover, it indicates on the limited robustness of the method as recorded holograms contain parasitic interference fringes and noise. Taking into account that focusing curves for the z = 100mm were already presented in Fig. 3 (g), we have presented in Fig. 5 the holograms and their automatic focusing outcomes for the sample-CCD distance equal to 20mm, 50mm and 150mm in Fig. 5 (a-b), Fig. 5 (c-d) and Fig. 5 (e-f), respectively.
Presented results of a single focal plane analysis allow for concluding that the Dubois metric is not versatile in terms of the region of interest selection and the transversal magnification variation. One can determine that the ToG and the DarkFocus, generating very similar outcomes, compare very favorably with the Dubois metric in terms of the versatility, robustness and accuracy, and are applicable for a wide range of the sample-CCD distances. Advantages of the ToG and DarkFocus seem to increase together with the sample-CCD distance.

The DarkFocus algorithm evaluation: double focal planes
It is often a case when the analysed object is not focused within a single plane, but instead it contains several focal planes. Special example of the multi-focal-plane object is a counting microchamber with samples, in our study microbeads, adhesively merged with both walls of the chamber. To mimic this conditions and ensure the flexibility in terms of the variable distance between both focal planes, we prepared two 100 μm thick chambers filled with 45 μm microbeads in aqueous medium.

The DarkFocus algorithm evaluation: double focal planes with large separation distance
We start this part of the algorithm evaluation by analysing the case of a largely separated planes. The distance between the point source and the CCD is 300 mm. We consider two cases of the different inter-sample distance. In the first scenario sample no.1 is placed 50 mm to the CCD and sample no.2 is placed 20 mm to the CCD. The resulting hologram is included in Fig. 6 (a). In the second scenario sample no.1 is placed 100 mm to the CCD and sample no.2 is located 50 mm from the CCD, while the resulting hologram is shown in Fig. 6 (c). Observable change of relative magnification is directly linked to the varying inter-sample distances. To check the double focal plane applicability of three selected autofocusing metrics, namely the Dubois, ToG and DarkFocus, we have calculated corresponding focusing curves and depicted them in Fig. 6 (b) and 6(d). As one can see, all three metrics provide the same focussing distances. High accuracy for the case of the large separation distance between two focal planes is thus corroborated for all three studied autofocusing metrics.
We have propagated the recorded in-line hologram into planes determined by autofocusing metrics and corroborated their accuracy, please see Fig. 7 . It is worth mentioning that in the case of largely separated planes all selected metrics provide satisfactory outcomes in terms of refocusing distance estimation. It is to be emphasized that the ToG and the DarkFocus metrics revealed, especially in the second case of 50mm separation, Fig. 7 (d), interesting ability to estimate the relative confluence of the in-focus samples in both focal planes as the ratio between autofocusing metric values. This way we can not only automatically detect the focal planes and digitally refocus the in-line hologram, additionally we acquire the important practical qualitative information of the ratio of "sample population ". This allows for the automatic selection of the dominant focal plane, or possibly estimation of the relative change in the confluence in several layers of evolving cell culture. It is the first Fig. 9. Double plane autofocusing: exemplifying reconstructed in-line holograms for very closely separated planes automatically estimated (see graphs in Fig. 8 (b)) for the 100 mm sample-CCD separation case: (a) the single focal plane estimated by the ToG, (b) the first focal plane estimated by the DarkFocus and (c) the second focal plane estimated by the DarkFocus. In-focus components can be easily observed in both planes estimated by the DarkFocus thus qualitatively corroborating its high axial resolution. time, to the best of the authors knowledge, that this qualitative feature of the automated digital refocusing metric is showcased.
We would like to note that we have performed an ensemble of trials (around 100) by imaging beads of different concentrations under different (but large in all cases) separation distances to initially corroborate the ability to estimate the confluence variation between two planes. Manual counting of the beads in each plane has been conducted by three independent operators for early validation purpose (average from 10 calculations per operator -a total average of 30 manual assessment of the number of the beads). Initial qualitative assessment showcased that the value of the metric is related to the number of sharply imaged microspheres in each plane. It is due to the fact that each object, imaged in the computational dark-field mode, adds its part to the total value of the metric, whereas this part increases with object sharpness. It is to be emphasized that in all of performed measurements both the ToG and the DarkFocus metrics were able to indicate correctly, by producing the largest metric value, on the plane with bigger concentration of in-focus objects. In future studies we will verify quantitatively the ability to measure relative confluence ratio in a function of plane separation distance and relative object occupation rate.
In the particular case presented in Fig. 7 (d) the DarkFocus metric indicates on the 0.2 value for the second focal plane, whereas the ToG calculated 0.4. Taking into account the ratio between two focal planes the DarkFocus suggests that confluence is 5 times higher in first plane, whereas the ToG indicates 'only' 2.5 higher confluence. By manually counting the number of in focus beads we can corroborate the DarkFocus result as first plane has approx. 5 times more beads. This is not a general remark, however, as more studies are yet to come. The proofof-concept of the qualitative assessment of the relative confluence level has been given, i.e., both the ToG and the DarkFocus metrics, supplied with two propagation distances, can indicate on a plane with the highest concentration of object (here microspheres).

Algorithm evaluation: double focal planes with close separation distance
Final case studied concerns two closely located focal planes. In this case, 45 μm (mean diameter) spheres are sandwiched between the coverslip -microscope slide -coverslip, so the distance between planes is around 1.1 mm, according to the thickness of the microscope slide. Following the procedure from the previous part we consider two architectures resulting in a different relative magnifications. Distances between the sample and the CCD were equal to 100 mm and 150 mm, please see resulting in-line holograms shown in Fig. 8 (a) and 8(c). To check the double closely-situated focal plane applicability of three selected autofocusing metrics, namely the Dubois, ToG and DarkFocus, we have calculated corresponding focusing curves and depicted them in Fig. 8 (b) and (d).
We have propagated the recorded in-line hologram into planes determined by the autofocusing metrics and tested their accuracy for 100mm and 150mm sample-CCD distances, please see Fig. 9 and Fig. 10 , respectively, where we depicted selected fragments of the whole FOV to increase readability. It is to be noted that two focal planes, although very closely separated, differ significantly and we can observe, both in Fig. 9 and Fig. 10 , how the DarkFocus was able to accurately estimate both of them in two studied cases. The Dubois failed by a great margin due to a severely limited axial resolution. The ToG metric managed to partially accurately estimate only the first focal plane (with induced slight "left-shift "), while missing out completely on the second one due to the limited axial resolution. The presented analysis corroborates that the DarkFocus metric compares favourably with reference techniques in terms of the autofocusing with high axial resolution. It is to be emphasized that studied samples exhibited spatially varying density of the sub-components (beads) and in these challenging conditions only proposed DarkFocus technique provided accurate outcomes. In-focus subcomponents (beads, dust) can be easily observed in each plane estimated In-focus components can be easily observed in both planes estimated by the DarkFocus thus qualitatively corroborating its high axial resolution. by the DarkFocus thus qualitatively corroborating its high axial resolution, see Fig. 9 and Fig 10 .

Discussion and conclusions
Optical imaging is considered as a central aspect of the biomedical research, medical diagnosis and various fields of engineering. Nowadays label-free imaging techniques based on a coherent holographic principles are especially of interest due to their non-invasive, non-phototoxic and quantitative nature. In our contribution we report on a novel and particularly robust numerical solution for the automatic refocusing to the sample plane investigated in the digital in-line holographic microscopy (DIHM) modality. Demonstrated novel computational technique for the automatic numerical refocusing in the DIHM is based on the adaptive filtering of the recorded on-axis hologram to eliminate its background term and extract its interference intensity-component connected with the light scattered on the sample (interference fringes). Numerical propagation of such filtered hologram yields the computationally generated dark-field imaging, expressed in the amplitude part of the complex field. We proposed in this contribution a simple and versatile measure in the form of the variance of the dark-field gradient, which attains its maximum value in the focal planes for all types of objects (phase, amplitude and mixed phase-amplitude), as an robust indicator of overall sharpness and in-focus quality. Demonstrated novel autofocusing technique is positively validated using the experimental data exhibiting significant variation of the magnification factor for a single and double focal plane scenarios. It compares favorably with other well-established automatic numerical refocusing techniques based on the high-pass filtered complex amplitude and the edge sparsity, mainly in terms of good axial resolution and robustness to the hologram low signal-to-noise ratio. For the first time, to the best of our knowledge, the indication on the autofocusing metric ability to indicate on the relative confluence between two focal planes (determining the denser one) is presented and positively evaluated. Possibility of assessing two layers of microspheres has been indicated in literature [ 87 , 88 ], however assessment of the confluence ratio was not mentioned. In [87] two holograms were required for numerical reconstruction whereas in [88] entropy is calculated as focusing metric (which works well only for amplitude objects), lens is used for imaging and the analyzed DOF is limited to 1mm. In this way presented fully lensless and single-shot DarkFocus technique differs significantly from both methods and advances studies in the field of autofocusing for digital inline holographic microscopy surpassing current state of-the-art.
The presented analysis provides a unique look into importance of the in-line hologram refocusing, while the DarkFocus expands its capabilities. Versatility of the proposed numerical solution is to be emphasized as it can enable accurate optical examination of diverse objects (with varying spatial density, magnification and with multiple focal planes). The DIHM is nowadays a well-established approach with huge potential mainly in the field-setting where compact, robust, portable and cost-effective devices are highly demanded in many technical and biological/biomedical applications. Some examples are global healthcare and point-of-care diagnosis [89] , continuous monitoring of cellular cultures inside an incubator at a controlled temperature and humidity [90] , portable microscopes with rapid and accurate diagnosis in the field setting [27][28][29][30][31][32] , in situ submersible imaging of seafloor environments and organisms [91] , as background technology for space missions and exobiological studies [92] , particle tracking (from intracellular dynamics to the characterization of cell motility and migration) [93,94] , and for 3D trajectory analysis in sperm samples [50][51][52] , among others. Hence, the proposed numerical procedure for accurate and robust autofocusing can be implemented to improve possibly previous developments in a vast range of applications.
The proposed method shares, however, the features of all stepped techniques, i.e., it needs a pre-defined range of propagation distances with a given step value (propagation sampling rate) to perform "scan-ning " and evaluation of the metric in each pre-selected z distance. It can be seen as limitation, especially in comparison with deep learning techniques, which apprehend upon extensive training how to directly estimate the distance to focal plane without any scanning nor iterations [57][58][59][60][61][62] . We would like to emphasize, however, that our approach is completely learning-free and works well for single-shot and singlewavelength holograms without any special parameter adjustments.

Declaration of Competing Interests
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
The authors declare the following financial interests/personal relationships which may be considered as potential competing interests.