# Non-Contact Heart Rate Detection Based on Hand Vein Transillumination Imaging
## 2 Materials and Methods
### Acquisition and Pre-Processing of One-Dimensional Pulse Wave Signal
#### 2.2.2 Elimination of Baseline Drift Based on Morphological Operation  
In the process of collecting video images for a period of time with an ordinary camera, noise is inevitably be introduced due to the influence of external factors (camera instability, light intensity, etc.), which contaminates the collected signal and affects subsequent processing. In addition, the heart rate signal, the PPG signal also contain a series of low-frequency noises, from sources such as breathing, body tremor, and skeletal muscle contraction. Therefore, the signal-to-noise ratio should be improved to obtain a more accurate blood volume. The pulse waveform requires the source signal to be denoised. In this research, a morphological operation was used to denoise the signal.  
Mathematical morphology theory states that open and close operations move structural elements below and above the signal, respectively. The open operation can cut off the signal \"wave crest\", which is contractible, eliminates isolated signal points, suppresses the positive impulse noise, and makes the signal smooth; the close operation can fill the signal \"valley\", with expansion, and can suppress negative impulse noise. The open and close operations both have low-pass characteristics. The purpose of the morphological filter is to eliminate the peaks and troughs of a specific width in the signal by combining open and close operations. The components that are actually filtered out of the signal are related to the structural elements used in the calculation. For example, the width of the structural element is \(M\), and the width of the peak or trough in the signal is \(N\), as shown in Equation (1).  
\[\left\{\begin{array}{c}N>M\text{, signal is retained}\\ N<M\text{, signal is filtered out}\end{array}\right. \tag{1}\]  
Figure 3: Principle diagram of pulse wave signal acquisition.  
Figure 2: Vein transmission image. (**a**) Original transmission image, (**b**) ROI image, (**c**) ROI image after performing the gray-scale operation.  
In order to simultaneously remove the positive and negative pulse noises in the signal, a cascade combination of open and close operations was adopted to define the open-close and close-open filters, as shown in Equation (2).  
\[\left\{\begin{array}{l} Morphological\ opening-closing:\ OC(f)=(f\circ k)\bullet k \\ Morphological\ closing-opening:\ CO(f)=(f\bullet k)\circ k\end{array}\right. \tag{2}\]  
where, \(f\) represents the original signal, and \(k\) represents the structural element.  
Due to the shrinkage of the open operation, the output of the morphological open-close filter is too small, and due to the expandability of the close operation, the output of the morphological close-open filter is too large, which greatly affects the filter's ability to efficiently remove noise. To reduce the occurrence of offsets and improve filtering effects, they are generally not used alone, instead the signal is filtered through the cascade of morphological open-close and close-open operations. The mathematical expression of the signal \(f\) after morphological filtering is shown in Equation (3).  
\[f^{\prime}=\frac{1}{2}[OC(f)+CO(f)] \tag{3}\]  
The mathematical morphology filter adopts the linear structure element. The width of the linear structure element is set to 20, which is greater than the width of the characteristic pulse waveform. Morphological open-close and close-open filters are applied to the pulse wave signal to simultaneously remove both positive and negative impulse noises in the signal, respectively. The signal is filtered through the cascade of morphological open-close and the close-open operations, thereby improving the filter's high-efficiency noise removal performance and achieving better filtering effects. The pulse wave signals before and after filtering are shown in Figure 4a,b.