## 3 Proposed Architecture and Algorithm
### Digital Watermark Insertion and Extraction  
Digital watermarking technology refers to directly embedding some identifying information (digital watermark) into the digital carrier (including multimedia, documents, software, _etc._) so that it does not affect the usage value of the original carrier and is hard to be perceived or noticed with by people's perception systems (such as visual or auditory systems) [23]. The information hidden in the carrier can help us confirm the content creators, buyers, carriers transmitting secret information, and determine whether the carrier has been altered. Digital watermarking is an important research direction in information-hiding technology.  
ECGs have high accuracy requirements for heart disease diagnosis. It is necessary to maintain the shape of the ECG waveforms in watermarking since the ECG diagnosis mainly depends on the PQRST waves. To achieve this goal, we use quantization-based digital watermark encryption technology on the electrocardiogram (ECG) to protect patient rights and information. First of all, the ECG signal is cut into several segments. The segment length depends on the level of wavelet decomposition. As shown in Figure 2, we then perform seven levels of wavelet decomposition on each segment so that the input ECG signal is decomposed into eight non-overlapping sub-bands. Taking into account the robust performance of the low-pass filtering, we embedded the watermark sequence with patient's information into the lowest frequency wavelet coefficients in level seven. The watermark sequence with patient's information { \(m_{i}\)} is embedded by the following rule:  
\[[\begin{array}{c}c^{{}^{\prime}}_{i}=\begin{bmatrix}\left|\begin{array}{c }c_{i}\\ \end{array}\right|T+\left.\begin{array}{c}3T\\ \end{array}\right|,\text{ if }m_{i}=1\\ \left|\begin{array}{c}c_{i}\\ \end{array}\right|T+\left.\begin{array}{c}  
In order to adjust a proper embedding strength \(T\), we consider the signal to noise ratio (SNR) which is defined by [24,25]:  
\[[\;SNR=-10\log_{10}\left\{\frac{\sum_{n}(\tilde{S}(n)-S(n))^{2}}{\sum_{n}(S(n))^{ 2}}\right\}] \tag{7}\]  
where \(S(n)\) and \(\tilde{S}(n)\) are the original and the watermarked audio.  
Due to the fact that the DWT coefficients are implemented with orthogonal wavelet bases and according to [PERSON]'s theorem, the energy in a signal is given as follows:  
\[[\;\int\;|\;S(t)\;|^{2}\;dt=\sum_{t=\infty}^{\infty}\;|\;c(t)\;|^{2}+\sum_{j=0 }^{\infty}\sum_{k=\infty}^{\infty}\;|\;d_{j}(k)\;|^{2}\;] \tag{8}\]  
Since the high frequency sub-band in Equation (8) are neglected by the proposed embedding algorithm, only the lowest DWT coefficients are adjusted. That is  
\[[\;\sum_{\text{SNR}}=-10\log\left(\frac{\sum\|\;c_{i}-c_{i}^{{}^{\prime}}\;\|_{ {}^{2}}^{2}}{\sum\|\;c_{i}\;\|_{{}^{2}}^{2}+\sum(\text{high frequency sub $-band $DWT$ coefficients})^{2}}\right)\approx-10\log(\frac{\sum\|\;c_{i}-c_{i}^{{}^{ \prime}}\;\|_{{}^{2}}^{2}}{\sum\|\;c_{i}\;\|_{{}^{2}}^{2}})\;] \tag{9}\]  
We use this formula to adjust the embedding strength \(T\).  
When extracting the hidden data, we first divide the watermarked ECG signal into the same segments in the embedding manner. Then, we perform DWT on each segment which has been embedded with a watermark. The watermark is extracted from the DWT lowest-frequency sub-band as follows. Suppose \(\{\;c_{i}^{{}^{\prime}}\;\}\) is the coefficient of the lowest-frequency sub-band; we use the following rule to extract watermark sequence \(\{\;m_{i}^{{}^{\prime}}\;\}\) from\(\{\;c_{i}^{{}^{\prime}}\;\}\):  
\[[\;m_{i}^{{}^{\prime}}=\begin{cases}1,\;\text{if}\;c_{i}^{{}^{\prime}}-\begin{cases} c_{i}^{{}^{\prime}}\\ \end{cases}T\geq T/2\\ 0,\;\text{if}\;c_{i}^{{}^{\prime}}-\begin{cases}c_{i}^{{}^{\prime}}\\ \end{cases}T\end{cases}T<T/2\end{cases} \tag{10}\]  
After we determine the location of the watermark sequence, we can extract the hidden information. The extraction model is shown in Figure 4.  
Figure 3: Watermark embedding model.