Skip to main content
. 2023 Aug 23;23(17):7365. doi: 10.3390/s23177365
Algorithm 2 Extraction algorithm
Input: Original watermarked PDF file and watermarked PDF file
Output: Extracted watermark sequence
  • 1:

    Convert the original PDF file and the watermarked PDF file into a series of images, and perform subsequent operations on each original image I and the watermarked image IW. Map the image I and IW to be detected from RGB space to YCbCr space, decompose the Y components, mark it as IY and IY, and convert them into binary text images Ib and Ib.

  • 2:

    for each original image Ib and corresponding watermarked image Ib do

  • 3:   

    Obtain the set of sub-blocks {Bi|i=1,2,,K,K=2P}, and {Bi|i=1,2,,K,K=2P}, where P is the number of rows.

  • 4:

       for each Bi do

  • 5:     

    Adjust its corresponding Bi to ensure that the pixels of Bi and Bi correspond one by one.

  • 6:     

    Calculate the number of black pixels in each row of Bi, find the row with the highest number of black pixels, and mark it as rlong.

  • 7:

         for each column in L do

  • 8:

            Find the white pixel closest to rlong, and mark it as Ib(x,y).

  • 9:

            Extract pixel Ib(x,y) from the watermarked image Ib.

  • 10:

          Calculate the difference m1(i).

  • 11:

        end for

  • 12:

        Obtain sets M1={m1(i)|i=1,2,,N}.

  • 13:    

    Extract watermark bit according to the number of positive and negative numbers in M1.

  • 14:

      end for

  • 15:  

    Extract all watermark bits and obtain the watermark string (length N) extracted from the current image.

  • 16:

    end for

  • 17:

    Overlay and average all extracted watermark strings to obtain the final extracted watermarks w1,w2,,wN.