Watermarking methods and devices
By generating multiple sample watermark images and training a watermark detection model, the reliability problem of machine learning models in recognizing variable watermarks is solved, and more efficient watermark detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING YOUKUN TECH CO LTD
- Filing Date
- 2023-08-09
- Publication Date
- 2026-05-26
Smart Images

Figure CN116824590B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to a watermarking method and apparatus. Background Technology
[0002] Currently, machine learning models are often used to detect the presence of watermarks in images. For example, a machine learning model can be trained using sample images with watermarks, enabling it to identify watermark regions in the image being tested.
[0003] In this approach, the watermark is usually one that already exists on the Internet. However, in reality, watermarks on images vary greatly depending on user needs. This can cause machine learning models to fail to recognize new watermarks, resulting in low reliability of watermark detection.
[0004] Therefore, there is an urgent need for a technical solution that can improve the reliability of watermark detection. Summary of the Invention
[0005] In view of this, this application provides a watermark processing method and apparatus to solve the technical defects of low reliability in current watermark detection, as follows:
[0006] A watermarking method, comprising:
[0007] Multiple background images are obtained; any two of the background images have different parameter values in at least one image parameter.
[0008] The initial watermark image is processed according to the image parameters to obtain a sample watermark image; any two sample watermark images have different parameter values for at least one watermark parameter.
[0009] The sample watermark image is added to the background image to obtain the sample image;
[0010] The watermark detection model is trained using the sample image and the sample watermark image so that the watermark detection model can detect the watermark region in the target image.
[0011] The above method, preferably, involves processing the initial watermark image according to the image parameters to obtain a sample watermark image, including:
[0012] According to the parameter range corresponding to each watermark parameter, the initial parameter value of the watermark parameter is obtained;
[0013] Based on the image parameters, the initial parameter values of the watermark parameters are adjusted to obtain the target parameter values of the watermark parameters;
[0014] According to the target parameter values, the initial watermark image is transformed to obtain a sample watermark image.
[0015] In the above method, preferably, the image parameters include at least one of: illumination parameters, hue parameters, contrast parameters, and content parameters;
[0016] The watermark parameters include at least one of the following: position parameter, color parameter, size parameter, transparency parameter, and rotation parameter.
[0017] The above method, preferably, involves adding the sample watermark image to the background image to obtain the sample image, including:
[0018] Based on the image content in the background image, a watermark area is determined in the background image; wherein, the location of the watermark area in the background image matches the location of the target content in the background image, and the target content is the content in the image content that meets the conditions for adding a watermark;
[0019] Add the sample watermark image to the watermark area.
[0020] In the above method, preferably, the initial watermark image includes at least one watermark symbol; the watermark symbol is a character or an icon; the watermark symbol is obtained from multiple data sources;
[0021] The process of processing the initial watermark image according to the image parameters to obtain a sample watermark image includes:
[0022] Based on the image parameters, the watermark parameters of at least one of the watermark symbols in the initial watermark image are adjusted to obtain a sample watermark image;
[0023] Wherein, when the sample watermark image includes characters and icons, the characters and icons in the sample watermark image have different parameter values for at least one of the watermark parameters.
[0024] Preferably, the above method further includes:
[0025] Region detection is performed on the target image to obtain the target region in the target image;
[0026] The watermark detection model is used to detect the watermark in the target area to obtain the watermark area in the target area.
[0027] The above method, preferably, involves using the watermark detection model to perform watermark detection on the target region to obtain the watermark region within the target region, including:
[0028] The target region is rotated by a target angle to obtain the region to be tested; the target angle is determined based on the watermark detection result of the watermark detection model on the historical image of the rotated test angle.
[0029] The watermark detection model is used to detect the watermark in the area to be tested, so as to obtain the watermark area in the target area.
[0030] In the above method, preferably, the target region is a face image region containing a human face;
[0031] The method further includes:
[0032] The face image region is segmented to obtain a segmentation result, the segmentation result containing at least one segmented region, and each segmented region contains a part of the face;
[0033] Based on the segmented region, the watermark region is parsed to obtain a first parsing result and / or a second parsing result;
[0034] The first analysis result indicates whether the segmented region is detected as the watermark symbol in the watermark region; the second analysis result indicates whether the watermark region occludes the segmented region.
[0035] The above method, preferably, includes:
[0036] If the intersection-union ratio of the first watermark symbol and the first segmentation region in the watermark region is greater than or equal to the first threshold and the size of the first watermark symbol is different from the size of the second watermark symbol, the first parsing result indicates that the first segmentation region is detected as the first watermark symbol; the second watermark symbol is the watermark symbol adjacent to the first watermark symbol in the watermark region.
[0037] If the ratio between the overlapping area of the watermark area and the second segmented area and the second segmented area is greater than or equal to the second threshold and the transparency of the watermark area meets the occlusion condition, the second analysis result indicates that the watermark area occludes the second segmented area.
[0038] A watermark processing device, comprising:
[0039] A background acquisition unit is used to acquire multiple background images; any two of the background images have different parameter values in at least one image parameter.
[0040] A watermark processing unit is used to process an initial watermark image according to the image parameters to obtain a sample watermark image; any two sample watermark images have different parameter values for at least one watermark parameter.
[0041] A watermark adding unit is used to add the sample watermark image to the background image to obtain a sample image;
[0042] The model training unit is used to train the watermark detection model using the sample image and the sample watermark image, so that the watermark detection model can detect the watermark region in the target image.
[0043] As can be seen from the above technical solution, in the watermark processing method and apparatus disclosed in this application, after obtaining multiple background images with different parameter values for image parameters, the initial watermark image is processed according to the image parameters of these background images to obtain sample watermark images. These sample watermark images have different parameter values for watermark parameters. Therefore, the sample watermark images are added to the background images, resulting in sample images with diverse watermarks for different backgrounds. These sample images and sample watermark images are then used to train a watermark detection model, enabling the model to detect watermark regions in the target image. It is evident that in this application, the watermark image is processed based on the image parameters of various background images, and then the processed watermark image is added to the background image, resulting in a variety of sample images. The watermark images in these sample images are diverse and related to the background images. Therefore, these sample images are used to train the watermark detection model, enabling it to detect a variety of watermarks, thereby improving the reliability of watermark detection. Attached Figure Description
[0044] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0045] Figure 1 A flowchart of a watermarking method provided in Embodiment 1 of this application;
[0046] Figure 2 This is a partial flowchart of a watermarking method provided in Embodiment 1 of this application;
[0047] Figure 3 This is an example diagram illustrating the construction of a sample watermark image based on an initial watermark image in an embodiment of this application.
[0048] Figure 4 and Figure 5 These are example images of sample watermark images from embodiments of this application;
[0049] Figure 6 and Figure 7These are partial flowcharts of a watermarking method provided in Embodiment 1 of this application;
[0050] Figure 8 This is a schematic diagram of the structure of a watermark processing device provided in Embodiment 2 of this application;
[0051] Figure 9 This is another structural schematic diagram of a watermark processing device provided in Embodiment 2 of this application;
[0052] Figure 10 This is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of this application. Detailed Implementation
[0053] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0054] refer to Figure 1 The diagram shown is a flowchart illustrating the implementation of a watermarking method according to Embodiment 1 of this application. This method can be applied to electronic devices capable of image processing, such as computers or servers. The technical solution in this embodiment is mainly used to improve the reliability of watermark detection.
[0055] Specifically, the method in this embodiment may include the following steps:
[0056] Step 101: Obtain multiple background images; any two background images must have different parameter values for at least one image parameter.
[0057] In this embodiment, background images can be acquired from various business scenarios, including background images with high complexity. For example, background images can be acquired from real environments across the country using various image acquisition devices such as cameras; background images can be acquired from various indoor environments, etc., to meet the needs of complex backgrounds.
[0058] Specifically, image parameters may include at least one of the following: lighting parameters, hue parameters, contrast parameters, and content parameters. Content parameters may include parameters such as the type of content contained in the background image, and the size or location of the content contained in the background image.
[0059] For example, in this embodiment, multiple cameras are used to capture images of real environments and various indoor spaces under different lighting, color tones and contrasts, thereby obtaining multiple background images with different parameter values in at least one image parameter.
[0060] Step 102: Process the initial watermark image according to the image parameters to obtain sample watermark images; any two sample watermark images have different parameter values for at least one watermark parameter.
[0061] The watermark parameters may include at least one of the following: position parameter, color parameter, size parameter, transparency parameter, and rotation parameter. The position parameter refers to the location of the initial watermark image to which it is added, and the rotation parameter refers to the degree of rotation of the initial watermark image relative to the background image. The size parameter may include length and height.
[0062] Specifically, in this embodiment, the parameter values of one or more watermark parameters of the initial watermark image can be adjusted according to the image parameters to obtain multiple sample watermark images. Thus, by adjusting the watermark parameters, the obtained sample watermark images become more diverse.
[0063] For example, by adjusting the transparency parameter of one initial watermark image based on the illumination parameters of the background image, multiple sample watermark images with different transparency parameters can be obtained; by adjusting the color parameter of one initial watermark image based on the hue parameters of the background image, multiple sample watermark images with different color parameters can be obtained; by adjusting the color parameter of one initial watermark image based on the illumination and contrast parameters of the background image, multiple sample watermark images with different color parameters can be obtained; by adjusting the position and rotation parameters of one initial watermark image based on the content parameters of the background image, such as the content area position, multiple sample watermark images with different position and rotation parameters can be obtained; by adjusting the size parameter of one initial watermark image based on the content parameters of the background image, such as the content area size, multiple sample watermark images with different size parameters can be obtained; and so on, a wide variety of sample watermark images can be obtained.
[0064] In one implementation, the image parameters used to process the initial watermark image in this embodiment can be the image parameters of all image regions in the background image, or the image parameters of a local region in the background image. The local region can be the area in the background image whose image content satisfies the watermark reference conditions.
[0065] For example, watermark reference conditions could be: the content belongs to a specific physical object, such as a building, text, or graphic. Alternatively, watermark reference conditions could be: the content does not belong to a specific physical object, such as something other than a human face, a building, or text.
[0066] Step 103: Add the sample watermark image to the background image to obtain the sample image.
[0067] In one implementation, this embodiment can add the sample watermark image to a preset watermark area in the background image according to a preset target position. The watermark area is the area in the background image corresponding to the target position, such as the middle area or the lower right corner area, thereby obtaining the sample image.
[0068] For example, in this embodiment, a sample watermark image is added to the middle area of the background image to obtain a sample image.
[0069] In another implementation, in this embodiment, the target position is determined in the background image according to a random algorithm, and then the sample watermark image is added to the watermark area corresponding to the target position in the background image, thereby obtaining the sample image.
[0070] For example, in this embodiment, the sample watermark image is randomly added to a local area of the background image to obtain the sample image.
[0071] In another implementation, this embodiment can determine the watermark region in the background image based on the image content in the background image; wherein the location of the watermark region in the background image matches the location of the target content in the background image, and the target content is the content in the image content that meets the watermark addition conditions; then, the sample watermark image is added to the watermark region in the background image.
[0072] The conditions for adding a watermark can be: the content belongs to a specific physical object, such as a building, text, or graphic.
[0073] For example, in this embodiment, the watermark area is determined based on the image content contained in the background image. For instance, the area where the building is located in the background image is determined as the watermark area. Then, the sample watermark image is added to the watermark area so that the sample watermark image at least partially obscures the building.
[0074] Alternatively, the conditions for adding a watermark can be: the content does not belong to a specific physical object, such as a non-human face, a non-building, or a non-text.
[0075] For example, in this embodiment, the watermark area is determined based on the image content contained in the background image. For instance, the non-face area in the background image is determined as the watermark area. Then, the sample watermark image is added to the non-face area in the background image so that the sample watermark image does not obscure the face area.
[0076] In another implementation, in this embodiment, the sample image watermark image can be added to the watermark area of the background image according to the position parameter in the watermark parameter of the sample watermark image to obtain the sample image.
[0077] For example, the watermark parameters of the sample watermark image in this embodiment include a position parameter, and the position parameter represents the location of the building in the background image. Based on this, in this embodiment, the sample watermark image is added to the watermark area corresponding to the position parameter in the background image according to the position parameter to obtain the sample image.
[0078] Step 104: Train the watermark detection model using the sample image and the sample watermark image so that the watermark detection model can detect the watermark region in the target image.
[0079] The target image is the image that needs to be watermarked.
[0080] Specifically, in this embodiment, a sample image can be used as input and a sample watermark image as output to train the watermark detection model. For example, a sample image is input into the watermark detection model to obtain the predicted region output by the model. The predicted region is compared with the sample watermark image in the sample image input into the model to obtain the comparison result. The model parameters in the watermark detection model are adjusted based on the comparison result. Then, the next sample image is input into the watermark detection model after the model parameters have been adjusted to obtain a new predicted region output by the model. This predicted region is compared with the sample watermark image in the sample image input into the model to obtain a new comparison result. The model parameters in the watermark detection model are adjusted again based on this comparison result. This process is repeated until the training conditions are met.
[0081] The training conditions may include at least one of the following:
[0082] The number of training iterations for the watermark detection model has reached the threshold.
[0083] Both the sample images and the sample watermark images have been used to train the watermark detection model;
[0084] The comparison results corresponding to the watermark detection model indicate that the similarity between the predicted region and the watermark region is greater than or equal to the similarity threshold.
[0085] As can be seen from the above technical solution, in the watermarking method provided in Embodiment 1 of this application, after obtaining multiple background images with different parameter values for image parameters, the initial watermark image is processed according to the image parameters of these background images to obtain sample watermark images. These sample watermark images have different parameter values for watermark parameters. Therefore, the sample watermark images are added to the background images, resulting in sample images with diverse watermarks for different backgrounds. These sample images and sample watermark images are then used to train a watermark detection model, enabling the model to detect watermark regions in the target image. It is evident that in this embodiment, the watermark image is processed according to the image parameters of various background images, and then the processed watermark image is added to the background image, resulting in a variety of sample images. The watermark images in these sample images are diverse and related to the background images. Therefore, training the watermark detection model using these sample images enables the model to detect a variety of watermarks, thereby improving the reliability of watermark detection.
[0086] In one implementation, step 102, when processing the initial watermark image according to image parameters to obtain the sample watermark image, can be achieved in the following way: Figure 2 As shown:
[0087] Step 201: Obtain the initial parameter values of the watermark parameters according to the parameter range corresponding to each watermark parameter.
[0088] In this embodiment, the parameter range for each watermark parameter can be pre-set according to requirements, and the parameter range for each watermark parameter can contain multiple parameter values. The parameter range for each watermark parameter can be represented by an upper limit value and a lower limit value. For example, the parameter range for the position parameter can be represented by an upper limit value and a lower limit value for the coordinates; the parameter range for the color parameter can be represented by the upper limit value and the lower limit value for the coordinates of the red RGB value, green RGB value, and blue RGB value; the parameter range for the size parameter can be represented by an upper limit value for the length, a lower limit value for the length, an upper limit value for the height, and a lower limit value for the height; the parameter range for the transparency parameter can be represented by an upper limit value and a lower limit value for the transparency; and the parameter range for the rotation parameter can be represented by an upper limit value and a lower limit value for the rotation.
[0089] Based on this, in this embodiment, one or more parameter values can be randomly selected from the parameter range corresponding to the watermark parameter as the initial parameter values of the watermark parameter.
[0090] For example, taking color parameters as an example, multiple values are randomly selected between the upper and lower limits of the red RGB value, green RGB value, and blue RGB value, and then combined separately to obtain the parameter values of multiple color parameters.
[0091] Taking the transparency parameter as an example, multiple transparency values can be selected between the upper and lower limits of transparency to obtain multiple transparency parameter values;
[0092] Taking the rotation parameter as an example, multiple rotation values can be selected between the upper and lower limits of rotation to obtain multiple rotation parameter values.
[0093] Step 202: Adjust the initial parameter values of the watermark parameters according to the image parameters to obtain the target parameter values of the watermark parameters.
[0094] Specifically, in this embodiment, each initial parameter value of each watermark parameter can be adjusted according to the lighting parameters, hue parameters, contrast parameters, and content parameters of the background image to obtain multiple target parameter values on each watermark parameter that match the background image.
[0095] Taking color parameters as an example, in this embodiment, each initial parameter value of the color parameters is appropriately adjusted according to the hue parameters of the background image so that the obtained target parameter value matches the hue parameters of the background image.
[0096] Specifically, in this embodiment, a machine learning model can be used to learn the image parameters of the background image and the parameter values of the matching watermark parameters. Thus, the image parameters of the background image can be processed by the machine learning model to output the parameter values of the matching watermark parameters. Based on this, the initial parameter values of the corresponding watermark parameters are adjusted to obtain the target parameter values of each watermark parameter that match the background image.
[0097] Step 203: Perform image transformation on the initial watermark image according to the target parameter value to obtain the sample watermark image.
[0098] In this embodiment, the parameter values of the watermark parameters in the initial watermark image can be adjusted to the corresponding target parameter values to obtain the sample watermark image.
[0099] In one implementation, each watermark parameter corresponds to multiple target parameter values. In this embodiment, the target parameter values corresponding to the multiple watermark parameters can be arranged and combined to obtain a combination of multiple watermark parameters. Any two combinations have different target parameter values for at least one watermark parameter. Based on this, the initial watermark image is transformed according to the target parameter values of the watermark parameters in each combination. That is, the image parameters of the initial watermark image are adjusted to the target parameter values of the watermark parameters in the combination to obtain the sample watermark image corresponding to each combination.
[0100] For example, in this embodiment, according to the target parameter values of the position parameter, color parameter, size parameter, transparency parameter, and rotation parameter in the combination, the image parameters in an initial watermark image are adjusted to the corresponding parameter values to obtain the sample watermark image corresponding to the combination. Based on this, based on the target parameter values of each watermark parameter in each combination, the image parameters in multiple initial watermark images are adjusted to the corresponding parameter values to obtain the sample watermark image corresponding to each combination for each initial watermark image, such as... Figure 3 As shown in the image.
[0101] In one implementation, there can be multiple initial watermark images, and these initial watermark images can be obtained from multiple data sources.
[0102] Specifically, in this embodiment, multiple images can be extracted from multiple data sources to obtain multiple initial watermark images.
[0103] In another implementation, there can be multiple initial watermark images, each of which can contain at least one watermark symbol, which can be a character or an icon, and these watermark symbols can be obtained from multiple data sources.
[0104] Specifically, in this embodiment, multiple different characters and icons are extracted from multiple data sources. These watermark characters differ in content and / or in the parameter values of the watermark parameters. For example, the red "S", the green "S", and the "M" are all different watermark characters. Based on this, this embodiment selects one or more watermark symbols from these watermark symbols to form an initial watermark image, thereby obtaining multiple initial watermark images. At least one watermark symbol differs between any two initial watermark images. The difference in watermark symbols is specifically manifested in: different content of the watermark symbols, and / or, different parameter values of the watermark symbols in at least one watermark parameter.
[0105] Based on this, in step 102, when processing the initial watermark image according to the image parameters to obtain the sample watermark image, it can be achieved in the following way:
[0106] Based on the image parameters, the watermark parameters of at least one watermark symbol in the initial watermark image are adjusted to obtain a sample watermark image.
[0107] For example, given an initial watermarked image, the parameter values of one or more watermark symbols are adjusted according to the image parameters to obtain multiple sample watermarked images. For each initial watermarked image, sample watermarked images containing different watermark symbols can be obtained, and at least one watermark symbol differs between any two sample watermarked images, or at least one watermark symbol differs in the parameter value of at least one watermark parameter.
[0108] Specifically, when the sample watermark image includes characters and icons, the characters and icons in the sample watermark image have different parameter values for at least one watermark parameter.
[0109] For example, the sample watermark image contains multiple characters and an icon, with the characters and the icon having different heights, such as... Figure 4 As shown; or, the color of the characters and the color of the icons are different, such as... Figure 5 As shown in the figure. Different characters can be the same in length, height, color, and transparency, or they can be different in at least one of these aspects.
[0110] In one implementation, this embodiment can use a watermark detection model to detect watermarks in the target image in order to obtain the watermark region in the target image.
[0111] To reduce the amount of data computation, another implementation method in this embodiment may include the following steps, such as... Figure 6 As shown:
[0112] Step 601: Perform region detection on the target image to obtain the target region in the target image;
[0113] Step 602: Use a watermark detection model to detect watermarks in the target area to obtain the watermarked area in the target area.
[0114] In this model, the target region is the area in the target image that meets the detection criteria, while other areas in the target image are considered as not being watermarked. The detection criteria are: the area containing specific content. For example, the target region is the area containing a face in the target image. Based on this, this embodiment uses a watermark detection model to perform watermark detection only on the target region in the target image, and not on other regions. Thus, by reducing the image areas involved in watermark detection, the data computation load of the watermark detection model is reduced, thereby improving efficiency.
[0115] Based on the above implementation method, in real-world scenarios, watermarks may be rotated to a certain angle. To improve the reliability of detection, in step 602, when using the watermark detection model to detect the watermark in the target area to obtain the watermark area in the target area, it can be achieved in the following way:
[0116] First, the target area is rotated by a target angle to obtain the area to be tested; the target angle is determined based on the watermark detection results of the watermark detection model on historical images of rotated test angles.
[0117] Then, a watermark detection model is used to detect the watermark in the area to be tested in order to obtain the watermark area in the target area.
[0118] The test angle is a preset angle that can be set according to requirements, such as ±5 degrees, 10 degrees, 15 degrees, 20 degrees, 25 degrees, 30 degrees, 35 degrees, 40 degrees, or 45 degrees. The detection result can include the prediction probability corresponding to the predicted region output by the watermark detection model for watermark detection on historical images. Specifically, the watermark detection model outputs a predicted region and its corresponding prediction probability. The higher the prediction probability, the higher the reliability of the predicted region as a watermark region. Based on this, in this embodiment, after performing watermark detection on the historical image rotated by the test angle according to the watermark detection model, if the prediction probability in the detection result is less than or equal to an adjustment threshold, the test angle is adjusted, such as increasing or decreasing. After multiple adjustments to the test angle until the prediction probability in the detection result is greater than the adjustment threshold, the test angle is used as the target angle. The target region in the target image belonging to the same batch as the historical image is rotated by the target angle, and then the watermark detection model is used to perform watermark detection on the obtained predicted region to obtain a watermark region with a higher prediction probability, thereby improving the reliability of the detection.
[0119] Based on the above implementation method, the target area is a facial image region containing a human face. Therefore, this embodiment may further include the following processing, such as... Figure 7 As shown:
[0120] Step 701: Perform region segmentation on the face image region to obtain a segmentation result. The segmentation result contains at least one segmented region, and each segmented region contains a part of the face.
[0121] For example, in this embodiment, the face image region can be segmented according to the face structure, thereby obtaining segmented regions containing various parts of the face. Each segmented region corresponds to an object label, which is the label for that part. These segmented regions constitute the face image region. For example, the face image region can be segmented into: skin segmented region, left eye segmented region, right eye segmented region, nose segmented region, mouth segmented region, etc. The object label "skin" corresponds to the skin segmented region, the object label "left eye" corresponds to the left eye segmented region, and so on. These segmented regions corresponding to these object labels constitute the face image region.
[0122] Specifically, in this embodiment, a face segmentation model can be used to process the face image region to obtain the segmentation result. The face segmentation model is trained using input samples and output samples. The input samples are image regions containing the face in the sample image, and the output samples include: at least one sample region, each sample region containing a part of the face. The sample region is a local region within the image region containing the face in the sample image, and all sample regions constitute the image region containing the face in the sample image.
[0123] Among them, the face segmentation model is a machine learning model. For example, the face segmentation model is built based on a neural network and trained using input samples and output samples.
[0124] Step 702: Based on the segmented region, parse the watermark region to obtain the first parsing result and / or the second parsing result.
[0125] The first analysis result indicates whether a segmented region is detected as a watermark symbol in the watermark region; the second analysis result indicates whether the watermark region occludes the segmented region.
[0126] In one implementation, this embodiment obtains the intersection-union ratio (IUU) between the watermark symbol of the watermark region and each segmented region, that is, the ratio of the intersection area and the union area of the watermark symbol region and the segmented region. If the IUU of the first watermark symbol and the first segmented region therein is greater than or equal to a first threshold and the size of the first watermark symbol is different from the size of the second watermark symbol, and the second watermark symbol is the watermark symbol adjacent to the first watermark symbol in the watermark region, then it indicates that the first watermark symbol is the first segmented region that was misdetected as a watermark, that is, the first segmented region in the face image region was misdetected as the first watermark symbol. At this time, the obtained first analysis result indicates that the first segmented region was detected as the first watermark symbol.
[0127] For example, in this embodiment, the intersection-union ratio of a watermark symbol in the segmented region with the left eye and the watermark region is as high as 96%, and the height of this watermark symbol is greater than the height of other watermark symbols in its vicinity. At this time, it can be determined that the left eye region in the face is misdetected as a watermark.
[0128] In another implementation, this embodiment obtains the overlapping area between the watermark area and each segmented area, and obtains the ratio between the overlapping area and the corresponding segmented area. If the ratio corresponding to the second segmented area is greater than or equal to the second threshold and the transparency of the watermark area meets the occlusion condition, then it indicates that the second segmented area is occluded by the watermark area.
[0129] The transparency of the watermark region can be obtained through a pre-trained classifier. For example, a classifier can be used to identify the transparency of the watermark region to determine its transparency. The occlusion condition for the watermark region's transparency can be: the transparency of the watermark region is less than or equal to a transparency threshold, meaning the watermark region will affect the normal display of the occluded segmented region.
[0130] For example, in this embodiment, a classifier is first used to obtain the transparency of the watermark area. If the transparency of the watermark area is less than or equal to the transparency threshold, and the ratio of the overlap area between the watermark area and the segmented area of the mouth to the segmented area of the mouth reaches 80%, that is, the occlusion rate reaches 80%, then it can be determined that the mouth area in the face is occluded by the watermark.
[0131] refer to Figure 8 The diagram shown is a structural schematic of a watermark processing device provided in Embodiment 2 of this application. This device can be configured in electronic devices capable of image processing, such as computers or servers. The technical solution in this embodiment is mainly used to improve the reliability of watermark detection.
[0132] Specifically, the device in this embodiment may include the following units:
[0133] Background acquisition unit 801 is used to acquire multiple background images; any two of the background images have different parameter values in at least one image parameter.
[0134] The watermark processing unit 802 is used to process the initial watermark image according to the image parameters to obtain a sample watermark image; any two sample watermark images have different parameter values for at least one watermark parameter.
[0135] The watermark adding unit 803 is used to add the sample watermark image to the background image to obtain a sample image;
[0136] The model training unit 804 is used to train the watermark detection model using the sample image and the sample watermark image, so that the watermark detection model can detect the watermark region in the target image.
[0137] As can be seen from the above technical solution, in the watermark processing device provided in Embodiment 2 of this application, after obtaining multiple background images with different parameter values for image parameters, the initial watermark image is processed according to the image parameters of these background images to obtain sample watermark images. These sample watermark images have different parameter values for watermark parameters. Therefore, the sample watermark images are added to the background images, resulting in sample images with diverse watermarks for different backgrounds. These sample images and sample watermark images are then used to train a watermark detection model, enabling the model to detect watermark regions in the target image. It is evident that in this embodiment, the watermark image is processed according to the image parameters of various background images, and then the processed watermark image is added to the background image, resulting in a variety of sample images. The watermark images in these sample images are diverse and related to the background images. Therefore, by training the watermark detection model using these sample images, the model can detect a variety of watermarks, thereby improving the reliability of watermark detection.
[0138] In one implementation, the watermark processing unit 802 is specifically used to: obtain the initial parameter value of the watermark parameter according to the parameter range corresponding to each watermark parameter; adjust the initial parameter value of the watermark parameter according to the image parameter to obtain the target parameter value of the watermark parameter; and perform image transformation on the initial watermark image according to the target parameter value to obtain a sample watermark image.
[0139] In one implementation, the image parameters include at least one of: illumination parameters, hue parameters, contrast parameters, and content parameters;
[0140] The watermark parameters include at least one of the following: position parameter, color parameter, size parameter, transparency parameter, and rotation parameter.
[0141] In one implementation, the watermark adding unit 803 is specifically used to: determine a watermark region in the background image based on the image content in the background image; wherein the region position of the watermark region in the background image matches the region position of the target content in the background image, and the target content is the content in the image content that meets the conditions for adding a watermark; and add the sample watermark image to the watermark region.
[0142] In one implementation, the initial watermark image includes at least one watermark symbol; the watermark symbol is a character or an icon; the watermark symbol is obtained from multiple data sources;
[0143] Specifically, the watermark processing unit 802 is used to: adjust the watermark parameters of at least one watermark symbol in the initial watermark image according to the image parameters to obtain a sample watermark image; wherein, when the sample watermark image includes characters and icons, the parameter values of the characters and icons in the sample watermark image are different in at least one of the watermark parameters.
[0144] In one implementation, the apparatus in this embodiment may also have the following structure, such as... Figure 9 As shown:
[0145] The watermark detection unit 805 is used to perform region detection on the target image to obtain the target region in the target image; and to use the watermark detection model to perform watermark detection on the target region to obtain the watermark region in the target region.
[0146] In one implementation, when the watermark detection unit 805 uses the watermark detection model to perform watermark detection on the target region to obtain the watermark region in the target region, it is specifically used to: rotate the target region by a target angle to obtain the region to be tested; the target angle is determined based on the detection result of watermark detection on historical images of the rotated test angle by the watermark detection model; and use the watermark detection model to perform watermark detection on the region to be tested to obtain the watermark region in the target region.
[0147] Specifically, the target area is a facial image region containing a human face;
[0148] The watermark detection unit 805 is further configured to: perform region segmentation on the face image region to obtain a segmentation result, the segmentation result including at least one segmented region, each segmented region including a part of the face; and parse the watermark region according to the segmented region to obtain a first parsing result and / or a second parsing result; wherein the first parsing result indicates whether the segmented region is detected as a watermark symbol in the watermark region; and the second parsing result indicates whether the watermark region occludes the segmented region.
[0149] Wherein, if the intersection-union ratio of the first watermark symbol and the first segmentation region in the watermark region is greater than or equal to the first threshold and the size of the first watermark symbol is different from the size of the second watermark symbol, the first parsing result indicates that the first segmentation region is detected as the first watermark symbol; the second watermark symbol is the watermark symbol adjacent to the first watermark symbol in the watermark region.
[0150] If the ratio between the overlapping area of the watermark area and the second segmented area and the second segmented area is greater than or equal to the second threshold and the transparency of the watermark area meets the occlusion condition, the second analysis result indicates that the watermark area occludes the second segmented area.
[0151] It should be noted that the specific implementation of each unit in this embodiment can be referred to the corresponding content above, and will not be described in detail here.
[0152] refer to Figure 10 This is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of this application. The electronic device may include the following structure:
[0153] Memory 1001 is used to store computer programs and data generated during the execution of computer programs;
[0154] Processor 1002 is configured to execute a computer program to: obtain multiple background images; ensure that any two background images have different parameter values for at least one image parameter; process an initial watermark image according to the image parameters to obtain a sample watermark image; ensure that any two sample watermark images have different parameter values for at least one watermark parameter; add the sample watermark image to the background images to obtain a sample image; and train a watermark detection model using the sample image and the sample watermark image so that the watermark detection model can detect watermark regions in a target image.
[0155] As can be seen from the above technical solution, in the electronic device provided in Embodiment 3 of this application, after obtaining multiple background images with different parameter values for image parameters, the initial watermark image is processed according to the image parameters of these background images to obtain sample watermark images. These sample watermark images have different parameter values for watermark parameters. Therefore, the sample watermark images are added to the background images, resulting in sample images with diverse watermarks for different backgrounds. These sample images and sample watermark images are then used to train a watermark detection model, enabling the model to detect watermark regions in the target image. It is evident that in this embodiment, the watermark image is processed according to the image parameters of various background images, and then the processed watermark image is added to the background image, resulting in a variety of sample images. The watermark images in these sample images are diverse and related to the background images. Therefore, by training the watermark detection model using these sample images, the model can detect a variety of watermarks, thereby improving the reliability of watermark detection.
[0156] Taking the scenario of detecting whether a watermark obscures a face as an example, watermark occlusion detection essentially falls under the category of watermark detection. However, since watermarks interfere with facial images, watermark occlusion detection also falls under the category of face quality evaluation. This application proposes a technical solution based on face segmentation and watermark detection to detect face watermark occlusion.
[0157] The main process includes:
[0158] First, facial information, i.e., facial image regions, is obtained based on face detection.
[0159] Then, obtain the location information of the watermark, that is, detect the watermark area.
[0160] Finally, the overlap between the face image area and the watermark area is used to determine whether there is watermark occlusion.
[0161] In this application, the following are various face watermark detection schemes based on complex scenarios:
[0162] Step 1: Obtain the face image region on the test image (i.e., the target image mentioned above) based on the face detection algorithm.
[0163] The face image region is the area containing the face bounding box.
[0164] It should be noted that in this embodiment, when detecting faces in the target image, one or more face bounding boxes may be detected. In this case, one of them can be selected as the face image region for face missing detection.
[0165] In one case, this embodiment uses a face detection algorithm to detect faces in the target image, obtains a face bounding box, and uses the face bounding box as the face image region;
[0166] In another scenario, this embodiment uses a face detection algorithm to detect faces in the target image, obtaining multiple face bounding boxes. Then, the master face bounding box is identified among these multiple face bounding boxes. The master face bounding box is defined as a face bounding box with an area greater than a box threshold and a distance less than a distance threshold between the face bounding box and the center point of the target image. If the master face bounding box can be identified, it is considered as a face image region. If the master face bounding box cannot be identified, it is considered that there is no face image region in the target image.
[0167] For example, in this embodiment, the number of face frames may be used to determine whether there is a single face in the image. If there is no face, an empty face is returned. If there are multiple faces, it is necessary to determine whether the main face and secondary faces can be distinguished. If they cannot be distinguished, multiple faces are returned. If they can be distinguished, the main face is recognized as the only face in the image.
[0168] Step 2: Obtain the face image region and use a classifier such as a watermark detection model to determine whether there is a watermark on the face. If there is no watermark, return "no watermark". If there is a watermark, further determine whether the watermark is obscuring the face.
[0169] Step 3: In training the watermark detection model, compared to other models, the technical solution of this application uses a variety of watermark images to construct sample images based on background images with complex business scenarios, and trains the watermark detection model using these diverse sample images:
[0170] 1. In business scenarios, human images are collected in real environments across the country. Differences in lighting, clarity, and equipment result in the complexity of the watermark background. Therefore, the background images collected can be used as training data to meet the requirements of complex backgrounds.
[0171] 2. In business scenarios, the position, length, size, direction, color, and content of a watermark are variables that exist between each other or within itself, thus the resulting watermark image can meet the diverse settings of a watermark.
[0172] 3. There are some special icons in the watermark, which exist in the middle of a row of watermarks, are taller than other watermarks, and the overall watermark is tilted.
[0173] 4. Special icon watermarks also exhibit characteristics such as running across the entire image and having different text colors on the left and right sides of the icon. This feature should also be addressed through targeted data training.
[0174] Specific sample watermark images can be generated in the following way:
[0175] Download an offline Chinese corpus beforehand as watermark content, prepare some transparent icon photos as watermark icons, and prepare portrait photos of people in complex scenes without watermarks as background images. Generate watermark data through the following processing.
[0176] 1. Random Watermark Parameters: Introducing randomness allows watermark parameters to be selected randomly within a certain range. For example, the position, color, direction (rotation), and length of the watermark can be randomly selected to increase watermark diversity. This ensures that the watermark is slightly different for each photo, enhancing the realism of the watermark.
[0177] 2. Intelligent Watermark Parameter Adjustment: Through algorithms, the watermark parameters are automatically adjusted based on the content and characteristics of the portrait photo. Utilizing machine learning technology, the watermark's color, size, transparency, and other parameters can be automatically optimized based on factors such as the photo's lighting conditions, tone, and contrast to enhance its visibility and adaptability.
[0178] 3. Adjusting Transparency and Blending Mode: When generating the watermark, try adjusting its transparency and blending mode to better integrate it into the photo. The transparency and blending mode can be automatically adjusted based on the photo's lighting conditions and background characteristics.
[0179] 4. Intelligent Watermark Position Selection: Utilizing computer vision and target detection technology, the system automatically selects the watermark position to avoid obscuring important features in portrait photos. It can identify key areas such as faces, eyes, and mouths, and automatically adjust the watermark position based on the location and distribution of these areas, ensuring the watermark's aesthetics and suitability.
[0180] 5. Diverse watermark icons: In addition to using transparent icon photos as watermark icons, other types of icons can be used, such as vector icons. This increases the variety of watermark styles and makes the watermark more attractive.
[0181] 6. Diverse Watermark Content: In addition to downloading offline Chinese corpora as watermark content, the sources of watermark content can be further enriched. For example, text data can be obtained from multiple channels such as news articles, social media comments, and blog posts, and used to generate watermarks. This increases the diversity of watermark content, making the watermark unique for each photo.
[0182] Step 4: The watermark detection model supports diverse watermark detection in complex scenarios, but the more complex the scenario and the more diverse the watermarks, the greater the impact on the detection results, which should be avoided as much as possible. Therefore, in this embodiment, for business scenario detection, only watermark detection of the face region can be performed.
[0183] In this study, because the alignment of rotated watermarks, such as italic watermarks, is not high, images rotated by 0 degrees, 45 degrees, and -45 degrees were used for detection. For images in the same batch, the watermark rotation angles show a certain tendency, and images rotated in this direction were used as the first rotated images for detection.
[0184] In addition, when detecting watermarks on a frontal face, it is easy to misidentify eyes and facial features as watermarks. Therefore, it is necessary to make judgments based on the information obtained, the relative positional relationship between the watermark frame and key facial points, and the aspect ratios of all watermark frames. For example, the watermark height and the intersection-union ratio of the watermark and the segmented facial region can be used to determine if there are any misidentifications.
[0185] Step 5: Face Occlusion Detection: Locate the coordinates of the watermark on the image using a watermark detection model to obtain the rotated bounding box of the watermark; use the face segmentation results to perform contour detection on the eyes, nose, and mouth to obtain the minimum rotated bounding boxes of the four facial features. Calculate the ratio of the intersection of the two bounding boxes to the minimum bounding box of the corresponding facial feature to obtain the occlusion rate, and set a threshold to determine whether occlusion exists.
[0186] Step 6: There are some special cases when determining watermark occlusion. Different criteria exist for judging watermark occlusion based on whether the watermark is transparent. In this case, this application can first use a classifier to determine whether the watermark is transparent. If the watermark is transparent (high transparency), it is determined that the watermark does not obscure the face. If the watermark is opaque (low transparency) and the watermark area overlaps with the face area with a high overlap ratio, it is determined that the watermark obscures the face.
[0187] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to the method section.
[0188] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0189] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0190] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A watermark processing method, characterized in that, include: Obtain multiple background images; The parameter values of at least one image parameter are different between any two of the background images; Based on the image parameters, the initial watermark image is processed to obtain a sample watermark image; The parameter values of at least one watermark parameter are different between any two of the sample watermark images; The sample watermark image is added to the background image to obtain the sample image; The watermark detection model is trained using the sample image and the sample watermark image so that the watermark detection model can detect the watermark region in the target image. Region detection is performed on the target image to obtain the target region in the target image; The watermark detection model is used to detect watermarks in the target area to obtain the watermarked area in the target area. When the target region is a face image region containing a face, the face image region is segmented to obtain a segmentation result. The segmentation result includes at least one segmented region, and each segmented region contains a part of the face. Based on the segmented region, the watermark region is parsed to obtain a first parsing result and / or a second parsing result. The first parsing result indicates whether the segmented region is detected as a watermark symbol in the watermark region. The second parsing result indicates whether the watermark region occludes the segmented region.
2. The method according to claim 1, characterized in that, Based on the image parameters, the initial watermark image is processed to obtain a sample watermark image, including: According to the parameter range corresponding to each watermark parameter, the initial parameter value of the watermark parameter is obtained; Based on the image parameters, the initial parameter values of the watermark parameters are adjusted to obtain the target parameter values of the watermark parameters; According to the target parameter values, the initial watermark image is transformed to obtain a sample watermark image.
3. The method according to claim 2, characterized in that, The image parameters include at least one of the following: illumination parameters, hue parameters, contrast parameters, and content parameters; The watermark parameters include at least one of the following: position parameter, color parameter, size parameter, transparency parameter, and rotation parameter.
4. The method according to claim 1 or 2, characterized in that, Adding the sample watermark image to the background image to obtain the sample image includes: Based on the image content in the background image, a watermark area is determined in the background image; wherein, the location of the watermark area in the background image matches the location of the target content in the background image, and the target content is the content in the image content that meets the conditions for adding a watermark; Add the sample watermark image to the watermark area.
5. The method according to claim 1 or 2, characterized in that, The initial watermark image includes at least one watermark symbol; the watermark symbol is a character or an icon; the watermark symbol is obtained from multiple data sources; The process of processing the initial watermark image according to the image parameters to obtain a sample watermark image includes: Based on the image parameters, the watermark parameters of at least one of the watermark symbols in the initial watermark image are adjusted to obtain a sample watermark image; Wherein, when the sample watermark image includes characters and icons, the characters and icons in the sample watermark image have different parameter values for at least one of the watermark parameters.
6. The method according to claim 1, characterized in that, The watermark detection model is used to perform watermark detection on the target region to obtain the watermark region in the target region, including: The target region is rotated by a target angle to obtain the region to be tested; the target angle is determined based on the watermark detection result of the watermark detection model on the historical image of the rotated test angle. The watermark detection model is used to detect the watermark in the area to be tested, so as to obtain the watermark area in the target area.
7. The method according to claim 1, characterized in that, in: If the intersection-union ratio of the first watermark symbol and the first segmentation region in the watermark region is greater than or equal to the first threshold and the size of the first watermark symbol is different from the size of the second watermark symbol, the first parsing result indicates that the first segmentation region is detected as the first watermark symbol; the second watermark symbol is the watermark symbol adjacent to the first watermark symbol in the watermark region. If the ratio between the overlapping area of the watermark area and the second segmented area and the second segmented area is greater than or equal to the second threshold and the transparency of the watermark area meets the occlusion condition, the second analysis result indicates that the watermark area occludes the second segmented area.
8. A watermark processing device, characterized in that, include: The background acquisition unit is used to acquire multiple background images; The parameter values of at least one image parameter are different between any two of the background images; The watermark processing unit is used to process the initial watermark image according to the image parameters to obtain a sample watermark image. The parameter values of at least one watermark parameter are different between any two of the sample watermark images; A watermark adding unit is used to add the sample watermark image to the background image to obtain a sample image; The model training unit is used to train the watermark detection model using the sample image and the sample watermark image, so that the watermark detection model can detect the watermark region in the target image. A watermark detection unit is used to perform region detection on the target image to obtain the target region in the target image; The watermark detection model is used to detect watermarks in the target area to obtain the watermarked area in the target area. Wherein, when the target region is a face image region containing a face, the watermark detection unit is further configured to: perform region segmentation on the face image region to obtain a segmentation result, the segmentation result containing at least one segmented region, each segmented region containing a part of the face; and parse the watermark region according to the segmented region to obtain a first parsing result and / or a second parsing result; wherein, the first parsing result indicates whether the segmented region is detected as a watermark symbol in the watermark region; and the second parsing result indicates whether the watermark region occludes the segmented region.
Citation Information
Patent Citations
Data acquisition method, watermark identification method, watermark removal method and device
CN111612681A
Watermark detection model training method and device, watermark removal method and device and electronic equipment
CN114612282A