CN113487473B - Method and device for adding image watermark, electronic equipment and storage medium - Google Patents

Method and device for adding image watermark, electronic equipment and storage medium Download PDF

Info

Publication number
CN113487473B
CN113487473B CN202110887835.3A CN202110887835A CN113487473B CN 113487473 B CN113487473 B CN 113487473B CN 202110887835 A CN202110887835 A CN 202110887835A CN 113487473 B CN113487473 B CN 113487473B
Authority
CN
China
Prior art keywords
image
content
watermark
contour
mask
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
CN202110887835.3A
Other languages
Chinese (zh)
Other versions
CN113487473A (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 Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and 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 Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202110887835.3A priority Critical patent/CN113487473B/en
Publication of CN113487473A publication Critical patent/CN113487473A/en
Application granted granted Critical
Publication of CN113487473B publication Critical patent/CN113487473B/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
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20172Image enhancement details
    • G06T2207/20192Edge enhancement; Edge preservation

Abstract

The disclosure provides a method, a device, electronic equipment and a storage medium for adding an image watermark, relates to the field of image processing, and particularly relates to the technical field of image watermarking. The specific implementation scheme is as follows: firstly, an image mask of a target image to be watermarked is obtained, wherein the image mask comprises the outline of a content image of the target image, and then the watermark image is covered in the area of pixels of the non-content outline of the target image at a preset watermark image adding position based on the image mask. According to the method provided by the disclosure, the watermark image is added in the non-image outline area based on the image mask of the target image, so that the watermark is visible, the user definitely perceives that the copyright is protected, the watching, reading and the like of the content in the target image are not influenced, and the purpose of properly adding the watermark is achieved.

Description

Method and device for adding image watermark, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of image processing technologies, and in particular, to a method, an apparatus, an electronic device, and a storage medium for adding an image watermark in an image watermarking technology.
Background
Currently, images on a network generally protect copyrights or trace back image sources by adding watermarks.
How to properly watermark an image is an urgent problem to be solved in the field of image processing.
Disclosure of Invention
The present disclosure provides a method, apparatus, electronic device, and storage medium for properly watermarking an image.
According to an aspect of the present disclosure, there is provided a method of watermarking an image, comprising:
acquiring a watermark image to be added and a target image to be added with the watermark;
acquiring an image mask of the target image; the image mask contains a content image contour of content in the target image;
and covering the area of the non-content image outline in the target image by using the watermark image at a preset watermark image adding position based on the image mask.
According to another aspect of the present disclosure, there is provided an apparatus for watermarking an image, comprising:
the target image acquisition module is used for acquiring the watermark image to be added and the target image to be added with the watermark;
an image mask acquisition module for acquiring an image mask of the target image; the image mask contains a content image contour of content in the target image;
and the watermark image adding module is used for covering the area of the non-content image outline in the target image by using the watermark image at a preset watermark image adding position based on the image mask.
According to another aspect of the present disclosure, there is provided an electronic device including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform any one of the methods of watermarking an image described above.
According to another aspect of the present disclosure, there is also provided a non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform the method of watermarking an image as described in any one of the above.
According to another aspect of the present disclosure, there is also provided a computer program product comprising a computer program which, when executed by a processor, implements a method of watermarking an image as described in any of the above.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification.
Drawings
The drawings are for a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
fig. 1 is a flow chart of a first embodiment of a method of watermarking an image provided in accordance with the present disclosure;
fig. 2 is a flow chart of a second embodiment of a method of watermarking an image provided in accordance with the present disclosure;
fig. 3 is a flow chart of a third embodiment of a method of watermarking an image provided in accordance with the present disclosure
Fig. 4 is a flow chart of a fourth embodiment of a method of watermarking an image provided in accordance with the present disclosure;
fig. 5 is a flowchart of a fifth embodiment of a method of watermarking an image provided in accordance with the present disclosure;
fig. 6a is a first schematic diagram of a specific application of the method of watermarking an image provided by the present disclosure;
fig. 6b is a second schematic diagram of a specific application of the method of watermarking an image provided by the present disclosure;
fig. 6c is a third schematic diagram of a specific application of the method of watermarking an image provided by the present disclosure;
FIG. 6d is a fourth schematic diagram of a specific application of the method of watermarking an image provided by the present disclosure;
fig. 7 is a schematic structural diagram of an apparatus for watermarking an image provided by the present disclosure;
fig. 8 is a block diagram of an electronic device for implementing a method of watermarking an image according to an embodiment of the disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure to facilitate understanding, and should be considered as merely exemplary. Accordingly, one 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 present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Currently, related personnel mostly use three watermark images, namely a semitransparent watermark, an opaque watermark and a dark watermark, when watermarking an image.
For a semitransparent watermark, if the semitransparent watermark is added to an image with single color of the content, the watermark can be identified and filtered by setting a certain color threshold.
For opaque watermarks, the opaque watermarks directly cover the original image, so that the user can be greatly influenced by watching and reading the image, and the like.
The dark watermark is invisible to the user, the user cannot clearly protect the copyright through the watermark, and the dark watermark cannot resist the conversion scenes such as camera shooting, printing, scanning and the like.
Therefore, there is a need for a method of watermarking an image that addresses the above-described problems.
In order to properly watermark an image, the present disclosure provides a method, an apparatus, an electronic device, and a storage medium for watermarking an image.
Referring to fig. 1, fig. 1 is a flowchart of a first embodiment of a method of watermarking an image provided in accordance with the present disclosure; the method specifically comprises the following steps:
step S110, obtaining a watermark image to be added and a target image to be added with the watermark;
step S120, an image mask of the target image is obtained; the image mask contains a content image contour of content in the target image;
step S130, based on the image mask, covering the area of the non-content image outline in the target image with the watermark image at a preset watermark image adding position.
According to the method for adding the image watermark, firstly, an image mask of a target image to be watermarked is obtained, the image mask comprises the content image outline of the target image, and then the watermark image is covered in the area of the non-content outline pixels of the target image at the preset watermark image adding position based on the image mask. According to the method provided by the disclosure, the watermark image is added in the non-image outline area based on the image mask of the target image, so that the watermark is visible, the user definitely perceives that the copyright is protected, the watching, reading and the like of the content in the target image are not influenced, and the purpose of properly adding the watermark is achieved.
In the embodiment of the present disclosure, the target image to be watermarked may be an image uploaded to a network by a user, and the images may be images of documents, papers or books, or images of people, animals, etc., which are not limited herein.
As described above, since the embodiments of the present disclosure are based on the image mask of the target image for which the watermark is added and the content image contour is included in the image mask, in the embodiments of the present disclosure, the effective content in the target image can be avoided when the watermark is added to the target image. Therefore, as a specific implementation manner of the embodiment of the disclosure, when the watermark is added to the images of documents, test papers and books, the watermark image with the same or similar color as the content of the images can be selected for adding, so that the purpose that the effective content is not covered, the reading of a user is not influenced and the watermark is difficult to remove can be achieved while the watermark image is visible, the user experience is improved, and the copyright of the target image is better protected.
Referring to fig. 2, fig. 2 is a flowchart of a second embodiment of a method of watermarking an image provided in accordance with the present disclosure; based on fig. 1 and fig. 2, the foregoing step S120 is further detailed, and the step S120 may specifically include the following steps:
step S121, acquiring a content image contour of the content in the target image.
In the embodiment of the disclosure, for documents, test papers and books, the acquired outline of the content image may be the outline of the edge of the text and the picture contained therein, and for images of people, animals and the like, the acquired outline of the content image may be the outline of the edge of the corresponding people, animals and the like.
And step 122, drawing the outline of the content image in the blank image to obtain an image mask of the target image.
In the embodiment of the disclosure, a blank image may be created in advance, and after the content image contour of the target image is acquired, the content image contour is drawn into the blank image.
In the method, the image mask is obtained by drawing the content image outline of the obtained target image in the blank image, and subsequent watermarking is performed based on the image mask, so that the watermarking image is further ensured not to block the content of the target image, namely, watermarking is more proper, that is, the added watermarking does not influence the watching, reading and the like of a user on the target image, and the user experience is further improved.
Referring to fig. 3, fig. 3 is a flowchart of a third embodiment of a method of watermarking an image provided in accordance with the present disclosure; the method specifically comprises the following steps:
step S310, obtaining a watermark image to be added and a target image to be added with the watermark.
This step may be identical to step S110 described above.
Step 320, performing edge recognition on the content in the target image to obtain an edge of the content image.
In the embodiment of the disclosure, an algorithm such as a Canny edge detection algorithm provided in an open source software platform (such as opencv) can be used for carrying out edge recognition on the content in the target image so as to obtain the edge of the content image.
And step S330, obtaining the outline of the content image of the content in the target image based on the identified edge of the content image.
Since the edge of the content image extracted by using the edge detection algorithm may have a certain noise, that is, the edge of the extracted content image may be wider, if the image mask is obtained directly based on the edge, the masking of the content image by the image mask may be inaccurate, so in the embodiment of the present disclosure, after the edge of the content image is obtained, the edge may be further processed to obtain a more accurate contour of the content image. In particular, it may be implemented using an edge tracking algorithm provided in an open source software platform.
And step 340, drawing the outline of the content image in the blank image, and filling the outline of the content image with a preset outline pixel value to obtain an image mask of the target image.
The preset contour pixel values may be set according to requirements, for example, may be set to RGB color values (255 ) corresponding to white, which is not particularly limited herein. The area outside the content image contour may be filled with pixel values that differ significantly from the above-mentioned pixel values, for example, if the color in the above-mentioned filled content contour surrounding area is selected to be white, the area outside the content contour may be filled with black, and the corresponding pixel values may be RGB values (0, 0) corresponding to black. And filling the outline of the content image to cover the area in the outline of the content image so as to obtain a corresponding image mask.
And step S350, covering the area of the non-content image outline in the target image with the watermark image at a preset watermark image adding position based on the image mask.
In the embodiment of the disclosure, the content in the target image is firstly subjected to edge recognition, the recognized edge is extracted and drawn in the blank image, and the outline of the content image is filled in the blank image to obtain the image mask, so that the obtained image mask can more accurately and completely cover the content in the target image, and further, the situation that the content in the target image is not blocked when the target image is subjected to watermark addition is further ensured.
Referring to fig. 4, fig. 4 is a flowchart of a fourth embodiment of a method of watermarking an image provided in accordance with an embodiment of the present disclosure; based on fig. 3 and fig. 4, the step S320 is refined, where the step S320 may specifically include the following steps:
step S321, converting the target image into a gray scale.
Currently, most images on a network are RGB images, which are images using RGB color patterns. RGB color patterns are varied by varying the three color channels of red (R), green (G), blue (B) and superimposing them on each other to obtain various colors. Each pixel point in the RGB image has its color value, which is the RGB value of the pixel point. Therefore, as a specific implementation of the embodiments of the present disclosure, converting the target image into the gray-scale image may be achieved by:
step one, obtaining color values of all pixel points in a target image;
and step two, converting the target image into a gray image based on the color values of the pixel points and preset color weights.
As a specific implementation manner of the embodiment of the present disclosure, the gray image pixel point corresponding to each pixel point may be calculated by using the following formula:
Grey=0.299*R+0.587*G+0.114*B
in the formula, R refers to the R (red) channel color value of a pixel point, and the preset weight of the color channel is 0.299; g refers to the color value of the G (green) channel of the pixel point, and the preset weight of the color channel is 0.587; b is the color value of the B (blue) channel of the pixel, and the preset weight of the color is 0.114.
Since in ALU (arithmetic and logic unit, arithmetic logic unit) bit operations are faster than integer additions, integer additions are faster than integer multiplications, while integer operations are superior in speed to floating point operations. Therefore, the formula can be optimized by converting floating point number operation into integer operation and converting the integer operation into bit operation, and the following formula can be obtained after the optimization:
Grey=(R*299+G*587+B*114+500)/1000
since integer operations truncate fractional parts, 500 can be added to the formula to reduce the loss of precision.
Traversing the pixel points in the target image, and obtaining a gray value corresponding to the pixel point based on the optimized formula for each pixel point, so that the target image can be converted into a gray image.
As shown in fig. 4, in step S322, edge recognition is performed on the content in the gray scale image, so as to obtain an edge of the content image.
Based on the gray level graph, the content in the graph is subjected to edge recognition, and a Canny edge detection algorithm can be adopted and can be realized by the following steps:
and step 1, carrying out noise reduction treatment on the gray level map.
This step can eliminate the effect of false edges caused by noise.
And step 2, calculating the image gradient of the gray level image after the noise reduction treatment to obtain the possible edge of the content image.
And 3, non-maximum value inhibition.
In general, the gray level change places are concentrated, so that the pixel points with large gray level change in the gradient direction in the local range are reserved, and the other pixel points are not reserved, so that most points can be removed, and the edge with multiple pixel widths is changed into an edge with single pixel width.
And 4, screening the double thresholds.
After non-maximum suppression there are still many possible edge points, so a double threshold, i.e. a low threshold (low) and a high threshold (high) can be further set. And setting the gray level change to be higher than high and set to be a strong edge pixel and lower than low, and eliminating. Pixels between low and high may be set to weak edges. If there are strong edge pixels in the region between low and high, then remain, if not, then cull. This allows the edges obtained to be as closed as possible.
The edge of the content image of the content in the target image can be obtained through the steps.
Of course, other edge detection algorithms may be used in the embodiments of the present disclosure to implement edge recognition of the content in the gray scale map, which is not specifically limited herein.
Accordingly, as shown in fig. 4, the step S330 may be refined as follows:
and step S331, performing edge expansion processing on the identified edges of the content image to obtain edge contours of the content image.
In this step, the edge generated in the previous step may be binarized. Specifically, the edge pixel value may be set to 1, the remaining pixels may be set to 0, and the pixel value of a pixel having a pixel distance from the pixel having the pixel value of 1 smaller than N may be set to 1. The value of N can be set according to the actual situation.
In this way, the acquired content image edge profile can be further made as close as possible.
The target image is converted into the gray level image, edge identification is carried out based on the gray level image, and edge expansion processing is carried out on the identified edge, so that the edge of the content image in the target image is obtained, and the obtained edge of the content image is more accurate, clear and complete.
Referring to fig. 5, fig. 5 is a flowchart of a fifth embodiment of a method of watermarking an image provided in accordance with an embodiment of the present disclosure; based on fig. 1, fig. 5 details the step S130, where the step S130 may specifically include the following steps:
step S131, determining whether each pixel point in the target image at the preset watermark image adding position is a contour pixel in the contour of the content image based on the image mask, and if the pixel point is the contour pixel in the contour of the content image, executing step S132; if the pixel point is not a contour pixel in the contour of the content image, step S133 is performed;
i.e. before replacing the pixels of the watermark image addition location preset for the target image with the pixels of the watermark image, it is necessary to query the image mask whether the pixels to be replaced belong to pixels in the content contour. Specifically, for a pixel point at a preset watermark image adding position in the target image, finding a pixel point with the same position as the pixel point in the image mask, and inquiring whether the pixel point belongs to the content image.
Step S132, reserving the pixel point;
step S133, replacing the pixel with the watermark image pixel.
In general, the images of the documents, test papers and books on the network are presented to the network user in the same size, so as to be an embodiment of the present disclosure, a watermark template with the same size as the target image may be preset, and the pattern, size and position of the watermark image are fixed on the watermark template in advance. Thus, when adding a watermark image to a target image, the watermark image can be added according to the watermark template. Specifically, the watermark image can be added at a watermark adding position preset in the target image based on an image mask of the target image, so that the watermark image is blocked by the outline of the content image of the target image. That is, as a specific implementation of the embodiments of the present disclosure, the process of watermarking the target image may be performed by using an image mask of the target image to mask the watermark image. The watermark images may be a plurality of identical images arranged according to a preset inclination angle, a preset pitch, or the like. Of course, the watermark image may be smaller than the target image, and accordingly, when the watermark image is added, the watermark images may be arranged according to a preset inclination angle, a preset pitch, or the like.
In the embodiment of the disclosure, the watermark image may have a plurality of patterns, and accordingly, the watermark image added to the target image may have one or more patterns, which are not limited herein.
In the embodiment of the disclosure, by inquiring whether the target image is the contour pixel of the content image before the pixels in the target image are replaced by the pixels of the watermark image, the watermark image can be added in the area of the contour pixel of the non-content image in the target image more accurately, so that the watermark addition is more proper.
Fig. 6 a-6 d illustrate one example of watermarking using the method of watermarking an image provided by embodiments of the present disclosure.
As shown in fig. 6a to 6d, the target image to be watermarked is a test paper image, and the content in the test paper image includes text and pictures.
A gray scale image of the target image is shown in fig. 6 a; edge recognition and edge expansion are performed on the content in the gray level image, so that the edge contour of the content image shown in fig. 6b can be obtained. The outline is drawn to a blank image and filled to obtain an image mask of the target image, as shown in fig. 6 c. After the image mask of the target image is obtained, watermark adding can be performed on the target image based on the image mask, as shown in fig. 6d, the added watermark image in this example may be a small watermark image composed of a graph and a text, or of course, the small watermark image may be arranged in a blank image with the same size as the target image according to a preset inclination angle, watermark interval, etc. to obtain a large watermark image template, and the watermark adding position preset in the target image according to the watermark image template covers the area with non-content outline.
The present disclosure also provides an apparatus for watermarking an image, as shown in fig. 7, which may include:
the target image obtaining module 710 may be configured to obtain a watermark image to be added and a target image to be watermarked;
an image mask acquisition module 720, configured to acquire an image mask of the target image; the image mask contains a content image contour of content in the target image;
the watermark image adding module 730 may be configured to cover, based on the image mask, an area of the target image that is not the contour of the content image with the watermark image at a preset watermark image adding position.
As a specific implementation of the embodiments of the present disclosure, the image mask acquiring module may include:
the image contour obtaining sub-module can be used for obtaining the content image contour of the content in the target image;
and the image mask acquisition sub-module can be used for drawing the outline of the content image in the blank image to obtain the image mask of the target image.
As a specific implementation of the disclosed embodiments, the image profile acquisition submodule may be specifically used,
performing edge recognition on the content in the target image to obtain the edge of the content image;
obtaining a content image contour of the content in the target image based on the identified edges of the content image;
the image mask obtaining sub-module may be specifically configured to draw the outline of the content image in the blank image, and fill the outline of the content image with a preset outline pixel value, so as to obtain an image mask of the target image.
As a specific implementation of the disclosed embodiments, the image profile acquisition submodule may be specifically used,
converting the target image into a gray scale map;
performing edge recognition on the content in the gray level image to obtain the edge of the content image;
and performing edge expansion processing on the identified edges of the content image to obtain edge contours of the content image.
As a specific implementation of the disclosed embodiments, the watermark image adding module may be specifically configured to,
for each pixel point in a target image at a preset watermark image adding position, determining whether the pixel point is a contour pixel in the contour of the content image or not based on the image mask;
if the pixel point is a contour pixel in the contour of the content image, reserving the pixel point;
if the pixel point is not a contour pixel in the contour of the content image, the pixel is replaced with the watermark image pixel.
In the technical scheme of the disclosure, the acquisition, storage, application and the like of the related user personal information all conform to the regulations of related laws and regulations, and the public sequence is not violated.
According to embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
Fig. 8 illustrates a schematic block diagram of an example electronic device 800 that may be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 8, the apparatus 800 includes a computing unit 801 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM) 802 or a computer program loaded from a storage unit 808 into a Random Access Memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other by a bus 804. An input/output (I/O) interface 805 is also connected to the bus 804.
Various components in device 800 are connected to I/O interface 805, including: an input unit 806 such as a keyboard, mouse, etc.; an output unit 807 such as various types of displays, speakers, and the like; a storage unit 808, such as a magnetic disk, optical disk, etc.; and a communication unit 809, such as a network card, modem, wireless communication transceiver, or the like. The communication unit 809 allows the device 800 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
The computing unit 801 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 801 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 801 performs the various methods and processes described above, such as a method of adding an image watermark. For example, in some embodiments, the method of watermarking an image may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as the storage unit 808. In some embodiments, part or all of the computer program may be loaded and/or installed onto device 800 via ROM 802 and/or communication unit 809. When the computer program is loaded into RAM 803 and executed by computing unit 801, one or more steps of the method of watermarking an image described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to perform the method of watermarking the image by any other suitable means (e.g. by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on 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.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the internet.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel or sequentially or in a different order, provided that the desired results of the technical solutions of the present disclosure are achieved, and are not limited herein.
The above detailed description should not be taken as limiting the scope of the present disclosure. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present disclosure are intended to be included within the scope of the present disclosure.

Claims (10)

1. A method of adding an image watermark, comprising:
acquiring a watermark image to be added and a target image to be added with the watermark;
acquiring an image mask of the target image; the image mask contains a content image contour of content in the target image;
covering a region of a non-content image contour in the target image with the watermark image at a preset watermark image adding position based on the image mask;
the step of covering the area of the non-content image contour in the target image with the watermark image at a preset watermark image adding position based on the image mask comprises the following steps:
for each pixel point in a target image at a preset watermark image adding position, determining whether the pixel point is a contour pixel in the contour of the content image or not based on the image mask;
if the pixel point is a contour pixel in the contour of the content image, reserving the pixel point;
if the pixel point is not a contour pixel in the contour of the content image, the pixel is replaced with the watermark image pixel.
2. The method of claim 1, wherein,
the step of acquiring the image mask of the target image comprises the following steps:
acquiring a content image contour of the content in the target image;
and drawing the outline of the content image in the blank image to obtain an image mask of the target image.
3. The method of claim 2, wherein,
the step of acquiring the content image contour of the content in the target image comprises the following steps:
performing edge recognition on the content in the target image to obtain the edge of the content image;
obtaining a content image contour of the content in the target image based on the identified edges of the content image;
the step of drawing the outline of the content image in the blank image to obtain the image mask of the target image comprises the following steps:
and drawing the outline of the content image in the blank image, and filling the outline of the content image with a preset outline pixel value to obtain an image mask of the target image.
4. The method of claim 3, wherein,
the step of performing edge recognition on the content in the target image to obtain the edge of the content image comprises the following steps:
converting the target image into a gray scale map;
performing edge recognition on the content in the gray level image to obtain the edge of the content image;
the step of obtaining the content image contour of the content in the target image based on the identified edges of the content image includes:
and performing edge expansion processing on the identified edges of the content image to obtain edge contours of the content image.
5. An apparatus for adding an image watermark, comprising:
the target image acquisition module is used for acquiring the watermark image to be added and the target image to be added with the watermark;
an image mask acquisition module for acquiring an image mask of the target image; the image mask contains a content image contour of content in the target image;
the watermark image adding module is used for covering the area of the non-content image outline in the target image by using the watermark image at a preset watermark image adding position based on the image mask;
the watermark image adding module is particularly used for,
for each pixel point in a target image at a preset watermark image adding position, determining whether the pixel point is a contour pixel in the contour of the content image or not based on the image mask;
if the pixel point is a contour pixel in the contour of the content image, reserving the pixel point;
if the pixel point is not a contour pixel in the contour of the content image, the pixel is replaced with the watermark image pixel.
6. The apparatus of claim 5, wherein the image mask acquisition module comprises:
an image contour obtaining sub-module, configured to obtain a content image contour of content in the target image;
and the image mask acquisition sub-module is used for drawing the outline of the content image in the blank image to obtain the image mask of the target image.
7. The apparatus of claim 6, wherein,
the image contour acquisition submodule is particularly used for,
performing edge recognition on the content in the target image to obtain the edge of the content image;
obtaining a content image contour of the content in the target image based on the identified edges of the content image;
the image mask obtaining submodule is specifically used for drawing the outline of the content image in the blank image, and filling the outline of the content image with a preset outline pixel value to obtain the image mask of the target image.
8. The apparatus of claim 7, wherein the image profile acquisition submodule is operable in particular to,
converting the target image into a gray scale map;
performing edge recognition on the content in the gray level image to obtain the edge of the content image;
and performing edge expansion processing on the identified edges of the content image to obtain edge contours of the content image.
9. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-4.
10. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-4.
CN202110887835.3A 2021-08-03 2021-08-03 Method and device for adding image watermark, electronic equipment and storage medium Active CN113487473B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110887835.3A CN113487473B (en) 2021-08-03 2021-08-03 Method and device for adding image watermark, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110887835.3A CN113487473B (en) 2021-08-03 2021-08-03 Method and device for adding image watermark, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113487473A CN113487473A (en) 2021-10-08
CN113487473B true CN113487473B (en) 2024-03-26

Family

ID=77945371

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110887835.3A Active CN113487473B (en) 2021-08-03 2021-08-03 Method and device for adding image watermark, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113487473B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114860182A (en) * 2022-05-27 2022-08-05 京东方科技集团股份有限公司 Display information processing method and device, storage medium and electronic equipment
CN116756708B (en) * 2023-05-30 2023-12-05 佛山众陶联供应链服务有限公司 Protection method for variable granularity of digital product page copyright

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107885565A (en) * 2017-10-31 2018-04-06 平安科技(深圳)有限公司 Watermark embedding method, device, equipment and the storage medium at financial APP interfaces
CN108550101A (en) * 2018-04-19 2018-09-18 腾讯科技(深圳)有限公司 Image processing method, device and storage medium
CN112183294A (en) * 2020-09-23 2021-01-05 广州虎牙科技有限公司 Text elimination method and device, electronic equipment and storage medium
CN112581344A (en) * 2020-11-20 2021-03-30 平安普惠企业管理有限公司 Image processing method and device, computer equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090080688A1 (en) * 2007-09-25 2009-03-26 The Hong Kong University Of Science And Technology Digital watermarking for few-color images
US9659338B2 (en) * 2015-05-12 2017-05-23 Digify Pte Ltd Method and system for adaptive content protection

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107885565A (en) * 2017-10-31 2018-04-06 平安科技(深圳)有限公司 Watermark embedding method, device, equipment and the storage medium at financial APP interfaces
CN108550101A (en) * 2018-04-19 2018-09-18 腾讯科技(深圳)有限公司 Image processing method, device and storage medium
CN112183294A (en) * 2020-09-23 2021-01-05 广州虎牙科技有限公司 Text elimination method and device, electronic equipment and storage medium
CN112581344A (en) * 2020-11-20 2021-03-30 平安普惠企业管理有限公司 Image processing method and device, computer equipment and storage medium

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
Blind Watermarking Algorithm for Color Images Based on Nearest Neighbor Interpolation;Zou, XG等;《 MEASUREMENT TECHNOLOGY AND ENGINEERING RESEARCHES IN INDUSTRY》;20140228;全文 *
图像特征里的小波域水印算法;王树梅;;《计算机工程与应用》;20110311(第08期);全文 *
基于回归型支持向量机的医学图像可视可逆水印算法;王楠等;《计算机科学》;20180915(第09期);全文 *

Also Published As

Publication number Publication date
CN113487473A (en) 2021-10-08

Similar Documents

Publication Publication Date Title
CN107403421B (en) Image defogging method, storage medium and terminal equipment
US11113795B2 (en) Image edge processing method, electronic device, and computer readable storage medium
CN108830780B (en) Image processing method and device, electronic device and storage medium
CN110705583A (en) Cell detection model training method and device, computer equipment and storage medium
CN113487473B (en) Method and device for adding image watermark, electronic equipment and storage medium
CN107622504B (en) Method and device for processing pictures
CN111259878A (en) Method and equipment for detecting text
CN106202086B (en) Picture processing and obtaining method, device and system
CN110969046B (en) Face recognition method, face recognition device and computer-readable storage medium
CN112651953B (en) Picture similarity calculation method and device, computer equipment and storage medium
WO2019201184A1 (en) License plate enhancement method, apparatus and electronic device
CN112396050B (en) Image processing method, device and storage medium
CN111368587A (en) Scene detection method and device, terminal equipment and computer readable storage medium
CN114298985B (en) Defect detection method, device, equipment and storage medium
CN114862897A (en) Image background processing method and device and electronic equipment
CN108805838B (en) Image processing method, mobile terminal and computer readable storage medium
CN113642471A (en) Image identification method and device, electronic equipment and storage medium
CN115345895B (en) Image segmentation method and device for visual detection, computer equipment and medium
JP2021196451A (en) Image converter, image conversion method, and computer program for image conversion
CN111311610A (en) Image segmentation method and terminal equipment
CN115601616A (en) Sample data generation method and device, electronic equipment and storage medium
CN114463440A (en) Single-camera target positioning method, system, equipment and storage medium
CN114596210A (en) Noise estimation method, device, terminal equipment and computer readable storage medium
JP2019100937A (en) Defect inspection device and defect inspection method
CN114266803A (en) Image processing method, image processing device, electronic 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
GR01 Patent grant
GR01 Patent grant