A watermark processing method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202211715034.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-27
- Publication Date
- 2026-08-18
- Estimated Expiration
- 2042-12-27
AI Technical Summary
[0007]为了解决现有的暗水印处理方式添加水印信息时破坏图像的完整性,以及识别水印的效果不佳的问题,本申请实施例提供了一种水印处理方法、装置、电子设备及存储介质
[0059] The watermarking method, apparatus, electronic device, and storage medium provided in this application obtain watermark information to be inserted, set a transparent layer on the terminal display screen, and draw the watermark information on the transparent layer with a set transparency. In this way, by drawing the watermark information on the transparent layer of the user terminal screen, there is no need to insert watermark information on the original image, and the integrity of the original image is not changed. When the user takes a screenshot of the content of the electronic document being viewed through the terminal's screenshot software, or records a video through the screen recording software, the system hook (hook function) technology of the terminal can ensure that the image frame obtained by the screenshot or screen recording software has dark watermark information. Therefore, the watermark information can be directly restored from the image frame of the screenshot or video without the need for a large number of watermark samples for training, and the applicability is high.
Smart Images

Figure CN118297780B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to a watermarking method, apparatus, electronic device and storage medium. Background Technology
[0002] With the development of internet technology, remote work, collaborative work, and online cooperation are becoming increasingly common, and electronic documents are becoming easier to access. In order to prevent the loss of traceability after the leakage of important electronic document information, related technologies add watermarks to important electronic documents. The watermarks on these electronic documents contain the user's identity information, so when an electronic document is leaked, the leaker can be traced back to the leaker based on the watermarks.
[0003] However, visible watermarks can negatively impact user reading experience. Therefore, hidden watermarking technology is becoming increasingly widely used. Hidden watermarks are watermarks that are imperceptible to users. They add information such as document source information and user information to electronic documents. If the electronic document is leaked, the watermark information can be recovered, enabling traceability of the electronic document.
[0004] Existing dark watermarking technologies mainly fall into the following two categories:
[0005] The first type is a deep learning-based image dark watermarking method. Its main approach is to pre-train a classification model to identify the presence of marker points in an image. When identifying a target image with a watermark, the classification model categorizes the presence of marker points at each location. The watermark is then obtained from the model's output and used to reconstruct the image's source information. However, this method requires continuous server training. The classification model needs to be trained on a large number of watermark samples to improve the recognition rate. Since watermark samples from different users are not identical, the effectiveness of this method is limited.
[0006] The second type is the spatial domain-based image dark watermarking method. The main means of implementation is to use image digitization micro-color difference processing technology. By changing the RGB values of image pixels, the watermark information is drawn onto the original image. This method can make the image have subtle color differences that are not easily detected by the human eye. If users leak electronic document information through screenshots or screen recordings, the leaked images or videos can be watermarked and the relevant responsible persons can be traced. However, this method draws the watermark information directly onto the original image, destroying the integrity of the original image. Summary of the Invention
[0007] To address the problems of existing dark watermarking methods that damage image integrity when adding watermark information and poor watermark recognition performance, this application provides a watermarking method, apparatus, electronic device, and storage medium.
[0008] In a first aspect, embodiments of this application provide a watermarking method, including:
[0009] Get the watermark information to be inserted;
[0010] Set a transparent layer on the terminal display screen;
[0011] The watermark information is drawn on the transparent layer with a set transparency.
[0012] In one possible implementation, a transparent layer is set on the terminal display screen, specifically including:
[0013] The size of the layer window is determined based on the size of the terminal display screen.
[0014] Use a transparent brush to paint the layer window with a transparent color to obtain a transparent layer;
[0015] The transparent layer is set on the top layer of the terminal display screen.
[0016] In one possible implementation, the method further includes:
[0017] Obtain the image of the watermark to be restored, wherein the image of the watermark to be restored is an image captured by the terminal or an image frame of a video recorded by the terminal;
[0018] The image of the watermark to be restored is divided into a corresponding number of image blocks according to a preset size;
[0019] For each image block, obtain the first color value that has the highest number of color values among the pixels.
[0020] The first color value with the highest quantity among all first color values is determined as the reference color value;
[0021] The corresponding reproduction color level value of the reference color value is determined based on the preset correspondence between color values and reproduction color level values;
[0022] The color levels of the image to be restored are adjusted according to the restored color level values to obtain the restored watermark image.
[0023] In one possible implementation, the method further includes:
[0024] Draw the set watermark on the solid color canvas corresponding to each color value with the set transparency to obtain the corresponding solid color canvas with added watermark;
[0025] For each solid color canvas after watermarking, the color level of the solid color canvas after watermarking is adjusted according to each color level value to obtain each corresponding restored watermark canvas.
[0026] Determine the contrast between the color values of the pixels with watermarks and the pixels without watermarks in each restored watermark canvas.
[0027] Select a color level value from the color level values corresponding to the restored watermark canvas with a contrast greater than the set threshold, and use it as the restored color level value corresponding to the color value of the pixel of the solid color canvas before adding the watermark.
[0028] The correspondence is obtained based on each color value and its corresponding restored color level value.
[0029] In one possible implementation, determining the contrast between the color values of watermarked pixels and unwatermarked pixels in each restored watermark canvas specifically includes:
[0030] The contrast of the corresponding watermark-restored canvas is determined based on the difference between the color values of the pixels with watermarks and the pixels without watermarks in each watermark-restored canvas.
[0031] In one possible implementation, the method further includes:
[0032] In response to a screenshot or screen recording operation on the terminal;
[0033] The watermark information is written into the image captured by the terminal or the video recorded using a hook function.
[0034] Secondly, embodiments of this application provide a watermark processing apparatus, including:
[0035] The first acquisition unit is used to acquire the watermark information to be inserted;
[0036] The setting unit is used to set a transparent layer on the terminal display screen;
[0037] The first watermark adding unit is used to draw the watermark information on the transparent layer with a set transparency.
[0038] In one possible implementation, the setting unit is specifically used to determine the size of the layer window based on the size of the terminal display screen; to draw the layer window in a transparent color using a transparent brush to obtain a transparent layer; and to set the transparent layer on the top layer of the terminal display screen.
[0039] In one possible implementation, the device further includes:
[0040] The second acquisition unit is used to acquire an image of the watermark to be restored, wherein the image of the watermark to be restored is an image captured by the terminal or an image frame of a video recorded by the terminal;
[0041] The segmentation unit is used to divide the image of the watermark to be restored into a corresponding number of image blocks according to a preset size;
[0042] The third acquisition unit is used to acquire the first color value with the largest number of color values in each image block;
[0043] The first determining unit is used to determine the first color value with the largest number among all first color values as the reference color value;
[0044] The second determining unit is used to determine the restored color level value corresponding to the reference color value based on the preset correspondence between color value and restored color level value;
[0045] The watermark restoration unit is used to adjust the color level of the image to be restored according to the restored color level value to obtain the restored watermark image.
[0046] In one possible implementation, the device further includes:
[0047] The second watermark adding unit is used to draw the set watermark on the solid color canvas corresponding to each color value with the set transparency, so as to obtain the corresponding solid color canvas with added watermark.
[0048] The color level adjustment unit is used to adjust the color level of each solid color canvas after watermarking is added according to each color level value, so as to obtain each corresponding restored watermark canvas.
[0049] The third determining unit is used to determine the contrast between the color values of the pixels with added watermarks and the color values of the pixels without added watermarks in each restored watermark canvas.
[0050] The selection unit is used to select a color level value from the color level values corresponding to the restored watermark canvas with a contrast greater than a set threshold, and use it as the restored color level value corresponding to the color value of the pixel of the solid color canvas before the watermark was added.
[0051] The obtaining unit is used to obtain the correspondence between each color value and its corresponding restored color level value.
[0052] In one possible implementation, the third determining unit is specifically used to determine the contrast of the corresponding watermark restoration canvas based on the difference between the color values of the pixels with added watermarks and the color values of the pixels without added watermarks in each watermark restoration canvas.
[0053] In one possible implementation, the device further includes:
[0054] A response unit is used to respond to a screenshot operation or a screen recording operation on the terminal;
[0055] The writing unit is used to write the watermark information into an image captured by the terminal or a recorded video using a hook function.
[0056] Thirdly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the watermarking method described in this application.
[0057] Fourthly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the watermarking method described in this application.
[0058] The beneficial effects of this application are as follows:
[0059] The watermarking method, apparatus, electronic device, and storage medium provided in this application obtain watermark information to be inserted, set a transparent layer on the terminal display screen, and draw the watermark information on the transparent layer with a set transparency. In this way, by drawing the watermark information on the transparent layer of the user terminal screen, there is no need to insert watermark information on the original image, and the integrity of the original image is not changed. When the user takes a screenshot of the content of the electronic document being viewed through the terminal's screenshot software, or records a video through the screen recording software, the system hook (hook function) technology of the terminal can ensure that the image frame obtained by the screenshot or screen recording software has dark watermark information. Therefore, the watermark information can be directly restored from the image frame of the screenshot or video without the need for a large number of watermark samples for training, and the applicability is high.
[0060] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description
[0061] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0062] Figure 1 This is a structural diagram of the watermarking component provided in an embodiment of this application;
[0063] Figure 2 This is a structural diagram of the watermark restoration component provided in an embodiment of this application;
[0064] Figure 3 A schematic diagram illustrating the implementation process of the watermarking method provided in this application embodiment;
[0065] Figure 4 A schematic diagram illustrating the implementation process of setting a transparent layer on a terminal display screen, provided in an embodiment of this application;
[0066] Figure 5 This is a schematic diagram of the watermark restoration implementation process provided in the embodiments of this application;
[0067] Figure 6 A schematic diagram illustrating the implementation process for determining the correspondence between color values and restored color level values, provided in an embodiment of this application;
[0068] Figure 7(a) is an example image of an image after watermark information has been added, provided in an embodiment of this application.
[0069] Figure 7(b) is an example image of the restored watermark provided in the embodiments of this application;
[0070] Figure 8 This is a schematic diagram of the watermark processing device provided in the embodiments of this application;
[0071] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0072] To address the problems in the background art, embodiments of this application provide a watermarking method, apparatus, electronic device, and storage medium.
[0073] The preferred embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit this application. Furthermore, the embodiments and features in the embodiments of this application can be combined with each other without conflict.
[0074] like Figure 1The diagram shows the structure of a watermark adding component provided in this application embodiment. The watermark adding component can be applied to a terminal and is used to add a dark watermark. The watermark adding component may include a network module 100, an image processing module 101, and a transparent layer 102. It may also include a hook function module 103. The network module 100 obtains the watermark information to be added and sends the watermark information to the image processing module 101. The image processing module 101 determines the size of the layer window based on the size of the terminal display screen so that the layer window can completely cover the display screen. It uses a transparent brush to draw the layer window of the determined size as a transparent color to obtain a transparent layer 102. The transparent layer is set on the top layer of the terminal display screen. A brush with a set transparency is used to draw the watermark information on the transparent layer 102 tiled on the terminal display screen. The set transparency can be set according to the needs. For example, the alpha channel value of the brush color can be set to 2 so that it is visually imperceptible to the user. To prevent watermarking failure on transparent layer 102, in this embodiment, when it is detected that a user performs a screenshot operation through screenshot software on the terminal or a screen recording operation through screen recording software on the terminal, the watermark information can be directly written into the image captured by the terminal or the video recorded through hook function module 103.
[0075] like Figure 2 The diagram shows the structure of the watermark restoration component provided in this application embodiment. The watermark restoration component is used to restore a dark watermark. The watermark restoration component may include: an image processing module 201, a color value to restoration color level value mapping table (i.e., the correspondence between color values and restoration color level values) 202, and a restored image export module 203. The image processing module 201 obtains the image of the watermark to be restored, divides the image of the watermark to be restored into a corresponding number of image blocks according to a preset size, obtains the color value with the most RGB color values of the pixels in each image block, and records it as the first color value. The first color value with the most RGB color values among all the first color values is determined as the reference color value. Based on the preset color value to restoration color level value mapping table 202, the restoration color level value corresponding to the reference color value is determined. The color level of the image of the watermark to be restored is adjusted according to the determined restoration color level value to obtain the restored watermark image. The image processing module 201 sends the restored watermark image to the restored image export module 203, and the restored image export module 203 exports the restored watermark image.
[0076] It should be noted that the terminal system in this application embodiment includes the function of hook function, and can be, but is not limited to, using Windows system. This application embodiment does not limit this.
[0077] like Figure 3The diagram shown illustrates the implementation flow of the watermarking method provided in this application embodiment, which may specifically include the following steps:
[0078] S31. Obtain the watermark information to be inserted.
[0079] In specific implementation, the watermark adding component and watermark restoration component described in the embodiments of this application are installed and run on the (user) terminal. The terminal uses the watermark adding component to obtain the watermark information to be inserted. The watermark information may include the source information of the electronic document and the user information of the terminal, such as user identification information. The watermark information can be sent to the user terminal by the administrator through the management terminal.
[0080] S32. Set a transparent layer on the terminal display screen.
[0081] In practical implementation, the watermark adding component can be achieved through methods such as... Figure 4 The process shown involves setting a transparent layer on the terminal display screen, including the following steps:
[0082] S321. Determine the size of the layer window based on the size of the terminal display screen.
[0083] In practice, since a user may use multiple screens, in order to ensure that the transparent layer can cover all screens, the current number of screens on the terminal and the maximum resolution of each screen are obtained. The maximum resolution of each screen is arranged diagonally to obtain a rectangle that can cover all screen sizes. The size of this rectangle is determined as the size of the layer window, and the size of the layer window is adjusted to the size of the calculated rectangle that can cover all screen sizes.
[0084] S322. Use a transparent brush to paint the layer window with a transparent color to obtain a transparent layer.
[0085] In practice, a transparent layer is obtained based on a defined layer window. During implementation, a transparent brush can be used to draw the layer window in a transparent color to obtain a transparent layer.
[0086] S323. Set the transparent layer to the top layer of the terminal display screen.
[0087] In practice, the coordinates of the top left corner of the screen are obtained in real time. Using the top left corner coordinates as the starting point of the transparent layer, the transparent layer is set on the top layer of the terminal display screen. This ensures that the transparent layer completely covers the entire screen of the terminal.
[0088] S33. Draw the watermark information on the transparent layer with the set transparency.
[0089] In practice, the watermark adding component can use a brush with a set transparency to draw watermark information on a transparent layer. The transparency can be set according to the requirements. For example, the alpha channel value of the brush color can be set to 2. This application embodiment does not limit this.
[0090] In one implementation, when the watermarking component detects that a user is taking a screenshot of the content of an electronic document being viewed using screenshot software on the terminal, or is recording a screen using screen recording software on the terminal, the component responds to the screenshot or screen recording operation by using a hook function to write the watermark information into the captured image or recorded video. In this way, if the electronic document content is leaked due to a failure to draw the watermark on a transparent layer, the watermark information in the screenshot or recorded video can still be restored, thus achieving the purpose of tracing the leaker.
[0091] When an end user takes a screenshot or records a screen, the Windows system hook technology on the terminal can ensure that the image frames obtained by the screenshot or screen recording software contain hidden watermark information. In this way, the watermark information can be directly restored from the image frames of the screenshot or video to trace the person who leaked the screenshot or video.
[0092] Specifically, according to such Figure 5 The process shown for restoring watermark information from an image may include the following steps:
[0093] S41. Obtain the image of the watermark to be restored.
[0094] In practice, the terminal obtains the image of the watermark to be restored through the watermark restoration component. The image of the watermark to be restored is an image captured by the terminal or an image frame of a video recorded by the terminal. The terminal can use screenshot software installed on it to capture the image, or it can use screen recording software installed on it to record the video.
[0095] S42. Divide the image to be restored into a corresponding number of image blocks according to the preset size.
[0096] In specific implementation, the watermark restoration component obtains an image of the watermark to be restored and divides it into a corresponding number of image blocks according to a preset size. The preset size can be set according to actual needs. For example, it can be set to 200*200 (pixels). This application embodiment does not limit this.
[0097] S43. Obtain the first color value with the highest number of color values for each pixel in each image block.
[0098] In practice, for each image block, the watermark restoration component uses the RGB color value of the pixel with the most RGB color values in the image block, that is, the mode of the RGB color values of the pixels in the image block, as the first color value. For example, if an image block contains 70,000 pixels, and the number of pixels with the RGB color value (10,10,10) is 50,000, which is the most numerous, then the RGB color value (10,10,10) of that pixel is determined as the first color value of the image block.
[0099] S44. Determine the first color value with the largest number among all first color values as the reference color value.
[0100] In practice, each image block corresponds to a first color value, and the first color value with the largest number of all first color values, that is, the mode of the first color values, is determined as the reference color value.
[0101] S45. Determine the corresponding restored color level value of the reference color value based on the preset correspondence between color values and restored color level values.
[0102] In practice, the watermark restoration component has a pre-set correspondence between color values and restored color level values (that is, the aforementioned color value and restored color level value mapping table), and queries the restored color level value corresponding to the reference color value from the correspondence between color values and restored color level values.
[0103] As one possible implementation, the watermark restoration component can be achieved through, for example... Figure 6 The process shown determines the correspondence between color values and the reproduced color level values:
[0104] S51. Draw the set watermark on the solid color canvas corresponding to each color value with the set transparency to obtain the corresponding solid color canvas with added watermark.
[0105] In practice, the values of R, G, and B are all in the range of 0 to 255. The corresponding solid color canvas is set with RGB color values from (0,0,0) to (255,255,255). This way, a 255-color canvas can be obtained. 3 Each pixel on a solid-color canvas has the same color value, and these pixels are respectively in the 255... 3 A watermark is drawn on a solid-color canvas with set transparency, resulting in a corresponding 255. 3 A solid color canvas for adding a watermark. The transparency setting is consistent with the transparency used by the watermark adding component when adding the watermark, which will not be elaborated here. The watermark can be any text information.
[0106] S52. For each solid color canvas after adding a watermark, adjust the color level of the solid color canvas with the added watermark according to each color level value to obtain each corresponding restored watermark canvas.
[0107] In practice, for each solid color canvas with a set watermark, the following steps are performed:
[0108] For the watermarked solid color canvas, iterate through each color level value in the color level table to restore the watermark. The color level includes white point, gray point, and black point. A color level value consists of (white point value, gray point value, black point value). The white point value, gray point value, and black point value all range from 0 to 255. Therefore, the color level table contains 255 values. 3 Each color level value represents the brightness of an image.
[0109] Specifically, the color level values of the solid color canvas with the added watermark are adjusted to the respective color level values in the color level table to obtain the corresponding restored watermark canvases of the solid color canvas with the added watermark.
[0110] S53. Determine the contrast between the color values of the pixels with added watermarks and the color values of the pixels without added watermarks in each restored watermark canvas.
[0111] In practice, the contrast between the color values of watermarked pixels and unwatermarked pixels in each restored watermark canvas can be determined using the following methods:
[0112] The contrast of the corresponding watermark-restored canvas is determined based on the difference between the color values of the pixels with watermarks and the pixels without watermarks in each watermark-restored canvas.
[0113] Specifically, for each restored watermark canvas of any solid color canvas with added watermark, the contrast of the restored watermark canvas is determined based on the difference between the color values of the pixels with added watermark and the color values of the pixels without added watermark.
[0114] In practice, the difference between the color values of the pixels with added watermarks and the color values of the pixels without added watermarks on the restored watermark canvas can be determined as the contrast between the two, which is the contrast of the restored watermark canvas.
[0115] The difference between the color values of pixels with added watermarks and pixels without watermarks in the restored watermark canvas can be calculated using the following formula:
[0116]
[0117] Where D represents the difference between the color values (r0, g0, b0) of the pixels with watermark added and the color values (r1, g1, b1) of the pixels without watermark added in the restored watermarked canvas. In other words, D represents the contrast between the color values of the pixels with watermark added and those without watermark added in the restored watermarked canvas. This formula can be understood as: calculating the distance difference between two points (r0, g0, b0) and (r1, g1, b1) in three-dimensional space, using R, G, and B as the three vector axes.
[0118] The above calculation of the difference between the color values of pixels with added watermarks and pixels without added watermarks on the restored watermark canvas can also use other distance formulas, such as Euclidean distance, Mahalanobis distance, etc., which are not limited in this embodiment.
[0119] S54. Select a color level value from the color level values corresponding to the restored watermark canvas with a contrast greater than the set threshold, and use it as the restored color level value corresponding to the color value of the pixel of the solid color canvas before adding the watermark.
[0120] In practice, the greater the contrast between the color values of pixels with added watermarks and those without watermarks on the restored watermark canvas, the more clearly the watermark information will be displayed. Based on this, any color level value can be selected from the color level values corresponding to the restored watermark canvas with a contrast greater than a set threshold as the restored color level value corresponding to the color values of the pixels in the solid color canvas before the watermark was added. The set threshold can be adjusted according to requirements, ensuring that the watermark information is clearly displayed.
[0121] As a preferred implementation, the color level value corresponding to the restored watermarked canvas can be selected as the restored color level value corresponding to the color value of the pixel in the original solid color canvas when the contrast between the pixel with the added watermark and the pixel without the added watermark is maximized. For example, after adding a watermark to a solid color canvas where all pixel color values are (10,10,10), if the contrast between the pixel with the added watermark and the pixel without the added watermark is maximized when the color level value (244,1,255) ((white point value, gray point value, black point value)) is adjusted, then the color level value (244,1,255) can be used as the restored color level value corresponding to the color value (10,10,10).
[0122] S55. Based on each color value and its corresponding restored color level value, obtain the correspondence between the color value and the restored color level value.
[0123] In practice, after obtaining the restored color level value corresponding to each color value, the correspondence between each color value and the restored color level value is stored.
[0124] S46. Adjust the color levels of the image to be restored according to the restored color level values to obtain the restored watermark image.
[0125] In practice, the watermark restoration component adjusts the color level of the image to be restored to the restored color level value corresponding to the queried reference color value, thus obtaining the image after watermark restoration.
[0126] In one example, the image after adding watermark information is shown in Figure 7(a), which is imperceptible to the naked eye. The image after restoring the watermark is shown in Figure 7(b), from which the added watermark information "test" can be clearly shown.
[0127] In this embodiment of the application, when adding a watermark, the watermark information is drawn on a transparent layer on the user terminal screen without changing the original information of the image. Even if the image is cropped or compressed and stretched, the watermark information can still be successfully restored.
[0128] The watermarking method provided in this application embodiment involves a terminal obtaining watermark information to be inserted through a watermark adding component, setting a transparent layer on the terminal display screen, and drawing the watermark information on the transparent layer with a set transparency. This way, by drawing the watermark information on the transparent layer of the user's terminal screen, the watermark information is not inserted into the original image, thus preserving the integrity of the original image. When a user captures a screenshot of the content of a viewed electronic document using screenshot software, or records video using screen recording software, the terminal's system hook technology ensures that the image frames obtained by the screenshot or screen recording software carry a dark watermark. Furthermore, the terminal obtains the image of the watermark to be restored through a watermark restoration component. The original watermark image is divided into a corresponding number of image blocks according to a preset size. The first color value with the largest number of color values of pixels in each image block is obtained. The first color value with the largest number of colors among all the first color values is determined as the reference color value. Based on the preset correspondence between color values and restored color level values, the restored color level value corresponding to the reference color value is determined. The color level of the image to be restored is adjusted according to the restored color level value to obtain the restored watermark image. In this way, watermark information can be directly restored from the image frame of the screenshot or video by matching the restored color level value with the color value. It does not require a large number of watermark samples for training, has high applicability, high watermark restoration efficiency, and does not consume too many computing resources.
[0129] Based on the same inventive concept, this application also provides a watermark processing device. Since the principle of the watermark processing device in solving the problem is similar to that of the watermark processing method, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0130] like Figure 8 As shown, it is a schematic diagram of the structure of the watermark processing device provided in the embodiment of this application, which may include:
[0131] The first acquisition unit 61 is used to acquire the watermark information to be inserted;
[0132] Setting unit 62 is used to set a transparent layer on the terminal display screen;
[0133] The first watermark adding unit 63 is used to draw the watermark information on the transparent layer with a set transparency.
[0134] In one possible implementation, the setting unit 62 is specifically used to determine the size of the layer window based on the size of the terminal display screen; draw the layer window in a transparent color using a transparent brush to obtain a transparent layer; and set the transparent layer on the top layer of the terminal display screen.
[0135] In one possible implementation, the device further includes:
[0136] The second acquisition unit is used to acquire an image of the watermark to be restored, wherein the image of the watermark to be restored is an image captured by the terminal or an image frame of a video recorded by the terminal;
[0137] The segmentation unit is used to divide the image of the watermark to be restored into a corresponding number of image blocks according to a preset size;
[0138] The third acquisition unit is used to acquire the first color value with the largest number of color values in each image block;
[0139] The first determining unit is used to determine the first color value with the largest number among all first color values as the reference color value;
[0140] The second determining unit is used to determine the restored color level value corresponding to the reference color value based on the preset correspondence between color value and restored color level value;
[0141] The watermark restoration unit is used to adjust the color level of the image to be restored according to the restored color level value to obtain the restored watermark image.
[0142] In one possible implementation, the device further includes:
[0143] The second watermark adding unit is used to draw the set watermark on the solid color canvas corresponding to each color value with the set transparency, so as to obtain the corresponding solid color canvas with added watermark.
[0144] The color level adjustment unit is used to adjust the color level of each solid color canvas after watermarking is added according to each color level value, so as to obtain each corresponding restored watermark canvas.
[0145] The third determining unit is used to determine the contrast between the color values of the pixels with added watermarks and the color values of the pixels without added watermarks in each restored watermark canvas.
[0146] The selection unit is used to select a color level value from the color level values corresponding to the restored watermark canvas with a contrast greater than a set threshold, and use it as the restored color level value corresponding to the color value of the pixel of the solid color canvas before the watermark was added.
[0147] The obtaining unit is used to obtain the correspondence between each color value and its corresponding restored color level value.
[0148] In one possible implementation, the third determining unit is specifically used to determine the contrast of the corresponding watermark restoration canvas based on the difference between the color values of the pixels with added watermarks and the color values of the pixels without added watermarks in each watermark restoration canvas.
[0149] In one possible implementation, the device further includes:
[0150] A response unit is used to respond to a screenshot operation or a screen recording operation on the terminal;
[0151] The writing unit is used to write the watermark information into an image captured by the terminal or a recorded video using a hook function.
[0152] Based on the same technical concept, this application also provides an electronic device 700, referring to... Figure 9 As shown, the electronic device 700 is used to implement the watermarking processing method described in the above-described method embodiments. The electronic device 700 in this embodiment may include: a memory 701, a processor 702, and a computer program, such as a watermarking processing program, stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps in the various watermarking processing method embodiments described above.
[0153] This application embodiment does not limit the specific connection medium between the memory 701 and the processor 702 described above. This application embodiment... Figure 9 The memory 701 and the processor 702 are connected via a bus 703, and the bus 703 is in Figure 9The connections between other components are shown in bold and are for illustrative purposes only, not as limiting information. The bus 703 can be divided into address bus, data bus, control bus, etc. For ease of illustration, Figure 9 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0154] Memory 701 may be volatile memory, such as random-access memory (RAM); memory 701 may also be non-volatile memory, such as read-only memory, flash memory, hard disk drive (HDD), or solid-state drive (SSD); or memory 701 may be any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but is not limited thereto. Memory 701 may be a combination of the above-described memories.
[0155] Processor 702 is used to implement watermarking processing methods in various exemplary embodiments of this application.
[0156] This application also provides a computer-readable storage medium storing computer-executable instructions required to execute the processor, including a program required to execute the processor.
[0157] In some possible implementations, various aspects of the watermarking method provided in this application can also be implemented as a program product, which includes program code that, when the program product is run on an electronic device, causes the electronic device to perform the steps of the watermarking method according to the various exemplary embodiments of this application described above.
[0158] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0159] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (devices), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0160] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0161] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0162] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0163] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A watermark processing method, characterized in that, include: Get the watermark information to be inserted; Set a transparent layer on the terminal display screen; The watermark information is drawn on the transparent layer with a set transparency. When a screenshot or screen recording operation is detected on the terminal, the method further includes: Obtain the image of the watermark to be restored; wherein the image of the watermark to be restored is an image captured by the terminal, or an image frame of a video recorded by the terminal; The image of the watermark to be restored is divided into a corresponding number of image blocks according to a preset size; For each image block, obtain the first color value that has the highest number of color values among the pixels. The first color value with the highest quantity among all first color values is determined as the reference color value; The corresponding restored color level value of the reference color value is determined based on the preset correspondence between color values and restored color level values; wherein, the preset correspondence between color values and restored color level values is constructed by setting solid color canvases with different color levels; The color levels of the image to be restored are adjusted according to the restored color level values to obtain the image with the restored watermark.
2. The method as described in claim 1, characterized in that, Setting a transparent layer on the terminal display screen includes: The size of the layer window is determined based on the size of the terminal display screen. Use a transparent brush to paint the layer window with a transparent color to obtain a transparent layer; The transparent layer is set on the top layer of the terminal display screen.
3. The method as described in claim 1, characterized in that, Also includes: Draw the set watermark on the solid color canvas corresponding to each color value with the set transparency to obtain the corresponding solid color canvas with added watermark; For each solid color canvas after watermarking, the color level of the solid color canvas after watermarking is adjusted according to each color level value to obtain each corresponding restored watermark canvas. Determine the contrast between the color values of the pixels with added watermarks and the color values of the pixels without watermarks in each restored watermark canvas. Select a color level value from the color level values corresponding to the restored watermark canvas with a contrast greater than the set threshold, and use it as the restored color level value corresponding to the color value of the pixel of the solid color canvas before adding the watermark. The correspondence is obtained based on each color value and its corresponding restored color level value.
4. The method as described in claim 3, characterized in that, Determine the contrast between the color values of watermarked pixels and unwatermarked pixels in each restored watermark canvas, specifically including: The contrast of the corresponding watermark-restored canvas is determined based on the difference between the color values of the pixels with watermarks and the pixels without watermarks in each watermark-restored canvas.
5. The method as described in claim 1, characterized in that, Also includes: In response to a screenshot or screen recording operation on the terminal; The watermark information is written into the image captured by the terminal or the video recorded using a hook function.
6. A watermark processing device, characterized in that, include: The first acquisition unit is used to acquire the watermark information to be inserted; The setting unit is used to set a transparent layer on the terminal display screen; The first watermark adding unit is used to draw the watermark information on the transparent layer with a set transparency. The second acquisition unit is used to acquire an image of the watermark to be restored when a screenshot operation or screen recording operation is detected on the terminal; wherein the image of the watermark to be restored is an image captured by the terminal or an image frame of a video recorded by the terminal. The segmentation unit is used to divide the image of the watermark to be restored into a corresponding number of image blocks according to a preset size; The third acquisition unit is used to acquire the first color value with the largest number of color values in each image block; The first determining unit is used to determine the first color value with the largest number among all first color values as the reference color value; The second determining unit is used to determine the restored color level value corresponding to the reference color value based on the preset correspondence between color values and restored color level values; wherein, the preset correspondence between color values and restored color level values is constructed by setting solid color canvases with different color levels; The watermark restoration unit is used to adjust the color level of the image to be restored according to the restored color level value to obtain the restored watermark image.
7. The apparatus as claimed in claim 6, characterized in that, The setting unit is specifically used to determine the size of the layer window based on the size of the terminal display screen; to draw the layer window in a transparent color using a transparent brush to obtain a transparent layer; and to set the transparent layer on the top layer of the terminal display screen.
8. The apparatus as claimed in claim 6, characterized in that, Also includes: The second watermark adding unit is used to draw the set watermark on the solid color canvas corresponding to each color value with the set transparency, so as to obtain the corresponding solid color canvas with added watermark. The color level adjustment unit is used to adjust the color level of each solid color canvas after watermarking is added according to each color level value, so as to obtain each corresponding restored watermark canvas. The third determining unit is used to determine the contrast between the color values of the pixels with added watermarks and the color values of the pixels without added watermarks in each restored watermark canvas. The selection unit is used to select a color level value from the color level values corresponding to the restored watermark canvas with a contrast greater than a set threshold, and use it as the restored color level value corresponding to the color value of the pixel of the solid color canvas before the watermark was added. The obtaining unit is used to obtain the correspondence between each color value and its corresponding restored color level value.
9. The apparatus as claimed in claim 8, characterized in that, The third determining unit is specifically used to determine the contrast of the corresponding watermark restoration canvas based on the difference between the color values of the pixels with added watermarks and the color values of the pixels without added watermarks in each watermark restoration canvas.
10. The apparatus as claimed in claim 6, characterized in that, Also includes: A response unit is used to respond to a screenshot operation or a screen recording operation on the terminal; The writing unit is used to write the watermark information into an image captured by the terminal or a recorded video using a hook function.
11. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the watermarking method as described in any one of claims 1 to 5.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps of the watermarking method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Screen watermark generation method, device and equipment
CN111310134A