Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete. It should be understood that the drawings and embodiments of the present disclosure are for illustration purposes only and are not intended to limit the scope of the present disclosure.
It should be noted that, for convenience of description, only the portions related to the present invention are shown in the drawings. Embodiments of the present disclosure and features of embodiments may be combined with each other without conflict.
It should be noted that the terms "first," "second," and the like in this disclosure are merely used to distinguish between different devices, modules, or units and are not used to define an order or interdependence of functions performed by the devices, modules, or units.
It should be noted that references to "one", "a plurality" and "a plurality" in this disclosure are intended to be illustrative rather than limiting, and those of ordinary skill in the art will appreciate that "one or more" is intended to be understood as "one or more" unless the context clearly indicates otherwise.
The names of messages or information interacted between the various devices in the embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 is a schematic diagram of one application scenario of a method for generating a watermark according to some embodiments of the present disclosure.
In the application scenario of fig. 1, first, the computing device 101 may receive the image 102 to be watermarked. In the present application scenario, the watermark image 102 to be added is a color picture, and the number of channels is 3. The computing device 101 may then convert the image 102 to be watermarked into a matrix form, generating a first matrix 103. The target user information 104 obtained in advance is expressed as a vector form, and the vector form of the target user information is subjected to inner product with the first matrix 103 to generate a second matrix 105. As an example, the target user information 104 may include a user number, such as "147" shown in fig. 1. Thereafter, the computing device 101 performs numerical adjustment on the second matrix 105, and generates a third matrix 106. Wherein the numerical adjustment of the second matrix 105 may include adding a preset weight to each element in the second matrix 105. For example, each element in the second matrix 105 described above is multiplied by 0.01. Finally, the computing device 101 converts the third matrix to an image format, generating the watermark 107.
The computing device 101 may be hardware or software. When the computing device is hardware, the computing device may be implemented as a distributed cluster formed by a plurality of servers or terminal devices, or may be implemented as a single server or a single terminal device. When the computing device is embodied as software, it may be implemented as a plurality of software or software modules, for example, to provide distributed services, or as a single software or software module. The present invention is not particularly limited herein.
It should be understood that the number of computing devices 101 in fig. 1 is merely illustrative. There may be any number of computing devices 101 as desired for an implementation.
With continued reference to fig. 2, a flow 200 of some embodiments of a method for generating a watermark according to the present disclosure is shown. The method for generating a watermark comprises the steps of:
a first matrix is generated based on the image to be watermarked, step 201.
In some embodiments, as an example, the execution subject of the method for generating a watermark may determine the size of the first matrix, i.e. the first dimension length, the second dimension length, the third dimension length, the fourth dimension length, according to the size of the image to be watermarked, i.e. the length, the width, the number of channels of the image. For example: the lengths from the first dimension to the third dimension of the first matrix may be the length, the width, and the number of channels of the watermark image to be added. While the fourth dimension length of the first matrix and the values of the elements in the first matrix may be randomly generated.
In some embodiments, the size of the first matrix may be in any proportion to the size of the image to be watermarked under the condition that the size of the image to be watermarked is smaller.
Step 202, generating a second matrix adapted to the image to be watermarked based on the target user information and the first matrix.
In some embodiments, the executing entity may represent the target user information in a numerical form, and then superimpose the numerical target user information on an element of the first matrix to generate the second matrix. The superposition position can be flexibly selected according to actual needs.
In some alternative implementations of some embodiments, the target user information may include a sequence of values for characterizing the target user. And generating a second matrix adapted to the watermark image to be added based on the target user information and the first matrix may include performing inner product on the first matrix and a vector corresponding to the numerical sequence to generate a second matrix, where a size of the second matrix is adapted to a size of a pixel matrix corresponding to the watermark image to be added.
With further reference to fig. 3, fig. 3 is an exemplary schematic diagram of a second matrix generation method of the method for generating a watermark according to the present disclosure.
As an example, the execution subject may first represent the target user information in a bit form, taking the case where the target user information is represented as "101". As shown in fig. 3, wherein reference numerals 301, 302, 303 are a first three-dimensional component, a second three-dimensional component, and a third three-dimensional component, respectively, in a fourth dimension of the first matrix. Then, the first matrix is inner-integrated with the user information "101", i.e. the first three-dimensional component 301 in the fourth dimension of the first matrix is added to the third three-dimensional component 303 in the fourth dimension of the first matrix, resulting in the second matrix 304.
And 203, performing numerical adjustment on the elements of the second matrix to generate a third matrix.
In some embodiments, performing numerical adjustment on elements of the second matrix may include the execution body adding a preset weight to each element of the second matrix.
In some alternative implementations of some embodiments, the execution body may apply an appropriate function to the elements of the second matrix to control the elements of the second matrix to be within a range of values. And then, adjusting the numerical value of the constrained second matrix element by using the super parameter to obtain a third matrix.
In step 204, the values of the elements in the third matrix are used as pixel values to generate the watermark.
With further reference to fig. 4, fig. 4 is an exemplary schematic diagram of generating a watermark using values of elements in a third matrix as pixel values in a method for generating a watermark according to some embodiments of the present disclosure.
In some embodiments, as an example, the execution body may set the size of the watermark to be the same as the size of the third matrix. On this basis, as shown in fig. 4, the third matrix is a three-dimensional matrix. Reference numeral 401 refers to the first two-dimensional component in its third dimension. Reference numeral 402 refers to a second two-dimensional component in its third dimension. Reference numeral 403 refers to a third two-dimensional component in its third dimension. Each pixel in the watermark 404 is composed of three values, representing the values of the three primary colors, respectively. Specifically, the value "1" in the first component 401 in the third dimension, the value "4" in the second component 402 in the third dimension, and the value "3" in the third component 403 in the third dimension form three values "1", "4", "3" of the first pixel "(1, 4, 3) in the watermark 404, respectively. Similarly, other pixels in the watermark 404 may be obtained using this method.
In some embodiments, the executing body may further use the watermark size to be any value smaller than the third matrix size. On the basis, according to actual needs, the corresponding relation between the elements in the third matrix and the pixel points in the watermark can be determined according to preset rules.
Some embodiments of the present disclosure provide methods that enable the determination of the addition location of a watermark without the need to base the image to be watermarked. After the watermark is added to the image in the follow-up process, the watermark is not easy to discard during image compression, so that the target user information in the watermark can be decoded more accurately.
With further reference to fig. 5, a flow 500 of further embodiments of a method for generating a watermark is shown. The flow 500 of the method for generating a watermark comprises the steps of:
step 501, a first matrix is generated based on an image to be watermarked.
In some embodiments, the specific implementation of step 501 and the technical effects thereof may refer to step 201 in the embodiment corresponding to fig. 2, which is not described herein.
Step 502, based on the target user information and the first matrix, generating a second matrix adapted to the image to be watermarked.
In some embodiments, the target user information may be a user number.
In some alternative embodiments of some embodiments, the target user information may also be a sequence of values used to characterize the target user information.
In some embodiments, the execution body may represent the target user information in a bit form, for example when the target user information is represented as "101". As shown in fig. 3, wherein reference numerals 301, 302, 303 are a first three-dimensional component, a second three-dimensional component, and a third three-dimensional component, respectively, in a fourth dimension of the first matrix. The first matrix is inner-product with the user information 101, i.e. the first three-dimensional component 301 in the fourth dimension of the first matrix is added to the third three-dimensional component 303 in the fourth dimension of the first matrix, resulting in a second matrix 304.
Step 503, performing numerical adjustment on the elements of the second matrix to generate a third matrix
In some embodiments, the execution body may apply an appropriate function to the elements of the second matrix to control the elements of the second matrix within a range of values. And then, adjusting the numerical value of the constrained second matrix element by using the super parameter to obtain a third matrix.
At step 504, the values of the elements in the third matrix are used as pixel values to generate the watermark.
In some embodiments, the specific implementation of step 504 and the technical effects thereof may refer to step 204 in the corresponding embodiment of fig. 2, which is not described herein.
And 505, superposing the values of the pixels in the watermark and the values of the pixels in the image to be watermarked to generate the image with the watermark. With further reference to fig. 6, fig. 6 is an exemplary schematic diagram of generating a watermarked image in a method for generating a watermark according to some embodiments of the present disclosure.
As shown in fig. 6, where reference numeral 601 is an image to be watermarked, the values of pixels in the image to be watermarked are shown. Reference numeral 602 is a watermark, which shows the values of pixels in the watermark. Reference numeral 603 is a watermarked image showing the values of the pixels in the watermarked image. For example, the pixel "(146,229,204)" in the image 601 to be watermarked is superimposed with the pixel "(1, 4, 3)" in the watermark 602 to obtain the pixel "(147,233,207)" in the watermarked image. The "146" and "1" are added to obtain "147". The addition of "229" and "4" yields "233". The "204" and "3" are added to obtain "207".
Step 506, performing image processing on the watermarked image to generate an attacked watermarked image.
In some embodiments, the method for performing image processing on a watermarked image by a subject may include: affine transformation, gaussian filtering, image compression coding, and the like. The execution subject may randomly combine the image processing methods according to actual needs. Further, parameters in the image processing method may also be selected randomly.
And step 507, decoding the attacked watermark image to obtain the target user information in the watermark.
In some embodiments, the executing entity may apply an image recognition technique to the attacked watermarked image to determine the target user information in the watermark.
In some embodiments, the executing entity may further apply an artificial neural network technology to the attacked watermarked image to determine target user information in the watermark.
Some embodiments of the present disclosure provide methods to hide user information in a watermark by generating the watermark with target user information. The original user of the picture can be screened through the watermark, and the viewing experience of the user viewing the picture can be improved. The use of functions and super-parameters to adjust the invisibility of the watermark and the accuracy of decoding allows the method to be flexibly applied to scenes with different requirements. By performing image processing on the watermarked image, the robustness of watermark decoding is enhanced. The method can cope with the situation that the original image is processed by users on the network in the real scene.
With further reference to fig. 7, as an implementation of the method shown in the above figures, the present disclosure provides some embodiments of an apparatus for generating watermarks, which apparatus embodiments correspond to those shown in fig. 2, and which apparatus is particularly applicable in various electronic devices.
As shown in fig. 7, an apparatus 700 for generating a watermark of some embodiments includes: a first generation unit 701, a second generation unit 702, a third generation unit 703, and a fourth generation unit 704. Wherein the first generating unit 701 is configured to generate a first matrix based on the image to be watermarked, and the second generating unit 702 is configured to generate a second matrix adapted to the image to be watermarked based on the target user information and the first matrix; the third generating unit 703 is configured to perform numerical adjustment on the elements of the second matrix to generate a third matrix; the fourth generation unit 704 is configured to generate a watermark using the values of the elements in the third matrix as pixel values.
In an alternative implementation of some embodiments, the apparatus 700 may further include: a fifth generating unit (not shown in the figure) configured to superimpose the values of the pixels in the watermark with the values of the pixels in the image to be watermarked, to generate the watermarked image.
In an alternative implementation of some embodiments, the second generating unit 702 is further configured to: the target user information includes a sequence of values for characterizing the target user. And generating a second matrix adapted to the watermark image to be added based on the target user information and the first matrix, including: and carrying out inner product on the vectors corresponding to the first matrix and the numerical sequence to generate a second matrix, wherein the size of the second matrix is matched with the size of the pixel matrix corresponding to the image to be watermarked.
In an alternative implementation of some embodiments, the third generating unit 703 is further configured to: applying a preset function to the second matrix element, and restricting the element of the matrix within a preset numerical range; and adjusting the numerical value of the constrained second matrix element by using the super parameter to obtain a third matrix.
In an alternative implementation of some embodiments, the apparatus 700 may further include: a sixth generation unit (not shown in the figure) is configured to perform image processing on the watermarked image, and generate an attacked watermarked image.
In an alternative implementation of some embodiments, the apparatus 700 may further include: and a determining unit (not shown in the figure) decodes the attacked watermarked image to obtain target user information in the watermark.
It will be appreciated that the elements described in the apparatus 700 correspond to the various steps in the method described with reference to fig. 2. Thus, the operations, features and resulting benefits described above for the method are equally applicable to the apparatus 700 and the units contained therein, and are not described in detail herein.
Referring now to fig. 8, a schematic diagram of an electronic device (e.g., server or terminal device of fig. 1) 800 suitable for use in implementing some embodiments of the present disclosure is shown. The electronic devices in some embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), car terminals (e.g., car navigation terminals), and the like, as well as stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 8 is merely an example, and should not impose any limitations on the functionality and scope of use of embodiments of the present disclosure.
As shown in fig. 8, the electronic device 800 may include a processing means (e.g., a central processor, a graphics processor, etc.) 801, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 802 or a program loaded from a storage means 808 into a Random Access Memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 are also stored. The processing device 801, the ROM 802, and the RAM 803 are connected to each other by a bus 804. An input/output (I/O) interface 805 is also connected to the bus 804.
In general, the following devices may be connected to the I/O interface 805: input devices 806 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 807 including, for example, a Liquid Crystal Display (LCD), speakers, vibrators, etc.; storage 808 including, for example, magnetic tape, hard disk, etc.; communication means 809. The communication means 809 may allow the electronic device 800 to communicate wirelessly or by wire with other devices to exchange data. While fig. 8 shows an electronic device 800 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead. Each block shown in fig. 8 may represent one device or a plurality of devices as needed.
In particular, according to some embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, some embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such embodiments, the computer program may be downloaded and installed from a network via communication device 809, or from storage device 808, or from ROM 802. The above-described functions defined in the methods of some embodiments of the present disclosure are performed when the computer program is executed by the processing device 801.
It should be noted that the computer readable medium according to some embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In some embodiments of the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In some embodiments of the present disclosure, however, the computer-readable signal medium may comprise a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
In some implementations, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol ), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the internet (e.g., the internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: generating a first matrix based on the watermark image to be added; generating a second matrix adapted to the watermark image to be added based on the target user information and the first matrix; adjusting the values of the elements in the second matrix to generate a third matrix; the watermark is generated using the value elements of the third matrix as pixel values.
Computer program code for carrying out operations for some embodiments of the present disclosure may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in some embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. The described units may also be provided in a processor, for example, described as: a processor includes a first generation unit, a second generation unit, a third generation unit, and a fourth generation unit. The names of these units do not in any way constitute a limitation of the unit itself, for example, the first generation unit may also be described as "unit generating the first matrix".
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
According to one or more embodiments of the present disclosure, there is provided a method for generating a watermark, comprising: generating a first matrix based on the watermark image to be added; generating a second matrix adapted to the watermark image to be added based on the target user information and the first matrix; performing numerical adjustment on elements of the second matrix to generate a third matrix; the watermark is generated using the value elements of the third matrix as pixel values.
In accordance with one or more embodiments of the present disclosure, a method for generating a watermark further comprises: and superposing the values of the pixel points in the watermark and the values of the pixel points in the image to be watermarked to generate the image with the watermark.
According to one or more embodiments of the present disclosure, the target user information includes a sequence of values for characterizing the target user; and generating a second matrix adapted to the image to be watermarked based on the target user information and the first matrix, comprising: and carrying out inner product on the vectors corresponding to the first matrix and the numerical sequence to generate a second matrix, wherein the size of the second matrix is matched with the size of the pixel matrix corresponding to the watermark image to be added.
According to one or more embodiments of the present disclosure, performing a numerical adjustment on the second matrix element, generating an adjusted second matrix as a watermark includes: applying a preset function to the second matrix element, and restricting the element of the matrix within a preset numerical range; and adjusting the numerical value of the constrained second matrix element by using the super parameter to obtain a third matrix.
According to one or more embodiments of the present disclosure, the method further comprises: and performing image processing on the watermarked image to generate the attacked watermarked image.
According to one or more embodiments of the present disclosure, the method further comprises: and decoding the attacked image with the watermark to obtain the target user information in the watermark.
According to one or more embodiments of the present disclosure, there is provided an apparatus for generating a watermark, comprising: a first generation unit configured to generate a first matrix based on an image to be watermarked; a second generation unit configured to generate a second matrix adapted to the watermark image to be added based on the target user information and the first matrix; the third generation unit is configured to carry out numerical adjustment on elements of the second matrix to generate a third matrix; and a fourth generation unit configured to generate a watermark using values of elements in the third matrix as pixel values.
According to one or more embodiments of the present disclosure, the apparatus further comprises: and a fifth generation unit configured to superimpose the values of the pixels in the watermark with the values of the pixels in the image to be watermarked, and generate the watermarked image.
According to one or more embodiments of the present disclosure, the second generation unit is further configured to: the target user information includes a sequence of values for characterizing the target user. And generating a second matrix adapted to the watermark image to be added based on the target user information and the first matrix, including: and carrying out inner product on the vectors corresponding to the first matrix and the numerical sequence to generate a second matrix, wherein the size of the second matrix is matched with the size of the pixel matrix corresponding to the image to be watermarked.
According to one or more embodiments of the present disclosure, the third generation unit is further configured to: applying a preset function to the second matrix element, and restricting the element of the matrix within a preset numerical range; and adjusting the numerical value of the constrained second matrix element by using the super parameter to obtain a third matrix.
According to one or more embodiments of the present disclosure, the apparatus further comprises: and a sixth generation unit configured to perform image processing on the watermarked image to generate an attacked watermarked image.
According to one or more embodiments of the present disclosure, the apparatus further comprises: and the determining unit is used for decoding the attacked image with the watermark to obtain target user information in the watermark.
According to one or more embodiments of the present disclosure, there is provided an electronic device including: one or more processors; and a storage device having one or more programs stored thereon, which when executed by the one or more processors, cause the one or more processors to implement a method as described above.
According to one or more embodiments of the present disclosure, a computer readable medium is provided, on which a computer program is stored, wherein the program, when executed by a processor, implements a method as described in any of the above.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by those skilled in the art that the scope of the invention in the embodiments of the present disclosure is not limited to the specific combination of the above technical features, but encompasses other technical features formed by any combination of the above technical features or their equivalents without departing from the spirit of the invention. Such as the above-described features, are mutually substituted with (but not limited to) the features having similar functions disclosed in the embodiments of the present disclosure.