CN113298687B - Watermark image adding method and device - Google Patents

Watermark image adding method and device Download PDF

Info

Publication number
CN113298687B
CN113298687B CN202110577758.1A CN202110577758A CN113298687B CN 113298687 B CN113298687 B CN 113298687B CN 202110577758 A CN202110577758 A CN 202110577758A CN 113298687 B CN113298687 B CN 113298687B
Authority
CN
China
Prior art keywords
image
watermark
watermark image
pixel
target
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
CN202110577758.1A
Other languages
Chinese (zh)
Other versions
CN113298687A (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.)
Beijing Jingdong Zhenshi Information Technology Co Ltd
Original Assignee
Beijing Jingdong Zhenshi Information Technology Co Ltd
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 Beijing Jingdong Zhenshi Information Technology Co Ltd filed Critical Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority to CN202110577758.1A priority Critical patent/CN113298687B/en
Publication of CN113298687A publication Critical patent/CN113298687A/en
Application granted granted Critical
Publication of CN113298687B publication Critical patent/CN113298687B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/22Matching criteria, e.g. proximity measures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/60Rotation of whole images or parts thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/12Edge-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Data Mining & Analysis (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • Artificial Intelligence (AREA)
  • General Engineering & Computer Science (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Editing Of Facsimile Originals (AREA)
  • Image Processing (AREA)

Abstract

The application discloses a watermark image adding method and a device, and relates to the technical field of computers, wherein the method comprises the steps of receiving a watermark adding request, and acquiring an image identifier in the watermark adding request so as to acquire an original image and a watermark image; identifying edges of the original image to determine a target watermark image addition area from the edges and the watermark image; determining a foreground color watermark image; rotating the foreground color watermark image to generate a mixed image corresponding to each rotation direction in the target watermark image adding area; and determining the similarity between each mixed image and the original image in the target watermark image adding area, so as to determine the adding direction of the watermark image according to the similarity, and further generate the watermark image. Thus, this embodiment can achieve a reduction in the impact of the added watermark on the original image quality.

Description

Watermark image adding method and device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a watermark image adding method and device.
Background
At present, for adding watermarks on photos, common practice is to automatically display the watermarks on fixed positions of the photos, automatically and uniformly add a plurality of watermarks on the photos, manually add watermark layers and original images on the photos to synthesize, and automatically generate watermarks which are not easy to view on the photos.
In the process of implementing the present application, the inventor finds that at least the following problems exist in the prior art:
the existing watermark image adding method has great influence on the quality of the original image.
Disclosure of Invention
In view of the above, the embodiment of the application provides a watermark image adding method and device, which can solve the problem that the existing watermark image adding method has great influence on the quality of original pictures.
To achieve the above object, according to an aspect of an embodiment of the present application, there is provided a watermark image adding method including:
receiving a watermark adding request, and acquiring an image identifier in the watermark adding request to acquire an original image and a watermark image;
identifying edges of the original image to determine a target watermark image addition area from the edges and the watermark image;
determining a foreground color watermark image;
rotating the foreground color watermark image to generate a mixed image corresponding to each rotation direction in the target watermark image adding area;
and determining the similarity between each mixed image and the original image in the target watermark image adding area, so as to determine the adding direction of the foreground color watermark image according to the similarity, and further generate the watermark image.
Optionally, identifying edges of the original image to determine a target watermark image addition area from the edges and the watermark image includes:
And identifying the edge of the original image, generating the original edge image, and dividing the original edge image according to the watermark image to determine a target watermark image adding area in the original image.
Optionally, segmenting the original edge image from the watermark image comprises:
determining the length of the longest diagonal of a rectangle corresponding to the watermark image;
constructing a square area by taking the length of the longest diagonal of the rectangle as the side length of the square;
the original edge image is segmented using square regions.
Optionally, determining the target watermark image adding area includes:
calculating the sum of pixel values in each square area after the original edge image is segmented;
and sequencing the sum of the pixel values to determine the target watermark image adding area according to the sequencing result.
Optionally, generating a hybrid image corresponding to each rotation direction within the target watermark image adding area includes:
and rotating the foreground color watermark image by taking the target watermark image adding area as the center, and further linearly mixing the foreground color corresponding to each rotation direction of the foreground color watermark image with the pixel color of the original image in the target watermark image adding area to generate each mixed image.
Optionally, determining the similarity of each hybrid image to the original image in the target watermark image adding area includes:
and determining the similarity between each mixed image and the original image in the target watermark image adding area based on a preset similarity formula according to the corresponding relation between the preset color channel corresponding to each pixel and the vector dimension, the pixels of the mixed image corresponding to each rotation direction and the pixels of the original image in the target watermark image adding area.
Optionally, generating the watermark image includes:
and adding the foreground color watermark image to the rotation direction corresponding to the maximum similarity to generate an explicit watermark image.
Optionally, after generating the watermark image, the watermark image adding method further comprises:
determining the longest edge pixel of the watermark image;
based on the color channel of each pixel, determining the average difference value of adjacent pixels of the same color channel of the longest side pixel, and further determining an average difference value linear table based on the arrangement position of each pixel in the longest side pixel;
determining the number of bytes corresponding to the original image;
and according to the byte number, moving the index position of the average difference value in the average difference value linear table according to a preset index sequence, and further determining the adding position of the implicit watermark.
Optionally, after determining the location of addition of the implicit watermark, the method further comprises:
acquiring an implicit watermark text, a preset code and a public key ciphertext character, and generating an encrypted implicit watermark byte array based on an exclusive-or algorithm;
determining an average difference value byte array according to the adding position of the implicit watermark, the average difference value linear table and the encrypted implicit watermark byte array;
performing exclusive OR calculation on the average difference value byte array and the encrypted implicit watermark byte array to generate a target average difference value byte array;
restoring the implicit watermark image based on the target average difference value byte array;
and adding the implicit watermark image to an adding position of the implicit watermark.
Optionally, restoring the implicit watermark image based on the target average difference value byte array includes:
determining a sum value of adjacent pixels of the same color channel of the longest edge pixel based on the color channel of each pixel;
and determining pixel values in the implicit watermark image based on the target average difference value byte array and each average sum value, so as to restore the implicit watermark image.
Optionally, determining the foreground color watermark image includes:
the pixel colors of the original image within the target watermark image adding area are determined to determine the foreground color of the watermark image based on the pixel colors, generating a foreground color watermark image.
In addition, the application also provides a watermark image adding device, which comprises:
the receiving unit is configured to receive the watermark adding request, acquire the image identifier in the watermark adding request and acquire the original image and the watermark image;
an identification unit configured to identify an edge of the original image to determine a target watermark image addition area from the edge and the watermark image;
a foreground color watermark image generation unit configured to determine a foreground color watermark image;
a mixed image generating unit configured to rotate the foreground color watermark image, generating mixed images corresponding to respective rotation directions within the target watermark image adding area;
and the watermark image generation unit is configured to determine the similarity between each mixed image and the original image in the target watermark image adding area so as to determine the adding direction of the foreground color watermark image according to the similarity and further generate the watermark image.
Optionally, the identification unit is further configured to:
and identifying the edge of the original image, generating the original edge image, and dividing the original edge image according to the watermark image to determine a target watermark image adding area in the original image.
Optionally, the identification unit is further configured to:
Determining the length of the longest diagonal of a rectangle corresponding to the watermark image;
constructing a square area by taking the length of the longest diagonal of the rectangle as the side length of the square;
the original edge image is segmented using square regions.
Optionally, the identification unit is further configured to:
calculating the sum of pixel values in each square area after the original edge image is segmented;
and sequencing the sum of the pixel values to determine the target watermark image adding area according to the sequencing result.
Optionally, the hybrid image generation unit is further configured to:
and rotating the foreground color watermark image by taking the target watermark image adding area as the center, and further linearly mixing the foreground color corresponding to each rotation direction of the foreground color watermark image with the pixel color of the original image in the target watermark image adding area to generate each mixed image.
Optionally, the watermark image generation unit is further configured to:
and determining the similarity between each mixed image and the original image in the target watermark image adding area based on a preset similarity formula according to the corresponding relation between the preset color channel corresponding to each pixel and the vector dimension, the pixels of the mixed image corresponding to each rotation direction and the pixels of the original image in the target watermark image adding area.
Optionally, the watermark image generation unit is further configured to:
and adding the foreground color watermark image to the rotation direction corresponding to the maximum similarity to generate an explicit watermark image.
Optionally, the watermark image adding apparatus further comprises an adding position determining unit configured to:
determining the longest edge pixel of the watermark image;
based on the color channel of each pixel, determining the average difference value of adjacent pixels of the same color channel of the longest side pixel, and further determining an average difference value linear table based on the arrangement position of each pixel in the longest side pixel;
determining the number of bytes corresponding to the original image;
and according to the byte number, moving the index position of the average difference value in the average difference value linear table according to a preset index sequence, and further determining the adding position of the implicit watermark.
Optionally, the watermark image adding apparatus further comprises an implicit watermark adding unit configured to:
acquiring an implicit watermark text, a preset code and a public key ciphertext character, and generating an encrypted implicit watermark byte array based on an exclusive-or algorithm;
determining an average difference value byte array according to the adding position of the implicit watermark, the average difference value linear table and the encrypted implicit watermark byte array;
performing exclusive OR calculation on the average difference value byte array and the encrypted implicit watermark byte array to generate a target average difference value byte array;
Restoring the implicit watermark image based on the target average difference value byte array;
and adding the implicit watermark image to an adding position of the implicit watermark.
Optionally, the implicit watermarking unit is further configured to:
determining a sum value of adjacent pixels of the same color channel of the longest edge pixel based on the color channel of each pixel;
and determining pixel values in the implicit watermark image based on the target average difference value byte array and each average sum value, so as to restore the implicit watermark image.
Optionally, the foreground color watermark image generation unit is further configured to:
the pixel colors of the original image within the target watermark image adding area are determined to determine the foreground color of the watermark image based on the pixel colors, generating a foreground color watermark image.
In addition, the application also provides watermark image adding electronic equipment, which comprises: one or more processors; and a storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement the watermark image addition method as described above.
In addition, the application also provides a computer readable medium, on which a computer program is stored, which when executed by a processor implements the watermark image adding method as described above.
One embodiment of the above application has the following advantages or benefits: the method comprises the steps of obtaining an image identifier in a watermark adding request by receiving the watermark adding request so as to obtain an original image and a watermark image; identifying edges of the original image to determine a target watermark image addition area from the edges and the watermark image; determining a foreground color watermark image, and further generating a mixed image corresponding to each rotation direction in the target watermark image adding area by rotating the foreground color watermark image; the similarity between each mixed image and the original image in the target watermark image adding area is determined, so that the adding direction of the foreground color watermark image is determined according to the similarity, the watermark image is generated, the color difference between the added watermark image (namely, the color watermark image) and the original image can be reduced, and the influence on the original image is reduced.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the application and are not to be construed as unduly limiting the application. Wherein:
fig. 1 is a schematic diagram of the main flow of a watermark image adding method according to a first embodiment of the application;
Fig. 2 is a schematic diagram of the main flow of a watermark image adding method according to a second embodiment of the application;
fig. 3 is a schematic view of an application scenario of a watermark image adding method according to a third embodiment of the application;
fig. 4 is a schematic diagram of main modules of a watermark image adding apparatus according to an embodiment of the application;
FIG. 5 is an exemplary system architecture diagram in which embodiments of the present application may be applied;
fig. 6 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the application.
Detailed Description
Exemplary embodiments of the present application will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present application are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the application. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of the main flow of a watermark image adding method according to a first embodiment of the application, and as shown in fig. 1, the watermark image adding method includes:
Step S101, a watermark adding request is received, and an image identifier in the watermark adding request is obtained so as to obtain an original image and a watermark image.
In this embodiment, the execution body (for example, may be a server) of the watermark image adding method may receive, by way of wired connection or wireless connection, a watermark adding request sent by a user through a terminal device. In particular, the watermarking request may include a location identification of the watermarking, which may include one or more location coordinates. The watermarking request may also include a form of watermarking, such as explicit or implicit. The watermark adding request may further include an image identifier for indicating the watermark image and an original image to which the watermark image is to be added. The execution subject can acquire the image identifier from the watermark adding request, and further acquire the original image and the watermark image corresponding to the image identifier from a local or cloud database by the acquired image identifier. For example, the image identifier may be 01-22, where "01" may correspond to the original image, and "22" may correspond to the watermark image, and the correspondence between each image identifier and the original image and the watermark image is stored in the local or cloud database. Alternatively, the execution subject may acquire the original image and the watermark image input by the user directly from the terminal device. The source and the mode of acquisition of the original image and the watermark image are not particularly limited.
Step S102, identifying the edge of the original image to determine a target watermark image adding area according to the edge and the watermark image.
In this embodiment, after the execution subject acquires the original image and the watermark image, the edge of the original image may be identified to determine the target watermark image adding area from the edge and the watermark image.
Specifically, identifying edges of the original image to determine a target watermark image addition area from the edges and the watermark image includes: and identifying the edge of the original image, generating the original edge image, and dividing the original edge image according to the watermark image to determine a target watermark image adding area in the original image. Specifically, identifying edges of the original image may include: the execution subject converts the original image into a gray scale map and performs sobel operator calculation. The gray level map can be converted into a two-dimensional array, and the dimensions of the two-dimensional array are the length and the width of the gray level map. The sobel operator is two fixed three-dimensional arrays, the first is the X-axis horizontal direction and the second is the Y-axis vertical direction. Illustratively, the first is the first behavior-3,0,3 of the three-dimensional array in the X-axis horizontal direction; second behavior-10, 0, 10; third behavior-3,0,3. The second is the first behavior 3, 10,3 of the three-dimensional array in the vertical direction of the Y axis; a second behavior 0,0; third behavior-3, -10, -3. First behaviors X1, X2 and X3 of the two-dimensional array in the horizontal direction of the X axis of the gray image; a second behavior X4, X5, X6; third behaviors X7, X8, X9. First behaviors Y1, Y2, Y3 of the two-dimensional array in the Y-axis vertical direction of the grayscale image; a second behavior Y4, Y5, Y6; third behavior Y7, Y8, Y9. Each sobel operator and each element in the two-dimensional array are calculated by the following calculation method: aligning the center number of the Sobel operator with the element to be calculated in the two-dimensional array, sequentially multiplying the element in the eight fields of the element and the element in the eight fields of the center number of the Sobel operator, and summing. That is, assuming that X is a sobel operator, Y is a continuous 3*3 region in the two-dimensional array, the operation procedure of the sobel operators of X5 and Y5 is: x1+x2+x2+x3+y3+x4+y4+x5+x5+x6+x7+y7+x8+x9. If y5 is the edge data in the two-dimensional array, i.e., the first row or last row, the first column or last column, then the corresponding missing data is filled with 0. Calculating the calculation results of two sobel operators in the horizontal direction and the vertical direction:
For example, it may be:
horizontal direction (x axis):
-3*y1+0*y2+3*y3+(-10)*y4+0*y5+10*y6+(-3)*y7+0*y8+3*y9=-3y1+3y3-10y4+10y6-3y7+3y9;
vertical direction (y axis):
x1*3+x2*10+x3*3+x4*0+x5*0+x6*0+x7*(-3)+x8*(-10)+x9*(-3)=3x1+10x2+3x3-3x7-10x8-3x9。
after the execution main body calculates the calculation results of the two sobel operators in the horizontal direction and the vertical direction, calculating the sum of absolute values of the calculation results of the two sobel operators of the elements in the two-dimensional array at the same position, namely substituting each corresponding value in the two-dimensional array converted from the gray image into the calculation value to obtain abs (x-axis value) +abs (y-axis value), and obtaining the final sobel operator calculation result. And then determining the horizontal edge and the vertical edge of the original image according to the final result of the Sobel operator operation, thereby determining the edge of the original image, and generating the original edge image according to the determined edge of the original image.
Specifically, segmenting the original edge image from the watermark image includes: determining the length of the longest diagonal of a rectangle corresponding to the watermark image; the square area is constructed by taking the length of the longest diagonal of the rectangle as the side length of the square, and specifically, the square area can be an original edge image obtained by calculating the number of pixels corresponding to the length of the longest diagonal of the rectangle by using the Sobel operator. Specifically, the execution body may construct a circumscribed circle on the watermark image, so that a rectangle inscribed in the circumscribed circle is the watermark image, and a square circumscribed by the circumscribed circle is a square area in the original edge image, that is, a square area to which the watermark image is to be added, so that when the watermark image is rotated by taking the center of the circumscribed circle as the center, the watermark image cannot be cut off in a border crossing manner. Each divided area is a square area, the distances between the square area and the upper edge and the lower edge of the original edge image are equal, each edge distance is not larger than the edge distance of the square area, and the left edge and the right edge are the same. The original edge image is segmented using square regions.
By way of example, the watermark image added area may be a square continuous contiguous area of 4 rows by 3 columns. The maximum number of square areas to be added with watermark images, which can be stored in the original edge image, can be 12, so that the square areas are guaranteed to be equidistant from the upper edge and the lower edge of the original edge image and equidistant from the left edge and the right edge of the original edge image.
Specifically, determining the target watermark image adding area includes: the sum of pixel values in each square area after the original edge image is segmented is calculated, and the value is used for representing the variation value of the pixel value relative to surrounding pixels. The execution body sorts the pixel value sums to determine the top N square areas with the largest pixel value sum in the square areas, wherein the top N square areas are the top N areas with the largest image change in all the square areas. The execution body may determine the target watermark image adding area, i.e. the first N square areas with the largest sum of pixel values, according to the sorting result.
Step S103, determining a foreground color watermark image.
In this embodiment, the execution subject may generate the foreground color watermark image by determining the pixel color of the original image within the target watermark image addition area to determine the foreground color of the watermark image based on the pixel color.
Specifically, the execution subject may convert the color of the watermark image into the front Jing Shanse in a square of the high frequency region, with the background transparent so as to be fused with the original image. The executing body may determine pixel colors of the original image in the target watermark image adding area, that is, pixel values of red, green and blue channels, and the foreground color of the watermark image is set to be an average value of the pixel colors, that is, an average value of red, green and blue three-channel pixel values of all pixels in the original image area in the target watermark image adding area (three primary colors are three color channels), that is, the watermark image may be a color image or an achromatic color image, and the specific color of the watermark image may be determined according to the average value of the red, green and blue three-channel pixel values. The executing body may then generate a foreground color watermark image based on the determined foreground color. The foreground color may be the color of the current composition, e.g., line, fill, etc., and may specifically be the color drawn by the brush.
Step S104, rotating the foreground color watermark image to generate a mixed image corresponding to each rotation direction in the target watermark image adding area.
After the execution body obtains the foreground color watermark image, the foreground color watermark image can be superimposed and rotated in the original image area in the target watermark image adding area. And calculating the pixel values of the foreground color watermark image in each rotation direction and the original image area in the target watermark image adding area according to a preset calculation formula, determining a mixed pixel value according to a calculation result, and generating a mixed image corresponding to each rotation direction in the target watermark image adding area based on the mixed pixel value in each rotation direction. In particular, the direction of rotation may refer to a specific orientation of the foreground color watermark image rotation within the target watermark image addition area. For example, the direction of rotation of the foreground color watermark image within the target watermark image addition area may be a 15 ° clockwise rotation direction, a 30 ° clockwise rotation direction, a 15 ° counterclockwise rotation direction, or the like.
Step S105, the similarity between each mixed image and the original image in the target watermark image adding area is determined, so that the adding direction of the foreground color watermark image is determined according to the similarity, and the watermark image is generated.
The executing body can determine the similarity between each mixed image and the original image in the target watermark image adding area through similarity calculation, one or more rotation directions corresponding to one or more similarities in a preset numerical range can be selected as the adding direction of the foreground color watermark image, and the executing body can select one of the rotation directions to generate an explicit watermark image. The explicit watermark image may be a watermark image that is visible to the naked eye.
In the embodiment, an image identifier in a watermark adding request is obtained by receiving the watermark adding request so as to obtain an original image and a watermark image; identifying the edge of the original image to determine a target watermark image adding area according to the edge and the watermark image, utilizing the edge detection of the image, realizing the edge detection by utilizing the Sobel operator, and confirming the adding area of the explicit watermark of the image, wherein the scheme has better accuracy and calculation efficiency; determining a foreground color watermark image, so that a color watermark image can be obtained, and further, a mixed image corresponding to each rotation direction in the target watermark image adding area can be generated by rotating the foreground color watermark image; the similarity between each mixed image and the original image in the target watermark image adding area is determined, so that the adding direction of the foreground color watermark image is determined according to the similarity, the watermark image is generated, the color difference between the added watermark image (namely, the color watermark image) and the original image can be reduced, and the influence of the added watermark image on the quality of the original image is reduced.
Fig. 2 is a main flow diagram of a watermark image adding method according to a second embodiment of the application, and as shown in fig. 2, the watermark image adding method includes:
step S201, a watermark adding request is received, and an image identifier in the watermark adding request is acquired to acquire an original image and a watermark image.
Step S202, identifying edges of the original image to determine a target watermark image adding area from the edges and the watermark image.
Step S203, determining a foreground color watermark image.
Step S204, rotating the foreground color watermark image to generate a mixed image corresponding to each rotation direction in the target watermark image adding area.
The principle of step S201 to step S204 is similar to that of step S101 to step S104, and will not be described here again.
Specifically, step S204 may also be implemented by step S2041:
step S2041, rotating the foreground color watermark image by taking the target watermark image adding area as the center, and further linearly mixing the foreground color corresponding to each rotation direction of the foreground color watermark image with the pixel color of the original image in the target watermark image adding area to generate each mixed image.
The execution body may rotate the foreground color watermark image continuously clockwise or anticlockwise (specifically, may rotate clockwise or anticlockwise according to a preset step length) with the square center of the target watermark image adding area as an origin, linearly mix pixels (original pixels are taken by pixels of a transparent portion) in the foreground color watermark image corresponding to each rotation direction with pixels of an original image in the target watermark image adding area (mixed pixels= (1-threshold%) x foreground color watermark image pixels+threshold%) xoriginal image pixels, and then generate each mixed image according to the pixels after linear mixing (i.e., mixed pixels).
According to the embodiment, the foreground color corresponding to each rotation direction of the foreground color watermark image is linearly mixed with the pixel color of the original image in the target watermark image adding area, so that the color difference is reduced after the foreground color watermark image is added, and the influence of the added watermark image on the quality of the original image is reduced.
Step S205, the similarity between each mixed image and the original image in the target watermark image adding area is determined, so as to determine the adding direction of the foreground color watermark image according to the similarity, and further generate the watermark image.
The execution subject may perform cosine similarity calculation on the mixed image obtained after linear mixing and the original image in the target watermark image adding area, so as to find a rotation direction with the maximum similarity, and add the foreground color image to the rotation direction with the maximum similarity, so as to generate a watermark image, which may specifically be an explicit watermark image.
The principle of step S205 is similar to that of step S105, and will not be described here.
Specifically, step S205 may also be implemented by-step S2052:
step S2051, according to the corresponding relationship between the preset color channel corresponding to each pixel and the vector dimension, the pixels of the mixed image corresponding to each rotation direction, and the pixels of the original image in the target watermark image adding area, determining the similarity between each mixed image and the original image in the target watermark image adding area based on the preset similarity formula.
The original image within the target watermark image adding area refers to an image within the target watermark image adding area in the original image.
Specifically, taking an example that the original image and the foreground color image in the target watermark image adding area are 3*3 pixel images. The execution body may convert the two 3*3 pixel images into high-dimensional vectors, respectively, and one conversion is taken as an example to describe the following:
pixel 1 red, pixel 1 green, pixel 1 blue, pixel 2 red, pixel 2 green, pixel 2 blue, pixel 3 red, pixel 3 green, pixel 3 blue, pixel 4 red, pixel 4 green, pixel 4 blue, pixel 5 red, pixel 5 green, pixel 5 blue, pixel 6 red, pixel 6 green, pixel 6 blue, pixel 7 red, pixel 7 green, pixel 7 blue, pixel 8 red, pixel 8 green, pixel 8 blue, pixel 9 red, pixel 9 green, pixel 9 blue
The size of each dimension is the numerical size of red, green, and blue in the color component, the subscript of pixel 1 red is 0, the subscript of pixel 1 green is 1, the subscript of pixel 1 blue is 2, the subscript of pixel 2 red is 3, the subscript of pixel 2 green is 4, the subscript of pixel 2 blue is 5, and so on, i.e., each subscript is a vector dimension data.
The execution body may then follow the cosine similarity formula (1) of the multidimensional vector:
and calculating the similarity between each mixed image and the original image in the target watermark image adding area, wherein x and y correspond to different dimension data of pixels at the same position in the mixed image and the original image in the target watermark image adding area. Wherein x1 represents vector dimension data of pixel 1 in the blended image, and similarly, xn represents vector dimension data of pixel n; y1 represents vector dimension data of pixel 1 in the original image within the target watermark image addition area, and so on, yn represents vector dimension data of pixel n. Or x1 represents vector dimension data of pixel 1 in the original image in the target watermark image adding area, xn represents vector dimension data of pixel n; y1 represents vector dimension data of pixel 1 in the blended image, and yn represents vector dimension data of pixel n. The present application is not particularly limited thereto.
Step S2052, adding the foreground color watermark image to the rotation direction corresponding to the maximum similarity to generate an explicit watermark image.
After calculating the similarity between each mixed image corresponding to each rotation direction and the original image in the target watermark image adding area, the executing body can determine the maximum similarity, determine the rotation direction corresponding to the maximum similarity as the direction of adding the foreground color watermark image, and add the foreground color watermark image to the direction to generate the explicit watermark image.
According to the embodiment, the similarity between each mixed image and the original image in the target watermark image adding area is calculated, and the rotation direction corresponding to the maximum similarity is determined to be the adding direction corresponding to the foreground color watermark image, so that the influence on the quality of the original image is minimized after the foreground color watermark image is added to the target watermark image adding area according to the adding direction.
In some alternative implementations of the present embodiment, after the explicit watermark image is generated, the executing subject may continue to calculate the addition location of the implicit watermark image (i.e., the invisible watermark image). Specifically, the watermark image adding method further includes:
the longest edge pixel of the generated watermark image (i.e., the longest edge pixel of the explicit (macroscopic) watermark image) is determined, and if the longest edge pixel is not even, the executing body may add a zero pixel point at the last column of pixels.
And determining average difference values of adjacent pixels of the same color channel of the longest edge pixel based on the color channel of each pixel, and further determining an average difference value linear table based on the arrangement positions of the pixels in the longest edge pixel. Specifically, the execution body may sequentially take, based on the longest edge pixel from top to bottom, an average difference (i.e., a sum value) of sums and differences (i.e., an average difference value) of pixel values of two adjacent pixels of the same color channel, and calculate the pixel values on different color channels, respectively. Two sets of means are reserved for the restoration of subsequent images.
Example: the image is a 3*2 pixel image, with 3 pixels on the longest side, odd, and 0 pixel value added to the last pixel to make it even, e.g., the first line: pixel 1 (red green blue), pixel 2 (red green blue), pixel 3 (red green blue), 0; second row: pixel 4 (red green blue), pixel 5 (red green blue), pixel 6 (red green blue), 0.
The sum of red channels in the pixels is (pixel 1 red+pixel 2 red)/2=a, (pixel 3 red+0)/2=b, each pixel is only used for calculating once, the sum of red, green and blue color channels of the pixels 1, 2 and 3 and 0 is calculated and put into the first row of the sum linear table, namely A, B is sequentially put into the first row of the sum linear table, (pixel 4 red+pixel 5 red)/2=c, (pixel 6 red+0)/2=d, the sum of red, green and blue color channels of the pixels 4, 5 and 6 and 0 is calculated and put into the second row of the sum linear table, namely C, D is sequentially put into the second row of the sum linear table, the sum of the other color channels is sequentially calculated according to the calculation sequence of the red, green and blue color channels, the calculation mode is similar, and the calculation result of the sum is sequentially put into the sum linear table.
The average difference of red channels in the pixels is (pixel 1 red-pixel 2 red)/2=e, (pixel 3 red-0)/2=f, each pixel is only used for calculating once, the average difference values of the red, green and blue color channels of the pixels 1, 2 and 3 and 0 are calculated, the first row of the average difference value linear table is put after the average difference values of the red, green and blue color channels of the pixels 1, 2 and 3 are calculated, E, F is sequentially put in the first row of the average difference value linear table, (pixel 4 red-pixel 5 red)/2=g, (pixel 6 red-0)/2=h, the second row of the average difference value linear table is put after the average difference values of the red, green and blue color channels of the pixels 4, 5 and 6 and 0 are calculated, G, H is sequentially put in the second row of the average difference value linear table, the average difference values of other color channels are sequentially calculated according to the calculation sequence of the red, green and blue color channels, the calculation mode is similar, and the average difference value calculation result is sequentially put in the average difference value linear table, so that the average difference value linear table is obtained.
Then the execution subject can determine the number of bytes corresponding to the original image; and according to the byte number, moving the index position of the average difference value in the average difference value linear table according to a preset index sequence, and further determining the adding position of the implicit watermark. Specifically, the execution body may convert each average difference value in the average difference value linear table into hexadecimal numbers, respectively, each hexadecimal number corresponding to an index position. The execution body may then calculate the position of addition of the implicit watermark starting from the starting position of the mean-difference linear table. Specifically, the executing body may sequentially shift the index positions in the average difference value linear table backward one after another according to the number of bytes corresponding to the original image, and when the index positions are shifted to the last index position and then shifted again, restore to the start position of the average difference value linear table until the value of the byte count is equal to the number of bytes corresponding to the original image, and the pixel position corresponding to the average difference value corresponding to the index position that is terminated is the adding position of the implicit watermark.
According to the embodiment, the adding position of the implicit watermark is determined by combining the average difference value linear table according to the byte number corresponding to the original image, so that the adding position of the implicit watermark is more hidden and is not easy to find, and the damage difficulty of the implicit watermark is increased.
In some optional implementations of the present embodiment, after determining the location of adding the implicit watermark, the execution subject may further encrypt the implicit watermark text to be added, and in particular, the watermark image adding method further includes:
the method comprises the steps of obtaining an implicit watermark text, a preset code and a public key ciphertext character, generating an encrypted implicit watermark byte array based on an exclusive or algorithm, wherein the preset code can be commodity code, and an execution body can determine the implicit watermark text character and convert the implicit watermark text character, commodity code and public key ciphertext character into a byte array of hexadecimal ASCII codes. For example, the watermark text is XJ, the commodity code is 1234, and the public key ciphertext character is two Chinese characters of "xiaojing". XJ characters are converted into bytes of 4a 44 two hexadecimal numbers, commodity code 1234 is converted into bytes of 31 32 33 34 four hexadecimal numbers, and tokyo two chinese characters are converted into bytes of 4e ac4e 1c four hexadecimal numbers. Since the exclusive-or operation satisfies the combining law, the watermark character and the public key ciphertext character are relatively unchanged, and the exclusive-or operation is performed on the watermark character and the byte corresponding to the public key ciphertext character. That is, 4a and 44 are exclusive-ored, and the exclusive-ored result is exclusive-ored with 31 until the exclusive-ored with the last 1c character is completed, thereby obtaining an exclusive-ored operation result. And carrying out exclusive-or operation on 31 32 33 34 corresponding to commodity codes and one hexadecimal byte after the exclusive-or operation result, wherein the length of the watermark text character after exclusive-or is unchanged, and further obtaining an encrypted implicit watermark byte array.
And determining an average difference value byte array according to the adding position of the implicit watermark, the average difference value linear table and the encrypted implicit watermark byte array, wherein the bytes are units of binary data. Specifically, the execution body may take, from the addition position of the implicit watermark in the average difference value linear table, a hexadecimal average difference value number equal to the number of bytes in the encrypted implicit watermark byte array according to the number of bytes in the encrypted implicit watermark byte array, and convert each obtained hexadecimal average difference value into a binary number, so as to obtain the average difference value byte array.
And performing exclusive or calculation on the average difference value byte array and the encrypted implicit watermark byte array to generate a target average difference value byte array, wherein the execution main body starts from the adding position (namely the starting position) of the implicit watermark in the average difference value linear table and backwards takes the length of the average difference value linear table equal to the binary number of the encrypted implicit watermark byte array, for example, the hexadecimal number corresponding to the encrypted implicit watermark byte array is EF, and the EF is converted into the binary number 11101111. Then 8 hexadecimal numbers are taken as 9, 10, a, b, c, d, e, f from the position of addition of the implicit watermark in the linear table of mean differences. Converting each number from 9 to F into binary numbers, performing exclusive-OR operation on the rightmost first bit of each converted binary number and the binary bit of the corresponding position of the EF converted binary number 11101111, namely performing exclusive-OR operation on the rightmost first bit of the binary corresponding to the first number 9 and the rightmost first bit of the binary corresponding to the 11101111 from the leftmost first bit, performing exclusive-OR operation on the rightmost first bit of the binary corresponding to the second number 10 and the 11101111 from the leftmost second bit, and the like, ending exclusive-OR operation after performing exclusive-OR operation on the rightmost first bit of the binary corresponding to the 8 th number F and the 11101111 from the leftmost eighth bit, and further generating the target average difference value byte array.
For another example, assume that two numbers y1, y2 are taken backward starting from the addition location (i.e., the start location) of the implicit watermark in the mean-difference linear table. The two mechanisms corresponding to y1 and y2 are 1001 and 1000 respectively. y is the encrypted watermark data. Wherein the positions of y are equal to the number of x.
Let y=11;
then 1001 the first right-most bit, 100 (1), is xored with (1) 1 of the first left-most bit of y;
the first bit at the rightmost side of 1000, namely 100 (0), is exclusive-ored with 1 (1) of the second bit from the leftmost side of y, and the exclusive-ored calculation is finished, so that a target average difference value byte array is generated.
Then, the execution body may restore the implicit watermark image based on the target average difference value byte array, and complete encryption of the implicit watermark text to be added. In some optional implementations of the present embodiment, restoring the implicit watermark image based on the target average difference value byte array includes: based on the color channel of each pixel, the sum of adjacent pixels of the same color channel of the longest edge pixel is determined. Specifically, the sum value determination method is as follows:
the longest edge pixel of the explicit watermark image is determined, and if the longest edge pixel is not even, the execution body may add a zero pixel point at the last column of pixels.
And determining average difference values of adjacent pixels of the same color channel of the longest edge pixel based on the color channel of each pixel, and further determining an average difference value linear table based on the arrangement positions of the pixels in the longest edge pixel. Specifically, the execution body may sequentially take, based on the longest edge pixel from top to bottom, an average difference (i.e., a sum value) of sums and differences (i.e., an average difference value) of pixel values of two adjacent pixels of the same color channel, and calculate the pixel values on different color channels, respectively. Two sets of means are reserved for the restoration of subsequent images.
Example: the image is a 3*2 pixel image, with 3 pixels on the longest side, odd, and 0 pixel value added to the last pixel to make it even, e.g., the first line: pixel 1 (red green blue), pixel 2 (red green blue), pixel 3 (red green blue), 0; second row: pixel 4 (red green blue), pixel 5 (red green blue), pixel 6 (red green blue), 0.
The sum of red channels in the pixels is (pixel 1 red+pixel 2 red)/2=a, (pixel 3 red+0)/2=b, each pixel is only used for calculating once, the sum of red, green and blue color channels of the pixels 1, 2 and 3 and 0 is calculated and put into the first row of the sum linear table, namely A, B is sequentially put into the first row of the sum linear table, (pixel 4 red+pixel 5 red)/2=c, (pixel 6 red+0)/2=d, the sum of red, green and blue color channels of the pixels 4, 5 and 6 and 0 is calculated and put into the second row of the sum linear table, namely C, D is sequentially put into the second row of the sum linear table, the sum of the other color channels is sequentially calculated according to the calculation sequence of the red, green and blue color channels, the calculation mode is similar, and the calculation result of the sum is sequentially put into the sum linear table.
And determining pixel values in the implicit watermark image based on each average value in the target average value byte array and the average value linear table, so as to restore the implicit watermark image. The execution body may convert the target average difference value byte array into a corresponding average difference value, i.e., a value that characterizes the pixel. The executing body may then calculate the pixel values of the pixels in the encrypted implicit watermark image according to formulas (2) - (3):
(a+b)/2=homoenergetic value (2)
(a-b)/2=mean difference value (3)
Wherein a and b are pixel values of adjacent pixels of the same color channel.
The execution body can restore the implicit watermark image according to the calculated pixel value of the pixel in the encrypted implicit watermark image, and encryption is completed.
The execution body may add the encrypted implicit watermark image to the determined position of the implicit watermark after the explicit watermark image has been added in the target watermark image adding area.
In the embodiment, the difference of adjacent pixels is obtained by utilizing the average sum and the average difference, and the watermark length is increased after the average difference and the redundancy are calculated, so that the attack resistance of the added watermark is higher than that of the traditional invisible watermark. And carrying out a series of exclusive or operations in combination with watermark text, commodity code and public key, only changing a unit color value (the unit color is usually a numerical value between 0 and 255, if the original value is 200, the new value is 200+1 or 200-1, and the encryption purpose can not be seen visually) in a color channel of a pixel. By introducing the calculation of gradient region change and rotation confusion calculation, the anti-attack capability of the added watermark is higher than that of the traditional visible watermark scheme, and the influence on the original image is reduced to the greatest extent. The average difference and average sum calculation can be iterated for a plurality of times to achieve better confusion encryption effect.
In some optional implementations of this embodiment, there is also provided a watermark verification method of an implicit encrypted watermark: the execution body may perform implicit watermark encryption on an explicit watermark image of an image to which the implicit watermark is not added using the implicit watermark encryption method described above. When the brightness of the image is changed, the rightmost binary bit in the pixel channel is changed, but the average difference value of adjacent elements is unchanged, and the bit non-operation result is still satisfied, for example, the last bit is 11000 in sequence, when the brightness is increased by even number, the last bit is 11000 and the original position are unchanged in sequence, when the brightness is increased by odd number, the last bit is 00111 in sequence, the bit non-calculation is equal to the original position, and the original image is generated by the watermark encryption algorithm, otherwise, the original image is not true.
Fig. 3 is a schematic view of an application scenario of a watermark image adding method according to a third embodiment of the present application. The watermark image adding method is applied to scenes with watermark processing of commodity photos with more changes. As shown in fig. 3, the server 303 receives the watermarking request 301, and acquires the image identifier 302 in the watermarking request 301 to acquire the original image O and the watermark image C. The server 303 identifies the edge 304 of the original image O to determine the target watermark image addition area a from the edge 304 and the watermark image O. The server 303 determines the pixel color 305 of the original image O within the target watermark image adding area a to determine the foreground color 306 of the watermark image C based on the pixel color 305, generating a foreground color watermark image Cn. The server 303 rotates the foreground color watermark image Cn to generate a mixed image C1A, C a corresponding to each rotation direction C1, C2 in the target watermark image addition area a. The server 303 determines the similarity 307 between each of the mixed images C1A, C a and the original image O in the target watermark image adding area a, so as to determine the adding direction C2 of the foreground color watermark image Cn according to the similarity 307, and further generate the watermark image C3 (which may be an explicit (macroscopic) watermark image or an implicit (macroscopic) watermark image, which is not particularly limited in the present application).
Fig. 4 is a schematic diagram of main modules of a watermark image adding apparatus according to an embodiment of the application. As shown in fig. 4, the watermark image adding apparatus includes a receiving unit 401, an identifying unit 402, a foreground color watermark image generating unit 403, a mixed image generating unit 404, and a watermark image generating unit 405.
The receiving unit 401 is configured to receive the watermarking request, and obtain the image identifier in the watermarking request, so as to obtain the original image and the watermark image.
An identification unit 402 is configured to identify edges of the original image to determine a target watermark image adding area from the edges and the watermark image.
The foreground color watermark image generation unit 403 is configured to determine a foreground color watermark image.
The mixed image generating unit 404 is configured to rotate the foreground color watermark image, generating mixed images corresponding to respective rotation directions within the target watermark image adding area.
The watermark image generation unit 405 is configured to determine the similarity between each mixed image and the original image in the target watermark image adding area, so as to determine the adding direction of the foreground color watermark image according to the similarity, and further generate the watermark image.
In some embodiments, the identification unit 402 is further configured to: and identifying the edge of the original image, generating the original edge image, and dividing the original edge image according to the watermark image to determine a target watermark image adding area in the original image.
In some embodiments, the identification unit 402 is further configured to: determining the length of the longest diagonal of a rectangle corresponding to the watermark image; constructing a square area by taking the length of the longest diagonal of the rectangle as the side length of the square; the original edge image is segmented using square regions.
In some embodiments, the identification unit 402 is further configured to: calculating the sum of pixel values in each square area after the original edge image is segmented; and sequencing the sum of the pixel values to determine the target watermark image adding area according to the sequencing result.
In some embodiments, the hybrid image generation unit 404 is further configured to: and rotating the foreground color watermark image by taking the target watermark image adding area as the center, and further linearly mixing the foreground color corresponding to each rotation direction of the foreground color watermark image with the pixel color of the original image in the target watermark image adding area to generate each mixed image.
In some embodiments, the watermark image generation unit 405 is further configured to: and determining the similarity between each mixed image and the original image in the target watermark image adding area based on a preset similarity formula according to the corresponding relation between the preset color channel corresponding to each pixel and the vector dimension, the pixels of the mixed image corresponding to each rotation direction and the pixels of the original image in the target watermark image adding area.
In some embodiments, the watermark image generation unit 405 is further configured to: and adding the foreground color watermark image to the rotation direction corresponding to the maximum similarity to generate an explicit watermark image.
In some embodiments, the watermark image adding apparatus further comprises an addition position determining unit, not shown in fig. 4, configured to: determining the longest edge pixel of the watermark image; based on the color channel of each pixel, determining the average difference value of adjacent pixels of the same color channel of the longest side pixel, and further determining an average difference value linear table based on the arrangement position of each pixel in the longest side pixel; determining the number of bytes corresponding to the original image; and according to the byte number, moving the index position of the average difference value in the average difference value linear table according to a preset index sequence, and further determining the adding position of the implicit watermark.
In some embodiments, the watermark image adding apparatus further comprises an implicit watermark adding unit, not shown in fig. 4, configured to: acquiring an implicit watermark text, a preset code and a public key ciphertext character, and generating an encrypted implicit watermark byte array based on an exclusive-or algorithm; determining an average difference value byte array according to the adding position of the implicit watermark, the average difference value linear table and the encrypted implicit watermark byte array; performing exclusive OR calculation on the average difference value byte array and the encrypted implicit watermark byte array to generate a target average difference value byte array; restoring the implicit watermark image based on the target average difference value byte array; and adding the implicit watermark image to an adding position of the implicit watermark.
In some embodiments, the implicit watermarking unit is further configured to: determining a sum value of adjacent pixels of the same color channel of the longest edge pixel based on the color channel of each pixel; and determining pixel values in the implicit watermark image based on the target average difference value byte array and each average sum value, so as to restore the implicit watermark image.
In some embodiments, the foreground color watermark image generation unit 403 is further configured to: the pixel colors of the original image within the target watermark image adding area are determined to determine the foreground color of the watermark image based on the pixel colors, generating a foreground color watermark image.
In the watermark image adding method and the watermark image adding apparatus of the present application, the specific implementation contents have a corresponding relationship, so that the repetitive contents will not be described.
Fig. 5 shows an exemplary system architecture 500 to which a watermark image adding method or watermark image adding apparatus of an embodiment of the application may be applied.
As shown in fig. 5, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 is used as a medium to provide communication links between the terminal devices 501, 502, 503 and the server 505. The network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 505 via the network 504 using the terminal devices 501, 502, 503 to receive or send messages or the like. Various communication client applications may be installed on the terminal devices 501, 502, 503, such as shopping class applications, web browser applications, search class applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 501, 502, 503 may be a variety of electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 505 may be a server providing various services, such as a background management server (by way of example only) providing support for watermarking requests submitted by users with terminal devices 501, 502, 503. The background management server can receive the watermark adding request, and acquire the image identifier in the watermark adding request so as to acquire the original image and the watermark image; identifying edges of the original image to determine a target watermark image addition area from the edges and the watermark image; determining a foreground color watermark image; rotating the foreground color watermark image to generate a mixed image corresponding to each rotation direction in the target watermark image adding area; and determining the similarity between each mixed image and the original image in the target watermark image adding area, so as to determine the adding direction of the foreground color watermark image according to the similarity, and further generate the watermark image. Thus, a reduction of the impact of the added watermark image on the original image quality can be achieved.
It should be noted that, the watermark image adding method provided in the embodiment of the present application is generally executed by the server 505, and accordingly, the watermark image adding apparatus is generally disposed in the server 505.
It should be understood that the number of terminal devices, networks and servers in fig. 5 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 6, there is illustrated a schematic diagram of a computer system 600 suitable for use in implementing an embodiment of the present application. The terminal device shown in fig. 6 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present application.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM603, various programs and data required for the operation of the computer system 600 are also stored. The CPU601, ROM602, and RAM603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, mouse, etc.; an output portion 607 including a Cathode Ray Tube (CRT), a liquid crystal credit authorization query processor (LCD), and the like, and a speaker, and the like; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The drive 610 is also connected to the I/O interface 605 as needed. Removable media 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed as needed on drive 610 so that a computer program read therefrom is installed as needed into storage section 608.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication portion 609, and/or installed from the removable medium 611. The above-described functions defined in the system of the present application are performed when the computer program is executed by a Central Processing Unit (CPU) 601.
The computer readable medium shown in the present application may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present application, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments of the present application may be implemented in software or in hardware. The described units may also be provided in a processor, for example, described as: a processor includes a receiving unit, an identifying unit, a foreground color watermark image generating unit, a mixed image generating unit, and a watermark image generating unit. Wherein the names of the units do not constitute a limitation of the units themselves in some cases.
As another aspect, the present application also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by one of the devices, cause the device to receive a watermarking request, obtain an image identification in the watermarking request, to obtain an original image and a watermark image; identifying edges of the original image to determine a target watermark image addition area from the edges and the watermark image; determining a foreground color watermark image; rotating the foreground color watermark image to generate a mixed image corresponding to each rotation direction in the target watermark image adding area; and determining the similarity between each mixed image and the original image in the target watermark image adding area, so as to determine the adding direction of the foreground color watermark image according to the similarity, and further generate the watermark image. Thus, a reduction of the impact of the added watermark image on the original image quality can be achieved.
According to the technical scheme of the embodiment of the application, the image identification in the watermark adding request is obtained by receiving the watermark adding request so as to obtain the original image and the watermark image; identifying edges of the original image to determine a target watermark image addition area from the edges and the watermark image; determining a foreground color watermark image, and further generating a mixed image corresponding to each rotation direction in the target watermark image adding area by rotating the foreground color watermark image; the similarity between each mixed image and the original image in the target watermark image adding area is determined, so that the adding direction of the foreground color watermark image is determined according to the similarity, the watermark image is generated, the color difference between the added watermark image (namely, the color watermark image) and the original image can be reduced, and the influence on the original image is reduced.
The above embodiments do not limit the scope of the present application. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present application should be included in the scope of the present application.

Claims (11)

1. A watermark image adding method, comprising:
receiving a watermark adding request, and acquiring an image identifier in the watermark adding request to acquire an original image and a watermark image;
identifying the edge of the original image, generating an original edge image, and further determining the length of the longest diagonal of the rectangle corresponding to the watermark image; constructing a square area by taking the length of the longest diagonal of the rectangle as the side length of the square; dividing the original edge image by using the square areas, and calculating the sum of pixel values in each square area after dividing the original edge image; sorting the pixel value sum to determine a target watermark image adding area according to a sorting result;
determining a foreground color watermark image;
Rotating the foreground color watermark image to generate a mixed image corresponding to each rotation direction in the target watermark image adding area;
and determining the similarity between each mixed image and the original image in the target watermark image adding area, so as to determine the adding direction of the foreground color watermark image according to the similarity, and further generate a watermark image.
2. The method of claim 1, wherein the generating a hybrid image for each rotation direction within the target watermark image addition area comprises:
and rotating the foreground color watermark image by taking the target watermark image adding area as the center, and further linearly mixing the foreground color corresponding to each rotation direction of the foreground color watermark image with the pixel color of the original image in the target watermark image adding area to generate each mixed image.
3. The method of claim 2, wherein said determining the similarity of each of the blended images to the original image within the target watermark image addition area comprises:
and determining the similarity between each mixed image and the original image in the target watermark image adding area based on a preset similarity formula according to the corresponding relation between the preset color channel corresponding to each pixel and the vector dimension, the pixels of the mixed image corresponding to each rotation direction and the pixels of the original image in the target watermark image adding area.
4. The method of claim 2, wherein the generating the watermark image comprises:
and adding the foreground color watermark image to a rotation direction corresponding to the maximum similarity to generate an explicit watermark image.
5. The method of claim 1, wherein after the generating the watermark image, the method further comprises:
determining the longest edge pixel of the watermark image;
based on the color channel of each pixel, determining the average difference value of adjacent pixels of the same color channel of the longest side pixel, and further determining an average difference value linear table based on the arrangement position of each pixel in the longest side pixel;
determining the number of bytes corresponding to the original image;
and according to the byte number, moving the index position of the average difference value in the average difference value linear table according to a preset index sequence, and further determining the adding position of the implicit watermark.
6. The method of claim 5, wherein after said determining the location of the addition of the implicit watermark, the method further comprises:
acquiring an implicit watermark text, a preset code and a public key ciphertext character, and generating an encrypted implicit watermark byte array based on an exclusive-or algorithm;
Determining an average difference value byte array according to the adding position of the implicit watermark, the average difference value linear table and the encrypted implicit watermark byte array;
performing exclusive OR calculation on the average difference value byte array and the encrypted implicit watermark byte array to generate a target average difference value byte array;
restoring an implicit watermark image based on the target average difference value byte array;
and adding the implicit watermark image to an adding position of the implicit watermark.
7. The method of claim 6, wherein the restoring the implicit watermark image based on the target average difference value byte array comprises:
determining a sum value of adjacent pixels of the same color channel of the longest edge pixel based on the color channel of each pixel;
and determining pixel values in the implicit watermark image based on the target average difference value byte array and the average sum values, so as to restore the implicit watermark image.
8. The method of claim 1, wherein the determining the foreground color watermark image comprises:
determining pixel colors of the original image within the target watermark image adding area to determine foreground colors of the watermark image based on the pixel colors, and generating a foreground color watermark image.
9. A watermark image adding apparatus, characterized by comprising:
a receiving unit configured to receive a watermarking request, and obtain an image identifier in the watermarking request, so as to obtain an original image and a watermark image;
the identification unit is configured to identify the edge of the original image, generate an original edge image and further determine the longest diagonal length of the rectangle corresponding to the watermark image; constructing a square area by taking the length of the longest diagonal of the rectangle as the side length of the square; dividing the original edge image by using the square areas, and calculating the sum of pixel values in each square area after dividing the original edge image; sorting the pixel value sum to determine a target watermark image adding area according to a sorting result;
a foreground color watermark image generation unit configured to determine a foreground color watermark image;
a mixed image generating unit configured to rotate the foreground color watermark image, generating mixed images corresponding to respective rotation directions within the target watermark image adding area;
and the watermark image generation unit is configured to determine the similarity between each mixed image and the original image in the target watermark image adding area, so as to determine the adding direction of the foreground color watermark image according to the similarity, and further generate a watermark image.
10. A watermark image adding electronic device, comprising:
one or more processors;
storage means for storing one or more programs,
when executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-8.
11. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-8.
CN202110577758.1A 2021-05-26 2021-05-26 Watermark image adding method and device Active CN113298687B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110577758.1A CN113298687B (en) 2021-05-26 2021-05-26 Watermark image adding method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110577758.1A CN113298687B (en) 2021-05-26 2021-05-26 Watermark image adding method and device

Publications (2)

Publication Number Publication Date
CN113298687A CN113298687A (en) 2021-08-24
CN113298687B true CN113298687B (en) 2023-09-29

Family

ID=77325282

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110577758.1A Active CN113298687B (en) 2021-05-26 2021-05-26 Watermark image adding method and device

Country Status (1)

Country Link
CN (1) CN113298687B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115239542A (en) * 2022-05-27 2022-10-25 南京文深信息技术有限公司 Safe printing-resistant scanning watermark method for staged training
CN117237177B (en) * 2023-11-15 2024-03-19 杭州海康威视数字技术股份有限公司 Watermark processing method and device and electronic equipment

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6226387B1 (en) * 1996-08-30 2001-05-01 Regents Of The University Of Minnesota Method and apparatus for scene-based video watermarking
CN103761700A (en) * 2013-12-23 2014-04-30 南京信息工程大学 Watermark method capable of resisting printing scanning attack and based on character refinement
CN105631797A (en) * 2015-12-24 2016-06-01 小米科技有限责任公司 Watermarking method and device
CN106023056A (en) * 2016-05-24 2016-10-12 河南师范大学 Zero-watermark embedding and extracting methods and zero-watermark embedding and extracting devices based on DWT and principal component analysis (PCA) compression
CN106485644A (en) * 2016-10-10 2017-03-08 中国农业大学 A kind of video zero watermarking generation method of resist geometric attackses and device
CN110418153A (en) * 2019-07-30 2019-11-05 北京达佳互联信息技术有限公司 Watermark adding method, device, equipment and storage medium
CN110458746A (en) * 2019-07-17 2019-11-15 腾讯科技(深圳)有限公司 Add method and device, the electronic equipment of watermark
CN111784556A (en) * 2020-06-23 2020-10-16 中国平安人寿保险股份有限公司 Method, device, terminal and storage medium for adding digital watermark in image
CN112634119A (en) * 2020-12-24 2021-04-09 深圳壹账通智能科技有限公司 Watermark adding method, watermark adding device, computer equipment and storage medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6226387B1 (en) * 1996-08-30 2001-05-01 Regents Of The University Of Minnesota Method and apparatus for scene-based video watermarking
CN103761700A (en) * 2013-12-23 2014-04-30 南京信息工程大学 Watermark method capable of resisting printing scanning attack and based on character refinement
CN105631797A (en) * 2015-12-24 2016-06-01 小米科技有限责任公司 Watermarking method and device
CN106023056A (en) * 2016-05-24 2016-10-12 河南师范大学 Zero-watermark embedding and extracting methods and zero-watermark embedding and extracting devices based on DWT and principal component analysis (PCA) compression
CN106485644A (en) * 2016-10-10 2017-03-08 中国农业大学 A kind of video zero watermarking generation method of resist geometric attackses and device
CN110458746A (en) * 2019-07-17 2019-11-15 腾讯科技(深圳)有限公司 Add method and device, the electronic equipment of watermark
CN110418153A (en) * 2019-07-30 2019-11-05 北京达佳互联信息技术有限公司 Watermark adding method, device, equipment and storage medium
CN111784556A (en) * 2020-06-23 2020-10-16 中国平安人寿保险股份有限公司 Method, device, terminal and storage medium for adding digital watermark in image
CN112634119A (en) * 2020-12-24 2021-04-09 深圳壹账通智能科技有限公司 Watermark adding method, watermark adding device, computer equipment and storage medium

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
Rotation, scaling and translation invariant image watermarking using feature points;Lei-da L.等;The Journal of China Universities of Posts and Telecommunications;全文 *
一种嵌入可读水印的自适应盲水印算法;张冠男, 王树勋, 温泉;电子学报(第02期);全文 *
基于图像插值的可逆水印算法研究;郑瑾;;西安文理学院学报(自然科学版)(第03期);全文 *

Also Published As

Publication number Publication date
CN113298687A (en) 2021-08-24

Similar Documents

Publication Publication Date Title
CN113298687B (en) Watermark image adding method and device
CN108269062B (en) Electronic contract making method, device, equipment and medium based on H5
US11727524B2 (en) System and method for encoding and authenticating a digital image
Mostafa et al. A robust high capacity gray code-based double layer security scheme for secure data embedding in 3d objects
CN104268825B (en) A kind of method that image procossing is carried out to ciphertext graph picture
CN115098888B (en) Map data packet full-flow adaptive generation and encryption method, device and equipment
CN110363837B (en) Method and device for processing texture image in game, electronic equipment and storage medium
CN108985421B (en) Method for generating and identifying coded information
Lee et al. Omnidirectional video coding using latitude adaptive down‐sampling and pixel rearrangement
CN111222611B (en) Color-based stacked three-dimensional code encoding method, encoding device, decoding method, decoding device and storage medium
CN115358911A (en) Screen watermark generation method, device, equipment and computer readable storage medium
CN113204296B (en) Method, device and equipment for highlighting graphics primitive and storage medium
CN112399027B (en) Picture encryption and decryption method and device, storage medium and electronic equipment
CN116611114B (en) Method for realizing encryption and offset of map raster data based on header file of image file
CN109214486B (en) Three-dimensional code, three-dimensional code generation method and device, and three-dimensional code identification method and device
CN111131270B (en) Data encryption and decryption method and device, electronic equipment and storage medium
US10542176B2 (en) Enhancing graph visualization with supplemental data
US11120317B2 (en) Graphic identification code generation method and apparatus
CN110969042B (en) Two-dimensional code identification method and device and hardware device
CN110751251A (en) Method and device for generating and transforming two-dimensional code image matrix
CN113781287B (en) Watermark image processing method, watermark image processing device, electronic equipment and computer readable storage medium
JP2024507308A (en) Image sample generation method, text recognition method, device, electronic device, storage medium and computer program
CN114723600A (en) Method, device, equipment, storage medium and program product for generating cosmetic special effect
CN114339282A (en) Method and device for transmitting anchor image picture in live broadcast interaction
Wu et al. Information hiding in motion data of virtual characters

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
GR01 Patent grant
GR01 Patent grant