## 1.

## Introduction

Automatic autofocusing (AF) in digital microscopy is highly dependent on the sample topography variability and also its color distribution. As stated by Qu et al.,^{1} different focus criterion functions perform quite differently even for the same sample. The majority of these methods have been addressed to study AF in the context of monochromatic frames.^{2}^{–}^{5} Furthermore, many works have been published that present a comparative evaluation of the performance of these kinds of AF techniques.^{6}^{–}^{8} Some research has determined that the best AF metric is based on the Brenner function;^{2} other research gives priority to the variance,^{9} Vollath-4,^{10}^{–}^{12} or the sum-modified-Laplacian,^{13} among other methods.

In the case of the RGB space, few works for AF have been reported.^{14}^{,}^{15} In addition, the effectiveness of the AF algorithms depends on the color space selection wherever the numerical computation is done.^{16} To avoid it, a wavelet-based technique for converting multichannel (e.g., color) data to a single channel by principal components analysis has been reported for this task;^{17} unfortunately, it is computationally intense.

In this paper, we propose an extension of the procedures currently used to digitally compute focus measure in the monochromatic version of an image; these techniques now will be utilized for color images with an adjustment of the AF algorithms through the modulus of the gradient of the color planes (MGC) operator.^{18}^{–}^{20} Hence, it is possible to improve the performance of a large quantity of AF algorithms since all of them are capable of indicating a focused slice from the MGC image. Even more, because first derivative methods can be efficiently implemented in GPUs, the MGC algorithm can work in parallel.

In widefield microscopy, it may be possible to focus the transverse sections that are placed at the depth of field (DOF) of the objective lens. To record the three-dimensional (3-D) volume, it is necessary to axially scan the sample. Additionally, an extra difficulty arises: the DOF of the optical objectives decreases when the numerical aperture (NA) increases. It abruptly produces blurry images in the portion of the object that lies outside of the DOF.

A common approach to digitally extend depth of field (EDoF) is by the use of a digital image fusion scheme. Typically, the image fusion schemes select the in-focus pixels along the $z$-axis to reconstruct an all-in-focus composite image. Due to the high computational effort, these methods have been implemented in parallel computer systems such as clusters and GPUs.^{21}^{–}^{23} In this work, a parallel implementation in GPU of a pixel-by-pixel image fusion of multifocus color images based on MGC is done. According to the image quality metrics, the proposed method is competitive to merge these kinds of images. The 3-D visualization of the in-focus images verifies the fusion results.

This work is organized as follows: in Sec. 2, the MGC transformation for multichannel to grayscale frames is briefly reviewed, and the AF functions and image fusion technique used in this paper are analyzed. In Sec. 3, the procedure for acquiring the different $z$-stacks of digital images is described. In this research, human and animal tissue samples have been employed as test objects to prove the proposed algorithms. The human tissue samples were prepared by Mikroskope. Net^{24}, and the animal tissue came from the Human Connective Tissues Microscope Slide Set.^{25} In Sec. 4, the AF and fusion results of the experiments, which we conducted to evaluate the algorithms are presented. Finally, the conclusions of the work are presented in Sec. 5.

## 2.

## Mathematical Methods

## 2.1.

### Multichannel Conversion to a Grayscale Image

In the RGB space, the red, green, and blue components of a vector are commonly related to the pixels of an RGB image of size $M\times N$. They can be represented by $C(x,y)$, as in the following equation:

where $R(x,y)$, $G(x,y)$, and $B(x,y)$ are the RGB space channels and $\widehat{i}$, $\widehat{j}$, $\widehat{k}$ are the unitary vectors, respectively.Typically, a compound gradient image ${g}^{c}(x,y)$ is determined by^{18}^{,}^{19}

In general, the modulus of the gradient of the color planes ${g}^{c}$ is computed using the Euclidean distance,^{20} as follows:

## Eq. (3)

$${g}^{c}(x,y)=\sqrt{\sum _{i=1}^{\text{band}}\{{\left[\frac{\partial C(x,y,i)}{\partial x}\right]}^{2}+{\left[\frac{\partial C(x,y,i)}{\partial y}\right]}^{2}\}},$$Conventionally, the partial derivative along the $x$-axis of a two-dimensional function $C(x,y,i)$ can be numerically approximated as $\frac{\partial C(x,y,i)}{\partial x}\approx C(x+1,y,i)-C(x,y,i)$. Likewise, the partial derivative along the $Y$-axis is given by $\frac{\partial C(x,y,i)}{\partial y}\approx C(x,y+1,i)-C(x,y,i)$.

In color image processing, the gradient is commonly used as a procedure of color edge detection. Therefore, the modulus of the gradient of the color planes is a sharp image, which can be computed using the equation

## Eq. (4)

$${g}^{c}(x,y)={[\sum _{i=1}^{\text{band}}{[C(x+1,y,i)-C(x,y,i)]}^{2}+\sum _{i=1}^{\text{band}}{[C(x,y+1,i)-C(x,y,i)]}^{2}]}^{1/2}.$$In addition to the RGB space, color images are also processed in the hue, saturation, and intensity (HSI) color space, because it is a suitable model for color description and analysis. The HSI space is modeled as a double cone where hue represents the dominant color, saturation represents the purity of the color, and intensity represents the brightness, respectively. As stated by Gonzalez and Woods,^{26} this model decouples the intensity component from the color-carrying information (hue-saturation) in a color image. The intensity channel is an essential descriptor of monochromatic images, and it is classically used for multichannel conversion to a grayscale image. The difference measurement when working in the HSI color space is modified as established by Koschan and Abidi.^{18}

In this work, the multichannel conversion to a grayscale image has been done by means of the MGC operator as is shown in Fig. 1. As the MGC operator is a color edge detection technique for digital images, the MGC(RGB) and MGC(HSI) matrices show the high spatial frequency content of the input color images. Thereby, this makes it suitable for finding focused regions.

## 2.2.

### Autofocus Methods

In the literature, there exist some comparisons about the performance of AF algorithms.^{4}^{,}^{6}^{,}^{8}^{,}^{9}^{,}^{12} Each algorithm is capable of producing a figure of merit (FM) that is analyzed by taking into account the global or local variance in the image intensity values $f(x,y)$. Customarily, the AF algorithms can be classified into five groups according to their mathematical nature: derivative-based algorithms,^{27}^{,}^{28} statistical algorithms,^{10} histogram-based algorithms,^{6}^{,}^{12} intuitive algorithms,^{9} and image transformations-based algorithms.^{3} Throughout this paper 15 AF algorithms, which have been widely reported in the literature, are tested and compared using the MGC images. This task was carried out to improve the performance of AF algorithms. Table 1 summarizes the definitions of the most typical AF metrics defined in the new approach, namely the MGC transformation. The output of an ideal AF algorithm is commonly defined as having a maximum value in relation to the best focused image position. Moreover, this value clearly decreases as defocus increases. As noted by Tian,^{3} the fundamental requirements for an FM are unimodality and monotonicity, which ensure that the FM has only one extreme value and is monotonic on each side of its peak or valley. Furthermore, Redondo et al.^{4} defined the number $\eta $ of local maxima, the width of the focus curve $\alpha /\beta $ given by the width of the focus curve at 80% and 40%, and noise/illumination invariance as important features of the autofocus curve. Another complementary characteristic of the AF algorithms is their accuracy and fast response. To evaluate the AF performance (AP) of each AF algorithm, the following score is proposed:

## Table 1

AF algorithms rewritten in terms of the modulus of the color gradient operator gc(x,y).

A. Derivative based algorithms | Brenner gradient (BG) | Thresholder absolute gradient (TAG) |

$\sum _{x=0}^{M-3}\sum _{y=0}^{N-1}{[{g}^{c}(x+2,y)-{g}^{c}(x,y)]}^{2}$ | $\sum _{x=0}^{M-2}\sum _{y=0}^{N-1}|{g}^{c}(x+1,y)-{g}^{c}(x,y)|$ | |

if ${[{g}^{c}(x+2,y)-{g}^{c}(x,y)]}^{2}\ge \in $ | if $|{g}^{c}(x+1,y)-{g}^{c}(x,y)|\ge \in $ | |

Squared gradient (SG) | Energy Laplace (EL) | |

$\sum _{x=0}^{M-2}\sum _{y=0}^{N-1}{[{g}^{c}(x+1,y)-{g}^{c}(x,y)]}^{2}$ | $\sum _{x=0}^{M-1}\sum _{y=0}^{N-1}{[{g}^{c}(x,y)*\mathrm{Lap}(x,y)]}^{2}$ | |

if ${[{g}^{c}(x+1,y)-{g}^{c}(x,y)]}^{2}\ge \in $ | $\mathrm{Lap}(x,y)=-[\mathrm{1,4},1;4,-\mathrm{20,4};\mathrm{1,4},1]$ | |

Tenenbaum gradient (TG) | ||

$\sum _{x=0}^{M-1}\sum _{y=0}^{N-1}\mathrm{TG}(x,y)$ | ||

$\mathrm{TG}(x,y)={[{g}^{c}(x,y)*S(x,y)]}^{2}+{[{g}^{c}(x,y)*S{(x,y)}^{T}]}^{2}$ | ||

$S(x,y)=[\mathrm{1,0},-1;\mathrm{2,0},-2;\mathrm{1,0},-1]$ | ||

Spatial frequency (SF) $\sqrt{{(\mathrm{RF})}^{2}+{(\mathrm{CF})}^{2}}$ | ||

$\mathrm{RF}=\sqrt{\frac{1}{MN}\sum _{x=0}^{M-1}\sum _{y=0}^{N-2}{[{g}^{c}(x,y)-{g}^{c}(x,y+1)]}^{2}}$ | ||

$\mathrm{CF}=\sqrt{\frac{1}{MN}\sum _{x=0}^{M-2}\sum _{y=0}^{N-1}{[{g}^{c}(x,y)-{g}^{c}(x+1,y)]}^{2}}$ | ||

B. Statistical algorithms | Variance ($V$) | Autocorrelation ($V4$) |

$\frac{1}{MN}\sum _{x=0}^{M-1}\sum _{y=0}^{N-1}{[{g}^{c}(x,y)-\mu ]}^{2}$ | $\sum _{x=0}^{M-2}\sum _{y=0}^{N-1}[{g}^{c}(x,y){g}^{c}(x+1,y)]-\sum _{x=0}^{M-3}\sum _{y=0}^{N-1}[{g}^{c}(x,y){g}^{c}(x+2,y)]$ | |

$\mu =\frac{1}{MN}\sum _{x=0}^{M-1}\sum _{y=0}^{N-1}{g}^{c}(x,y)$ | ||

Normalized variance (NV) | Standard deviation-based correlation (V5) | |

$\frac{1}{MN\mu}\sum _{x=0}^{M-1}\sum _{y=0}^{N-1}{[{g}^{c}(x,y)-\mu ]}^{2}$ | $\sum _{x=0}^{M-2}\sum _{y=0}^{N-1}[{g}^{c}(x,y){g}^{c}(x+1,y)]-MN{\mu}^{2}$ | |

C. Histogram-based algorithms | Entropy algorithm (EA) | Squared minimum (SM) |

$-\sum _{l}[{P}_{l}\text{\hspace{0.17em}}{\mathrm{log}}_{2}({P}_{l})]$ | $-\sum _{l=1}[{P}_{l}^{2}-\frac{1}{L}]$ | |

${P}_{l}=h(l)/MN$ | $l=0..L-1$; $L=256$ | |

D. Intuitive algorithms | Thresholder content (TC) | Power square (PS) |

$\sum _{x=0}^{M-1}\sum _{y=0}^{N-1}[{g}^{c}(x,y)]$; if $[{g}^{c}(x,y)]\ge \epsilon $ | $\sum _{x=0}^{M-1}\sum _{y=0}^{N-1}{[{g}^{c}(x,y)]}^{2}$; if ${[{g}^{c}(x,y)]}^{2}\ge \epsilon $ | |

E. Image transformations based algorithms | Midfrequency-DCT (MDCT) | |

$\mathrm{MDCT}=\sum _{x=0}^{M-1}\sum _{y=0}^{N-1}{[{g}^{c}(x,y)*O(x,y)]}^{2}$ | ||

$O(x,y)=[\mathrm{1,1},-1,-1;\mathrm{1,1}-1,-1;-1,-\mathrm{1,1},1;-1,-\mathrm{1,1},1]$ |

## 2.3.

### Multifocus Image Fusion

As mentioned previously, any microscopic imaging system can only focus the field of view (FOV) of the sample that is inside the DOF of the objective lens. This means that only certain axial planes of the sample are in-focus. A current solution to this drawback is a multifocus image fusion to reconstruct an all-in-focus image of the complete FOV for a particular specimen. This can be done by capturing images of the sample on different focal axial planes. In this section, a color image fusion scheme based on the MGC method is proposed as shown in Fig. 2.

Let ${C}_{z}(x,y,i)$ be a set of input images, where $z=\mathrm{1,2},\dots ,Z$. The index $i=\mathrm{1,2},3$ is related with the channel/band used. For each axial plane, Eq. (2) is computed to create a compound gradient image and then for each pixel $(x,y)$ the maximum value is selected using $\mathrm{sap}(x,y)={\mathrm{max}}_{z}\{{g}_{1}^{c}(x,y),\cdots {g}_{Z}^{c}(x,y)\}$. In other words, the $\mathrm{sap}(x,y)$ matrix denotes the slice axial position of in-focus pixels along the $z$-axis. A postprocessing stage involves a spatial consistency algorithm.^{17} This postprocessing is carried out by means of a low pass filtered $\tilde{\mathrm{sap}}(x,y)$ matrix using a $p\times q$ median filter. This algorithm ensures that the majority of the intensity pixels in a $p\times q$ neighborhood of $\tilde{\mathrm{sap}}(x,y)$, come from the same $z$-slice or from the closest one. For example, the spatial consistency of the $\tilde{\mathrm{sap}}(x,y)$ matrix is shown in Fig. 3. Figure 3(a) contains three $p\times q$ neighborhoods, where the value of the slice axial position is higher than its neighbors. Figure 3(b) shows these values adjusted to match the values of the $p\times q$ neighborhood of $\tilde{\mathrm{sap}}(x,y)$ to conserve the continuity of the surface of the sample.

To avoid the introduction of artificial information, the fused image $\mathrm{\varphi}(x,y,i)$ is composed from the (multichannel) pixels that are present in the original input data ${C}_{z}(x,y,i)$, only if the slice position fulfills the condition $z\in \tilde{\mathrm{sap}}(x,y)$ for each pixel $(x,y)$. Therefore, a multifocus image fusion algorithm can be defined as follows:

Schematically, the proposed image fusion procedure is shown in Fig. 2. As can be seen, the fused image $\mathrm{\varphi}(x,y,i)$ is composed of the sharp regions provided by the in-focus pixels of the input color images. To accelerate the numerical computation, the fusion process is migrated to GPU.The resulting fused images are evaluated with a nonreference image quality metric based on measuring the anisotropy of the images. The anisotropic quality index (AQI) of an image $\mathrm{\varphi}(x,y,i)$ is given by^{29}

## Eq. (7)

$$\mathrm{AQI}(\mathrm{\varphi})=\sqrt{\sum _{s=1}^{S}{[{\mu}_{\mathrm{\varphi}}-R(t,{\theta}_{\mathrm{\varphi}})]}^{2}/S},$$^{29}

## 2.3.1.

#### Simulated data

For testing purposes, a simulated stack of 20 frames is constructed from a color image of $2584\times 1936\text{\hspace{0.17em}\hspace{0.17em}}\text{pixels}$. Figure 2(a) shows some digitally defocused slices using the software package extended EDoF plug-in.^{17} Each blurred image was obtained by convolving an image with a Gaussian point spread function (PSF) with increasing width. The 3-D visualization of the resulting in-focus image using the fused scheme of Eq. (6) is sketched in Fig. 2(d). Their spatial consistency of the $\tilde{\mathrm{sap}}(x,y)$ matrix is shown in Fig. 3. In addition, the results of the AQI of the fused image and the normalized mean square error (NMSE)^{30} between the original image and the merged image are shown in Table 2.

## Table 2

Image quality assessment of in-focus images.

Metrics | In-focus image ϕ(x,y,i) | In-focus image using EDoF plug-in31 |
---|---|---|

AQI | 0.0675 | 0.0240 |

NMSE^{30} | 0.1955 | 0.5462 |

## 3.

## Image Acquisition of Histological Samples

A motorized Axio-Imager-M1 optical microscope system manufactured by Carl Zeiss is used to image the histological samples and to capture their color digital images. Some examples of these kinds of tissue samples are shown in Fig. 4. These microscopic objects are imaged using bright-field illumination in the optical microscope system. The microscope incorporates an AxioCam Mid Range Color camera of 5 megapixels with an image resolution of $2584\times 1936\text{\hspace{0.17em}\hspace{0.17em}}\text{pixels}$, a chip size of $8.7\text{\hspace{0.17em}\hspace{0.17em}}\mathrm{mm}\times 6.6\text{\hspace{0.17em}\hspace{0.17em}}\mathrm{mm}$, a pixel size of $3.4\text{\hspace{0.17em}\hspace{0.17em}}\mu \mathrm{m}\text{\hspace{0.17em}\hspace{0.17em}}\times \text{\hspace{0.17em}\hspace{0.17em}}3.4\text{\hspace{0.17em}\hspace{0.17em}}\mu \mathrm{m}$, and a spectral range of 400 to 710 nm. Furthermore, as part of the optical microscope device, an $x$ to $y$ mechanical platform and a motorized stage are integrated to control the focus movements along the $z$-axis. From Table 3, it is evident that interplanar distance $\mathrm{\Delta}Z$ between different optical sections is determined by the NA of the objective lens.

## Table 3

Specifications of the EC plan-Neofluar objective lenses (Carl Zeiss microscopy, retrieved from Ref. 32) employed during image acquisition.33,34

MT | NA | DOF (μm) nλ(NA)2 | Lateral resolution d=0.61λ/NA (μm) |
---|---|---|---|

$2.5\times $ | 0.075 | 97.64 | 4.47 |

$10\times $ | 0.30 | 5.97 | 1.11 |

$40\times $ | 0.75 | 0.812 | 0.44 |

$100\times $ | 1.3 | 0.212 | 0.25 |

## 4.

## Results and Discussions

## 4.1.

### Focusing Results

To obtain a performance evaluation of the 15 AF techniques on the MGC images, six $z$-stacks of 21 multichannel images are recorded using two histological samples. Each stack has a particular color that is highly dominant as shown in Fig. 4. This allows us to evaluate the MGC method for different color distributions and amplifications inside of the digital image.

Case I: Figures 5 and 6 show the focus measure graphs for a $z$-stack of images obtained from the human carotid tissue amplified at $2.5\times $ and $40\times $, respectively. According to the focus measure curves, the MGC image turns out to be a suitable space for AF measurements because all the FM decrease monotonically as the defocus increases. Also, the focus curves of all the AF algorithms show a monotonic behavior, a single local maxima $\eta $, a narrow width $\alpha /\beta $, and they achieve the highest performance.

Case II: Figure 7 shows an elastic cartilage sample amplified at $2.5\times $, $10\times $, $40\times $, and $100\times $. From this histological sample, four $z$-stacks of frames are acquired. Every RGB image is transformed into the MGC space to measure the focusing. As can be seen, when the objective lens is modified, it is necessary to modify the illumination intensity over the sample, which causes the color distribution to change. Data are processed and the results are graphed in Fig. 8.

Some research^{4} has reported that beyond a magnification of $63\times $, the performance of the various AF metrics is drastically impaired. According to results shown in the graphs of Fig. 8, when using the MGC approach all the FM curves present monotonic behavior, even when the magnification is increased to $100\times $ (oil immersion). This last experimental result supports the advantage of a color-to-MGC space transformation. Nevertheless, a problem arises when images of a sample of thickness $t\ge \mathrm{DOF}$ are acquired at a magnification of $100\times $. There exist portions of the image partly in focus. In the graphs of Fig. 8(d), two regions in focus located at $z=0$ and $z=6\text{\hspace{0.17em}\hspace{0.17em}}\mu \mathrm{m}$ can be seen. According to the results given in Tables 4 and 5, all the AF measures realized in the MGC space are accurate in spite of the different magnifications, unlike some typically used channels for focus measure.

## Table 4

Autofocusing Performance AP of all metrics in different grayscale channels and MGC images. The mean and standard deviation of AP is given in bold.

Elastic cartilage magnified at 40× | ||||||
---|---|---|---|---|---|---|

L (CieLab) | Brightness (YIQ) | Value (HSV) | Intensity (HSI) | MGC (RGB) | MGC (HSI) | |

EL | 0.7 | 1 | 1 | 1 | 1 | 1 |

TAG | 1 | 1 | 1 | 1 | 1 | 1 |

SG | 1 | 1 | 1 | 1 | 1 | 1 |

BG | 1 | 1 | 1 | 1 | 1 | 1 |

EA | 1 | 1 | 0.9 | 0.9 | 1 | 1 |

SM | 1 | 1 | 0.9 | 0.9 | 1 | 1 |

PS | 0.7 | 0.9 | 0.9 | 0.9 | 1 | 1 |

V-4 | 1 | 1 | 1 | 1 | 1 | 1 |

V-5 | 0.7 | 1 | 0.9 | 0.9 | 1 | 1 |

V | 1 | 1 | 0.9 | 1 | 1 | 1 |

VN | 1 | 1 | 1 | 1 | 1 | 1 |

TG | 1 | 1 | 1 | 1 | 1 | 1 |

MDTC | 0.7 | 1 | 1 | 1 | 1 | 1 |

SF | 1 | 1 | 1 | 1 | 1 | 1 |

TC | 0.7 | 1 | 1 | 1 | 1 | 1 |

$\mu (\mathrm{AP})$ | 0.90 | 0.99 | 0.97 | 0.97 | 1 | 1 |

$\sigma (\mathrm{AP})$ | 0.14 | 0.02 | 0.05 | 0.04 | 0 | 0 |

## Table 5

Autofocusing Performance AP of all metrics in different grayscale channels and MGC images. The mean and standard deviation of AP is given in bold.

Elastic cartilage magnified at 100× | ||||||
---|---|---|---|---|---|---|

L (CieLab) | Brightness (YIQ) | Value (HSV) | Intensity (HSI) | MGC (RGB) | MGC (HSI) | |

EL | 1 | 1 | 0.9 | 0.6 | 1 | 1 |

TAG | 1 | 1 | 0.9 | 0.8 | 1 | 1 |

SG | 1 | 1 | 1 | 1 | 1 | 1 |

BG | 1 | 1 | 1 | 1 | 1 | 1 |

EA | 1 | 0.9 | 0.9 | 1 | 1 | 1 |

SM | 1 | 0.9 | 0.9 | 0.9 | 1 | 1 |

PS | 0.8 | 0.8 | 0.8 | 0.8 | 1 | 1 |

V-4 | 1 | 1 | 1 | 1 | 1 | 1 |

V-5 | 0.8 | 1 | 1 | 0.9 | 1 | 1 |

V | 1 | 1 | 1 | 1 | 1 | 1 |

VN | 1 | 1 | 1 | 0.8 | 1 | 1 |

TG | 1 | 1 | 1 | 1 | 1 | 1 |

MDTC | 1 | 1 | 1 | 1 | 1 | 1 |

SF | 1 | 1 | 1 | 1 | 1 | 1 |

TC | 0.8 | 0.6 | 0.6 | 0.6 | 1 | 1 |

$\mu (\mathrm{AP})$ | 0.96 | 0.95 | 0.93 | 0.89 | 1 | 1 |

$\sigma (\mathrm{AP})$ | 0.08 | 0.11 | 0.11 | 0.14 | 0 | 0 |

Another advantage of the MGC method is its computational simplicity and inherent parallelism. Figure 9 shows the computational cost of the MGC(RGB) method in a $z$-stack of digital images of $2584\times 1936\text{\hspace{0.17em}\hspace{0.17em}}\text{pixels}$, when they run on Intel^{©} X^{©}(R) 2.10 GHz, 16 GB RAM, NVIDIA Quadro K4000. The parallelized MGC method on the GPU is one order of magnitude faster than the same application implemented in CPU.

## 4.2.

### Multifocus Image Fusion Results

It is well known that the digital images of thick microscopic objects provided by an optical widefield microscope device are strongly blurred for the portion of the object that lies outside of the DOF of the objective lens. We can seek those regions of the FOV, which are conveniently located in-focus. The present subsection will describe the results of a method to merge multifocus frames based on the MGC approach.

Our experiment starts with the acquisition of a digital image $z$-stack from a histological sample. This set of $z$-images are obtained by moving the microscope stage along the optical axis. For this, the axial extension $t$ of the sample is defined and then the axial stage with the sample is moving to cover this extension. The interplanar distance $\mathrm{\Delta}Z$ between different optical sections is less than the axial resolution of the microscope, defined as the DOF in Table 3. From this table, it is evident that $\mathrm{\Delta}Z$ is determined by the NA of the objective lens.

Digital images of a beetle shell are acquired with amplification of $10\times $ and interplanar distance $\mathrm{\Delta}Z=3\text{\hspace{0.17em}\hspace{0.17em}}\mu \mathrm{m}$. The given $z$-stack is composed of 42 images with $1024\times 768\text{\hspace{0.17em}\hspace{0.17em}}\text{pixels}$. Figure 10(a) shows the in-focus image obtained with the software package EDoF plug-in^{31} based on a complex wavelets algorithm for EDoF.^{17} The fusion process takes an average execution time of 52.2 s, whereas the fused image of Fig. 10(b) is based on the proposed MGC fusion method. In this technique, the resulted slice axial position matrix $\mathrm{sap}(x,y)$ is low-pass filtered using a $p\times q$ median filter with $p=q=3,15,35$. The total execution time is 32.1 s. The 3-D visualization of the resulting in-focus image is sketched in Fig. 10(c). Finally, the nonreference image quality metric of Eq. (7) is computed for the in-focus image quality assessment. The results are shown in Fig. 10(d).

Another example is the case of an umbilical cord that is imaged at the amplification of $10\times $ and interplanar distance $\mathrm{\Delta}Z=3\text{\hspace{0.17em}\hspace{0.17em}}\mu \mathrm{m}$. The given $z$-stack is composed of 39 images with $2584\times 1936\text{\hspace{0.17em}\hspace{0.17em}}\text{pixels}$. Again, Fig. 11(a) shows the in-focus image obtained with the EDoF plug-in.^{17}^{,}^{31} It takes an average execution time of 477.43 s. The fused image of Fig. 11(b) is based on the proposed MGC fusion method, where the resulted slice axial position matrix $\mathrm{sap}(x,y)$ is again low-pass filtered using a $p\times q$ median filter with $p=q=\mathrm{3,15},35$. The total execution time is 238.9 s, and the fusion evaluation is shown in Fig. 11(d). As we can see, the proposed fusion method reveals a high-quality image independent of faulty illumination during the image acquisition.

## 5.

## Conclusions

In this research, the MGC operator has been applied to digital color images. This procedure transforms the multichannel information to a grayscale image, which is used for (a) focus measurements during the AF process and (b) for extending the DOF in the framework of digital microscopy applications.

The AF experimental results of this work demonstrate the effectiveness of the MGC method when it is applied to several $z$-stacks of images. From this point of view, we can conclude that the use of the proposed MGC image increases the performance of currently used passive AF algorithms and produces monotonic FM curves with an only one local maximum $\eta $ and a similar width $\alpha /\beta $ of the focus curve, as shown in Figs. 5, 6, and 8. The test frames have been acquired from two histological samples, which are amplified at the magnifications of $2.5\times $, $10\times $, $40\times $, and $100\times $ (oil immersion). The AF graphs in Fig. 8 that are obtained by the MGC method present similar behaviors even up to a magnification of $100\times $. Therefore, all the AF algorithms reveal the image slice on $z=0$. Contrastingly, as shown in the AP results in Tables 4 and 5, the same AF algorithms in other color spaces only work properly in some cases. As can be seen in the same tables, the mean and the standard deviation of the AF performance for the MGC image are 1 and 0, respectively, for both amplifications. We can conclude that the effectiveness of the AF algorithms depends on several factors (1) the color space selection for doing the numerical computation, (2) the color distribution of the sample under inspection, and (3) the sample magnification. Only in the MGC space does the AF performance tend to be invariant according to these factors. Another remarkable characteristic of the MGC method is that it is computationally simple and inherently parallel. The computational cost of the MGC(RGB) algorithm implemented on a GPU can be reduced by an order of magnitude, for images with $2584\times 1936\text{\hspace{0.17em}\hspace{0.17em}}\text{pixels}$, as is shown in Fig. 9.

On the other hand, the fusion scheme $\mathrm{\varphi}(x,y,i)$ was implemented on an image $z$-stack for EDoF. The fused image is composed of the sharp regions provided by the in-focus pixels $\tilde{\mathrm{sap}}(x,y)$ of the input data. Our fusion method has been quantitatively and qualitatively compared with the EDoF plug-in, which is widely used in digital microscopy for DOF extension. From a simulated image stack, the resulting image fusion was compared with the corresponding original images using the NMSE, as shown in Fig. 2. Also, a nonreference image quality metric AQI was implemented for image quality assessment. These quantitative evaluations given in Table 2 show that the quality of the resulting fused image $\mathrm{\varphi}(x,y,i)$ is better than the fused image given by the EDoF plug-in.

The 3-D visualization of the in-focus images verifies the fusion results. Based on the experimental results of Figs. 10 and 11, the MGC method is an algorithm sufficiently competitive to merge multifocus images. In general, the main advantages of the proposed fusion method based on MGC transformation are that it is computationally simpler, faster, and more efficient than other methods which have been typically used to fuse multifocus information. Additionally, the comparisons in Figs. 11(a) and 11(b) show that our method reveals a high-quality image independent of faulty illumination during the image acquisition.

## Acknowledgments

R. Hurtado thanks to Consejo Nacional de Ciencia y Tecnología (CONACyT); Award no. 578446. Also we thank by the support to PADES program; Award no. 2017-13-011-053. We extend our gratitude to the reviewers and Jennifer Speier for their useful suggestions.

## References

^{®}/SIMULINK

^{®}, CRC Press, New York (2016). Google Scholar

## Biography

**Román Hurtado-Pérez** received his bachelor’s degree in computational systems and his master’s degree from the Polytechnic University of Tulancingo (UPT) in 2004 and 2013, respectively. He is a PhD degree student in optomechatronics from UPT. His current research areas include multifocus image fusion, autofocusing, GPU, and computer vision.

**Carina Toxqui-Quitl** is an assistant professor at the Polytechnic University of Tulancingo. She received her BS degree from the Puebla Autonomous University, Mexico, in 2004. She received her MS and PhD degrees in optics from the National Institute of Astrophysics, Optics, and Electronics in 2006 and 2010, respectively. Her current research areas include image moments, multifocus image fusion, wavelet analysis, and computer vision.

**Alfonso Padilla-Vivanco** received his bachelor in physics from Puebla Autonomous University, Mexico, and his MS and PhD degrees both in optics from the National Institute of Astrophysics, Optics, and Electronics in 1995 and 1999, respectively. In 2000, he held a postdoctoral position in the physics department at the University of Santiago de Compostela, Spain. He is a professor at the Polytechnic University of Tulancingo. His research interests include optical information processing, image analysis, and computer vision.

**J. Félix Aguilar-Valdez** received his BS degree in physics from National Autonomous University of Mexico in 1980. He received his MS and PhD degrees in optics from Center for Scientific Research and Higher Education of Ensenada, Baja California, México, in 1994. His current research areas include high-resolution microscopy, confocal microscopy, near-field diffraction, and microscopic imaging.

**Gabriel Ortega-Mendoza** received his PhD from the FCFM-BUAP, Puebla, México, in 2013 and has been a full-professor at Universidad Politécnica de Tulancingo, Hidalgo, México, since 2013. His research areas include multifocus image fusion, image microscopy, optical fiber laser, plasmon resonance, and manipulation of photothermal-induced microbubbles.