1 Introduction

Advancements in high-bandwidth digital communication technologies has opened up newer opportunities of transmitting medical data across geographical boundaries through Internet, mobile networks, and other wireless/wired communication channels and thus covering rural/remote areas, accident sites, ambulance, and hospitals. Transmission of medical data over an open communication channel poses different possibilities of threat that can severely affect its authenticity, integrity, and confidentiality. This calls for implementing some kind of medical watermarking scheme to avoid prompting attention and preventing access by an unintended recipient. Digital watermarking of medical image provides the best solution to these issues [1]. Despite the broad literature on various application fields, little work has been done towards the exploitation of health-oriented perspectives of watermarking [27]. Medical image watermarking requires extreme care when embedding additional data within the medical images because the additional information must not affect the image quality. Confidentiality, authentication, integrity and availability are important security requirements with electronic patient record (EPR) data exchange through open channels [8, 9]. Image watermarking techniques are distinguished on the basis of two domain methods [10]: Spatial domain method and transform domain method. In spatial domain methods [11, 12] (LSB substitution, spread spectrum and patchwork), the data is embedded directly by manipulating the pixel values, bit stream or code values of the host signal. Spatial domain methods are less complex but are not robust against attacks whereas transform domain watermarking techniques are more robust. In this method, the data is embedded by modulating the coefficients in transform domain like discrete Fourier transform (DFT), discrete Cosine transform (DCT) and discrete wavelet transform (DWT) etc. Advantages of watermarking in wavelet transform domain includes- space frequency localization, multi-resolution representation, multi-scale analysis and linear complexity [1315]. Watermarking technique can also be further classified as reversible and irreversible [16, 17]. The reversible watermarking develops the techniques to extract exactly the original image by avoiding the irreversible distortions in the host image. This technique is mainly used in the field of medical image watermarking to avoid the distortion that may result into faulty diagnosis. Due to increase in medical identity theft there is a great demand of secure watermarking schemes [1820]. This calls for the development of secure medical data/image watermarking schemes. The problem of watermark security can be solved using spread-spectrum scheme [8, 2126]. Many wavelet based watermarking schemes were proposed for medical images [2730]. Authors of this paper have presented a new wavelet based watermarking scheme for image watermarks using spread-spectrum [31]. This paper investigates the performance of watermarking algorithm proposed in Ref. [31] for text file watermark where each character is represented in binary format using ASCII codes. A pair of pseudo noise (PN) sequences is generated corresponding to each bit of text watermark. These PN sequences are embedded into selected wavelet coefficients in column wise operation. Performance of the proposed algorithm has been extensively evaluated against numerous known attacks and results are compared with some latest reported algorithms [26] and it is found that the algorithm gives superior robustness performance without much degradation in the image quality.

2 Spread-Spectrum Watermarking in DWT Domain

The proposed DWT based spread-spectrum watermarking scheme embeds encoded text medical watermarks into cover MR medical image with the aim to achieve higher degree of robustness while maintaining imperceptibility. A brief description of the related concepts is as follows:

2.1 Watermarking in DWT Domain

Due to its ability to provide excellent multi-resolution analysis, space-frequency localization and superior HVS modeling, wavelet-based watermarking has recently gained great attention [32]. DWT separates an image into a lower resolution approximation image (LL1) as well as horizontal (HL1), vertical (LH1) and diagonal (HH1) detail components. Dyadic sub-band decomposition of DWT coefficients at higher levels offers added benefits like increased robustness, tolerance to various compression algorithms and filtering as it allows us to use higher energy regions for embedding where high degree of robustness is achieved as the cost of imperceptibility.

2.2 Spread-Spectrum Watermarking Principle

In spread-spectrum watermarking technique [8], the watermark is spread over many frequency bins so that the energy in any one bin is very small and thus undetectable. Spreading the watermark throughout the spectrum of an image ensures a large measure of security against unintentional or intentional attack as location of the watermark is not obvious and frequency region is selected in a fashion that ensures sufficiently small energy in any single coefficient. A watermark that is well placed in the frequency domain of an image will be practically impossible to detect.

2.3 Error Correction Codes

Error correcting codes are used for reducing probability of error during data transmission over noisy channels. It case of watermarking, ECC can be applied with the objective of enhancing bit error rate (BER) performance of the extracted watermark. In error correcting process, the sender adds redundant bits to the original message which is used for error detection or error correction on the receiver side. BCH code is a class of cyclic codes that includes both binary and non-binary alphabets. Binary BCH codes can be constructed with the parameters (n, k, t): where, n = length of the code word (BCH coded binary sequence), k = length of signature (original binary sequence), t = no. of bit errors this BCH can correct.

In this paper, BCH code has been used along with the proposed watermarking scheme and performance of the extracted watermark is analyzed with or without BCH coder.

3 Performance Measures

The performance of the watermarking algorithm can be evaluated on the basis of its robustness and imperceptibility. Larger peak signals-to-noise ratio (PSNR) indicates that the watermarked image more closely resembles the original image and hence more imperceptibility. Generally, watermarked image with PSNR value greater than 27 dB is acceptable [22]. PSNR is defined as

$$ PSNR = 10\log \frac{{(255)^{2} }}{MSE} $$
(1)

where the mean square error (MSE) is defined as

$$MSE = \frac{1}{X \times Y} \sum\nolimits_{i = 1}^{X} \sum\nolimits_{j = 1}^{Y} ({I_{{ij}}} - W_{{ij}})^{2} $$
(2)

where I ij is a pixel of the original image of size X × Y and W ij is a pixel of the watermarked image of size X × Y. Robustness of the algorithm is determined in term of bit error rate (BER). BER is defined as ratio between number of incorrectly decoded bits and total number of bits. It is suitable for random binary sequence watermark. Ideally it should be zero.

$$ BER = ({\text{Number}}\,\,{\text{of}}\,\, {\text{incorrectly}}\,\,{\text{decoded}}\,\, {\text{bits}})/({\text{Total}}\,\, {\text{number}}\,\,{\text{of}}\,\, {\text{bits}}). $$
(3)

4 Proposed Algorithm

This paper proposes a new DWT based spread-spectrum watermarking algorithm for embedding text watermarks using medical images as cover. Dyadic sub-band decomposition is performed on the cover image using Haar wavelet transform. The text watermark used in the algorithm is converted into binary format using ASCII codes. In the embedding process, the cover image is decomposed up to third level DWT. The text watermark is embedded into horizontal and vertical sub-band coefficients of the first, second and third level. Different watermark bits are hidden in the same transform coefficients of the cover image using uncorrelated codes, i.e. low cross correlation value (orthogonal/near orthogonal) among codes. For each message (text) bit, two different PN sequence vectors of size identical to the size of DWT column vector are generated. Based on the value of the bit of the message vector, the respective two PN sequence pairs are then added/subtracted to/from selective columns of wavelet coefficient. This selection is done by thresholding the coefficient values present in that column. Proposed algorithm procedure is described in Fig. 1. The column wise DWT coefficients of second level horizontal and vertical sub-bands are taken. In each column, the coefficients fulfilling the threshold criteria are used for embedding and rest of coefficients remain unchanged as shown in Fig. 1. Values of coefficients S2 and S3 are changed after watermarking as these value lie inside the threshold range while values of coefficients S1 and S4 lying outside the threshold criteria, are remain unchanged. The wavelet coefficients of cover image are divided into b w number of bins having equal width for desired level. Bin having maximum number of coefficients is selected and represented as max_bin. In medical images, the DWT coefficients are mostly concentrated toward the origin. Thus, max_bin has coefficients concentrated toward origin. Width of each bin is obtained by using formula:

$$ {\text{Width of each bin}} = \frac{{{\text{maximum coefficient}} - {\text{minimum coefficient}}}}{{{\text{b}}_{\text{w}} }} $$

b 1 and b 2 are the minimum and maximum values within max_bin. In each column, the coefficients under the threshold criteria are used for embedding the data bit as follows:

$$ {\text{W}} = {\text{V}} + {\text{kX }}\quad {\text{if}}\; {\text{b}} = 0 $$
$$ {\text{W}} = {\text{V}} - {\text{kX }}\quad {\text{if}}\; {\text{b}} = 1 $$

where V is embeddable wavelet coefficient column vector of the cover image, W is the wavelet coefficient vector after watermark embedding, k is the gain factor, X is the PN sequence vector and b is the message bit that has to be embedded. Generation of a pair of PN sequences for embedding each bit enhances the security of the watermarking algorithm. Following steps are applied in data embedding process:

Fig. 1
figure 1

Embedding procedure of PN sequence by the proposed method

4.1 Text Embedding Process

  1. (i)

    Read the cover image I(M,N) of size M × N.

  2. (ii)

    Read the text watermark to be hidden and convert it into binary sequences Dd (d = 1 to n).

  3. (iii)

    Perform BCH encoding of Dd to obtain the BCH encoded binary sequences.

  4. (i)

    Transform the host image using “Haar” wavelet transform and get first, second and third level sub-band coefficients.

  5. (ii)

    Generate n different PN sequence pairs (PN_h and PN_v) each of \( \frac{M}{{2^{\ell } }} \times 1 \) using a secret key to reset the random number generator for each level \( \ell \) = 1–3.

  6. (iii)

    For d = 1 to n, and \( \ell \) = 13

    $$ {\text{p}} = \left\{ {\begin{array}{*{20}l} {{\text{modulo}}\left( {{\text{d}},\frac{\text{N}}{{2^{\ell } }}} \right)} \hfill & {{\text{if}}\;{\text{modulo}}({\text{d}},\frac{\text{N}}{{2^{\ell } }}) \ne 0} \hfill \\ {\frac{\text{N}}{{2^{\ell } }},} \hfill & { {\text{else}}} \hfill \\ \end{array} } \right. $$

    where p is the column in which sequence has to be added, \( \frac{\text{N}}{{2^{\ell } }} \) is the number of columns in coefficient matrix and \( \ell \) represents one of three sub-bands.

Case 1 When message vector bit = 0

Hence 1 ≤ p ≤ (N/2), For i = 1 to (M/2)

$$ {\text{cH}}^{\ell } ({\text{i,p}}) = \left\{ {\begin{array}{*{20}l} {{\text{cH}}^{\ell } ({\text{i,p}}) + {\text{k}} \times {\text{PN}}\_{\text{h}}\left( {\text{i,d}} \right) } \hfill & {{\text{if}}\;{\text{b}}1 < cH1^{\ell } (i,p) < b2} \hfill \\ {{\text{cH}}^{\ell } ({\text{i,p}})} \hfill & {\text{otherwise}} \hfill \\ \end{array} } \right. $$
$$ {\text{cV}}^{\ell } ({\text{i,}}\,{\text{p}}) = \left\{ {\begin{array}{*{20}l} {{\text{cV}}^{\ell } ({\text{i,}}\,{\text{p}}) + {\text{k}} \times {\text{PN}}\_{\text{v}}\left( {{\text{i,}}\,{\text{d}}} \right) } \hfill & {{\text{if}}\;{\text{b}}1 < cV1^{\ell } (i,p) < b2} \hfill \\ {{\text{cV}}^{\ell } ({\text{i,}}\,{\text{p}})} \hfill & {\text{otherwise}} \hfill \\ \end{array} } \right. $$

Case 2 When message vector bit = 1

Hence 1 ≤ p ≤ (N/2), For i = 1 to (M/2)

$$ {\text{cH}}^{\ell } ({\text{i,}}\,{\text{p}}) = \left\{ {\begin{array}{*{20}l} {{\text{cH}}^{\ell } ({\text{i,p}}) - {\text{k}} \times {\text{PN}}\_{\text{h}}\left( {\text{i,d}} \right)} \hfill & {{\text{if}}\;{\text{b}}1 < cH1^{\ell } (i,p) < b2} \hfill \\ {{\text{cH}}^{\ell } ({\text{i,p}})} \hfill & {\text{otherwise}} \hfill \\ \end{array} } \right. $$
$$ {\text{cV}}^{\ell } ({\text{i,p}}) = \left\{ {\begin{array}{*{20}l} {{\text{cV}}^{\ell } ({\text{i,p}}) - {\text{k}} \times {\text{PN}}\_{\text{v}}\left( {\text{i,d}} \right)} \hfill & {{\text{if}}\;{\text{b}}1 < cV1^{\ell } (i,p) < b2 } \hfill \\ {{\text{cV}}^{\ell } ({\text{i,p}})} \hfill & {\text{otherwise}} \hfill \\ \end{array} } \right. $$

where k is the gain factor used to specify the strength of the embedded data

  1. (iv)

    Apply inverse “Haar” Wavelet transform to get the final watermarked image I w (M, N).

4.2 Text Watermark Extraction Process

To detect the embedded watermark, the same PN sequence vectors are generated which were used during insertion of watermark by using same state key and their correlation with the corresponding selected detail sub-bands DWT coefficient columns is determined. Average of n correlation coefficients corresponding to each PN sequence vector is obtained for both LH and HL sub-bands. Mean of the average correlation values are taken as threshold T for message extraction. During detection, if the average correlation exceeds T for a particular sequence, a “0” is recovered; otherwise a “1” is recovered. The recovery process then iterates through the entire PN sequence until all bits of the watermark are recovered. For extracting the watermark, following steps are applied to the watermarked image:

  1. (i)

    Read the watermarked image I w (M, N)

  2. (ii)

    Transform the stego image using “Haar” Wavelet transform and get first, second and third level sub-band coefficients.

  3. (iii)

    Generate one’s sequences (msg) equal to message vector (from 1 to n).

  4. (iv)

    Generate n different PN sequence pairs (\( PN^{\ell } h1 \) and \( PN^{\ell } v1 \)) each of size \( \frac{M}{{2^{\ell } }} \times 1 \) using same secret key to reset the random number generator for each level ℓ = 1–3.

For d = 1 to n, generate \( PN^{\ell } h2\left( d \right) \) and \( PN^{\ell } v2\left( d \right) \) as

For i = 1 to (M/2)

$$ PN^{\ell } h2\left( {i, d} \right) = \left\{ {\begin{array}{*{20}l} {PN^{\ell } h1\left( {i, d} \right)} \hfill & {{\text{if}}\;{\text{b}}1 < cH1^{\ell } (i,\,p) < b2} \hfill \\ 0 \hfill & {\text{else}} \hfill \\ \end{array} } \right. $$
$$ PN^{\ell } v2\left( {i, d} \right) = \left\{ {\begin{array}{*{20}l} {PN^{\ell } v1\left( {i, d} \right)} \hfill & {{\text{if}}\;{\text{b}}1 < cV1^{\ell } (i,p) < b2} \hfill \\ 0 \hfill & {\text{else}} \hfill \\ \end{array} } \right. $$

Calculate the correlations between the values cH1 and PN h2 and store in corr_H (d) and cV1 and PN v2 and store in corr_V (d).

corr_H (d) = correlation between PN h2 (d) and cH1 (pth column)

corr_V (d) = correlation between PN v2 (d) and PN v2 (pth column)

$$ {\text{p}} = \left\{ {\begin{array}{*{20}l} {{\text{modulo}}\left( {{\text{d}},\frac{\text{N}}{{2^{\ell } }}} \right)} \hfill & {{\text{if}}\;{\text{modulo}}\left( {{\text{d}},\frac{\text{N}}{{2^{\ell } }}} \right) \ne 0} \hfill \\ {\frac{\text{N}}{{2^{\ell } }},} \hfill & {\text{else}} \hfill \\ \end{array} } \right. $$

Hence 1 ≤ p ≤ \( \frac{N}{4} \)

  1. (v)

    Calculate average correlation avg_corr (d) = (corr_H (d) + corr_V(d))/2 at each level.

  2. (vi)

    Calculate the corr (mean) = mean of all the values stored in avg_corr (d) at each level.

  3. (vii)

    Extract the watermark bit stream, using the relationship given below

    for d = 1 to n

    if avg_corr (d) > corr (mean)

    Msg (d) = 0.

  1. (viii)

    Apply BCH decoding on the extracted watermark to obtain Msg.

  2. (ix)

    This Msg to get the binary matrix representation of the text watermark.

  3. (x)

    Convert the matrix back to string to get the recovered watermark.

5 Experimental Results and Discussion

Experiments were carried out using 8-bit gray-scale MR images of size 512 × 512 as cover image [33]. The medical information such as doctor’s identification code of eight characters, image/diagnostic code of eight characters and patient name of eight characters are embedded into third level HL3 and LH3 sub-bands, second level HL2 and LH2 sub-bands and the first level HL1 and LH1 sub-bands respectively. Also, BCH (Bose, Ray-Chaudhuri, Hocquenghem) error correcting code is applied to the ASCII representation of the text and the encoded text watermark is then embedded into the cover medical images. Effect of BCH coding is observed by embedding text watermarks in two different ways: without ECC and with BCH (127, 64) code.

The encoded text watermark length for BCH is 381 bits. Strength of watermark is varied by varying the gain factor in the watermarking algorithm. The proposed medical watermarking scheme has been implemented in MATLAB environment. Imperceptibility performance of the scheme is evaluated by calculating the PSNR between cover image and watermarked image whereas robustness performance is measured by calculating BER between original and extracted watermark (Table 1).

Table 1 PSNR performance of watermarked image and BER performance of extracted watermark with/without BCH coder at different gain

In Table 2, robustness performance of the proposed algorithm with/without BCH coder has been tested at gain = 10 against different attacks. With BCH coder, BER value = 0 is obtained against JPEG compression (quality factor = 90) whereas without BCH code it comes out to be 0.0052. It is also observed from the table that the implementation of BCH coder improves the BER performance for sharpening mask noise attack with threshold = 1. Table 3 shows PSNR and BER performance of the proposed algorithm for different imaging modalities at varying gain factor. It is observed that ultrasound image gives maximum PSNR = 41.30 dB at a gain factor of five whereas minimum BER value = 0 is obtained with MRI image at gain factor of 11. Table 4 provides the performance comparison with the existing methods. In this table, the maximum BER value with proposed method has been obtained as 0.0 against 1.5306 obtained by Kumar et al. in Ref. [26]. The maximum PSNR value has been obtained with this method is 45.51 dB. However, the maximum PSNR value achieved by the proposed method is 49.12 dB. The existing method can embed only 196 bits only whereas 381 bits can be embedded by the proposed method. Therefore, it can be concluded that the watermarking method proposed in this paper performs very well in terms of image quality of the watermarked image, robustness of the extracted watermark and embedding capacity also. Figure 2 shows original MR image and watermarked image and Fig. 3 shows the extracted watermark image at gain factor = 15. PSNR and BER performance of the proposed watermarking scheme with and without BCH coder are illustrated in Table 1. In this table, highest PSNR obtained without and with BCH coder are 43.96 and 40.48 dB respectively (at gain = 5) whereas BER obtained without and with BCH coder are 0.0236 and 0.0183 respectively. It is also observed that the watermarking scheme with BCH coder achieves desired zero BER at gain factor of 15 but its PSNR performance is slightly compromised i.e. 29.46 dB as compared to 34.95 dB achieved without coder.

Table 2 Robustness performance of proposed watermarking scheme with/without BCH coder against different attacks at gain = 10
Table 3 Effect of host images on the performance of proposed scheme at different gain factor
Table 4 The comparison results under PSNR and BER value
Fig. 2
figure 2

a Cover MR image b watermarked image at gain factor = 15

Fig. 3
figure 3

Extracted watermark at gain factor = 15

6 Conclusion

This paper proposed a new robust and secure watermarking scheme based on dynamic selection of DWT coefficients for embedding text watermarks like patient’s identity, image code, and doctor’s identity. Spread-spectrum technique along with BCH error correcting code was used to enhance robustness performance of the proposed algorithm. Proposed watermarking algorithm was analyzed and compared with some latest reported watermarking algorithms and our method gave superior performance. Use of BCH error correcting code significantly improved the BER performance of the extracted watermark. For further improvement in error correction capability, length of the error correction code may be suitably increased. The proposed watermarking algorithm can be potentially used in secure and bandwidth efficient telemedicine application.