Watermark embedding and extracting method and device, equipment, storage medium and product
By generating a purely transparent mask template image and embedding the target watermark, the problem of limitations in the existing technology of watermark embedding applicable scenarios is solved, and the watermark embedding of carrier objects with different background colors is realized, which improves security and visual effect.
Patent Information
- Application Number
- CN202411573079.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-02-14
AI Technical Summary
In the prior art, there are limitations in the applicable scenarios for watermark embedding. Watermark setting is based on the solid background color of the carrier object, and it cannot be applied to carrier objects with different background colors.
By generating a pure transparent mask template image of the carrier object to be embedded in the target watermark, embed the target watermark into the pure transparent mask template image, and set the fill color of the target watermark to be completely opaque mask watermark, and finally add it to the vector in object.
The universality and flexibility of watermark embedding is realized. The watermark can be effectively embedded regardless of the background color of the carrier object, which improves the security and visual effect of the carrier object.
Smart Images

Figure CN119444544A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of digital watermark technology, and in particular to watermark embedding and extraction methods, devices, equipment, storage media and products. Background Art
[0002] With the rapid development of the digital age, the easy duplication and dissemination of carrier objects such as web pages, multimedia, documents, software, etc. have also brought serious security risks, such as unauthorized copying, tampering and illegal dissemination. In order to protect the copyright and security of carrier objects, effective measures need to be taken to prevent the carrier objects from being illegally used.
[0003] Watermark is a technology that adds identification information to the carrier object, which is used to protect the copyright of the carrier object, ensure the authenticity of the carrier object and improve the security of the carrier object. The watermark can be information in the form of text, picture, QR code, etc., which is embedded in each page or specific location of the carrier object, so that the carrier object can be identified and tracked when it is copied, printed or disseminated.
[0004] In the related art, the prerequisite for embedding a watermark is that the carrier object has a solid background color, and the color of the embedded watermark needs to be set depending on the solid background color of the carrier object, which limits the watermark embedding scenario. Summary of the invention
[0005] The main purpose of this application is to provide a watermark embedding and extraction method, device, equipment, storage medium and product, aiming to solve the problem that the applicable scenarios of watermark embedding are limited.
[0006] To achieve the above purpose, the present application proposes a watermark embedding method, comprising:
[0007] Generate a pure transparent mask template image of a carrier object to be embedded with a target watermark;
[0008] Embedding the target watermark into the pure transparent mask template image, and setting the filling color of the target watermark to obtain a completely opaque mask watermark;
[0009] The fully opaque mask watermark is added to the carrier object.
[0010] In one embodiment, the step of embedding the target watermark into the pure transparent mask template image and setting the filling color of the target watermark to obtain a completely opaque mask watermark includes:
[0011] Converting the pure transparent mask template image into a pure transparent canvas;
[0012] Dividing the pure transparent canvas into a preset number of grids based on a preset grid size;
[0013] Determining the watermark size of each grid according to the target watermark size and the preset grid size;
[0014] embedding the target watermark into each grid in sequence based on the watermark size of each grid;
[0015] The filling color of the watermark in each grid is set to obtain the completely opaque mask watermark.
[0016] In one embodiment, setting the filling color of the watermark in each grid to obtain the completely opaque mask watermark includes:
[0017] The channel values of the watermark in each grid in the R channel, the G channel and the B channel are all set to 0, and the channel value of the Alpha channel is set to 1, so as to obtain the completely opaque mask watermark.
[0018] In one embodiment, the step of generating a pure transparent mask template image of a carrier object to be embedded with a target watermark comprises:
[0019] generating an image having the same page size as the display page of the carrier object;
[0020] The channel values of the R channel, the G channel and the B channel of the image are all set to 255, and the channel value of the Alpha channel of the image is set to 0, so as to obtain the pure transparent mask template image.
[0021] In one embodiment, the step of adding the completely opaque mask watermark to the carrier object comprises:
[0022] Obtain each display page associated with the carrier object;
[0023] The completely opaque mask watermark is added to the topmost layer of each display page of the carrier object.
[0024] In addition, to achieve the above purpose, the present application also proposes a watermark extraction method, comprising:
[0025] Taking a screenshot of the carrier object to which the target watermark has been added, to obtain a screenshot image, wherein the carrier object to which the target watermark has been added is obtained by the watermark embedding method described above;
[0026] Determine a pixel difference between an original pixel value and a reference pixel value of each pixel point in the screenshot image, and enlarge the pixel difference;
[0027] The original pixel value is updated by using the enlarged pixel difference value to obtain the target watermark in the screenshot image.
[0028] In one embodiment, the step of determining a pixel difference between an original pixel value and a reference pixel value of each pixel point in the screenshot image and expanding the pixel difference comprises:
[0029] Converting the screenshot image into a grayscale image;
[0030] Performing a scaling operation on the grayscale image to obtain a scaled grayscale image;
[0031] Determine a pixel difference between an original pixel value and a reference pixel value of each pixel in the grayscale image;
[0032] The pixel difference is enlarged to obtain an enlarged pixel difference.
[0033] In one embodiment, the step of expanding the pixel difference to obtain the expanded pixel difference includes:
[0034] Determine the pixel difference magnification factor;
[0035] The enlarged pixel difference is obtained according to the product of the difference enlargement factor and the pixel difference.
[0036] In addition, to achieve the above purpose, the present application also proposes a watermark embedding device, the watermark embedding device comprising:
[0037] A generating module, used for generating a pure transparent mask template image of a carrier object to be embedded with a target watermark;
[0038] An embedding module, used for embedding the target watermark into the pure transparent mask template image and setting the filling color of the target watermark to obtain a completely opaque mask watermark;
[0039] An adding module is used to add the completely opaque mask watermark to the carrier object.
[0040] In addition, to achieve the above purpose, the present application also proposes a watermark extraction device, the watermark extraction device comprising:
[0041] A screenshot module is used to take a screenshot of the carrier object to which the target watermark has been added to obtain a screenshot image;
[0042] An enlargement module, used to determine a pixel difference between an original pixel value and a reference pixel value of each pixel point in the screenshot image, and to enlarge the pixel difference;
[0043] The extraction module is used to update the original pixel value with the enlarged pixel difference value to obtain the target watermark in the screenshot image.
[0044] In addition, to achieve the above-mentioned purpose, the present application also proposes an electronic device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the watermark embedding method described above, or the computer program is configured to implement the steps of the watermark extraction method described above.
[0045] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the watermark embedding method described above are implemented, or when the computer program is executed by a processor, the steps of the watermark extraction method described above are implemented.
[0046] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps of the watermark embedding method described above, or when the computer program is executed by a processor, it implements the steps of the watermark extraction method described above.
[0047] Compared with the related art, the present application generates a pure transparent mask template image of a carrier object to be embedded with a target watermark; embeds the target watermark into the pure transparent mask template image, and sets the fill color of the target watermark to obtain a completely opaque mask watermark; finally, adds the completely opaque mask watermark to the carrier object, thereby achieving the effect of watermark embedding. The watermark embedding method adopted by the present application uses a pure transparent mask template image regardless of the background of the carrier object in which the watermark is embedded, and the fill color of the target watermark is uniformly set to be completely opaque, and does not depend on the background color of the carrier object. It can be applied to carrier objects with different background colors, thereby improving the versatility and flexibility of watermark embedding. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0049] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0050] Figure 1 A schematic diagram of a flow chart of the first embodiment of the watermark embedding method of the present application;
[0051] Figure 2 A detailed flow chart of the first embodiment of the watermark embedding method of the present application is provided;
[0052] Figure 3 A schematic diagram of a flow chart of a second embodiment of a watermark embedding method of the present application;
[0053] Figure 4 A screenshot of the document after the watermark is embedded for this application;
[0054] Figure 5 This is a schematic diagram of the effect of extracting watermarks using the watermark extraction algorithm of this application;
[0055] Figure 6 This is a schematic diagram of the module structure of the watermark embedding device of this application;
[0056] Figure 7 This is a schematic diagram of the module structure of the watermark extraction device of this application;
[0057] Figure 8 This is a schematic diagram of the structure of the electronic device of this application.
[0058] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0059] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0060] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0061] In the related art, the watermark information to be embedded in the carrier object is obtained by determining the solid color background area of the carrier object; the watermark information is embedded in the canvas to obtain the canvas containing the watermark information; the canvas containing the watermark information is added to the solid color background area of the carrier object, thereby achieving the effect of embedding the watermark information in the carrier object. The prerequisite for embedding the watermark is that the carrier object is a solid color background area, and the watermark color during embedding needs to be set based on the background color of the carrier object, which limits the watermark embedding scenario.
[0062] In view of the above problems, the present application proposes a watermark embedding method, the main technical scheme of which includes: generating a pure transparent mask template image of a carrier object to be embedded with a target watermark; embedding the target watermark into the pure transparent mask template image, and setting the fill color of the target watermark to obtain a completely opaque mask watermark; adding the completely opaque mask watermark to the carrier object. The watermark embedding method adopted in the present application uses a pure transparent mask template image regardless of the background of the carrier object in which the watermark is embedded, and the fill color of the target watermark is uniformly set to be completely opaque, and does not depend on the background color of the carrier object. It can be applied to carrier objects with different background colors, thereby improving the versatility and flexibility of watermark embedding.
[0063] In addition, the present application sets a pure transparent mask template image. The use of a pure transparent mask template image means that the watermark can be superimposed on any background without being affected by the background color, so that the embedded watermark does not block the content displayed by the carrier object itself, thereby improving the visual effect of the content displayed by the carrier object.
[0064] In addition, the target watermark is embedded in the pure transparent mask template image, and the filling color of the target watermark is set to obtain a completely opaque mask watermark. By using pixel value difference technology to add the target watermark to the carrier object, a dark watermark with low human perception can be added to the carrier object quickly and efficiently, effectively improving the security of the carrier object while minimizing the impact on the appearance of the carrier object.
[0065] It should be noted that the execution subject of this embodiment may be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, etc. The following takes an electronic device as an example to illustrate this embodiment and the following embodiments.
[0066] The present application embodiment provides a watermark embedding method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the watermark embedding method of the present application.
[0067] In this embodiment, the watermark embedding method includes steps S10 to S30:
[0068] Step S10, generating a pure transparent mask template image of a carrier object to be embedded with a target watermark;
[0069] It should be noted that the target watermark refers to the identification information to be embedded in the carrier object. Watermarking is a technology that adds identification information to the carrier object to protect the copyright of the carrier object, ensure the authenticity of the carrier object and improve the security of the carrier object. The watermark can be information in the form of text, pictures, QR codes, etc., which are embedded in each page or specific location of the carrier object. This enables the carrier object to be identified and tracked when it is copied, printed or disseminated. The target watermark can be the company name of a company, or the employee number or other identification information of an employee. For example, the user account information for logging into the system containing the carrier object is obtained as the target watermark; the target watermark can also include the time when the user logged into the system. For another example, the user account information for accessing a web page is obtained as the target watermark, and the target watermark can also include any of the following information: user access time, device information used by the user to access the web page, and address information.
[0070] It should be noted that the carrier object refers to the object in which the watermark information needs to be embedded. The carrier object can be a digital carrier, such as a web page, multimedia, document, software, etc. When the carrier object is a document application scenario, it includes Word documents, PDF documents, PPT documents, etc. When the carrier object is a software application scenario, it includes chat software. The carrier object can also be other objects with a solid color background to facilitate watermark embedding. This application takes the carrier object as a PDF document as an example.
[0071] In a feasible implementation, obtaining the carrier object to be embedded with the target watermark includes: using a PDF document processing library to read a PDF document stored on a hard disk. Alternatively, downloading a PDF document from a network via an HTTP request. Alternatively, allowing a user to select or input a path of a PDF document via a graphical user interface, thereby obtaining the carrier object to be embedded with the target watermark.
[0072] It should be noted that the pure transparent mask template image is usually a binary image or mask of the same size as the carrier object, which is used to define the area where the watermark is embedded. The pure transparent mask template image can be completely black, that is, all pixel values are 0, indicating an area where no watermark is embedded, or it can be an image containing white or a specific color area, that is, an area where a watermark is embedded.
[0073] In a feasible implementation, generating a pure transparent mask template image of a carrier object to be embedded with a target watermark includes: manually drawing the pure transparent mask template image using image editing software. Alternatively, automatically generating the pure transparent mask template image based on the characteristics of the carrier object such as edge detection, specific color area detection, etc.
[0074] In another feasible implementation, generating a pure transparent mask template image of a carrier object to be embedded with a target watermark may also be: parsing the carrier object to obtain the size information of the carrier object, and then generating a pure transparent mask template image of the carrier object according to the size information of the carrier object. The size information of the carrier object may be the height and width of the current display page of the carrier object, and generating a pure transparent mask template image that is consistent with the height and width.
[0075] In another feasible implementation, generating a pure transparent mask template image of a carrier object to be embedded with a target watermark may also be: generating an image with the same page size as the display page of the carrier object, setting the channel values of the color channel and the transparency channel of the carrier object to be embedded with the target watermark, and obtaining a pure transparent mask template image.
[0076] The pure transparent mask template image may include four channels, namely, R channel, G channel, B channel and Alpha channel, wherein the R channel, G channel and B channel are all color channels, and the Alpha channel is a channel indicating transparency.
[0077] In another feasible implementation, generating a pure transparent mask template image of a carrier object to be embedded with a target watermark may also be: generating an image with the same page size as the display page of the carrier object; setting the channel values of the R channel, G channel and B channel of the image to 255, and setting the channel value of the Alpha channel of the image to 0, to obtain the pure transparent mask template image.
[0078] The R channel mentioned above is the red channel. When the channel value of the R channel is set to 255, it means that the highest color intensity is reached on the red channel. The range of the red channel is 0 to 255, and 255 represents the maximum value of the red component. The G channel mentioned above is the green channel. When the channel value of the G channel is set to 255, it means that the highest color intensity is also reached on the green channel. The range of the green channel is also 0 to 255, and 255 represents the maximum value of the green component. The B channel mentioned above is the blue channel. When the channel value of the B channel is set to 255, it means that the highest color intensity is also reached on the blue channel. The range of the blue channel is 0 to 255, and 255 represents that the highest color intensity is also reached on the blue channel. Since the values of the three channels of R, G, and B are all 255, this color is represented as white in the RGB color space. White is one of the pure colors in the RGB color space, which is a mixture of equal amounts of red, green, and blue light. When the channel value of the Alpha channel is set to 1, it means that this color is completely opaque. In image processing, the alpha channel is used to represent the transparency of an image, ranging from 0 to 1, or 0 to 255, depending on the bit depth of the image, with 0 representing full transparency and 1 or 255 representing full opacity. (255, 255, 255, 1) represents a fully opaque white.
[0079] This embodiment obtains a purely transparent mask template image by setting the channel values of each channel of the mask template. The use of a purely transparent mask template image means that the watermark can be superimposed on any background without being affected by the background color, so that the embedded watermark does not block the content displayed by the carrier object itself, thereby improving the visual effect of the content displayed by the carrier object.
[0080] Step S20, embedding the target watermark into the pure transparent mask template image, and setting the filling color of the target watermark to obtain a completely opaque mask watermark;
[0081] It should be noted that the mask watermark refers to a mask template containing a target watermark.
[0082] In a feasible implementation, the pure transparent mask template image can be converted into a pure transparent canvas, the target watermark can be directly embedded in the pure transparent canvas, and the filling color of the target watermark can be set to obtain a completely opaque mask watermark.
[0083] In another feasible implementation, the pure transparent mask template image can be converted into a pure transparent canvas, the target watermark can be directly embedded in the pure transparent canvas, and the channel values of the target watermark in the R channel, G channel and B channel are set to 0, and the channel value in the Alpha channel is set to 1, so as to obtain the completely opaque mask watermark.
[0084] In another possible implementation, referring to Figure 2 , step S20 comprises:
[0085] Step S21, converting the pure transparent mask template image into a pure transparent canvas;
[0086] It should be noted that a pure transparent canvas refers to an image container or image element that can be used to draw graphics or images that can be embedded in a carrier object. For example, the Canvas in the HTML language can be used to draw images on a web page. By controlling the pixels of the Canvas, graphics or images can be drawn, including strings, to facilitate the subsequent embedding of watermarks. The size of the pure transparent canvas created here can be the same as the size of the target watermark.
[0087] Step S22, dividing the pure transparent canvas into a preset number of grids based on a preset grid size;
[0088] It should be noted that the preset grid size can be set according to actual conditions, for example, it can be set according to the size of the pure transparent canvas and / or the size of the target watermark, wherein the larger the size of the transparent canvas, the larger the preset grid size is set, and the larger the size of the target watermark, the larger the preset grid size is set. For example, the generated pure transparent canvas can be divided into m rows and n columns to form m*n grids of the same size, where m and n can be user-defined. Of course, the pure transparent canvas can also be divided into multiple grids of inconsistent sizes.
[0089] It should be noted that the preset number can also be set according to actual conditions, for example, according to the size of the transparent canvas and / or the size of the target watermark, wherein, when the size of the transparent canvas is larger, the number of preset grids set is more, and when the size of the target watermark is larger, the number of preset grids set is more, thereby achieving adaptive grid division.
[0090] Step S23, determining the watermark size of each grid according to the target watermark size and the preset grid size;
[0091] It should be noted that one target watermark can be set for each grid, or, when the target watermark is large, multiple grids are required to embed one target watermark.
[0092] It should be noted that the watermark size of each grid refers to the size of the watermark that each grid can accommodate. The size of the watermark that each grid can accommodate is different, which requires considering the type of watermark and the overlapping part of the watermark and the grid.
[0093] In a feasible implementation, when a target watermark is set for each grid, it is necessary to determine how many target watermarks or scaled versions of the target watermark can be accommodated under the preset grid size. Then, the size to which the target watermark needs to be scaled to fit the grid is calculated. This usually involves calculating the ratio of the width and height of the watermark to the width and height of the grid unit, and selecting an appropriate scaling ratio, which should ensure that the watermark remains recognizable and clear after scaling. Then, using the calculated scaling ratio, the target watermark is scaled to a size suitable for the grid unit, which can be achieved through the scaling function in the image processing library, such as Python's PIL or OpenCV library. Then, if the calculated watermark size does not completely match the grid unit size, and this mismatch has a significant impact on the placement or visual effect of the watermark, the grid size or the scaling ratio of the watermark needs to be adjusted to achieve the best effect. Finally, the scaled watermark is placed in an appropriate position in the grid, which may require considering the alignment, spacing, and grid boundaries between watermarks. The target watermark can be automatically scaled based on the grid size.
[0094] In another feasible implementation, when the target watermark is large, the maximum overlapping area between the watermark and the grid can be calculated, and then the watermark size of each grid can be determined according to the maximum overlapping area. In this case, each grid only embeds part of the watermark information of a target watermark, rather than the entire target watermark.
[0095] Step S24, embedding the target watermark into each grid in sequence based on the watermark size of each grid;
[0096] After determining the watermark size that each grid can accommodate, the target watermark is embedded into each grid in turn based on the watermark size of each grid.
[0097] Step S25, setting the filling color of the watermark in each grid to obtain the completely opaque mask watermark.
[0098] It should be noted that the filling color of the watermark is obtained by setting the channel values of the color channel and the transparency channel. The target watermark can be directly embedded in a pure transparent canvas, and the channel values of the target watermark in the color channel and the channel used to represent transparency can be set to obtain a completely opaque mask watermark.
[0099] The above-mentioned channels include four channels, namely R channel, G channel, B channel and Alpha channel, that is, the filling color of the above-mentioned watermark is (R, G, B, Alpha). Among them, the R channel, G channel and B channel are all color channels, and the Alpha channel is a channel indicating transparency. The channel values of the watermark in each grid can be set to 0 in the R channel, G channel and B channel, and the channel value in the Alpha channel can be set to 1, so as to obtain a completely opaque mask watermark.
[0100] The R channel mentioned above is the red channel. When the channel value of the R channel is set to 0, it means that there is no color intensity on the red channel. The range of the red channel is 0 to 255, and 0 represents no red component at all. The G channel mentioned above is the green channel. When the channel value of the G channel is set to 0, it means that there is no color intensity on the green channel. The range of the green channel is also 0 to 255, and 0 represents no green component at all. The B channel mentioned above is the blue channel. When the channel value of the B channel is set to 0, it means that there is no color intensity on the blue channel. The range of the blue channel is 0 to 255, and 0 represents no blue component at all. Since the values of the three channels of R, G, and B are all 0, this color is represented as black in the RGB color space. However, it should be noted that the black here is not completely opaque black, because there is also an Alpha channel value to consider. When the channel value of the Alpha channel is 1, it means that this color is completely opaque. The channel value of the Alpha channel ranges from 0 to 1, or 0 to 255. 0 represents complete transparency, while 1 or 255 represents complete opacity.
[0101] The fill color of the watermark is (0, 0, 0, 1), which means a completely opaque black. This color is usually used to embed invisible watermark information in an image because black does not visually interfere with the content of the original image. At the same time, the opacity value of the Alpha channel ensures that the embedding of the watermark information does not affect the overall visual effect of the image, thereby achieving the hidden effect of the watermark and improving the security of the carrier object.
[0102] In this embodiment, the pure transparent canvas is divided into a preset number of grids based on a preset grid size; the watermark size of each grid is determined according to the target watermark size and the preset grid size; the target watermark is embedded into each grid in turn based on the watermark size of each grid; the channel value of the watermark in each grid in each channel is set to obtain the completely opaque mask watermark, thereby achieving the effect of embedding the target watermark in the pure transparent canvas, and because the mask watermark is completely opaque, it is ensured that the embedding of the watermark information will not affect the overall visual effect of the image, thereby achieving the watermark hiding effect and improving the security of the carrier object.
[0103] Step S30, adding the completely opaque mask watermark to the carrier object.
[0104] After obtaining the completely opaque mask watermark, the completely opaque mask watermark is merged with the carrier object to obtain the watermark embedding effect.
[0105] In a feasible implementation manner, each display page associated with the carrier object may be obtained; and a completely opaque mask watermark may be added to the topmost layer of each display page of the carrier object.
[0106] For example, get the initial PDF document to be embedded with the target watermark. Call the Pdf.open method of the pikepdf library to read the initial PDF document and parse it to get the PDF file object target_pdf. Get the width and height of the current initial PDF document page through the target_pdf.page.trimbox property method; then, generate a mask template of the same size according to the width and height of the current initial PDF document page, so as to achieve the purpose of generating a mask template for the carrier object.
[0107] In order to solve the problem that the mask watermark cannot be directly added to the initial PDF document, the PDF document processing technology is used to generate the mask watermark as a mask watermark PDF file, and the output file handle is watermark_pdf; the file handle watermark_pdf page object is obtained, which has only one page content, recorded as watermark_page; the PDF file object target_pdf and the mask watermark PDF page object watermark_page are obtained, and each display page of the PDF file object target_pdf is processed in a loop, and the mask watermark PDF page object watermark_page is added to the top layer of each display page of the PDF file object target_pdf; until each display page of the PDF file object target_pdf is processed, the PDF document watermark is embedded successfully. After the PDF document watermark is successfully embedded, the PDF document with the target watermark embedded is output. There is no obvious difference in visual effect between the PDF document with the target watermark embedded and the initial PDF document, and the watermark information has low perception to the human eye.
[0108] In this embodiment, a pure transparent mask template image of a carrier object to be embedded with a target watermark is generated; the target watermark is embedded in the pure transparent mask template image, and the fill color of the target watermark is set to obtain a completely opaque mask watermark; finally, the completely opaque mask watermark is added to the carrier object, thereby achieving the effect of watermark embedding. The watermark embedding method adopted in this application uses a pure transparent mask template image regardless of the background of the carrier object in which the watermark is embedded, and the fill color of the target watermark is uniformly set to be completely opaque, which does not depend on the background color of the carrier object. It can be applied to carrier objects with different background colors, thereby improving the versatility and flexibility of watermark embedding.
[0109] Based on the same inventive concept, the present application embodiment provides a watermark extraction method, referring to Figure 3 , Figure 3 This is a flow chart of the first embodiment of the watermark extraction method of the present application.
[0110] In this embodiment, the watermark embedding method includes steps S110 to S130:
[0111] Step S110, taking a screenshot of the carrier object to which the target watermark has been added, to obtain a screenshot image;
[0112] It should be noted that the target watermark refers to the identification information to be embedded in the carrier object. Watermarking is a technology that adds identification information to the carrier object to protect the copyright of the carrier object, ensure the authenticity of the carrier object and improve the security of the carrier object. The watermark can be information in the form of text, pictures, QR codes, etc., which are embedded in each page or specific location of the carrier object. This enables the carrier object to be identified and tracked when it is copied, printed or disseminated. The target watermark can be the company name of a company, or the employee number or other identification information of an employee. For example, the user account information for logging into the system containing the carrier object is obtained as the target watermark; the target watermark can also include the time when the user logged into the system. For another example, the user account information for accessing a web page is obtained as the target watermark, and the target watermark can also include any of the following information: user access time, device information used by the user to access the web page, and address information.
[0113] It should be noted that the carrier object refers to the object in which the watermark information needs to be embedded. The carrier object can be a digital carrier, such as a web page, multimedia, document, software, etc. When the carrier object is a document application scenario, it includes Word documents, PDF documents, PPT documents, etc. When the carrier object is a software application scenario, it includes chat software. The carrier object can also be other objects with a solid color background to facilitate watermark embedding. This application takes the carrier object as a PDF document as an example.
[0114] The target watermark can be embedded into the carrier object based on the watermark embedding method described above to obtain the carrier object to which the target watermark has been added. The watermark embedding method refers to the above embodiment and will not be described in detail here.
[0115] It should be noted that a screenshot can be taken at any position of the carrier object with the target watermark added thereto to obtain a screenshot image, and the screenshot image here can be one or more.
[0116] Step S120, determining a pixel difference between an original pixel value and a reference pixel value of each pixel point in the screenshot image, and enlarging the pixel difference;
[0117] It should be noted that the screenshot image includes a watermark area and a non-watermark area. There are multiple pixels in both the watermark area and the non-watermark area. Each pixel has a corresponding pixel value, and the pixel values of the pixels in the watermark area and the non-watermark area are different.
[0118] It should be noted that the purpose of expanding the pixel difference is to identify the target watermark in the carrier object so as to be able to identify and track the source of the leakage and effectively improve the security of the carrier object.
[0119] It should be noted that the reference pixel value can be set according to actual conditions, for example, set to 255.
[0120] It should be noted that the pixel difference value represents the brightness change of each pixel relative to the reference pixel value.
[0121] In a feasible implementation manner, the pixel difference between the watermark area and the non-watermark area may be determined, and the pixel difference may be expanded to obtain an expanded pixel difference.
[0122] In another feasible implementation, a pixel difference magnification factor may be determined, and the enlarged pixel difference may be obtained by multiplying the difference magnification factor and the pixel difference.
[0123] In another feasible implementation, the screenshot image can also be converted into a grayscale image; the grayscale image can be scaled to obtain a scaled grayscale image; the pixel difference between the original pixel value and the reference pixel value of each pixel point in the grayscale image can be determined; and the pixel difference can be expanded to obtain an expanded pixel difference.
[0124] It should be noted that the screenshot image may contain three color channels of red, green and blue, that is, a color image, which can be converted into a grayscale image by, for example, weighted averaging. A grayscale image is an image with only one color channel, and its pixel value usually represents brightness, ranging from 0 to 255.
[0125] It should be noted that in order to further speed up the watermark extraction efficiency, some preprocessing of the grayscale image is required. For example, to avoid large calculation amount due to large image size, the grayscale image needs to be scaled to change its size. For example, an interpolation algorithm can be used to scale the grayscale image to obtain a scaled grayscale image.
[0126] In a feasible implementation, the pixel difference between the original pixel value and the reference pixel value of each pixel point in the grayscale image can be determined, and the pixel difference magnification factor can be determined; the enlarged pixel difference can be obtained based on the product of the difference magnification factor and the pixel difference.
[0127] It should be noted that the pixel difference magnification factor here can be customized according to the actual situation. Enlarging the pixel difference can enhance the contrast in the image or highlight certain features. For example, if the base pixel value is selected as the average brightness of the image, the enlarged pixel difference will make the bright and dark areas in the image more distinct.
[0128] For example, the document screenshot image after embedding the watermark is as follows: Figure 4 As shown, the schematic diagram of the effect of watermark extraction algorithm extracting watermark is as follows Figure 5 shown.
[0129] In this embodiment, the watermark information in the carrier object screenshot can be successfully extracted through the pixel difference technology, and the source of the leakage can be identified and tracked, effectively improving the security of the carrier object.
[0130] Based on the same inventive concept, this application also provides a watermark embedding device, please refer to Figure 6 , the watermark embedding device comprises:
[0131] A generating module 10, used for generating a pure transparent mask template image of a carrier object to be embedded with a target watermark;
[0132] An embedding module 20, used for embedding the target watermark into the pure transparent mask template image and setting the filling color of the target watermark to obtain a completely opaque mask watermark;
[0133] The adding module 30 is used to add the completely opaque mask watermark to the carrier object.
[0134] Optionally, the embedding module 20 is further used to convert the pure transparent mask template image into a pure transparent canvas; divide the pure transparent canvas into a preset number of grids based on a preset grid size; determine the watermark size of each grid according to the target watermark size and the preset grid size; embed the target watermark into each grid in turn based on the watermark size of each grid; set the fill color of the watermark in each grid to obtain the completely opaque mask watermark.
[0135] Optionally, the embedding module 20 is further configured to set the channel values of the watermark in each grid in the R channel, the G channel and the B channel to 0, and set the channel value of the Alpha channel to 1, so as to obtain the completely opaque mask watermark.
[0136] Optionally, the generation module 10 is also used to generate an image with the same page size as the display page of the carrier object; set the channel values of the R channel, G channel and B channel of the image to 255, and set the channel value of the Alpha channel of the image to 0, so as to obtain the pure transparent mask template image.
[0137] Optionally, the adding module 30 is further configured to obtain each display page associated with the carrier object; and add the completely opaque mask watermark to the topmost layer of each display page of the carrier object.
[0138] The watermark embedding device provided by the present application adopts the watermark embedding method in the above embodiment, which can solve the technical problem that the applicable scenarios of watermark embedding are limited. Compared with the prior art, the beneficial effects of the watermark embedding device provided by the present application are the same as the beneficial effects of the watermark embedding method provided by the above embodiment, and other technical features in the watermark embedding device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0139] Based on the same inventive concept, this application also provides a watermark extraction device, please refer to Figure 7 , the watermark extraction device comprises:
[0140] A screenshot module 30 is used to take a screenshot of the carrier object to which the target watermark has been added to obtain a screenshot image;
[0141] An enlargement module 40, used to determine a pixel difference between an original pixel value and a reference pixel value of each pixel point in the screenshot image, and to enlarge the pixel difference;
[0142] The extraction module 50 is used to update the original pixel value with the enlarged pixel difference value to obtain the target watermark in the screenshot image.
[0143] Optionally, the expansion module 40 is also used to convert the screenshot image into a grayscale image; scale the grayscale image to obtain a scaled grayscale image; determine the pixel difference between the original pixel value and the reference pixel value of each pixel point in the grayscale image; and expand the pixel difference to obtain an expanded pixel difference.
[0144] Optionally, the extraction module 50 is further configured to determine a pixel difference magnification factor; and obtain the enlarged pixel difference according to the product of the difference magnification factor and the pixel difference.
[0145] The watermark extraction device provided by the present application adopts the watermark extraction method in the above embodiment, which can improve the security of the carrier object. Compared with the prior art, the beneficial effects of the watermark extraction device provided by the present application are the same as the beneficial effects of the watermark extraction method provided by the above embodiment, and other technical features in the watermark extraction device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0146] Based on the same inventive concept, the present application provides an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the watermark embedding method in the above-mentioned first embodiment or execute the watermark extraction method in the above-mentioned second embodiment.
[0147] Reference below Figure 8 , which shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present application. The electronic devices in the embodiments of the present application may include but are not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0148] like Figure 8As shown, the electronic device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the electronic device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows an electronic device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.
[0149] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0150] The electronic device provided by the present application adopts the watermark embedding method in the above embodiment, which can improve the versatility and flexibility of watermark embedding. Compared with the prior art, the beneficial effects of the electronic device provided by the present application are the same as the beneficial effects of the watermark embedding method provided by the above embodiment, and other technical features in the electronic device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0151] Alternatively, the electronic device provided by the present application can improve the security of the carrier object by using the watermark extraction method in the above embodiment. Compared with the prior art, the beneficial effects of the electronic device provided by the present application are the same as the beneficial effects of the watermark extraction method provided by the above embodiment, and the other technical features in the electronic device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0152] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0153] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0154] Based on the same inventive concept, the present application provides a computer-readable storage medium having computer-readable program instructions (i.e., computer program) stored thereon, and the computer-readable program instructions are used to execute the watermark embedding method in the above-mentioned first embodiment or execute the watermark extraction method in the above-mentioned second embodiment.
[0155] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0156] The computer-readable storage medium may be included in the electronic device, or may exist independently without being installed in the electronic device.
[0157] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by an electronic device, the electronic device generates a pure transparent mask template image of a carrier object to be embedded with a target watermark; embeds the target watermark into the pure transparent mask template image, and sets the fill color of the target watermark to obtain a completely opaque mask watermark; and adds the completely opaque mask watermark to the carrier object. Alternatively, the electronic device takes a screenshot of the carrier object to which the target watermark has been added to obtain a screenshot image; determines the pixel difference between the original pixel value and the reference pixel value of each pixel point in the screenshot image, and expands the pixel difference; updates the original pixel value with the expanded pixel difference to obtain the target watermark in the screenshot image.
[0158] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0159] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0160] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0161] The readable storage medium provided in this application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned watermark embedding method, and can improve the versatility and flexibility of watermark embedding. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the watermark embedding method provided in the above-mentioned embodiment, and will not be described in detail here.
[0162] Alternatively, the readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned watermark extraction method, and can improve the security of the carrier object. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the watermark extraction method provided by the above-mentioned embodiment, and will not be repeated here.
[0163] Based on the same inventive concept, the present application also provides a computer program product, including a computer program, which implements the steps of the watermark embedding method as described above when executed by a processor. The computer program product provided by the present application can improve the versatility and flexibility of watermark embedding. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as those of the watermark embedding method provided by the above embodiment, and will not be described in detail here.
[0164] Alternatively, when the computer program is executed by the processor, the steps of the watermark extraction method described above are implemented. The computer program product provided by the present application can improve the security of the carrier object. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the watermark extraction method provided by the above embodiment, which will not be described in detail here.
[0165] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A watermark embedding method, characterized in that: The method comprises: Generate a pure transparent mask template image of a carrier object to be embedded with a target watermark; Embedding the target watermark into the pure transparent mask template image, and setting the filling color of the target watermark to obtain a completely opaque mask watermark; The fully opaque mask watermark is added to the carrier object.
2. The method according to claim 1, characterized in that The step of embedding the target watermark into the pure transparent mask template image and setting the filling color of the target watermark to obtain a completely opaque mask watermark comprises: Converting the pure transparent mask template image into a pure transparent canvas; Dividing the pure transparent canvas into a preset number of grids based on a preset grid size; Determining the watermark size of each grid according to the target watermark size and the preset grid size; embedding the target watermark into each grid in sequence based on the watermark size of each grid; The filling color of the watermark in each grid is set to obtain the completely opaque mask watermark.
3. The method according to claim 2, characterized in that The step of setting the filling color of the watermark in each grid to obtain the completely opaque mask watermark comprises: The channel values of the watermark in each grid in the R channel, the G channel and the B channel are all set to 0, and the channel value of the Alpha channel is set to 1, so as to obtain the completely opaque mask watermark.
4. The method according to claim 1, characterized in that The step of generating a pure transparent mask template image of a carrier object to be embedded with a target watermark comprises: generating an image having the same page size as the display page of the carrier object; The channel values of the R channel, the G channel and the B channel of the image are all set to 255, and the channel value of the Alpha channel of the image is set to 0, so as to obtain the pure transparent mask template image.
5. The method according to any one of claims 1 to 4, characterized in that: The step of adding the completely opaque mask watermark to the carrier object comprises: Obtain each display page associated with the carrier object; The completely opaque mask watermark is added to the topmost layer of each display page of the carrier object.
6. A watermark extraction method, characterized in that: The method comprises: Taking a screenshot of the carrier object to which the target watermark has been added, to obtain a screenshot image, wherein the carrier object to which the target watermark has been added is obtained by the watermark embedding method according to any one of claims 1 to 5; Determine a pixel difference between an original pixel value and a reference pixel value of each pixel point in the screenshot image, and enlarge the pixel difference; The original pixel value is updated by using the enlarged pixel difference value to obtain the target watermark in the screenshot image.
7. The method according to claim 6, characterized in that The step of determining the pixel difference between the original pixel value and the reference pixel value of each pixel point in the screenshot image and expanding the pixel difference comprises: Converting the screenshot image into a grayscale image; Performing a scaling operation on the grayscale image to obtain a scaled grayscale image; Determine a pixel difference between an original pixel value and a reference pixel value of each pixel in the grayscale image; The pixel difference is enlarged to obtain an enlarged pixel difference.
8. The method according to claim 7, characterized in that The step of enlarging the pixel difference to obtain the enlarged pixel difference comprises: Determine the pixel difference magnification factor; The enlarged pixel difference is obtained according to the product of the difference enlargement factor and the pixel difference.
9. A watermark embedding device, characterized in that: The watermark embedding device comprises: A generating module, used for generating a pure transparent mask template image of a carrier object to be embedded with a target watermark; An embedding module, used for embedding the target watermark into the pure transparent mask template image and setting the filling color of the target watermark to obtain a completely opaque mask watermark; An adding module is used to add the completely opaque mask watermark to the carrier object.
10. A watermark extraction device, characterized in that: The watermark extraction device comprises: A screenshot module is used to take a screenshot of the carrier object to which the target watermark has been added to obtain a screenshot image; An enlargement module, used to determine a pixel difference between an original pixel value and a reference pixel value of each pixel point in the screenshot image, and to enlarge the pixel difference; The extraction module is used to update the original pixel value with the enlarged pixel difference value to obtain the target watermark in the screenshot image.
11. An electronic device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the watermark embedding method as described in any one of claims 1 to 5, or the computer program is configured to implement the steps of the watermark extraction method as described in any one of claims 6 to 8.
12. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the watermark embedding method as described in any one of claims 1 to 5 are implemented, or when the computer program is executed by a processor, the steps of the watermark extraction method as described in any one of claims 6 to 8 are implemented.
13. A computer program product, characterized in that The computer program product comprises a computer program, which implements the steps of the watermark embedding method according to any one of claims 1 to 5 when executed by a processor, or implements the steps of the watermark extraction method according to any one of claims 6 to 8 when executed by a processor.
Citation Information
Cited By
Traceable, efficient and high-robustness video watermarking method and system
CN121486585A