Image watermark embedding and extracting method and device, electronic equipment and storage medium

By generating a watermark encoding matrix and combining it with a preset key and position coordinate sequence in a two-stage block embedding method, the reliability and applicability issues of image dark watermarking in the prior art are solved, achieving efficient watermark information embedding and extraction, and improving the robustness and security of image dark watermarking.

CN121961817APending Publication Date: 2026-05-01CHINA MOBILE COMM LTD RES INST +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHINA MOBILE COMM LTD RES INST
Filing Date
2025-12-19
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Existing image dark watermarking technology has low reliability and applicability in practical applications, is difficult to resist erasure attacks, and cannot effectively detect image tampering areas. It is also highly complex to implement and has low usability.

Method used

By generating a watermark encoding matrix, combining a preset key and a sequence of position coordinates, and employing a two-stage block embedding and scaling process, watermark information is embedded. Furthermore, the watermark information is extracted by using an embedding mechanism that incorporates key and position transformations to resist attacks.

Benefits of technology

It improves the robustness and security of watermarks, effectively resisting attacks such as cropping, scaling, and compression, preventing unauthorized extraction and tampering, and features fast processing speed and strong practicality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121961817A_ABST
    Figure CN121961817A_ABST
Patent Text Reader

Abstract

The invention discloses an image watermark embedding and extracting method and device, electronic equipment and a storage medium, and relates to the technical field of security, and the method comprises the steps: generating a watermark coding matrix based on a preset key and watermark information, and embedding corresponding data in the watermark coding matrix into image blocks of an original image according to the preset key and a position coordinate sequence. Combining the first image blocks and performing scaling processing to obtain a first intermediate image; and embedding corresponding data in the watermark coding matrix into the image blocks of the first intermediate image according to a preset key and the position coordinate sequence. And combining the second image blocks and performing scaling processing according to the size of the original image to obtain a watermark image. By applying the technical scheme of the invention, multiple attacks such as cutting, zooming, compression and the like can be resisted, the security of the watermark is improved based on a collaborative mechanism of the key and the position coordinate sequence, unauthorized extraction and tampering are avoided, the processing is efficient, and the practicability is high.
Need to check novelty before this filing date? Find Prior Art

Description

Methods, apparatuses, electronic devices and storage media for embedding and extracting image watermarks Technical Field

[0001] This application relates to the field of security technology, and in particular to a method, apparatus, electronic device and storage medium for embedding and extracting image watermarks. Background Technology

[0002] Digital watermarking, as a key information security technology, embeds watermark information into digital images, videos, and other carriers through specific rules and algorithms to achieve core objectives such as copyright verification and data breach tracking. Among these, image dark watermarking, due to its imperceptible nature to the human eye, has become an important research direction in the field of copyright protection. Image dark watermarking technology modifies pixel positions or values ​​in the image's spatial or transform domain to hide the marking information within redundant image data. Based on whether the extraction relies on the original image, it is further divided into blind watermarking and non-blind watermarking. Blind watermarking, with its advantage of being able to reconstruct information without the original image, is suitable for copyright tracing and data verification in practical scenarios.

[0003] Image watermarking can be implemented using frequency domain transformation algorithms, such as matrix transformation methods including Discrete Fourier Transform, Discrete Cosine Transform, Discrete Wavelet Transform, and Singular Value Decomposition. Among related technologies, three core implementation paths have emerged around frequency domain transformation: first, embedding multiple transformation methods in combination; second, optimizing image segmentation strategies; and third, optimizing the watermark embedding position through selection. These methods balance the relationship between watermark embedding capacity, transparency, and robustness.

[0004] However, some of the aforementioned image dark watermarking schemes based on frequency domain transformation neglect the implementation performance and decoding effectiveness in practical applications. Although some schemes optimize for block segmentation or embedding positions, they suffer from high implementation complexity, low usability, and difficulty in implementation. Moreover, most schemes rely on the inherent stealth of the algorithm itself, making them not only difficult to resist erasure attacks but also unable to effectively detect tampered areas of the image, thus affecting the reliability and applicability of dark watermarking technology in actual copyright protection scenarios. Summary of the Invention

[0005] In view of this, this application provides a method, apparatus, electronic device and storage medium for embedding and extracting image watermarks to solve the problems of low reliability and applicability of dark watermarking technology.

[0006] In a first aspect, this application provides an image watermark embedding method, comprising: generating a watermark encoding matrix based on a preset key and watermark information; embedding corresponding data in the watermark encoding matrix into a first image block of an original image according to the preset key and a position coordinate sequence; merging the first image blocks and performing scaling processing to obtain a first intermediate image; embedding corresponding data in the watermark encoding matrix into a second image block of the first intermediate image according to the preset key and the position coordinate sequence; merging the second image blocks and performing scaling processing according to the size of the original image to obtain a watermarked image.

[0007] In the above method, an encoding matrix is ​​generated collaboratively by the key and watermark information. The two-stage block embedding of the original image and the scaled intermediate image is achieved by combining the position coordinate sequence. The watermark image is then restored to the original size and output. This method not only has a small modification range to the image and low impact on the visual experience, but also effectively resists multiple attacks such as cropping, scaling, compression, and tampering, greatly improving the robustness of the watermark. The embedding mechanism based on key and position transformation does not rely on the stealth of the algorithm. Even if the algorithm process is known, the watermark cannot be extracted or tampered with without authorization, which is more secure. In addition, the image processing speed is fast and the implementation difficulty is low. The watermark information is carried in the form of a bit string matrix, which does not require manual identification and is extremely practical.

[0008] Optionally, generating a watermark encoding matrix based on a preset key and watermark information includes: performing encoding processing on the watermark information to obtain a bit string; determining the matrix dimension according to the length of the bit string, wherein the matrix dimension is the minimum value that satisfies a preset length condition; padding the bit string to a sequence of a preset length using the opposite value of the watermark information matrix identifier; converting a first matrix according to the matrix dimension and the padded bit string; filling the first row and first column of the first matrix with the watermark information matrix identifier to obtain a second matrix; and generating the watermark encoding matrix according to the second matrix and the preset key.

[0009] Optionally, before embedding the corresponding data in the watermark coding matrix into the first image block of the original image, the method further includes: extracting the luminance component data of the original image through a color space conversion algorithm; and performing block processing on the original image based on the luminance component data to obtain the first image block.

[0010] Optionally, embedding the corresponding data in the watermark coding matrix into the first image block of the original image, or embedding the corresponding data in the watermark coding matrix into the second image block of the first intermediate image, includes: in response to the embedded data being a first value, determining that the difference between the first coordinate and the second coordinate of the embedding position satisfies that the first coordinate value is greater than the second coordinate value, and the difference between the first coordinate value and the second coordinate value exceeds a preset threshold; in response to the embedded data being a second value, determining that the second coordinate value is greater than the first coordinate value, and the difference between the second coordinate value and the first coordinate value exceeds the preset threshold.

[0011] Optionally, the method further includes: in response to the first image block or the second image block being filled with rows and columns of watermark information matrix identifier, determining the embedding position as the corresponding sequence number of the position coordinate sequence obtained after the preset key is transformed; in response to the first image block or the second image block not being filled with rows and columns of watermark information matrix identifier, determining the embedding position as the corresponding sequence number of the position coordinate sequence obtained after the preset key and the block identifier are combined and transformed; the block identifier is the identifier of the first image block or the second image block.

[0012] Secondly, this application provides a method for extracting image watermarks, comprising: extracting embedding information from image blocks to be extracted according to a preset key and a position coordinate sequence to obtain extraction information; wherein the image blocks to be extracted are a third image block of a watermark image or a fourth image block of a second intermediate image, and the second intermediate image is an image obtained by scaling the watermark image; retrieving the starting position of the watermark encoding matrix according to the extraction information; extracting the embedding information of the image blocks to be extracted based on the starting position to obtain an extraction information matrix; performing statistical processing on the extraction information matrix to obtain the watermark encoding matrix; and restoring the watermark information according to the preset key and the watermark encoding matrix.

[0013] Optionally, the step of extracting embedding information from the image blocks to be extracted includes: extracting embedding information from the third image block of the watermark image to obtain first extraction information; retrieving the starting position of the watermark coding matrix based on the first extraction information; performing scaling processing on the watermark image in response to not finding the starting position to obtain the second intermediate image; extracting embedding information from the fourth image block of the second intermediate image to obtain second extraction information; and retrieving the starting position of the watermark coding matrix based on the second extraction information.

[0014] Optionally, after retrieving the starting position of the watermark encoding matrix based on the second extracted information, the method further includes: determining that no watermark information has been extracted in response to the failure to retrieve the starting position; and performing the step of extracting embedded information based on the starting position in response to the retrieval of the starting position.

[0015] Optionally, before performing embedding information extraction on the image blocks to be extracted, the method further includes: extracting the luminance component data of the watermark image through a color space conversion algorithm; and performing block processing on the watermark image based on the luminance component data to obtain the image blocks to be extracted.

[0016] Optionally, retrieving the starting position of the watermark encoding matrix based on the extracted information includes: performing extraction and retrieval operations on each offset within the size range of the image block to be extracted, wherein the offset is all combinations within the coordinate range corresponding to the image block; and determining the starting position of the watermark encoding matrix by retrieving the rows and columns filled by the watermark information matrix identifier.

[0017] Optionally, performing statistical processing on the extracted information matrix includes: dividing the extracted information matrix into blocks according to the matrix dimension to obtain an encoding matrix; the matrix dimension is determined according to the length of the bit string; performing statistical operations on the data at the same coordinate position in the encoding matrix to exclude outliers in the tampered area, thereby obtaining the watermark encoding matrix.

[0018] Optionally, the method further includes: in response to a difference in the encoding matrix corresponding to the target region, determining that the target region is a tampered region and locating the tampered region.

[0019] Optionally, the image block to be extracted is the same size as the image block when the watermark information is embedded, and the preset key is the same as the preset key when the watermark information is embedded.

[0020] Thirdly, this application provides an image watermark embedding device, comprising: an encoding module configured to generate a watermark encoding matrix based on a preset key and watermark information; and an embedding module configured to embed corresponding data in the watermark encoding matrix into a first image block of an original image according to the preset key and a position coordinate sequence; merge the first image blocks and perform scaling processing to obtain a first intermediate image; embed corresponding data in the watermark encoding matrix into a second image block of the first intermediate image according to the preset key and the position coordinate sequence; and merge the second image blocks and perform scaling processing according to the size of the original image to obtain a watermarked image.

[0021] Fourthly, this application provides an image watermark extraction device, comprising: an extraction module configured to perform embedding information extraction on an image block to be extracted according to a preset key and a position coordinate sequence to obtain extraction information; the image block to be extracted is a third image block of a watermark image or a fourth image block of a second intermediate image, wherein the second intermediate image is an image obtained by scaling the watermark image; retrieving the starting position of a watermark encoding matrix according to the extraction information; extracting the embedding information of the image block to be extracted based on the starting position to obtain an extraction information matrix; and a restoration module configured to perform statistical processing on the extraction information matrix to obtain the watermark encoding matrix; and restoring the watermark information according to the preset key and the watermark encoding matrix.

[0022] Fifthly, this application provides an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect embodiment.

[0023] In a sixth aspect, this application provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to perform the method described in the first aspect embodiment.

[0024] In a seventh aspect, this application provides a computer program product, including a computer program that, when executed by a processor, implements the method described in the first aspect embodiment described above.

[0025] As can be seen from the above technical solutions, the image watermark embedding and extraction method, apparatus, electronic device, and storage medium disclosed in this application relate to the field of security technology. The method generates a watermark encoding matrix based on a preset key and watermark information, and embeds the corresponding data from the watermark encoding matrix into image blocks of the original image according to the preset key and position coordinate sequence. The first image blocks are then merged and scaled to obtain a first intermediate image. The corresponding data from the watermark encoding matrix is ​​then embedded into image blocks of the first intermediate image according to the preset key and position coordinate sequence. The second image blocks are then merged and scaled according to the size of the original image to obtain the watermarked image. By applying the technical solution of this application, it can resist multiple attacks such as cropping, scaling, and compression. The collaborative mechanism based on the key and position coordinate sequence improves watermark security, avoids unauthorized extraction and tampering, and is highly efficient and practical.

[0026] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description

[0027] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0028] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0029] Figure 1 shows a schematic diagram of the blind watermark embedding process provided in an embodiment of this application; Figure 2 shows a schematic diagram of the blind watermark extraction process provided in an embodiment of this application; Figure 3 shows a schematic diagram of an image watermark embedding method provided in an embodiment of this application; Figure 4 shows a schematic diagram of an image watermark extraction method provided in an embodiment of this application; Figure 5 shows a schematic diagram of outliers in a matrix provided in an embodiment of this application; Figure 6 shows a schematic diagram of a target region provided in an embodiment of this application; Figure 7 shows a schematic diagram of an image watermark embedding device provided in an embodiment of this application; Figure 8 shows a schematic diagram of an image watermark extraction device provided in an embodiment of this application; Figure 9 shows a schematic block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0030] The embodiments of this application will now be described in more detail with reference to the accompanying drawings. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.

[0031] This disclosure is not exhaustive, but merely illustrative of some embodiments, and is not intended to limit the scope of protection of this disclosure. Unless otherwise specified, each step in a particular embodiment can be implemented as an independent embodiment, and the steps can be arbitrarily combined. For example, a solution after removing some steps in a particular embodiment can also be implemented as an independent embodiment, and the order of the steps in a particular embodiment can be arbitrarily interchanged. Furthermore, the optional implementation methods in a particular embodiment can be arbitrarily combined; moreover, the embodiments can be arbitrarily combined, for example, some or all steps of different embodiments can be arbitrarily combined, and a particular embodiment can be arbitrarily combined with the optional implementation methods of other embodiments.

[0032] In each of the disclosed embodiments, unless otherwise specified or logically conflicting, the terminology and / or descriptions between the embodiments are consistent and can be referenced interchangeably. Technical features in different embodiments can be combined to form new embodiments based on their inherent logical relationships. The terminology used in the embodiments of this disclosure is for the purpose of describing specific embodiments only and is not intended to limit the disclosure. In the embodiments of this disclosure, unless otherwise stated, elements expressed in the singular form, such as "a," "an," "the," "the," "the," "the," "the," "this," etc., can mean "one and only one," or "one or more," "at least one," etc. For example, when using articles such as "a," "an," "the," etc. in translation, the noun after the article can be understood as either a singular or a plural expression. In some embodiments, terms such as "in response to," "in response to determining," "in the case of," "when," "if," "if," etc., can be interchanged. In some embodiments, terms such as "greater than," "greater than or equal to," "not less than," "more than," "more than or equal to," "not less than," "higher than," "higher than or equal to," "not lower than," and "above" can be used interchangeably. Similarly, terms such as "less than," "less than or equal to," "not greater than," "less than," "less than or equal to," "not more than," "lower than," "lower than or equal to," "not higher than," and "below" can be used interchangeably. Prefixes such as "first" and "second" in the embodiments of this disclosure are merely for distinguishing different descriptive objects and do not constitute limitations on the position, order, priority, quantity, or content of the descriptive objects. The description of the descriptive objects should be referred to the claims or the context of the embodiments, and the use of prefixes should not constitute unnecessary restrictions.

[0033] In this embodiment of the disclosure, "multiple" refers to two or more. In this embodiment of the disclosure, terms such as "import," "input," and "read in" can be used interchangeably.

[0034] In some embodiments, devices, etc., can be interpreted as physical or virtual, and their names are not limited to the names recorded in the embodiments. Terms such as “device”, “equipment”, “circuit”, “network element”, “node”, “function”, “unit”, “section”, “system”, “network”, “chip”, “chip system”, “entity”, and “subject” can be used interchangeably.

[0035] In some embodiments, the terms "terminal", "terminal device", "user equipment (UE)", "user terminal", "mobile station (MS)", "mobile terminal (MT)", "subscriber station", "mobile unit", "subscriber unit", "wireless unit", "remote unit", "mobile device", "wireless device", "wireless communication device", "remote device", "mobile subscriber station", "access terminal", "mobile terminal", "wireless terminal", "remote terminal", "handset", "useragent", "mobile client", and "client" can be used interchangeably.

[0036] Digital watermarking is an information security technology that embeds watermark information into digital carriers (such as digital images, digital videos, or structured data) using certain rules and algorithms to identify digital copyright owners and track data breach perpetrators. Digital watermarking is divided into visible watermarks and invisible watermarks. Visible watermarks are watermark information that is visible to the human eye, such as common logos, while invisible watermarks are watermark information that is imperceptible to the human eye.

[0037] For image dark watermarking, algorithms modify pixel positions or values ​​in the spatial or transform domain of the image to hide the marking information within redundant image data. The core characteristics of image dark watermarking include transparency (the watermark embedding does not cause perceptible distortion to the human eye, maintaining the image's appearance), robustness (the watermark resists common attacks such as compression, noise addition, and cropping, and can still be detected after an attack), security (difficult to forge or tamper with, unauthorized individuals cannot read or remove the watermark), and provability (it can provide reliable evidence of image ownership through extraction, supporting copyright traceability). Dark watermarking is further divided into blind watermarking and non-blind watermarking. Blind watermarking refers to watermark information extraction that does not require the original image; the watermark information can be restored solely through algorithms.

[0038] In related technologies, image processing and matrix transformation methods include Discrete Fourier Transform (DFT), Discrete Cosine Transform (DCT), Discrete Wavelet Transform (DWT), Singular Value Decomposition (SVD), etc.

[0039] There are many schemes for embedding watermark information in image processing based on frequency domain transform algorithms, including those combining multiple transform methods, optimizing block segmentation, and optimizing embedding position. Schemes combining multiple transform methods do not consider implementation performance or the effectiveness of decoding after watermark information extraction. Schemes optimizing block segmentation and embedding position use edge values ​​to filter blocks and embedding positions, or optimize embedding capacity by combining embedding positions. These methods are complex to implement, have low usability, are difficult to implement, or rely on algorithmic stealth, making them vulnerable to erasure attacks and detection of tampered areas.

[0040] To address the aforementioned issues, this application provides a method for embedding and extracting image watermarks. As shown in Figure 1, the embedding process involves first encoding the watermark information and generating a watermark encoding matrix together with a key; second, processing and segmenting the image, and embedding the corresponding data from the watermark encoding matrix into each segment using the key and a sequence of position coordinates; then, scaling the image, segmenting the scaled image again, and embedding the corresponding data from the watermark encoding matrix into each segment using the key and a sequence of position coordinates; finally, scaling the image back to its original size and outputting the image with the embedded watermark information.

[0041] As shown in Figure 2, extraction is the reverse of embedding. The extraction process involves first processing and dividing the image into blocks, then extracting the embedded information in each block using the key and position coordinate sequence, and retrieving the starting position of the watermark encoding matrix. If no watermark encoding matrix is ​​found, the image is scaled, and the scaled image is divided into blocks. The embedded information in each block is extracted using the key and position coordinate sequence, and the starting position of the watermark encoding matrix is ​​retrieved. Based on the starting position, the embedded information in each block is extracted to form an extraction information matrix. All watermark encoding matrices are statistically analyzed to restore the watermark information.

[0042] As shown in Figure 3, in some embodiments, the image watermark embedding method provided in this application includes steps S101-S105.

[0043] S101. Generate a watermark encoding matrix based on the preset key and watermark information.

[0044] The watermark information is encoded and used to generate a watermark encoding matrix together with a preset key.

[0045] S102. Based on the preset key and position coordinate sequence, embed the corresponding data in the watermark coding matrix into the first image block of the original image.

[0046] The original image is processed and divided into blocks. Combining the key and the position coordinate sequence, the corresponding data in the watermark coding matrix is ​​embedded in each image block (the first image block).

[0047] S103. Merge the first image blocks and perform scaling to obtain the first intermediate image.

[0048] After performing the above operation (step S102) on each image block (first image block), the image blocks are merged and restored to a complete image, and the restored image is scaled to serve as the first intermediate image.

[0049] It should be noted that the original image, the first intermediate image, and the watermark image, the second intermediate image, etc., described in the embodiments of this application are only used to distinguish the images obtained from different processing processes, and are not intended to generate a new image with other content.

[0050] S104. Based on the preset key and position coordinate sequence, embed the corresponding data in the watermark coding matrix into the second image block of the first intermediate image.

[0051] The scaled image (first intermediate image) is further divided into blocks, and the corresponding data in the watermark coding matrix is ​​embedded in each image block (second image block) by combining the key and the position coordinate sequence.

[0052] S105. Merge the second image blocks and perform scaling processing according to the size of the original image to obtain the watermark image.

[0053] After embedding the data corresponding to the watermark coding matrix into the second image blocks, the second image blocks are merged and scaled to the size of the original image to obtain a watermarked image with embedded watermark information.

[0054] In this embodiment, a watermark encoding matrix is ​​first generated based on a preset key and watermark information. Then, the original image is processed and divided into blocks. The corresponding matrix data is embedded into the first image block by combining the key and the position coordinate sequence. The blocks are merged and scaled to obtain a first intermediate image. The first intermediate image is then divided into blocks again and the embedding operation is repeated. Finally, the second image block is merged and scaled to the original image size to complete the watermark embedding.

[0055] In this way, the dual-stage block embedding and scaling collaborative design allows the watermark data to be carried by redundant data in both the original and scaled images, effectively resisting multiple attacks such as cropping, scaling, and compression, and ensuring the effectiveness of watermark extraction. The embedding process only modifies specific coordinate data in the image blocks, which has little impact on image quality. Moreover, the embedding mechanism based on the key and position coordinate sequence does not rely on the stealth of the algorithm, which improves the security of the watermark and avoids unauthorized extraction and tampering.

[0056] In some embodiments, for step S101, when generating the watermark encoding matrix based on the preset key and watermark information, the watermark information is encoded to obtain a bit string. That is, the watermark information is transformed into a bit string composed of 0s and 1s.

[0057] In one implementation, the watermark information is encoded, and the conversion methods used to convert the watermark information into a bit string include, but are not limited to, UTF8 (Unicode Transformation Format-8-bit binary encoding), converting the string into binary encoding based on ASCII (American Standard Code for Information Interchange) after base64 processing, and various compression algorithms.

[0058] The matrix dimension is then determined based on the length of the bit string, where the matrix dimension is the minimum value that satisfies the preset length condition. The bit string is padded to a preset length (L) using the inverse value of the watermark information matrix identifier. The first matrix is ​​then transformed based on the matrix dimension and the padded bit string. The first row and first column of the first matrix are filled with the watermark information matrix identifier to obtain the second matrix. Finally, a watermark encoding matrix is ​​generated based on the second matrix and the preset key.

[0059] In other words, generating the watermark encoding matrix together with the key involves converting the watermark information encoding sequence into an n*n matrix, where n is determined by the length L of the watermark information encoding sequence. n is the minimum value satisfying (n-1)*(n-2)>L. The watermark information encoding sequence is padded to a length of (n-1)*(n-1) using the inverse value of the watermark information matrix identifier (e.g., if the watermark information matrix identifier is 1, it is padded with 0s). This padded sequence is then converted into an (n-1)*(n-1) matrix in a specific order. This order can be from left to right, top to bottom, or an S-shaped padding, etc., as long as it remains consistent during extraction. The watermark information matrix identifier is then filled into the first row and first column of the matrix. Finally, this matrix is ​​transformed with the key to generate the watermark encoding matrix.

[0060] Exemplarily, the watermark information is "Jiutian", the watermark encoding method is based on UTF8 binary encoding, and it is converted into a binary bit stream "111001001011100110011101111001011010010010101001". The length L of the watermark information encoding sequence is 48, so n is 9. The watermark information matrix identifier is 1, and its opposite value is 0. The watermark information encoding sequence is filled to a length of 64, that is, "1110010010111001100111011110010110100100101010010000000000000000". Converted into a matrix in the order from top to bottom and from left to right:

[0061] Then, the opposite value of the watermark information matrix identifier is filled in the first row and the first column of the matrix (the watermark information matrix identifier is 0, and 1 is filled here), and it is converted into:

[0062] Let the key be "cmri", which is converted into a binary code "1100011110110111100101101001". Using the transformation method of exclusive OR operation, it performs an exclusive OR operation on the matrix in sequence in a loop to generate the following watermark encoding matrix:

[0063] In some embodiments, before embedding the corresponding data in the watermark encoding matrix into the first image block of the original image, the luminance component data of the original image is extracted through a color space conversion algorithm, such as Y-channel data. Then, based on the luminance component data, the original image is block-processed to obtain the first image block. That is to say, processing and blocking the image means obtaining the channel component data of the image and then dividing the image into blocks of m*m pixel size for subsequent processing.

[0064] Exemplarily, the Y-channel data of the image, that is, the luminance component data, is extracted through a color space conversion algorithm. The image is blocked in the size of 8*8, that is, for subsequent processing, the matrix information of 8*8 size is read each time.

[0065] The same logic applies to the embedding in steps S102 or S104. Specifically, in some embodiments, in response to rows and columns filled with the watermark information matrix identifier in the first or second image block, the embedding position is determined to be the corresponding sequence number of the position coordinate sequence obtained after transformation using the preset key. In response to rows and columns not filled with the watermark information matrix identifier in the first or second image block (the remaining positions), the embedding position is determined to be the corresponding sequence number of the position coordinate sequence obtained after transformation using the preset key and the block identifier, where the block identifier is the identifier of the first or second image block.

[0066] For example, the embedding position is obtained by combining the key and the position coordinate sequence. The position coordinate sequence refers to a list of pairs of (x,y) coordinates: {((x1,y1),(x1',y1')),((x2,y2),(x2',y2')),……,((xn,yn),(xn',yn'))}, with the coordinates ranging within the block size. The method for obtaining the embedding position is as follows: the watermark information matrix identifies the rows and columns to be filled (i.e., the first row and the first column), and the position coordinates are the sequence numbers of the position coordinate sequence obtained after a specific transformation of the key. For the remaining positions, the key and the block identifier are transformed using specific methods to obtain the position coordinate sequence numbers. Transformation methods include, but are not limited to, MD5 modulo operation.

[0067] For steps S102 or S104, in some embodiments, when embedding the corresponding data in the watermark coding matrix into the first image block of the original image, or embedding the corresponding data in the watermark coding matrix into the second image block of the first intermediate image, in response to the embedded data being a first value (e.g., binary 0), it is determined that the difference between the first coordinate and the second coordinate of the embedding position satisfies that the first coordinate value is greater than the second coordinate value, and the difference between the first coordinate value and the second coordinate value exceeds a preset threshold (a set influence factor); in response to the embedded data being a second value (e.g., binary 1), it is determined that the second coordinate value is greater than the first coordinate value, and the difference between the second coordinate value and the first coordinate value exceeds a preset threshold.

[0068] In other words, the corresponding data in the watermark encoding matrix is ​​embedded in each block. The embedding method is to modify the values ​​on the coordinate pairs. If the code to be embedded is 0, then the value of (x1,y1) minus the value of (x1',y1') is greater than the threshold (the threshold is a set influence factor); if the code to be embedded is 1, then the value of (x1',y1') minus the value of (x1,y1) is greater than the threshold.

[0069] For example, starting from position (0,0) of the image Y channel data, take 8*8 blocks of data. This is the Y channel data of block (0,0), as follows: 125.0,125.0,133.0,128.0,120.0,116.0,123.0,124.0; 125.0,125.0,133.0,128.0,120.0,116.0,123.0,124.0; 125.0,125.0,133.0,128.0,120.0,116.0,123.0,124. 0; 125.0,125.0,133.0,128.0,120.0,116.0,123.0,124.0; 125.0,125.0,133.0,128.0,120.0,116.0,123.0,124.0; 123.0,123.0,113.0,111.0,120.0,115.0,120.0,113.0; 119.0,119.0,116.0,115.0,125.0,112.0,116.0,105.0.

[0070] The DCT transform was performed on the (0,0) block, and the data is as follows: 968.875, 19.382953643798828, -0.2289784699678421, -9.218305587768555, 0.3749999701976776, 4.847121715545654, -5.452414512634277, 7.779252052307129; 28.8714656829834, -0.45282626152038574, 1.9509299993515015, -22.767311096191406, -0.79441 67852401733, 8.182661056518555, 8.19821548461914, 0.2988029718399048; -13.483139991760254, 1.0958551168441772, -2.79549503326416, 10.09438705444336, 1.3181697130203247, -3.4494378566741943, -3.32950496673584, -1.6353787183761597; -0.5551390647888184, -1.272569 179534912, 2.372530937194824, 1.0421216487884521, -1.5409390926361084, -0.6134693026542664, -0.9860425591468811, 2.99237966537475 6; 5.625003337860107, 0.5631776452064514, 0.004807732999324799, -4.27766227722168, 1.1249998807907104, 1.6065157651901245, 2.29809 18884277344, -3.673015832901001; -2.0246357917785645, 0.6510186791419983, -3.1905150413513184, 0.2704140245914459, -0.27794158458 709717,0.13465583324432373,-0.7960514426231384,3.434537172317505;-3.4801013469696045,-1.4569029808044434,4.92049503326416,4.723311424255371,-0.41070476174354553,-2.121901035308838,-1.2045046091079712,-2.503922700881958;4.340950012207031,1.1826868057250977,-3.6606545448303223,-4.889768600463867,0.4792250990867615,2.0892906188964844,1.5144151449203491,1.2760486602783203。.

[0071] Taking the modulo of the column width 9 of the watermark coding matrix from block (0,0), we obtain the code for the watermark coding matrix at position (0,0), which is 1. Therefore, we need to obtain the data at coordinates ((4,1), (3,2)). The value at (4,1) is -0.7944167852401733, and the value at (3,2) is 2.372530937194824. With the influence factor set to 20, we need to ensure that the value at (3,2) minus the value at (4,1) is greater than 20. Therefore, we modify the value at (3,2) to 20. The revised DCT data are: 968.875, 19.382953643798828, -0.2289784699678421, -9.218305587768555, 0.3749999701976776, 4.847121715545654, -5.452414512634277, 7.779252052307129; 28.8714656829834, -0.45282626152038574, 1.950929 9993515015, -22.767311096191406, -0.7944167852401733, 8.182661056518555, 8.19821548461914, 0.2988029718399048; -13.483139991760254, 1.0958551168441772, -2.79549503326416, 10.09438705444336, 1.318169713020324 7, -3.4494378566741943, -3.32950496673584, -1.6353787183761597; -0.5551390647888184, -1.272569179534912, 20.0, 1.0421216487884521, -1.5409390926361084, -0.6134693026542664, -0.9860425591468811, 2.992379665374 756; 5.625003337860107, 0.5631776452064514, 0.004807732999324799, -4.27766227722168, 1.1249998807907104, 1.6065157651901245, 2.2980918884277344, -3.673015832901001; -2.0246357917785645, 0.6510186791419983, -3.1905150413513184,0.2704140245914459,-0.27794158458709717,0.13465583324432373,-0.7960514426231384,3.434537172317505;-3.4801013469696045,-1.4569029808044434,4.92049503326416,4.723311424255371,-0.41070476174354553 ,-2.121901035308838,-1.2045046091079712,-2.503922700881958;4.340950012207031,1.1826868057250977,-3.6606545448303223,-4.889768600463867,0.4792250990867615,2.0892906188964844,1.5144151449203491,1.2760486602783203。 .

[0072] The DCT data is subjected to inverse DCT transformation to restore the Y-channel data. After performing the above operation on each block, the blocks are merged to restore the complete image, thus completing the embedding process of the watermark coding matrix.

[0073] In some embodiments, merging the first image blocks and performing scaling processing refers to obtaining the length and width of the image and scaling it to a specified size using a strategy. For example, if the image's width and height are 700*568, the strategy is to enlarge the image. After enlargement, the height H = watermark encoding matrix column width n * block pixel size * m, where m is the minimum value satisfying H>=568. Using n=9, the block pixel size=8, and m=8, the image will be enlarged to 718*576.

[0074] In some embodiments, the corresponding data of the watermark coding matrix can be embedded into the second image block of the first intermediate image, as described in the above embodiments. The principle and logic are the same, and will not be repeated here.

[0075] In some embodiments, the second image blocks are merged and scaling is performed according to the size of the original image to scale the image information back to the original size, and an image with embedded watermark information is output.

[0076] Based on the above image watermark embedding method, similarly as shown in Figure 4, this application also provides an image watermark extraction method. In some embodiments, the image watermark extraction method may include S201-S205.

[0077] S201. Based on the preset key and position coordinate sequence, perform embedding information extraction on the image blocks to be extracted to obtain the extracted information.

[0078] The image block to be extracted is either the third image block of the watermark image or the fourth image block of the second intermediate image. The second intermediate image is the image obtained by scaling the watermark image.

[0079] In one implementation, if the starting position of the watermark coding matrix can be determined based on the extracted information of the image blocks (third image block) of the watermark image, then the embedding information is extracted through the watermark image; otherwise, the watermark image is scaled, and the embedding information is extracted based on the image blocks (fourth image block) of the scaled image (second intermediate image).

[0080] S202. Retrieve the starting position of the watermark coding matrix based on the extracted information.

[0081] The starting position of the watermark coding matrix can be retrieved based on the information extracted above. It can be determined by the information extracted from the image blocks of the watermark image or by the information extracted from the image blocks of the second intermediate image.

[0082] S203. Based on the starting position, extract the embedding information of the image blocks to be extracted to obtain the extraction information matrix.

[0083] Based on the starting position, combined with the preset key and position coordinate sequence, the information embedded in each image block to be extracted is extracted to form an extraction information matrix.

[0084] S204. Perform statistical processing on the extracted information matrix to obtain the watermark encoding matrix.

[0085] After obtaining the extracted information matrix, statistical analysis is performed on it to exclude outliers, resulting in the watermark encoding matrix.

[0086] S205. The watermark information is restored based on the preset key and the watermark encoding matrix.

[0087] By combining the preset key and the watermark encoding matrix, the corresponding watermark information is restored, thus completing the extraction of the watermark information.

[0088] In this embodiment, based on a preset key and a sequence of position coordinates, embedding information extraction is performed on the third image block of the watermark image or the fourth image block of the second intermediate image obtained by scaling. The starting position of the watermark encoding matrix is ​​retrieved first by using the extracted information of the watermark image. If it is not found, the extracted information of the second intermediate image is used to retrieve it again. Based on the retrieved starting position, the embedding information of all image blocks to be extracted is extracted to form an extraction information matrix. After statistical processing to exclude outliers, the watermark encoding matrix is ​​obtained. Finally, the original watermark information is restored by combining the preset key.

[0089] In this way, the collaborative design of secondary scaling retrieval and block extraction allows the extraction process to adapt to scenarios where images have been attacked by cropping, scaling, etc., greatly improving the robustness of watermark extraction; the statistical processing of the extracted information matrix can effectively eliminate outliers in the tampered area and realize the location of the tampered area in the image; the extraction process relies on the preset key and location coordinate sequence, and does not rely on the algorithm's stealth, so even if the algorithm process is known, the watermark cannot be extracted without authorization, which is more secure, and no manual intervention is required throughout the process, making the processing efficient and accurate.

[0090] In some embodiments, the image block to be extracted is the same size as the image block when the watermark information is embedded, and the preset key is the same as the preset key when the watermark information is embedded.

[0091] In some embodiments, when performing embedding information extraction on the image blocks to be extracted, embedding information extraction is performed on the third image block of the watermark image to obtain first extracted information. The starting position of the watermark coding matrix is ​​retrieved based on the first extracted information.

[0092] In other words, the watermarked image is processed and divided into blocks. By combining the key and the position coordinate sequence, the information embedded in each block (the third image block) is extracted, and the starting position of the watermark coding matrix is ​​retrieved.

[0093] In some embodiments, before performing embedded information extraction on the image blocks to be extracted, the luminance component data of the watermark image is extracted by a color space conversion algorithm, and then the watermark image is segmented based on the luminance component data to obtain the image blocks to be extracted.

[0094] For example, processing and segmenting the watermarked image involves acquiring the image's channel component data, dividing the image into m*m pixel blocks for subsequent processing, where the value of m remains consistent with the embedding process. The embedding position of the watermark information matrix identifier is obtained by combining the key and the position coordinate sequence. The method for obtaining the position coordinate sequence and sequence number remains consistent with the embedding process. Information is extracted from each block to obtain the first extracted information, using the same method as the embedding process. The starting position of the watermark information encoding matrix is ​​retrieved; specifically, this can be done by searching the rows and columns of the watermark information matrix identifier (i.e., the first row and first column are filled with the watermark information matrix identifier) ​​to determine the specific coordinates of the watermark information encoding matrix.

[0095] It should be noted that due to the possibility of cropping attacks, the amount of cropping may not be a multiple of the exact cropped block size, and a portion may be cropped out. Therefore, to improve the extraction effectiveness, the above operation needs to be performed on each offset within the block size (offset refers to the extraction starting from image coordinates (0,1), (0,2)...(7,6), (7,7)) to form an extraction information matrix, and then search for the presence of watermark information. If a watermark information encoding matrix is ​​found, proceed to step S203.

[0096] In response to the failure to find the starting position, the watermark image is scaled to obtain a second intermediate image. Then, embedding information is extracted from the fourth image block of the second intermediate image to obtain the second extracted information. Finally, the starting position of the watermark coding matrix is ​​retrieved based on the second extracted information.

[0097] In some embodiments, after retrieving the starting position of the watermark encoding matrix based on the second extraction information, if the starting position is not found, it is determined that no watermark information has been extracted; if the starting position is found, the step of extracting embedded information based on the starting position is performed (i.e., step S203).

[0098] In other words, if the starting position is not found, the watermark image is scaled up, the scaled image (the second intermediate image) is divided into blocks, and the information embedded in each block (the fourth image block) is extracted by combining the key and the position coordinate sequence to retrieve the starting position of the watermark encoding matrix.

[0099] For example, scaling the watermark image specifically involves obtaining the image's length and width, and then scaling it to a specified size using a strategy. The strategy remains consistent with the embedding method. Following the same principle as the retrieval method described above, the starting position of the watermark information encoding matrix is ​​retrieved. If not found, the system returns that no watermark information was extracted and the process ends; otherwise, step S203 is executed.

[0100] In some embodiments, when retrieving the starting position of the watermark encoding matrix based on the extracted information, extraction and retrieval operations are performed on each offset within the size range of the image block to be extracted, and the starting position of the watermark encoding matrix is ​​determined by retrieving the rows and columns filled by the watermark information matrix identifier. Here, the offset represents all combinations within the coordinate range corresponding to the image block.

[0101] In other words, the process of extracting embedding information from image blocks based on their starting positions to obtain an embedding information matrix involves using the starting position (i.e., obtaining the image's extraction coordinate offset) as the starting point and extracting watermark encoding information from that offset. The extraction positions of the watermark encoding are obtained by combining the key and block identifiers. The method involves filling the rows and columns (i.e., the first row and first column) of the watermark information matrix identifier, with the position coordinates being the sequence number of the position coordinate sequence obtained after a specific transformation of the key. For other positions, the sequence number of the position coordinate sequence is obtained by performing a specific transformation of the key and the block identifier. The transformation method is consistent with that used during embedding. The embedded information in each block is then extracted to obtain the extraction information matrix.

[0102] In some embodiments, when extracting the information matrix, it is necessary to perform a transformation operation with a preset key (to maintain consistency with the embedding process) to restore it to the original watermark encoding matrix.

[0103] In some embodiments, when performing statistical processing on the extracted information matrix, the extracted information matrix is ​​divided into blocks according to the matrix dimension to obtain an encoding matrix, wherein the matrix dimension is determined according to the length of the bit string. Then, statistical operations are performed on the data at the same coordinates in the encoding matrix to exclude outliers in tampered areas, resulting in a watermark encoding matrix.

[0104] In other words, the statistical method for the watermark encoding matrix is ​​to divide the extracted information matrix into n*n blocks, obtain all the watermark information encoding matrices from the extracted information matrix, and statistically analyze the value of each coordinate position to exclude abnormal values ​​in the tampered area, thus forming the watermark encoding matrix.

[0105] In some embodiments, in response to a difference in the encoding matrix corresponding to the target region, the target region is determined to be a tampered region and the tampered region is located.

[0106] For example, as shown in Figure 5, after statistical counting of the watermark information encoding matrix 501, outlier values ​​502 in the first matrix can be eliminated.

[0107] During the extraction process, anomaly detection of the watermark encoding matrix can be performed. If the watermark encoding matrix of a certain region (target region) differs from that of other regions, it can be determined that the image of that region has been tampered with. As shown in Figure 6, the difference in the position of the matrix of target region 601 compared to other matrices indicates that the block involved in target region 601 has been tampered with.

[0108] In some embodiments, the watermark information is restored according to a preset key and a watermark encoding matrix, that is, the watermark information encoding matrix is ​​restored into a bit string according to the order of encoding, and then decoded into the original watermark information.

[0109] Based on the above-described image watermark embedding method, this application also provides an image watermark embedding device, as shown in FIG7. In some embodiments, the device 700 includes an encoding module 701 and an embedding module 702, wherein: the encoding module 701 is configured to generate a watermark encoding matrix based on a preset key and watermark information; the embedding module 702 is configured to embed corresponding data in the watermark encoding matrix into a first image block of the original image according to the preset key and a position coordinate sequence; merge the first image blocks and perform scaling processing to obtain a first intermediate image; embed corresponding data in the watermark encoding matrix into a second image block of the first intermediate image according to the preset key and a position coordinate sequence; merge the second image blocks and perform scaling processing according to the size of the original image to obtain a watermarked image.

[0110] In some embodiments, the encoding module 701 is configured to perform encoding processing on the watermark information to obtain a bit string; determine the matrix dimension based on the length of the bit string, wherein the matrix dimension is the minimum value that satisfies a preset length condition; pad the bit string to a sequence of a preset length using the inverse value of the watermark information matrix identifier; transform a first matrix according to the matrix dimension and the padded bit string; fill the first row and first column of the first matrix with the watermark information matrix identifier to obtain a second matrix; and generate the watermark encoding matrix according to the second matrix and the preset key.

[0111] In some embodiments, the apparatus 700 further includes a block processing module, which is configured to extract luminance component data of the original image by means of a color space conversion algorithm before embedding the corresponding data in the watermark coding matrix into the first image block of the original image; and to perform block processing on the original image based on the luminance component data to obtain the first image block.

[0112] In some embodiments, the embedding module 702 is configured to embed the corresponding data in the watermark coding matrix into a first image block of the original image, or to embed the corresponding data in the watermark coding matrix into a second image block of the first intermediate image, including: in response to the embedded data being a first value, determining that the difference between the first coordinate and the second coordinate of the embedding position satisfies that the first coordinate value is greater than the second coordinate value, and the difference between the first coordinate value and the second coordinate value exceeds a preset threshold; in response to the embedded data being a second value, determining that the second coordinate value is greater than the first coordinate value, and the difference between the second coordinate value and the first coordinate value exceeds the preset threshold.

[0113] In some embodiments, the embedding module 702 is configured to, in response to rows and columns filled with watermark information matrix identifiers in the first image block or the second image block, determine the embedding position as the corresponding sequence number of the position coordinate sequence obtained after the preset key is transformed; in response to rows and columns not filled with watermark information matrix identifiers in the first image block or the second image block, determine the embedding position as the corresponding sequence number of the position coordinate sequence obtained after the preset key and the block identifier are combined and transformed; the block identifier is the identifier of the first image block or the second image block.

[0114] Based on the above-described image watermark extraction method, this application also provides an image watermark extraction device, as shown in FIG8. In some embodiments, the device 800 includes an extraction module 801 and a restoration module 802, wherein: the extraction module 801 is configured to perform embedding information extraction on the image block to be extracted according to a preset key and a position coordinate sequence to obtain extraction information; the image block to be extracted is the third image block of the watermark image or the fourth image block of the second intermediate image, wherein the second intermediate image is an image obtained by scaling the watermark image; the starting position of the watermark encoding matrix is ​​retrieved according to the extraction information; the embedding information of the image block to be extracted is extracted based on the starting position to obtain an extraction information matrix; the restoration module 802 is configured to perform statistical processing on the extraction information matrix to obtain the watermark encoding matrix; and restore the watermark information according to the preset key and the watermark encoding matrix.

[0115] In some embodiments, the extraction module 801 is configured to perform embedding information extraction on a third image block of the watermark image to obtain first extraction information; retrieve the starting position of the watermark coding matrix based on the first extraction information; in response to not finding the starting position, perform scaling processing on the watermark image to obtain a second intermediate image; perform embedding information extraction on a fourth image block of the second intermediate image to obtain second extraction information; and retrieve the starting position of the watermark coding matrix based on the second extraction information.

[0116] In some embodiments, the extraction module 801 is configured to retrieve the starting position of the watermark encoding matrix based on the second extraction information, and then, in response to not finding the starting position, determine that no watermark information has been extracted; and in response to finding the starting position, perform the step of extracting embedded information based on the starting position.

[0117] In some embodiments, the extraction module 801 is configured to extract the luminance component data of the watermark image through a color space conversion algorithm before performing embedded information extraction on the image blocks to be extracted; and to perform block processing on the watermark image based on the luminance component data to obtain the image blocks to be extracted.

[0118] In some embodiments, the extraction module 801 is configured to perform extraction and retrieval operations on each offset within the size range of the image block to be extracted, wherein the offset is all combinations within the coordinate range corresponding to the image block; and to determine the starting position of the watermark encoding matrix by retrieving the rows and columns filled by the watermark information matrix identifier.

[0119] In some embodiments, the restoration module 802 is configured to divide the extracted information matrix into blocks according to the matrix dimension to obtain an encoding matrix; the matrix dimension is determined according to the length of the bit string; and to perform statistical operations on the data at the same coordinate position in the encoding matrix to exclude outliers in the tampered area, thereby obtaining the watermark encoding matrix.

[0120] In some embodiments, the restoration module 802 is configured to determine that the target region is a tampered region and locate the tampered region in response to a difference in the encoding matrix corresponding to the target region.

[0121] In some embodiments, the image block to be extracted is the same size as the image block when the watermark information is embedded, and the preset key is the same as the preset key when the watermark information is embedded.

[0122] It should be noted that the foregoing explanation of the method embodiments also applies to the apparatus of the embodiments of this disclosure, and the principle is the same. Therefore, the embodiments of this disclosure are not limited thereto.

[0123] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0124] Figure 9 illustrates a schematic block diagram of an example electronic device 900 that can be used to implement embodiments of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0125] As shown in Figure 9, the electronic device 900 includes a computing unit 901, which can perform various appropriate actions and processes based on a computer program stored in ROM (Read-Only Memory) 902 or loaded from storage unit 908 into RAM (Random Access Memory) 903. The RAM 903 can also store various programs and data required for the operation of the electronic device 900. The computing unit 901, ROM 902, and RAM 903 are interconnected via bus 904. An I / O (Input / Output) interface 905 is also connected to bus 904.

[0126] Multiple components in electronic device 900 are connected to I / O interface 905, including: input unit 906, such as keyboard, mouse, etc.; output unit 907, such as various types of displays, speakers, etc.; storage unit 908, such as disk, optical disk, etc.; and communication unit 909, such as network card, modem, wireless transceiver, etc. Communication unit 909 allows electronic device 900 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0127] The computing unit 901 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, CPUs (Central Processing Units), GPUs (Graphics Processing Units), various special-purpose AI (Artificial Intelligence) computing chips, various computing units running machine learning model algorithms, DSPs (Digital Signal Processors), and any suitable processor, controller, microcontroller, etc. The computing unit 901 performs the various methods and processes described above, such as image watermark embedding or extraction methods. For example, in some embodiments, the image watermark embedding or extraction method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 908. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 900 via ROM 902 and / or communication unit 909. When the computer program is loaded into RAM 903 and executed by the computing unit 901, one or more steps of the methods described above may be performed. Alternatively, in other embodiments, the computing unit 901 may be configured by any other suitable means (e.g., by means of firmware) to perform the aforementioned image watermark embedding or extraction method.

[0128] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, FPGAs (Field Programmable Gate Arrays), ASICs (Application-Specific Integrated Circuits), ASSPs (Application-Specific Standard Products), SOCs (System-on-Chips), CPLDs (Complex Programmable Logic Devices), computer hardware, firmware, software, and / or combinations thereof. These various implementations may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0129] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0130] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, RAM, ROM, EPROM (Electrically Programmable Read-Only Memory) or flash memory, optical fiber, CD-ROM (Compact Disc Read-Only Memory), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0131] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (Cathode-Ray Tube) or LCD (Liquid Crystal Display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0132] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include LANs (Local Area Networks), WANs (Wide Area Networks), the Internet, and blockchain networks.

[0133] Computer systems can include clients and servers. Clients and servers are generally geographically separated and typically interact via communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. A server can be a cloud server, also known as a cloud computing server or cloud host, a hosting product within the cloud computing service system that addresses the shortcomings of traditional physical hosts and VPS (Virtual Private Server) services, such as high management difficulty and weak business scalability. Servers can also be servers for distributed systems or servers incorporating blockchain technology.

[0134] It's important to note that artificial intelligence (AI) is the study of enabling computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, and planning). It encompasses both hardware and software technologies. AI hardware technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, and big data processing. AI software technologies primarily include computer vision, speech recognition, natural language processing, machine learning / deep learning, big data processing, and knowledge graph technologies.

[0135] As can be seen from the above technical solutions, the image watermark embedding and extraction method, apparatus, electronic device, and storage medium disclosed in this application, by combining block-based and scaling embedding methods, can resist multiple attacks such as cropping, scaling, compression, tampering, pasting, brightness, contrast, and chroma manipulation without affecting image quality, thus ensuring the effectiveness of watermark information extraction. Simultaneously, the image processing speed is faster than other algorithms, and the watermark information is processed through bit strings rather than embedded in the image, minimizing the impact on image quality. Extraction does not require manual identification of the watermark image information. Based on the key and position transformation mechanism, it does not rely on the concealment of the algorithm process; even if the algorithm process is known, the watermark information cannot be extracted or tampered with. Furthermore, by detecting anomalies in the watermark encoding matrix during extraction, the tampered area of ​​the image can be detected and located.

[0136] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.

[0137] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A method for embedding an image watermark, characterized in that, include: A watermark encoding matrix is ​​generated based on a preset key and watermark information; Based on the preset key and the position coordinate sequence, the corresponding data in the watermark encoding matrix is ​​embedded into the first image block of the original image; The first image blocks are merged and scaled to obtain the first intermediate image; Based on the preset key and the position coordinate sequence, the corresponding data in the watermark encoding matrix is ​​embedded into the second image block of the first intermediate image; The second image blocks are merged and scaled according to the original image size to obtain the watermarked image.

2. The method according to claim 1, characterized in that, The step of generating a watermark encoding matrix based on a preset key and watermark information includes: performing encoding processing on the watermark information to obtain a bit string; determining the matrix dimension according to the length of the bit string, wherein the matrix dimension is the minimum value that satisfies a preset length condition; padding the bit string to a sequence of a preset length using the opposite value of the watermark information matrix identifier; converting a first matrix according to the matrix dimension and the padded bit string; filling the first row and first column of the first matrix with the watermark information matrix identifier to obtain a second matrix; and generating the watermark encoding matrix according to the second matrix and the preset key.

3. The method according to claim 1, characterized in that, Before embedding the corresponding data in the watermark coding matrix into the first image block of the original image, the method further includes: extracting the luminance component data of the original image through a color space conversion algorithm; and performing block processing on the original image based on the luminance component data to obtain the first image block.

4. The method according to claim 1, characterized in that, The step of embedding the corresponding data in the watermark coding matrix into the first image block of the original image, or embedding the corresponding data in the watermark coding matrix into the second image block of the first intermediate image, includes: in response to the embedded data being a first value, determining that the difference between the first coordinate and the second coordinate of the embedding position satisfies that the first coordinate value is greater than the second coordinate value, and the difference between the first coordinate value and the second coordinate value exceeds a preset threshold; in response to the embedded data being a second value, determining that the second coordinate value is greater than the first coordinate value, and the difference between the second coordinate value and the first coordinate value exceeds the preset threshold.

5. The method according to claim 1, characterized in that, Also includes: In response to the first image block or the second image block being filled with rows and columns of watermark information matrix identifiers, the embedding position is determined to be the corresponding sequence number of the position coordinate sequence obtained after the preset key is transformed; In response to rows and columns in the first or second image block that are not filled with watermark information matrix identifiers, the embedding position is determined to be the corresponding sequence number of the position coordinate sequence obtained by performing transformation after combining the preset key and the block identifier; The block identifier is either the identifier of the first image block or the identifier of the second image block.

6. A method for extracting image watermarks, characterized in that, include: Based on the preset key and the position coordinate sequence, the image to be extracted is divided into blocks to perform embedding information extraction to obtain the extracted information; The image block to be extracted is either the third image block of the watermark image or the fourth image block of the second intermediate image, wherein the second intermediate image is an image obtained by scaling the watermark image. The starting position of the watermark encoding matrix is ​​retrieved based on the extracted information; Based on the starting position, the embedding information of the image block to be extracted is extracted to obtain the extraction information matrix; statistical processing is performed on the extraction information matrix to obtain the watermark encoding matrix; The watermark information is obtained by restoring the watermark information based on the preset key and the watermark encoding matrix.

7. The method according to claim 6, characterized in that, The step of extracting embedding information from the image blocks to be extracted includes: extracting embedding information from the third image block of the watermark image to obtain first extraction information; retrieving the starting position of the watermark coding matrix based on the first extraction information; performing scaling processing on the watermark image in response to not finding the starting position to obtain the second intermediate image; extracting embedding information from the fourth image block of the second intermediate image to obtain second extraction information; and retrieving the starting position of the watermark coding matrix based on the second extraction information.

8. The method according to claim 7, characterized in that, After retrieving the starting position of the watermark encoding matrix based on the second extracted information, the method further includes: determining that no watermark information has been extracted in response to the failure to retrieve the starting position; and performing the step of extracting embedded information based on the starting position in response to the retrieval of the starting position.

9. The method according to claim 6, characterized in that, Before performing embedded information extraction on the image blocks to be extracted, the method further includes: extracting the luminance component data of the watermark image through a color space conversion algorithm; and performing block processing on the watermark image based on the luminance component data to obtain the image blocks to be extracted.

10. The method according to claim 6, characterized in that, The step of retrieving the starting position of the watermark encoding matrix based on the extracted information includes: performing extraction and retrieval operations on each offset within the size range of the image block to be extracted, wherein the offset is all combinations within the coordinate range corresponding to the image block; and determining the starting position of the watermark encoding matrix by retrieving the rows and columns filled by the watermark information matrix identifier.

11. The method according to claim 6, characterized in that, The step of performing statistical processing on the extracted information matrix includes: dividing the extracted information matrix into blocks according to the matrix dimension to obtain an encoding matrix; the matrix dimension is determined according to the length of the bit string; performing statistical operations on the data at the same coordinate position in the encoding matrix to exclude outliers in the tampered area, thereby obtaining the watermark encoding matrix.

12. The method according to claim 6 or 11, characterized in that, Also includes: In response to the discrepancy in the encoding matrix corresponding to the target region, the target region is determined to be a tampered region and the tampered region is located.

13. The method according to claim 6, characterized in that, The image block to be extracted has the same size as the image block when the watermark information is embedded, and the preset key is the same as the preset key when the watermark information is embedded.

14. An image watermark embedding device, characterized in that, include: The encoding module is configured to generate a watermark encoding matrix based on a preset key and watermark information; The embedding module is configured to embed the corresponding data in the watermark coding matrix into the first image block of the original image according to the preset key and the position coordinate sequence; The first image blocks are merged and scaled to obtain the first intermediate image; Based on the preset key and the position coordinate sequence, the corresponding data in the watermark encoding matrix is ​​embedded into the second image block of the first intermediate image; The second image blocks are merged and scaled according to the original image size to obtain the watermarked image.

15. An image watermark extraction device, characterized in that, include: The extraction module is configured to extract embedded information from the image blocks to be extracted based on a preset key and a sequence of position coordinates, thereby obtaining the extracted information. The image block to be extracted is either the third image block of the watermark image or the fourth image block of the second intermediate image, wherein the second intermediate image is an image obtained by scaling the watermark image. The starting position of the watermark encoding matrix is ​​retrieved based on the extracted information; Based on the starting position, the embedding information of the image block to be extracted is extracted to obtain the extraction information matrix; The restoration module is configured to perform statistical processing on the extracted information matrix to obtain the watermark encoding matrix; The watermark information is obtained by restoring the watermark information based on the preset key and the watermark encoding matrix.

16. An electronic device, characterized in that, include: At least one processor; And a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-5 or 6-13.

17. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-5 or 6-13.

18. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method according to any one of claims 1-5 or 6-13.