CN112634119B - Watermark adding method, device, computer equipment and storage medium - Google Patents

Watermark adding method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN112634119B
CN112634119B CN202011551624.4A CN202011551624A CN112634119B CN 112634119 B CN112634119 B CN 112634119B CN 202011551624 A CN202011551624 A CN 202011551624A CN 112634119 B CN112634119 B CN 112634119B
Authority
CN
China
Prior art keywords
picture
pixel point
value
pixel
byte
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011551624.4A
Other languages
Chinese (zh)
Other versions
CN112634119A (en
Inventor
曹春辉
臧磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
OneConnect Financial Technology Co Ltd Shanghai
Original Assignee
OneConnect Financial Technology Co Ltd Shanghai
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by OneConnect Financial Technology Co Ltd Shanghai filed Critical OneConnect Financial Technology Co Ltd Shanghai
Priority to CN202011551624.4A priority Critical patent/CN112634119B/en
Publication of CN112634119A publication Critical patent/CN112634119A/en
Priority to PCT/CN2021/125219 priority patent/WO2022134804A1/en
Application granted granted Critical
Publication of CN112634119B publication Critical patent/CN112634119B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • G06T1/0021Image watermarking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/001Texturing; Colouring; Generation of texture or colour
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/40Filling a planar surface by adding surface attributes, e.g. colour or texture
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10024Color image

Abstract

The application relates to the field of data processing, and provides a watermark adding method, a watermark adding device, computer equipment and a storage medium, wherein the method comprises the following steps: acquiring target data to be added into the picture; performing byte conversion processing on target data to obtain an original byte array; processing the original byte array based on the encode method of base64 to generate a specified byte array; sequentially using every three bytes in the specified byte array to carry out one-to-one corresponding updating processing on the color values of the three color channels in the corresponding pixel points of the corresponding row in the picture according to a preset updating rule; and filling the character length on the designated pixel point in the picture to obtain a target picture so as to finish the watermark adding processing of the picture. According to the method and the device, the target data are added into the picture in an implicit mode, and the safety and the concealment of target data sharing are guaranteed. The method and the device can also be applied to the field of block chains, and the data such as the target picture can be stored on the block chains.

Description

Watermark adding method, device, computer equipment and storage medium
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a watermark adding method and apparatus, a computer device, and a storage medium.
Background
In order to protect still pictures, watermark technology is used, and the picture to be protected is embedded with some information which can prove copyright ownership or track infringement, such as author serial number, company logo, meaningful text and the like. By adding the explicit watermark, the aims of protecting the copyright of the picture and tracking the infringement behavior of the picture are achieved. However, the way of adding the display watermark affects the display of the picture information, and has the problems of poor aesthetic property, poor concealment and poor safety.
Disclosure of Invention
The application mainly aims to provide a watermark adding method, a watermark adding device, computer equipment and a storage medium, and aims to solve the technical problems that the existing mode of adding and displaying watermarks in pictures can influence the display of picture information, and the concealment performance and the safety performance are poor.
The application provides a watermark adding method, which comprises the following steps:
acquiring target data to be added into the picture;
performing byte conversion processing on the target data to obtain a corresponding original byte array;
processing the original byte array based on an encode method of base64 to generate a specified byte array;
Acquiring the character length of bytes contained in the specified byte array, and calling a preset calculation formula to calculate the number of the placing positions based on the character length;
acquiring a width value and a height value of the picture;
calculating the number of placement lines based on the number of placement positions and the width value, and determining first line information for adding the watermark based on the number of placement lines and the height value;
sequentially acquiring a first byte, a second byte and a third byte which are sequenced most in sequence according to the sequence of each byte in the designated byte array;
acquiring a first pixel point which is sequenced most in a first adding line corresponding to the first line information, and acquiring a first color value of an R channel of the first pixel point, a second color value of a G channel of the first pixel point and a third color value of a B channel of the first pixel point based on a first pixel value of the first pixel point;
updating the first color value using the first byte, updating the second color value using the second byte, and updating the third color value using the third byte to form an updated pixel value for the first pixel, to effect an update of the pixel value for the first pixel point, and so on, starting with the first added row, traversing a plurality of target pixel points which are contained in each adding row corresponding to the placing row number and have the same number with the placing positions from left to right and from top to bottom, according to the arrangement sequence of each byte in the designated byte array, updating the color values of three color channels in corresponding pixel points of corresponding rows in the picture by using every three bytes in the designated byte array in a one-to-one correspondence manner until all bytes contained in the designated byte array are filled into the picture;
And filling the character length on a designated pixel point in the picture to obtain a target picture so as to finish the watermark adding processing of the picture.
Optionally, the step of calling a preset calculation formula to calculate the number of the placement positions based on the character length includes:
judging whether the character length is a multiple of 3;
if the character length is a multiple of 3, calling a first calculation formula count ═ bytes/3 to calculate the number of the placing positions, wherein the count is the number of the placing positions, and the bytes are the character length;
if the character length is not a multiple of 3, calling a second calculation formula count ═ bytes/3+1 to calculate the number of the placement positions, wherein the count is the number of the placement positions, and the bytes are the character length.
Optionally, the step of calculating a number of placement lines based on the number of placement positions and the width value, and determining the first line information for adding the watermark based on the number of placement lines and the height value includes:
judging whether the number of the placing positions is a multiple of the width value;
if the number of the placing positions is a multiple of the width value, calling a third calculation formula row which is a number of placing lines, count which is the number of the placing positions and width which is the width value to calculate the number of the placing lines;
If the number of the placing positions is not a multiple of the width value, calling a fourth calculation formula row which is count/width +1 to calculate the number of the placing lines, wherein row is the number of the placing lines, count is the number of the placing positions, and width is the width value;
and calling a fifth calculation formula position-height-row to determine the head line information, wherein the position is the head line information, the height is the height value, and the row is the placing line number.
Optionally, the step of obtaining, based on the first pixel value of the first pixel point, a first color value of an R channel of the first pixel point, a second color value of a G channel of the first pixel point, and a third color value of a B channel of the first pixel point includes:
converting the picture into a buffer image object;
acquiring a two-dimensional coordinate of the first pixel point;
acquiring a first pixel value corresponding to the first pixel point by an acquisition method corresponding to the buffered image object according to the two-dimensional coordinate;
transforming the first pixel value based on a preset first transformation code to obtain a first color value of an R channel of the first pixel point; and the number of the first and second groups,
Transforming the first pixel value based on a preset second transformation code to obtain a second color value of the G channel of the first pixel point; and (c) a second step of,
and carrying out transformation processing on the first pixel value based on a preset third transformation code to obtain a third color value of the B channel of the first pixel point.
Optionally, the step of filling the character length in a designated pixel point in the picture includes:
judging whether the character length is three digits;
if the character length is three digits, acquiring the position information of a specified pixel point in the picture;
acquiring color values of the color channels corresponding to the designated pixel points based on the position information;
on the basis of the character length, respectively extracting the hundred digits of the character length, the ten digits of the character length and the single digits of the character length;
replacing the color value of the R channel of the designated pixel point with the hundred digits of the character length; and the number of the first and second groups,
changing the color value of the G channel of the designated pixel point into a ten-digit number of the character length; and the number of the first and second groups,
and replacing the color value of the B channel of the specified pixel point with the single digit of the character length.
Optionally, before the step of filling the character length in a designated pixel point in the picture to obtain a target picture to complete the watermark adding process for the picture, the method includes:
judging whether the last pixel point of the last line in the picture is in an updating state currently or not, wherein the last pixel point of the last line in the picture is marked as a second pixel point;
if the second pixel point is not in the updating state currently, the second pixel point is used as the designated pixel point;
if the second pixel point is in an updating state currently, taking a first pixel point of a first line of the picture and a last pixel point of the first line of the picture as alternative pixel points;
displaying selection information corresponding to the alternative pixel points;
and determining the designated pixel points from the alternative pixel points based on the fed back selection results corresponding to the selection information.
Optionally, after the step of filling the character length in a designated pixel point in the picture to obtain a target picture to complete the watermark adding process for the picture, the method includes:
judging whether a watermark analyzing instruction for the target picture is received or not;
If a watermark analyzing instruction for the target picture is received, acquiring a second pixel value of the specified pixel point based on a pre-stored character length storage rule;
generating a corresponding byte length value based on the second pixel value;
based on the byte length value, calculating the number of pixel points contained in the watermark and the initial insertion line of the watermark in the target picture;
starting from the initial insertion row, acquiring the pixel value of an insertion pixel point which is arranged at the top of the initial insertion row in sequence from left to right and from top to bottom, sequentially acquiring the color value of an R channel, the color value of a G channel and the color value of a B channel of the insertion pixel point based on the pixel value of the insertion pixel point, sequentially placing the color value of the R channel of the insertion pixel point, the color value of the G channel of the insertion pixel point and the color value of the B channel of the insertion pixel point in a preset byte template, and so on, extracting the color values of three channels of other insertion pixel points except the insertion pixel points based on the number of the pixel points and correspondingly placing the color values in the byte template to obtain a byte template after data updating;
Calling a decode method of base64, and performing numerical value conversion reduction processing on all numerical values in the byte template after the data updating to obtain a reduced byte template;
and converting all numerical values in the byte template after the reduction processing into character strings to obtain target data added into the picture.
The present application further provides a watermark adding apparatus, including:
the first acquisition module is used for acquiring target data to be added into the picture;
the first processing module is used for carrying out byte conversion processing on the target data to obtain a corresponding original byte array;
the second processing module is used for processing the original byte array based on the encode method of base64 to generate a specified byte array;
the first calculation module is used for acquiring the character length of bytes contained in the specified byte array and calling a preset calculation formula to calculate the number of the placing positions based on the character length;
the second acquisition module is used for acquiring the width value and the height value of the picture;
the second calculation module is used for calculating the number of the placement rows based on the number of the placement positions and the width value, and determining first row information for adding the watermark based on the number of the placement rows and the height value;
The third acquisition module is used for sequentially acquiring a first byte, a second byte and a third byte which are arranged at the top according to the arrangement sequence of each byte in the specified byte array;
a fourth obtaining module, configured to obtain a first pixel point sorted foremost in a first adding line corresponding to the first line information, and obtain, based on a first pixel value of the first pixel point, a first color value of an R channel of the first pixel point, a second color value of a G channel of the first pixel point, and a third color value of a B channel of the first pixel point; the pixel value of the pixel point consists of three color channels in a { R, G, B } form, and the upper limit and the lower limit of each color channel are {0, 255 };
an update module to update the first color value using the first byte and update the second color value using the second byte, and updating the third color value using the third byte to form an updated pixel value for the first pixel, to effect an update of the pixel value for the first pixel point, and so on, starting with the first added row, traversing a plurality of target pixel points which are contained in each adding row corresponding to the placing row number and have the same number with the placing positions from left to right and from top to bottom, according to the arrangement sequence of each byte in the designated byte array, updating the color values of three color channels in corresponding pixel points of corresponding rows in the picture one by using every three bytes in the designated byte array until all bytes contained in the designated byte array are filled in the picture;
And the first generation module is used for filling the character length on a designated pixel point in the picture to obtain a target picture so as to finish the watermark adding processing of the picture.
The present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.
The present application also provides a computer-readable storage medium having stored thereon a computer program which, when being executed by a processor, carries out the steps of the above-mentioned method.
The watermark adding method, the watermark adding device, the computer equipment and the storage medium have the following beneficial effects:
according to the watermark adding method, the watermark adding device, the computer equipment and the storage medium, when target data needing to be added to a picture are obtained, byte conversion processing and numerical control processing are carried out on the target data to generate a corresponding specified byte array, then, according to a preset updating rule, every three bytes in the specified byte array are sequentially used for carrying out one-to-one corresponding updating processing on color values of three color channels in corresponding pixel points of corresponding rows in the picture to generate the target picture, and further, the target data are added to the picture in an implicit mode, and large visual influence cannot exist on an original picture Covert and traceability of circulation.
Drawings
Fig. 1 is a schematic flowchart of a watermarking method according to an embodiment of the present application;
fig. 2 is a schematic structural diagram of a watermarking apparatus according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a computer device according to an embodiment of the present application.
The implementation, functional features and advantages of the objectives of the present application will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may also be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. As used herein, the term "and/or" includes all or any element and all combinations of one or more of the associated listed items.
It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
Referring to fig. 1, a watermarking method according to an embodiment of the present application includes:
s1: acquiring target data to be added into the picture;
s2: performing byte conversion processing on the target data to obtain a corresponding original byte array;
s3: processing the original byte array based on an encode method of base64 to generate a specified byte array;
s4: acquiring the character length of bytes contained in the specified byte array, and calling a preset calculation formula to calculate the number of the placing positions based on the character length;
s5: acquiring a width value and a height value of the picture;
s6: calculating the number of placement lines based on the number of placement positions and the width value, and determining first line information for adding the watermark based on the number of placement lines and the height value;
S7: sequentially acquiring a first byte, a second byte and a third byte which are sequenced most at the beginning according to the sequence of each byte in the designated byte array;
s8: acquiring a first pixel point which is sequenced most in a first adding line corresponding to the first line information, and acquiring a first color value of an R channel of the first pixel point, a second color value of a G channel of the first pixel point and a third color value of a B channel of the first pixel point based on a first pixel value of the first pixel point; the pixel value of the pixel point is composed of three color channels in a { R, G, B } form, and the upper limit and the lower limit of each color channel are {0, 255 };
s9: updating the first color value using the first byte, updating the second color value using the second byte, and updating the third color value using the third byte to form an updated pixel value for the first pixel, to effect an update of the pixel value for the first pixel point, and so on, starting with the first added row, traversing a plurality of target pixel points which are contained in each adding row corresponding to the placing row number and have the same number with the placing positions from left to right and from top to bottom, according to the arrangement sequence of each byte in the designated byte array, updating the color values of three color channels in corresponding pixel points of corresponding rows in the picture one by using every three bytes in the designated byte array until all bytes contained in the designated byte array are filled in the picture;
S10: and filling the character length on a designated pixel point in the picture to obtain a target picture so as to finish the watermark adding processing of the picture.
As described in the above steps S1 to S10, the main implementation of the embodiment of the method is a watermarking apparatus. In practical applications, the watermark adding apparatus may be implemented by a virtual apparatus, such as a software code, or by an entity apparatus in which a relevant execution code is written or integrated, and may perform human-computer interaction with a user through a keyboard, a mouse, a remote controller, a touch panel, or a voice control device. The watermarking device in this embodiment can add the target data to the picture in an implicit manner to complete the watermarking processing for the picture, and does not have a large visual impact on the original picture. Specifically, target data to be added into a picture is first acquired. The target data is original data used for generating a subsequent picture watermark, and the target data is not particularly limited, and may be generated according to actual needs or obtained by user input, for example, 123456. And after the target data is obtained, carrying out byte conversion processing on the target data to obtain a corresponding original byte array. Wherein, the byte conversion processing of the target data can be realized by a Content. And then processing the original byte array based on an encode method of base64 to generate a specified byte array. In order to satisfy that all numbers in the byte array are between 0 and 255, the original byte data is further subjected to base64 encode method processing, so that all values in the obtained specified byte data are between 0 and 255, and the bytes in the generated specified byte array can be used for successfully replacing the color values of corresponding pixel points in the picture, thereby realizing the watermark adding processing of the picture. And after the appointed byte array is obtained, acquiring the character length of bytes contained in the appointed byte array, and calling a preset calculation formula to calculate the number of the placing positions based on the character length. The character length refers to the number of bytes included in the specified byte array. In addition, based on the multiple relationship between the character length and 3, the corresponding calculation formula count ═ bytes/3 or count ═ bytes/3+1 is called to calculate the number of placement positions, where count is the number of placement positions and bytes is the character length. And acquiring the width value and the height value of the picture. The width value represents the number of any row of pixel points in the picture, namely the number of pixels which can be placed in one row, and the height value represents the number of any column of pixel points in the picture. And then, calculating the number of placement lines based on the number of placement positions and the width value, and determining the first line information for adding the watermark based on the number of placement lines and the height value. The number of rows to be placed refers to the number of rows required to fill all the characters included in the designated byte array in the picture. Based on the multiple relationship between the number of the placing positions and the width value, the corresponding calculation formula row is called as count/width or row is called as count/width +1 to calculate the placing line number, the row is the placing line number, the count is the number of the placing positions, and the width is the width value. And sequentially acquiring a first byte, a second byte and a third byte which are arranged at the top in sequence according to the arrangement sequence of each byte in the specified byte array. The arrangement sequence of the bytes is from left to right and from top to bottom. And then acquiring a first pixel point which is arranged in the first adding line and corresponds to the first line information and is the first in the sorting, and acquiring a first color value of an R channel of the first pixel point, a second color value of a G channel of the first pixel point and a third color value of a B channel of the first pixel point based on a first pixel value of the first pixel point. The pixel value of the pixel point is composed of three color channels in a { R, G, B } form, and the upper and lower limits of each color channel are {0, 255 }. In addition, the picture can be converted into a buffered image object, corresponding pixel values are obtained based on two-dimensional coordinates of any pixel point in the picture, and color values on each color channel corresponding to the pixel values are extracted based on a preset conversion code. The arrangement order in the first additional line is from left to right. Then, the first byte is used to update the first color value, the second byte is used to update the second color value, and updating the third color value by using the third byte to form an updated pixel value of the first pixel point, so as to update the pixel value of the first pixel point, and so on, starting from the first added line, traversing a plurality of target pixel points which are contained in each adding row corresponding to the placing row number and have the same number as the placing positions from left to right and from top to bottom, and according to the arrangement sequence of each byte in the designated byte array, updating the color values of three color channels in corresponding pixel points of corresponding rows in the picture one by using every three bytes in the designated byte array until all bytes contained in the designated byte array are filled into the picture. And finally, filling the character length on a specified pixel point in the picture to obtain a target picture so as to finish the watermark adding processing of the picture. The designated pixel point is not specifically limited, and for example, an edge pixel point in a picture may be used. In this embodiment, when target data to be added to a picture is acquired, byte conversion processing and numerical control processing are performed on the target data to generate a corresponding specified byte array, and then, according to a preset update rule, every three bytes in the specified byte array are sequentially used to perform one-to-one corresponding update processing on color values of three color channels in corresponding pixel points of corresponding rows in the picture to generate a target picture.
Further, in an embodiment of the present application, the step S4 includes:
s400: judging whether the character length is a multiple of 3;
s401: if the character length is a multiple of 3, calling a first calculation formula count ═ bytes/3 to calculate the number of the placing positions, wherein the count is the number of the placing positions, and the bytes are the character length;
s402: if the character length is not a multiple of 3, calling a second calculation formula count ═ bytes/3+1 to calculate the number of the placement positions, wherein the count is the number of the placement positions, and the bytes are the character length.
As described in the above steps S400 to S402, three positions of the pixel points in the picture, that is, three color channels included in the pixel point, can be set, so that each three bytes sequentially ordered in the designated byte array corresponding to the target data to be added into the picture can be set as a group in the plurality of pixel points in a one-to-one correspondence manner, so as to realize the implicit addition of the watermark corresponding to the target data in the picture in the form of byte filling. The step of calculating the number of the placement positions by invoking a preset calculation formula based on the character length may specifically include: and judging whether the character length is a multiple of 3. If the character length is a multiple of 3, a first calculation formula count ═ bytes/3 is called to calculate the number of the placing positions, wherein the count is the number of the placing positions, the bytes is the character length, and the/is the rounding symbol. And if the character length is not a multiple of 3, calling a second calculation formula, count being the number of the placement positions, bytes being the character length, and/or the rounding symbol, to calculate the number of the placement positions. In addition, when the character length is not multiple of 3, the purpose of adding 1 in the calculation formula is to divide the character by a number in java, if the division cannot be completely divided, only an integer part is taken, and a decimal part is not available, so that the character corresponding to the decimal part, whether one character or two characters, always occupies the position of one pixel, and therefore 1 is added on the basis of bytes/3 to obtain the number of the placement positions. The number of the placement positions corresponding to the specified byte array can be quickly calculated based on the character length, the number of the placement rows corresponding to the specified byte array can be quickly and conveniently calculated according to the obtained number of the placement positions, the first row information used for adding the watermark can be determined, and then the specified byte array can be accurately and quickly used for realizing the watermark adding processing of the picture according to the number of the placement rows and the first row information.
Further, in an embodiment of the present application, the step S6 includes:
s600: judging whether the number of the placing positions is a multiple of the width value;
s601: if the number of the placing positions is a multiple of the width value, calling a third calculation formula row which is a number of placing lines, count which is the number of the placing positions and width which is the width value to calculate the number of the placing lines;
s602: if the number of the placing positions is not a multiple of the width value, calling a fourth calculation formula row which is count/width +1 to calculate the number of the placing lines, wherein row is the number of the placing lines, count is the number of the placing positions, and width is the width value;
s603: and calling a fifth calculation formula position-height-row to determine the head line information, wherein the position is the head line information, the height is the height value, and the row is the placing line number.
As described in the foregoing steps S600 to S603, the step of calculating the number of placement lines based on the number of placement positions and the width value, and determining the top line information for adding a watermark based on the number of placement lines and the height value may specifically include: firstly, judging whether the number of the placing positions is a multiple of the width value. If the number of the placing positions is a multiple of the width value, calling a third calculation formula row which is the number of the placing rows, count which is the number of the placing positions, and width which is the width value, and/or a rounding symbol to calculate the number of the placing rows. And if the number of the placing positions is not a multiple of the width value, calling a fourth calculation formula row which is the number of the placing rows, count which is the number of the placing positions, and width +1 to calculate the number of the placing rows, wherein the/is a rounding symbol. In addition, when the number of the placing positions is not multiple of the width value, the purpose of adding 1 in the calculation formula is to divide the number by one in java, if the division cannot be completely divided, only an integer part is taken, and a decimal part is not available, but the decimal part always occupies the position of one or more pixels in a new line no matter what data is, so 1 is added on the basis of count/width to obtain the number of the placing rows. And calling a fifth calculation formula position-height-row to determine the first-row information, wherein the position is the first-row information, the first-row information is a row which is used for adding a watermark in the picture, the height is a height value, and the row is a number of placement rows. In order to avoid that the added watermark corresponding to the target data has a great influence on the original content of the picture, the byte data in the designated character array corresponding to the target data is preferentially added to the position of the pixel point of the last line or lines at the lowest part of the picture. In this embodiment, the number of placement lines is calculated based on the number of placement positions and the width value, and the first line information for adding a watermark is determined based on the number of placement lines and the height value, so that the watermark adding process on the picture can be realized accurately and quickly by using the specified byte array according to the number of placement lines and the first line information.
Further, in an embodiment of the present application, the step S8 includes:
s800: converting the picture into a bufferedmiage object;
s801: acquiring a two-dimensional coordinate of the first pixel point;
s802: acquiring a first pixel value corresponding to the first pixel point by an acquisition method corresponding to the buffered image object according to the two-dimensional coordinate;
s803: transforming the first pixel value based on a preset first transformation code to obtain a first color value of an R channel of the first pixel point; and the number of the first and second groups,
s804: transforming the first pixel value based on a preset second transformation code to obtain a second color value of the G channel of the first pixel point; and the number of the first and second groups,
s805: and carrying out transformation processing on the first pixel value based on a preset third transformation code to obtain a third color value of the B channel of the first pixel point.
As described in the foregoing steps S800 to S805, the step of obtaining the first color value of the R channel of the first pixel, the second color value of the G channel of the first pixel, and the third color value of the B channel of the first pixel based on the first pixel value of the first pixel may specifically include: the picture is first converted into a bufferedmiage object. After the picture is converted into the buffered image object, the pixel value of any pixel point in the picture can be obtained, so that the color values of the color channels on the pixel points can be respectively extracted subsequently according to the pixel value. And then acquiring the two-dimensional coordinates of the first pixel point. And then, according to the two-dimensional coordinates, acquiring a first pixel value corresponding to the first pixel point by an acquisition method corresponding to the buffered image object. If the coordinate of the first pixel point is (x, y), the corresponding obtaining method may be a buffer image. Finally, the first pixel value is transformed based on a preset first transformation code to obtain a first color value of the R channel of the first pixel point, where the first transformation code may specifically be int R ═ (rgb &0xff0000) > >16, and the first color value may be calculated by executing the first transformation code; and transforming the first pixel value based on a preset second transformation code to obtain a second color value of the G channel of the first pixel, where the second transformation code specifically may be: int g ═ (rgb &0xff00) > >8, and the second color value can be calculated by executing the second conversion code; and performing transformation processing on the first pixel value based on a preset third transformation code to obtain a third color value of the B channel of the first pixel point, where the third transformation code specifically may be: int b ═ (rgb &0xff), the third color value can be calculated by executing the third transform code. The embodiment can rapidly acquire the color values of the first pixel points on the color channels based on a preset acquisition method and a preset conversion code, and further facilitates the follow-up accurate execution of the watermark adding process of updating the first color values by using the first bytes, updating the second color values by using the second bytes, and updating the third color values by using the third bytes.
Further, in an embodiment of the present application, the step S10 includes:
s1000: judging whether the character length is three digits;
s1001: if the character length is three digits, acquiring the position information of a specified pixel point in the picture;
s1002: acquiring color values of the color channels corresponding to the designated pixel points based on the position information;
s1003: on the basis of the character length, respectively extracting the hundred digits of the character length, the ten digits of the character length and the single digits of the character length;
s1004: replacing the color value of the R channel of the designated pixel point with the hundred digits of the character length; and the number of the first and second groups,
s1005: changing the color value of the G channel of the designated pixel point into a ten-digit number of the character length; and the number of the first and second groups,
s1006: and replacing the color value of the B channel of the specified pixel point with the single digit of the character length.
As described in the foregoing steps S1000 to S1006, the step of filling the character length in the designated pixel point in the picture may specifically include: first, whether the character length is three digits is judged. Wherein, the three-digit number means that the character length is in the range of 100-999. And if the character length is three digits, acquiring the position information of the specified pixel point in the picture. The designated pixel points refer to pixel point positions for storing the character lengths, the positions of specific pixel points corresponding to the designated pixel points are not specifically limited, the designated pixel points can be set according to actual use requirements, and pixel points at the edge position of the picture, such as the last pixel point of the last line in the picture, the first pixel point of the first line of the picture or the last pixel point of the first line of the picture, can be preferably used as the designated pixel points, so that the phenomenon that the added byte length can cause large visual influence on the original content of the picture is effectively avoided. The position information is two-dimensional coordinate information of the designated pixel. And then, based on the position information, acquiring the color value of each color channel corresponding to the specified pixel point. The color values of the color channels corresponding to the designated pixel points can be obtained by referring to the method for obtaining the color values of the first pixel points, and the details are not repeated here. Then, based on the character length, the hundreds digit of the character length, the tens digit of the character length and the single digit of the character length are extracted. Wherein, the hundred digits, the ten digits and the ones digits of the character length can be calculated by adopting a corresponding rounding formula and a remainder formula. For example, if the character length is 123, 123/100 is 1 by following the following rounding equation and remainder equation; 123% 100 ═ 23, 23/10 ═ 2; the three values 1, 2 and 3 are obtained by 23% to 10 ═ 3, that is, 1, 2 and 3 correspond to the hundreds digit, the tens digit and the units digit of the character length, respectively. Finally, the color value of the R channel of the specified pixel point is changed into hundreds of digits of the character length; changing the color value of the G channel of the appointed pixel point into a ten-digit number of the character length; and replacing the color value of the B channel of the appointed pixel point with the single digit of the character length. After the processing of filling the character length in the designated pixel point in the picture is completed, the corresponding character length storage rule needs to be stored subsequently, so that the watermark contained in the generated target picture is subjected to inverse analysis processing subsequently according to the character length storage rule to extract original target data. When all bytes contained in the designated byte array corresponding to the target data are filled into the picture, the character length is stored in the designated pixel point of the picture, so that the character length can be rapidly and intelligently analyzed according to the designated pixel point, and the added content in the picture can be analyzed according to the character length, so that the implicit watermark in the picture can be accurately analyzed. Furthermore, for the character lengths of different numerical values, various storage methods can be flexibly set according to actual requirements. For example, if the character length is two digits, the process of filling the character length on the designated pixel point in the picture may include: and keeping the color value of the R channel of the designated pixel unchanged, replacing the color value of the R channel of the designated pixel with the hundred digits of the character length, and replacing the color value of the G channel of the designated pixel with the ten digits of the character length.
Further, in an embodiment of the present application, before the step S10, the method includes:
s1100: judging whether the last pixel point of the last line in the picture is in an updating state currently or not, wherein the last pixel point of the last line in the picture is marked as a second pixel point;
s1101: if the second pixel point is not in the updating state currently, taking the second pixel point as the designated pixel point;
s1102: if the second pixel point is in an updating state currently, taking a first pixel point of a first line of the picture and a last pixel point of the first line of the picture as alternative pixel points;
s1103: displaying selection information corresponding to the alternative pixel points;
s1104: and determining the designated pixel points from the alternative pixel points based on the fed back selection results corresponding to the selection information.
As described in the foregoing steps S1100 to S1104, before the filling process of filling the character length into the designated pixel point in the picture, a determination process of determining the designated pixel point may be further included. Specifically, before the step of filling the character length in the designated pixel point in the picture to obtain the target picture to complete the watermark adding process for the picture, the method may further include: firstly, judging whether the last pixel point of the last line in the picture is in an updating state currently, wherein the last pixel point of the last line in the picture is marked as a second pixel point. In addition, the update state refers to a state of whether the color value of the color channel included in the second pixel is replaced by other data. And if the second pixel point is not in the updating state currently, taking the second pixel point as the specified pixel point. The second pixel point refers to a first edge pixel point at the lower right corner of the picture. And if the second pixel point is in the updating state currently, taking the first pixel point of the first line of the picture and the last pixel point of the first line of the picture as alternative pixel points. The first pixel point of the first line of the picture refers to a second edge pixel point of the upper left corner of the picture, and the last pixel point of the first line of the picture refers to a second edge pixel point of the upper right corner of the picture. And then showing the selection information corresponding to the alternative pixel points. The selection information is used for reminding a user to select one of the two displayed alternative pixel points. And finally, determining the designated pixel point from the alternative pixel points based on the fed back selection result corresponding to the selection information. Wherein, an alternative pixel point corresponding to the selection result of the user can be used as the designated pixel point. This embodiment is through using the special pixel in the picture, like the second edge pixel in the upper left corner, the third edge pixel in the upper right corner or the fourth edge pixel in the lower right corner store character length, can cause great visual effect to the original content of picture with the byte length of effectively avoiding adding, be favorable to the follow-up watermark in the target picture that can be in the analysis generation, can acquire the character length of adding the watermark in this target picture fast based on this special pixel, and then analyze the interpolation content in above-mentioned picture according to this character length, in order to realize the accurate analysis to the implicit watermark in the picture.
Further, in an embodiment of the present application, after the step S10, the method includes:
s1200: judging whether a watermark analyzing instruction for the target picture is received or not;
s1201: if a watermark analyzing instruction for the target picture is received, acquiring a second pixel value of the specified pixel point based on a pre-stored character length storage rule;
s1202: generating a corresponding byte length value based on the second pixel value;
s1203: based on the byte length value, calculating the number of pixel points contained in the watermark and the initial insertion line of the watermark in the target picture;
s1204: starting from the initial insertion row, acquiring the pixel value of an insertion pixel point which is arranged at the top of the initial insertion row in sequence from left to right and from top to bottom, sequentially acquiring the color value of an R channel, the color value of a G channel and the color value of a B channel of the insertion pixel point based on the pixel value of the insertion pixel point, sequentially placing the color value of the R channel of the insertion pixel point, the color value of the G channel of the insertion pixel point and the color value of the B channel of the insertion pixel point in a preset byte template, and so on, extracting the color values of three channels of other insertion pixel points except the insertion pixel points based on the number of the pixel points and correspondingly placing the color values in the byte template to obtain a byte template after data updating;
S1205: calling a decode method of base64, and performing numerical value conversion reduction processing on all numerical values in the byte template after the data updating to obtain a reduced byte template;
s1206: and converting all numerical values in the byte template after the reduction processing into character strings to obtain target data added into the picture.
As described in steps S1200 to S1206, after the watermark adding process for the picture is completed based on the target data to obtain the target picture, the watermark analyzing process may be further performed on the target picture to query the target data. Specifically, after the step of filling the character length in the designated pixel point in the picture to obtain the target picture so as to complete the watermark adding process for the picture, the method may further include: firstly, whether a watermark analyzing instruction for the target picture is received or not is judged. And if a watermark analyzing instruction for the target picture is received, acquiring a second pixel value of the specified pixel point based on a pre-stored character length storage rule. The character length storage rule is a pre-stored rule corresponding to the character length filled in the target picture. And then generating a corresponding byte length value based on the second pixel value. The color value of each corresponding color channel may be first obtained according to the second pixel value, and then the byte length value may be generated according to the obtained color value and the character length storage rule. And based on the byte length value, calculating the number of pixel points contained in the watermark and the initial insertion line of the watermark in the target picture. The number of the pixel points can be calculated by referring to a calculation formula corresponding to the calculation mode of the number of the placing positions. And calculating the initial insertion line based on a formula count1/width, wherein count1 is the number of pixel points, and width is the width value of the picture. Later from above-mentioned initial row of inserting begins, according to from left to right, from the top down order, acquire the pixel value of the foremost insertion pixel of above-mentioned initial row of inserting sequencing, and based on the pixel value of above-mentioned insertion pixel acquires the color value of the R passageway of above-mentioned insertion pixel in proper order, the color value of G passageway, the color value of B passageway, with the above-mentioned color value of the R passageway of inserting the pixel, the color value of the G passageway of inserting the pixel, the color value of the B passageway of inserting the pixel is placed in preset byte template in proper order, so on, based on above-mentioned pixel quantity, extract the color value of the three passageway of other insertion pixels except above-mentioned insertion pixel and correspond and place in above-mentioned byte template, obtain the byte template after the data update. And subsequently calling a decode method of base64 to perform numerical value conversion and reduction processing on all numerical values in the byte template after the data updating, so as to obtain the byte template after the reduction processing. And finally, converting all numerical values in the byte template after the reduction treatment into character strings to obtain target data added into the picture. After the target picture added with the watermark data is generated, since the designated pixel point in the target picture stores the character length corresponding to the added character array, the designated pixel point can be analyzed according to the pre-stored character length storage rule to obtain the character length value, and then the target data corresponding to the designated character array added to the target picture can be rapidly and intelligently analyzed according to the analyzed character length value, so that the target picture can be accurately authenticated, the authenticity of the picture can be conveniently verified, and the efficiency of privacy disclosure can be greatly improved.
The watermark adding method in the embodiment of the present application may also be applied to the field of block chains, for example, data such as the target picture is stored in the block chain. By using the block chain to store and manage the target picture, the security and the non-tamper property of the target additional risk information can be effectively ensured.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism and an encryption algorithm. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
The block chain underlying platform can comprise processing modules such as user management, basic service, intelligent contract and operation monitoring. The user management module is responsible for identity information management of all blockchain participants, and comprises public and private key generation maintenance (account management), key management, user real identity and blockchain address corresponding relation maintenance (authority management) and the like, and under the authorization condition, the user management module supervises and audits the transaction condition of certain real identities and provides rule configuration (wind control audit) of risk control; the basic service module is deployed on all block chain node equipment and used for verifying the validity of the service request, recording the service request to storage after consensus on the valid request is completed, for a new service request, the basic service firstly performs interface adaptation analysis and authentication processing (interface adaptation), then encrypts service information (consensus management) through a consensus algorithm, transmits the service information to a shared account (network communication) completely and consistently after encryption, and performs recording and storage; the intelligent contract module is responsible for registering and issuing contracts, triggering the contracts and executing the contracts, developers can define contract logics through a certain programming language, issue the contract logics to a block chain (contract registration), call keys or other event triggering and executing according to the logics of contract clauses, complete the contract logics and simultaneously provide the function of upgrading and canceling the contracts; the operation monitoring module is mainly responsible for deployment, configuration modification, contract setting, cloud adaptation in the product release process and visual output of real-time states in product operation, such as: alarm, monitoring network conditions, monitoring node equipment health status, and the like.
Referring to fig. 2, an embodiment of the present application further provides a watermarking apparatus, including:
the first acquisition module 1 is used for acquiring target data to be added into the picture;
the first processing module 2 is used for performing byte conversion processing on the target data to obtain a corresponding original byte array;
the second processing module 3 is configured to process the original byte array based on an encode method of base64 to generate a specified byte array;
the first calculation module 4 is configured to obtain a character length of bytes included in the specified byte array, and call a preset calculation formula to calculate the number of the placement positions based on the character length;
the second obtaining module 5 is configured to obtain a width value and a height value of the picture;
the second calculation module 6 is configured to calculate a placement line number based on the number of placement positions and the width value, and determine first line information for adding a watermark based on the placement line number and the height value;
a third obtaining module 7, configured to sequentially obtain, according to an arrangement order of each byte in the specified byte array, a first byte, a second byte, and a third byte that are sorted foremost;
A fourth obtaining module 8, configured to obtain a first pixel point sorted foremost in a first adding line corresponding to the first line information, and obtain, based on a first pixel value of the first pixel point, a first color value of an R channel of the first pixel point, a second color value of a G channel of the first pixel point, and a third color value of a B channel of the first pixel point;
an update module 9 for updating the first color value using the first byte, updating the second color value using the second byte, and updating the third color value using the third byte to form an updated pixel value for the first pixel, to effect an update of the pixel value for the first pixel point, and so on, starting with the first added row, traversing a plurality of target pixel points which are contained in each adding row corresponding to the placing row number and have the same number with the placing positions from left to right and from top to bottom, according to the arrangement sequence of each byte in the designated byte array, updating the color values of three color channels in corresponding pixel points of corresponding rows in the picture one by using every three bytes in the designated byte array until all bytes contained in the designated byte array are filled in the picture;
And the first generating module 10 is configured to fill the character length in a designated pixel point in the picture to obtain a target picture, so as to complete the watermarking processing on the picture.
In this embodiment, the implementation processes of the functions and actions of the first obtaining module, the first processing module, the second processing module, the first calculating module, the second obtaining module, the second calculating module, the third obtaining module, the fourth obtaining module, the updating module and the first generating module in the watermark adding apparatus are specifically described in the implementation processes corresponding to steps S1 to S10 in the watermark adding method, and are not described herein again.
Further, in an embodiment of the application, the first calculating module includes:
a first judging unit, configured to judge whether the character length is a multiple of 3;
a first calculating unit, configured to call a first calculation formula count ═ bytes/3 to calculate the number of the placement positions if the character length is a multiple of 3, where count is the number of the placement positions, and bytes is the character length;
and a second calculating unit, configured to call a second calculation formula count ═ bytes/3+1 to calculate the number of the placement positions if the character length is not a multiple of 3, where the count is the number of the placement positions, and the bytes is the character length.
In this embodiment, the implementation processes of the functions and actions of the first determining unit, the first calculating unit and the second calculating unit in the watermark adding apparatus are specifically described in the implementation processes corresponding to steps S400 to S402 in the watermark adding method, and are not described herein again.
Further, in an embodiment of the application, the second calculating module includes:
the second judging unit is used for judging whether the number of the placing positions is a multiple of the width value;
a third calculating unit, configured to, if the number of the placement positions is a multiple of the width value, call a third calculation formula row ═ count/width to calculate the number of the placement lines, where row is the number of the placement lines, count is the number of the placement positions, and width is the width value;
a fourth calculating unit, configured to, if the number of the placement positions is not a multiple of the width value, call a fourth calculation formula row ═ count/width +1 to calculate the number of the placement lines, where row is the number of the placement lines, count is the number of the placement positions, and width is the width value;
and the fifth calculation unit is used for calling a fifth calculation formula position-height-row to determine the head line information, wherein the position is the head line information, the height is the height value, and the row is the placing line number.
In this embodiment, the implementation processes of the functions and functions of the second determining unit, the third calculating unit, the fourth calculating unit and the fifth calculating unit in the watermark adding apparatus are specifically described in the implementation processes corresponding to steps S600 to S603 in the watermark adding method, and are not described herein again.
Further, in an embodiment of the application, the fourth obtaining module includes:
the conversion unit is used for converting the picture into a buffer image object;
the first acquisition unit is used for acquiring the two-dimensional coordinates of the first pixel point;
a second obtaining unit, configured to obtain, according to the two-dimensional coordinate, a first pixel value corresponding to the first pixel point by using a obtaining method corresponding to the buffered image object;
the first transformation unit is used for transforming the first pixel value based on a preset first transformation code to obtain a first color value of an R channel of the first pixel point; and the number of the first and second groups,
the second transformation unit is used for transforming the first pixel value based on a preset second transformation code to obtain a second color value of the G channel of the first pixel point; and the number of the first and second groups,
and the third transformation unit is used for transforming the first pixel value based on a preset third transformation code to obtain a third color value of the B channel of the first pixel point.
In this embodiment, the implementation processes of the functions and actions of the conversion unit, the first obtaining unit, the second obtaining unit, the first transformation unit, the second transformation unit, and the third transformation unit in the watermark adding apparatus are specifically described in the implementation processes corresponding to steps S800 to S805 in the watermark adding method, and are not described herein again.
Further, in an embodiment of the present application, the generating module includes:
a third judging unit, configured to judge whether the character length is a three-digit number;
a third obtaining unit, configured to obtain position information of a specified pixel point in the picture if the character length is a three-digit number;
a fourth obtaining unit configured to obtain color values of the respective color channels corresponding to the designated pixel point, based on the position information;
the extraction unit is used for respectively extracting the hundreds digit of the character length, the tens digit of the character length and the single digit of the character length based on the character length;
the first replacing unit is used for replacing the color value of the R channel of the specified pixel point with the hundred digits of the character length; and the number of the first and second groups,
the second replacement unit is used for replacing the color value of the G channel of the specified pixel point with the ten-digit of the character length; and the number of the first and second groups,
And the third replacing unit is used for replacing the color value of the B channel of the specified pixel point with the single digit of the character length.
In this embodiment, the implementation processes of the functions and functions of the third determining unit, the third obtaining unit, the fourth obtaining unit, the extracting unit, the first replacing unit, the second replacing unit and the third replacing unit in the watermark adding apparatus are specifically described in the implementation processes corresponding to steps S1000 to S1006 in the watermark adding method, and are not described herein again.
Further, in an embodiment of the present application, the watermark adding apparatus includes:
the first judging module is used for judging whether the last pixel point of the last line in the picture is in an updating state currently or not, wherein the last pixel point of the last line in the picture is marked as a second pixel point;
the first determining module is used for taking the second pixel point as the designated pixel point if the second pixel point is not in the updating state currently;
the second determining module is used for taking the first pixel point of the first line of the picture and the last pixel point of the first line of the picture as alternative pixel points if the second pixel point is in an updating state currently;
The display module is used for displaying the selection information corresponding to the alternative pixel points;
and the third determining module is used for determining the designated pixel point from the alternative pixel points based on the fed back selection result corresponding to the selection information.
In this embodiment, the implementation processes of the functions and actions of the first determining module, the second determining module, the displaying module and the third determining module in the watermark adding apparatus are specifically described in the implementation processes corresponding to steps S1100 to S1104 in the watermark adding method, and are not described herein again.
Further, in an embodiment of the present application, the watermark adding apparatus includes:
the second judgment module is used for judging whether a watermark analysis instruction for the target picture is received or not;
a fifth obtaining module, configured to, if a watermark analysis instruction for the target picture is received, obtain a second pixel value of the specified pixel point based on a pre-stored character length storage rule;
a second generating module for generating a corresponding byte length value based on the second pixel value;
a third calculating module, configured to calculate, based on the byte length value, the number of pixels included in the watermark and an initial insertion row of the watermark in the target picture;
A third processing module, configured to obtain, from the beginning insertion row, pixel values of insertion pixels that are sorted in the beginning insertion row in a top-to-bottom order from left to right, and sequentially obtain, based on the pixel values of the insertion pixels, color values of R channels, color values of G channels, and color values of B channels of the insertion pixels, sequentially place, in a preset byte template, color values of R channels of the insertion pixels, color values of G channels of the insertion pixels, and color values of B channels of the insertion pixels, and so on, and based on the number of the pixels, extract color values of three channels of other insertion pixels except the insertion pixels and correspondingly place the color values in the byte template, thereby obtaining a byte template after data update;
the restoring module is used for calling a decode method of base64 to perform numerical value conversion and restoration processing on all numerical values in the byte template after the data updating so as to obtain a byte template after restoration processing;
and the conversion module is used for converting all numerical values in the byte template after the reduction processing into character strings to obtain target data added into the picture.
In this embodiment, the implementation processes of the functions and functions of the second determining module, the fifth obtaining module, the second generating module, the third calculating module, the third processing module, the restoring module and the converting module in the watermark adding apparatus are specifically described in the implementation processes of steps S1200 to S1206 in the watermark adding method, and are not described herein again.
Referring to fig. 3, an embodiment of the present application further provides a computer device, where the computer device may be a server, and an internal structure of the computer device may be as shown in fig. 3. The computer device comprises a processor, a memory, a network interface, a display screen, an input device and a database which are connected through a system bus. Wherein the processor of the computer device is designed to provide computing and control capabilities. The memory of the computer device comprises a storage medium and an internal memory. The storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operating system and computer programs in the storage medium to run. The database of the computer device is used for storing target data, a specified byte array, the number of placing positions, the number of placing lines, target pixel points, specified pixel points and a target picture. The network interface of the computer device is used for communicating with an external terminal through a network connection. The display screen of the computer equipment is an indispensable image-text output equipment in the computer, and is used for converting digital signals into optical signals so that characters and figures are displayed on the screen of the display screen. The input device of the computer equipment is the main device for information exchange between the computer and the user or other equipment, and is used for transmitting data, instructions, some mark information and the like to the computer. The computer program is executed by a processor to implement a watermarking method.
The processor executes the steps of the watermarking method:
acquiring target data to be added into the picture;
performing byte conversion processing on the target data to obtain a corresponding original byte array;
processing the original byte array based on an encode method of base64 to generate a specified byte array;
acquiring the character length of bytes contained in the specified byte array, and calling a preset calculation formula to calculate the number of the placing positions based on the character length;
acquiring a width value and a height value of the picture;
calculating the number of placement lines based on the number of placement positions and the width value, and determining first line information for adding the watermark based on the number of placement lines and the height value;
sequentially acquiring a first byte, a second byte and a third byte which are sequenced most in sequence according to the sequence of each byte in the designated byte array;
acquiring a first pixel point which is sequenced most in a first adding line corresponding to the first line information, and acquiring a first color value of an R channel of the first pixel point, a second color value of a G channel of the first pixel point and a third color value of a B channel of the first pixel point based on a first pixel value of the first pixel point;
Updating the first color value using the first byte, updating the second color value using the second byte, and updating the third color value using the third byte to form an updated pixel value for the first pixel, to effect an update of the pixel value for the first pixel point, and so on, starting with the first added row, traversing a plurality of target pixel points which are contained in each adding row corresponding to the placing row number and have the same number with the placing positions from left to right and from top to bottom, according to the arrangement sequence of each byte in the designated byte array, updating the color values of three color channels in corresponding pixel points of corresponding rows in the picture one by using every three bytes in the designated byte array until all bytes contained in the designated byte array are filled in the picture;
and filling the character length on a designated pixel point in the picture to obtain a target picture so as to finish the watermark adding processing of the picture.
Those skilled in the art will appreciate that the structure shown in fig. 3 is only a block diagram of a part of the structure related to the present application, and does not constitute a limitation to the apparatus and the computer device to which the present application is applied.
An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a watermarking method, and specifically:
acquiring target data to be added into the picture;
performing byte conversion processing on the target data to obtain a corresponding original byte array;
processing the original byte array based on an encode method of base64 to generate a specified byte array;
acquiring the character length of bytes contained in the specified byte array, and calling a preset calculation formula to calculate the number of the placing positions based on the character length;
acquiring a width value and a height value of the picture;
calculating the number of placement lines based on the number of placement positions and the width value, and determining first line information for adding the watermark based on the number of placement lines and the height value;
sequentially acquiring a first byte, a second byte and a third byte which are sequenced most in sequence according to the sequence of each byte in the designated byte array;
acquiring a first pixel point which is sequenced most in a first adding line corresponding to the first line information, and acquiring a first color value of an R channel of the first pixel point, a second color value of a G channel of the first pixel point and a third color value of a B channel of the first pixel point based on a first pixel value of the first pixel point;
Updating the first color value using the first byte, updating the second color value using the second byte, and updating the third color value using the third byte to form an updated pixel value for the first pixel, to effect an update of the pixel value for the first pixel point, and so on, starting with the first added row, traversing a plurality of target pixel points which are contained in each adding row corresponding to the placing row number and have the same number with the placing positions from left to right and from top to bottom, according to the arrangement sequence of each byte in the designated byte array, updating the color values of three color channels in corresponding pixel points of corresponding rows in the picture one by using every three bytes in the designated byte array until all bytes contained in the designated byte array are filled in the picture;
and filling the character length on a designated pixel point in the picture to obtain a target picture so as to finish the watermark adding processing of the picture.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and can include the processes of the embodiments of the methods described above when the computer program is executed. Any reference to memory, storage, database, or other medium provided herein and used in the examples may include non-volatile and/or volatile memory. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double-rate SDRAM (SSRSDRAM), Enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The above description is only a preferred embodiment of the present application, and not intended to limit the scope of the present application, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the specification and the drawings of the present application, or which are directly or indirectly applied to other related technical fields, are also included in the scope of the present application.

Claims (10)

1. A watermarking method, comprising:
acquiring target data to be added into the picture;
performing byte conversion processing on the target data to obtain a corresponding original byte array;
processing the original byte array based on an encode method of base64 to generate a specified byte array;
acquiring the character length of bytes contained in the specified byte array, and calling a preset calculation formula to calculate the number of the placing positions based on the character length;
acquiring a width value and a height value of the picture;
calculating the number of placement lines based on the number of placement positions and the width value, and determining first line information for adding the watermark based on the number of placement lines and the height value;
sequentially acquiring a first byte, a second byte and a third byte which are sequenced most in sequence according to the sequence of each byte in the designated byte array;
Acquiring a first pixel point which is sequenced most in a first adding line corresponding to the first line information, and acquiring a first color value of an R channel of the first pixel point, a second color value of a G channel of the first pixel point and a third color value of a B channel of the first pixel point based on a first pixel value of the first pixel point;
updating the first color value using the first byte, updating the second color value using the second byte, and updating the third color value using the third byte to form an updated pixel value for the first pixel, to effect an update of the pixel value for the first pixel point, and so on, starting with the first added row, traversing a plurality of target pixel points which are contained in each adding row corresponding to the placing row number and have the same number with the placing positions from left to right and from top to bottom, according to the arrangement sequence of each byte in the designated byte array, updating the color values of three color channels in corresponding pixel points of corresponding rows in the picture by using every three bytes in the designated byte array in a one-to-one correspondence manner until all bytes contained in the designated byte array are filled into the picture;
And filling the character length on a specified pixel point in the picture to obtain a target picture so as to finish the watermark adding processing of the picture.
2. The method for adding watermark according to claim 1, wherein the step of calculating the number of the placement positions by calling a preset calculation formula based on the character length comprises:
judging whether the character length is a multiple of 3;
if the character length is a multiple of 3, calling a first calculation formula count ═ bytes/3 to calculate the number of the placing positions, wherein the count is the number of the placing positions, and the bytes are the character length;
if the character length is not a multiple of 3, calling a second calculation formula count ═ bytes/3+1 to calculate the number of the placement positions, wherein the count is the number of the placement positions, and the bytes are the character length.
3. The method according to claim 1, wherein the step of calculating a number of placement lines based on the number of placement positions and the width value, and determining first-line information for adding a watermark based on the number of placement lines and the height value includes:
judging whether the number of the placing positions is a multiple of the width value;
If the number of the placing positions is a multiple of the width value, calling a third calculation formula row which is a number of placing lines, count which is the number of the placing positions and width which is the width value to calculate the number of the placing lines;
if the number of the placing positions is not a multiple of the width value, calling a fourth calculation formula row which is count/width +1 to calculate the number of the placing lines, wherein row is the number of the placing lines, count is the number of the placing positions, and width is the width value;
and calling a fifth calculation formula position-height-row to determine the head line information, wherein the position is the head line information, the height is the height value, and the row is the placing line number.
4. The method of claim 1, wherein the step of obtaining a first color value of an R channel of the first pixel, a second color value of a G channel of the first pixel, and a third color value of a B channel of the first pixel based on the first pixel value of the first pixel comprises:
converting the picture into a bufferedmiage object;
acquiring a two-dimensional coordinate of the first pixel point;
Acquiring a first pixel value corresponding to the first pixel point by an acquisition method corresponding to the buffered image object according to the two-dimensional coordinate;
transforming the first pixel value based on a preset first transformation code to obtain a first color value of an R channel of the first pixel point; and the number of the first and second groups,
transforming the first pixel value based on a preset second transformation code to obtain a second color value of the G channel of the first pixel point; and the number of the first and second groups,
and carrying out transformation processing on the first pixel value based on a preset third transformation code to obtain a third color value of the B channel of the first pixel point.
5. The method of claim 1, wherein the step of filling the character length at a specific pixel point in the picture comprises:
judging whether the character length is three digits;
if the character length is three digits, acquiring the position information of a specified pixel point in the picture;
acquiring color values of the color channels corresponding to the designated pixel points based on the position information;
on the basis of the character length, respectively extracting the hundred digits of the character length, the ten digits of the character length and the single digits of the character length;
Replacing the color value of the R channel of the designated pixel point with the hundred digits of the character length; and the number of the first and second groups,
changing the color value of the G channel of the designated pixel point into a ten-digit number of the character length; and the number of the first and second groups,
and replacing the color value of the B channel of the specified pixel point with the single digit of the character length.
6. The method of claim 1, wherein before the step of filling the character length in a designated pixel point in the picture to obtain a target picture to complete the watermarking process for the picture, the method comprises:
judging whether the last pixel point of the last line in the picture is in an updating state currently or not, wherein the last pixel point of the last line in the picture is marked as a second pixel point;
if the second pixel point is not in the updating state currently, taking the second pixel point as the designated pixel point;
if the second pixel point is in an updating state currently, taking a first pixel point of a first line of the picture and a last pixel point of the first line of the picture as alternative pixel points;
displaying selection information corresponding to the alternative pixel points;
And determining the designated pixel points from the alternative pixel points based on the fed back selection results corresponding to the selection information.
7. The method of claim 1, wherein the step of filling the character length in a designated pixel point in the picture to obtain a target picture, so as to complete the watermarking process for the picture, comprises:
judging whether a watermark analyzing instruction for the target picture is received or not;
if a watermark analyzing instruction for the target picture is received, acquiring a second pixel value of the specified pixel point based on a pre-stored character length storage rule;
generating a corresponding byte length value based on the second pixel value;
based on the byte length value, calculating the number of pixel points contained in the watermark and the initial insertion line of the watermark in the target picture;
starting from the initial insertion row, acquiring the pixel value of an insertion pixel point which is arranged at the top of the initial insertion row in sequence from left to right and from top to bottom, sequentially acquiring the color value of an R channel, the color value of a G channel and the color value of a B channel of the insertion pixel point based on the pixel value of the insertion pixel point, sequentially placing the color value of the R channel of the insertion pixel point, the color value of the G channel of the insertion pixel point and the color value of the B channel of the insertion pixel point in a preset byte template, and so on, extracting the color values of three channels of other insertion pixel points except the insertion pixel points based on the number of the pixel points and correspondingly placing the color values in the byte template to obtain a byte template after data updating;
Calling a decode method of base64, and performing numerical value conversion reduction processing on all numerical values in the byte template after the data updating to obtain a reduced byte template;
and converting all numerical values in the byte template after the reduction processing into character strings to obtain target data added into the picture.
8. A watermarking apparatus comprising:
the first acquisition module is used for acquiring target data to be added into the picture;
the first processing module is used for carrying out byte conversion processing on the target data to obtain a corresponding original byte array;
the second processing module is used for processing the original byte array based on the encode method of base64 to generate a specified byte array;
the first calculation module is used for acquiring the character length of bytes contained in the specified byte array and calling a preset calculation formula to calculate the number of the placing positions based on the character length;
the second acquisition module is used for acquiring the width value and the height value of the picture;
the second calculation module is used for calculating the number of the placement rows based on the number of the placement positions and the width value, and determining first row information for adding the watermark based on the number of the placement rows and the height value;
The third obtaining module is used for sequentially obtaining a first byte, a second byte and a third byte which are arranged at the top according to the arrangement sequence of each byte in the specified byte array;
a fourth obtaining module, configured to obtain a first pixel point sorted foremost in a first adding line corresponding to the first line information, and obtain, based on a first pixel value of the first pixel point, a first color value of an R channel of the first pixel point, a second color value of a G channel of the first pixel point, and a third color value of a B channel of the first pixel point;
an update module to update the first color value using the first byte and update the second color value using the second byte, and updating the third color value using the third byte to form an updated pixel value for the first pixel, to effect an update of the pixel value for the first pixel point, and so on, starting with the first added row, traversing a plurality of target pixel points which are contained in each adding row corresponding to the placing row number and have the same number with the placing positions from left to right and from top to bottom, according to the arrangement sequence of each byte in the designated byte array, updating the color values of three color channels in corresponding pixel points of corresponding rows in the picture by using every three bytes in the designated byte array in a one-to-one correspondence manner until all bytes contained in the designated byte array are filled into the picture;
And the first generation module is used for filling the character length on a specified pixel point in the picture to obtain a target picture so as to finish the watermarking processing of the picture.
9. A computer device comprising a memory and a processor, the memory having stored therein a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN202011551624.4A 2020-12-24 2020-12-24 Watermark adding method, device, computer equipment and storage medium Active CN112634119B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202011551624.4A CN112634119B (en) 2020-12-24 2020-12-24 Watermark adding method, device, computer equipment and storage medium
PCT/CN2021/125219 WO2022134804A1 (en) 2020-12-24 2021-10-21 Watermark adding method and apparatus, computer device, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011551624.4A CN112634119B (en) 2020-12-24 2020-12-24 Watermark adding method, device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112634119A CN112634119A (en) 2021-04-09
CN112634119B true CN112634119B (en) 2022-07-29

Family

ID=75324501

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011551624.4A Active CN112634119B (en) 2020-12-24 2020-12-24 Watermark adding method, device, computer equipment and storage medium

Country Status (2)

Country Link
CN (1) CN112634119B (en)
WO (1) WO2022134804A1 (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112634119B (en) * 2020-12-24 2022-07-29 深圳壹账通智能科技有限公司 Watermark adding method, device, computer equipment and storage medium
CN113298687B (en) * 2021-05-26 2023-09-29 北京京东振世信息技术有限公司 Watermark image adding method and device
CN113810189B (en) * 2021-10-27 2024-01-09 中电金信软件有限公司 Method and device for generating key picture
CN117234114B (en) * 2023-11-13 2024-03-15 新黎明科技股份有限公司 Dual-mode control method and system for intelligent evacuation lamp controller

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104794677A (en) * 2015-05-05 2015-07-22 哈尔滨工程大学 Vector map watermark method based on space geometric features
CN105741226A (en) * 2016-02-01 2016-07-06 江苏实达迪美数据处理有限公司 Electronic stamp based visible digital image watermark embedding and detection methods
CN106097239A (en) * 2016-06-15 2016-11-09 常熟理工学院 A kind of Quick Response Code watermark encrypting parallelization quickly embeds and extracting method
CN107846530A (en) * 2017-09-28 2018-03-27 四川长虹电器股份有限公司 Digital watermarking algorithm
CN111652789A (en) * 2020-06-05 2020-09-11 北京信息科技大学 Color image embedding method and color image extracting method

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8385592B2 (en) * 2009-02-04 2013-02-26 Quicksilver Software, Inc. Digital watermarking system and method
CN106228502B (en) * 2016-07-15 2018-01-23 北华航天工业学院 The digital watermark embedding and extracting method of satellite remote-sensing image tiff file
CN106507130A (en) * 2016-11-24 2017-03-15 成都天脉拓道科技有限公司 Method and the watermark stacking apparatus of watermark superpose on yuv frame
CN112634119B (en) * 2020-12-24 2022-07-29 深圳壹账通智能科技有限公司 Watermark adding method, device, computer equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104794677A (en) * 2015-05-05 2015-07-22 哈尔滨工程大学 Vector map watermark method based on space geometric features
CN105741226A (en) * 2016-02-01 2016-07-06 江苏实达迪美数据处理有限公司 Electronic stamp based visible digital image watermark embedding and detection methods
CN106097239A (en) * 2016-06-15 2016-11-09 常熟理工学院 A kind of Quick Response Code watermark encrypting parallelization quickly embeds and extracting method
CN107846530A (en) * 2017-09-28 2018-03-27 四川长虹电器股份有限公司 Digital watermarking algorithm
CN111652789A (en) * 2020-06-05 2020-09-11 北京信息科技大学 Color image embedding method and color image extracting method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于RTF格式的加密水印算法研究;张瑞 等;《甘肃科技》;20101231;第26卷(第24期);第88-89页 *

Also Published As

Publication number Publication date
CN112634119A (en) 2021-04-09
WO2022134804A1 (en) 2022-06-30

Similar Documents

Publication Publication Date Title
CN112634119B (en) Watermark adding method, device, computer equipment and storage medium
KR101859942B1 (en) Captcha provision method and computer readable medium on which captcha provision computer program is recorded
CN109726794A (en) Image based on concern generates neural network
WO2020073508A1 (en) Method and device for adding and extracting audio watermark, electronic device and medium
CN113326081A (en) Static resource processing method and device, computer equipment and storage medium
EP3410685A1 (en) Image processing device, image processing method, and program
US8612763B1 (en) Digital signature verification processes, methods and systems
CN111680480A (en) Template-based job approval method and device, computer equipment and storage medium
CN112668041A (en) Document file generation method and device, computer equipment and storage medium
CN110362542A (en) Nuclear power station document No. method, apparatus, computer equipment and storage medium
CN112637282B (en) Information pushing method and device, computer equipment and storage medium
CN113962838A (en) Watermark image embedding/enhancing method, device and computer system
CN110647350A (en) Interface document generation method and device, computer equipment and storage medium
CN112650659B (en) Buried point setting method and device, computer equipment and storage medium
CN113569258B (en) Real estate mortgage registration data security query working method
CN113762053B (en) Image processing method, device, computer and readable storage medium
CN114298321A (en) Joint modeling method and device, electronic equipment and storage medium
CN111985001A (en) Desensitization method and device of Chinese character data, computer equipment and storage medium
EP3699863A1 (en) Image interpretation device
CN117649673B (en) Picture processing method in book editing and correction
CN113434895B (en) Text decryption method, device, equipment and storage medium
CN117274507B (en) AI simulation method and system for facial beauty and shaping based on Internet
CN113791695B (en) Password input method, device, electronic equipment and storage medium
CN110717157B (en) User authentication method, device, computer equipment and storage medium
CN109918065B (en) Picture code editing method and device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40049940

Country of ref document: HK

GR01 Patent grant
GR01 Patent grant