Image watermark generation method and device based on thinking chain strategy and computer equipment

Through the image watermark generation method based on thinking chain strategy, the visual language model and the Grounded SAM model are used to perform adaptive watermark generation, which solves the problem of difficult balance between aesthetics and copyright protection in the existing technology, and achieves highly aesthetic and visible watermark generation.

CN120510012APending Publication Date: 2025-08-19HUNAN UNIV
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510649129.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-20
Publication Date
2025-08-19

AI Technical Summary

Technical Problem

Most of the existing visible watermark schemes are regular and have poor aesthetics, and cannot adaptively adjust according to the content of the picture, making it difficult to balance copyright protection and visual effects.

Method used

The image watermark generation method based on thinking chain strategy is adopted, the visual language model is used to analyze the image content, and the Grounded SAM model is combined for region segmentation and edge optimization. The visual language model is used to iteratively adjust the watermark position and size to ensure that the watermark is visually significant and highly aesthetic.

Benefits of technology

The generated watermark is not only highly aesthetic, but also effectively guarantees the visibility and immutability of the watermark. It is suitable for copyright protection for visual communication such as art works as the main purpose.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120510012A_ABST
    Figure CN120510012A_ABST
Patent Text Reader

Abstract

The invention relates to an image watermark generation method and device based on a thinking chain strategy and computer equipment. The method is based on a visual perception visual large model, after knowledge enhancement is carried out on the visual large model through expert knowledge, the visual large model firstly analyzes the content of a picture, then a watermark scheme is given, then a segmentation model and an edge optimization module are called, and finally a watermark is rendered to the image. According to the method, the balance between the visual effect of the artwork and copyright protection is fully considered in the watermark generation process, and the technical path from art aesthetics, image processing to watermark embedding ensures that the generated watermark not only has high aesthetics, but also can effectively ensure the visibility and non-tampering property of the watermark.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of watermark generation, and in particular to a method, apparatus and computer equipment for generating an image watermark based on a thought chain strategy. Background Art

[0002] The rapid growth of digitization and internet technology has significantly accelerated the global dissemination of digital artworks, such as illustrations, posters, and digital collections. However, this accessibility has also heightened concerns about copyright protection. Unauthorized use and redistribution are common on open platforms such as social media and online marketplaces, largely due to the low technical barriers and minimal costs associated with the misappropriation of digital content. Consequently, artists often struggle to protect their intellectual property and maintain control over their original works.

[0003] Current research explores watermark generation techniques, primarily categorized as visible watermarks and steganographic watermarks. Invisible watermarks (steganographic watermarks) embed watermark information within digital content to ensure copyright protection, data integrity, and authenticity verification. Related research falls into two main categories: spatial domain methods and transform domain methods. Spatial domain steganographic watermarks directly manipulate image pixel values to embed the watermark. Common spatial domain algorithms include LSB (least significant bit) embedding techniques and pixel modulation methods. LSB embedding is the most classic approach, hiding the watermark information by modifying the least significant bit (LSB) of the image. Since this method modifies the least significant bit (LSB) of the image, it typically does not cause noticeable visual changes, but it is also susceptible to noise or compression attacks. To improve robustness, some improved algorithms incorporate error diffusion or more complex modulation techniques. Unlike spatial domain methods, transform domain methods first convert the image into a transform domain (such as the discrete cosine transform (DCT), discrete wavelet transform (DWT), or discrete Fourier transform (DFT)), and then embed the watermark information into the transform coefficients. These methods are generally more robust than spatial domain methods and can resist common attacks such as image compression, rotation, and cropping. In particular, the DCT and DWT methods have become a research hotspot due to their widespread application in image compression and image processing. For example, the DCT method embeds a watermark in the low-frequency portion of the frequency coefficients, ensuring that the watermark remains robust during image compression. These methods are primarily used for post-hoc verification and as evidence in copyright infringement cases. However, steganographic watermarks cannot prevent initial illegal use.

[0004] Visible watermarking technology is used for copyright protection and authentication of digital content and is commonly found in multimedia content such as images, videos, and documents. Unlike steganographic watermarking, visible watermarking explicitly adds a logo, text, or graphic containing copyright information to an image or video, ensuring that the content's ownership information is easily identifiable. Visible watermarking not only prevents piracy but also enhances the legitimate rights and interests of the original creator or copyright owner. It is widely used in digital media, film and television production, and image sharing platforms. The construction of visible watermarks relies primarily on two key aspects: image processing and image generation. Traditional watermark embedding techniques typically rely on pixel-level image processing, embedding watermark information directly into the image. Common methods include adding low-transparency watermarks to edges, corners, or transparent areas of the image to ensure that the watermark does not affect the primary visual quality of the content. Frequency-domain transform-based techniques are also commonly used in the design of visible watermarks. For example, techniques such as the discrete cosine transform (DCT) and discrete wavelet transform (DWT) can be used to embed watermark information into specific frequency coefficients of the image, making the watermark visible without overly interfering with the image's visual quality.

[0005] Most existing visible watermarking schemes are regular and have poor aesthetics, and their positions do not adapt adaptively to the content of the image. Summary of the Invention

[0006] Based on this, it is necessary to provide an image watermark generation method, device and computer equipment based on the thought chain strategy to address the above technical problems.

[0007] A method for generating an image watermark based on a thought chain strategy, the method comprising: Get the image to be protected and the watermark text content.

[0008] A visual language model is used to analyze the image to be protected to obtain a watermark scheme, from which object description instructions, curvature layout patterns and style attributes of the watermark are extracted.

[0009] According to the image to be protected and the object description instructions, the Grounded SAM model is used to perform region segmentation to obtain the optimal mask image.

[0010] The edge of the optimal mask image is optimized to obtain a reference closed polygon for watermark positioning.

[0011] Watermark embedding is performed in the spatial domain according to the image to be protected, the curvature layout pattern, the watermark text content, the reference closed polygon and the style attribute of the watermark to obtain an initial embedded watermark image.

[0012] The VLM is used to evaluate the watermark position and size of the initial watermarked image. The position and size of the watermark are adjusted or fine-tuned according to the obtained position evaluation results and watermark size evaluation results until the preset conditions are met to obtain the final watermarked image.

[0013] In one embodiment, the style attributes of the watermark include: the color and transparency of the watermark.

[0014] The visual language model is used to analyze the image to be protected and obtain a watermark scheme. The object description instructions, curvature layout pattern and style attributes of the watermark are extracted from the watermark scheme, including: The visual language model GPT-4o is used to analyze the image to be protected and obtain the watermarking scheme.

[0015] Regular expressions are used to clean the watermark scheme and convert it into a structured dictionary, from which object description instructions, curvature layout pattern, watermark color text description and watermark transparency text description are extracted.

[0016] Convert the watermark color text description into a numerical value to obtain the watermark color.

[0017] In one embodiment, the watermark color text description is converted into a numerical value to obtain the watermark color, including: Perform semantic analysis on the watermark color text description and get the target color as:

[0018] in, t is the target color, is a function for converting a hexadecimal color code to an RGB triplet, A function that matches the input to a standard CSS3 color name. is a function for fuzzy semantic matching based on keywords. c A text description of the watermark color.

[0019] The KMeans clustering algorithm is used to extract the dominant color set from the image to be protected.

[0020] Match the target color and compare it with the dominant color set, and the matching color is:

[0021] in, To match the color, is the CIEDE2000 color difference metric, It is a function that converts the original image in RGB mode to Lab mode. Cis the dominant color set extracted by the KMeans clustering algorithm, The dominant color set extracted by the KMeans clustering algorithm C A color in the.

[0022] Apply a tolerance fine-tuning to the matched color to get the color of the watermark.

[0023] In one embodiment, the Grounded SAM model includes an open-set object detector Grounding DINO and a cue-driven segmentation model SAM.

[0024] According to the image to be protected and the object description instructions, the Grounded SAM model is used to perform region segmentation to obtain the optimal mask image, including: According to the image to be protected and the object description instructions, the open set object detector Grounding DINO is used to extract bounding boxes and semantic associations.

[0025] Bounding boxes and semantic associations are filtered based on confidence thresholds and text thresholds.

[0026] A hint-driven segmentation model (SAM) is used to segment the bounding box after image segmentation, generate a mask, and select the optimal mask image based on the text similarity of the filtered semantic association.

[0027] In one embodiment, edge optimization is performed on the optimal mask image to obtain a reference closed polygon for watermark positioning, including: The optimal mask image is subjected to morphological aesthetic optimization to remove noise and smooth edges to obtain the optimized mask image.

[0028] The optimized mask image is subjected to binary threshold processing and external contour detection to obtain all detected contours.

[0029] The Douglas-Peck algorithm is applied to each contour, and the shape-preserving polygonal representation of the generated contour is:

[0030] in, Maintain a polygonal representation for the shape of the outline, is the adaptive precision dilution, For outline The circumference of is the smoothing factor, is the minimum smoothing error.

[0031] For each contour shape, keep each point in the polygonal representation of the point sequence , calculation point and the normal vector of the line segment formed by its adjacent points, and then move the offset distance along the normal vector d , get the offset point.

[0032] Reconstruct the offset contour by calculating the intersection points of the connected offset line segments.

[0033] The offset contour with the largest number of points is selected as the reference closed polygon for watermark positioning.

[0034] In one embodiment, watermark embedding is performed in the spatial domain according to the image to be protected, the curvature layout pattern, the watermark text content, the reference closed polygon, and the style attribute of the watermark to obtain an initial embedded watermark image, including: When the curvature layout mode is Edge mode: Place the watermark text content on the longest line segment of the reference closed polygon edge; the total width of the text is determined by the width of a single character and the spacing between characters; i The actual position of the character and the rotation angle relative to the line segment direction are:

[0035]

[0036] in, For the i The actual position of the characters, is the starting point of the longest line segment, offset is the offset, is the width of the jth character, is the width of the i-th character, is the unit direction vector, s is the spacing between characters; is the angle of the longest line segment where the character is located, For the i The rotation angle of the character.

[0037] For the center of rotation The character image, its position after rotation is:

[0038] in, The center of rotation is The position of the character image after rotation, is the rotation matrix, is the center of rotation, is the position of the character image before rotation.

[0039] The watermark text image is transparently superimposed on the image to be protected and rendered to obtain the initial embedded watermark image; the pixel-by-pixel transparency interpolation formula is:

[0040] in, is the initial watermarked image, is the transparency of the character image, is the watermark text image, This is the image to be protected.

[0041] When the curvature layout mode is "Curve" mode: The reference closed polygon is converted into an equilateral polygon, and then the line segments of the vector are grouped according to the number of characters in the watermark text content.

[0042] Calculate the minimum inner angle for each group and select the group with the largest minimum inner angle. Treat each character in the watermark text content as a complete text and render it onto a line segment. Repeat the operation in the "edge" mode to obtain the initial embedded watermark image.

[0043] In one embodiment, the VLM is used to evaluate the watermark position and size of the initial watermarked image, and the position and size of the watermark are adjusted or fine-tuned according to the obtained position evaluation results and watermark size evaluation results until the preset conditions are met to obtain the final watermarked image, including: The VLM is used to evaluate the watermark position and size of the initial watermarked image.

[0044] If the location of the watermark does not match the predefined watermark scheme, the object description instructions are adjusted or fine-tuned.

[0045] If the size of the watermark is not visually significant, the position and size of the watermark are adjusted or fine-tuned, and the watermark image is continued to be generated.

[0046] The watermark image is generated continuously until the preset conditions are met to obtain the final embedded watermark image; the preset conditions are: the position of the watermark matches the predefined watermark scheme, and the size of the watermark is visually significant.

[0047] An image watermark generation device based on a thought chain strategy, the device comprising: The image and watermark text acquisition module is used to obtain the image to be protected and the watermark text content.

[0048] The art image analysis module is used to analyze the image to be protected using a visual language model to obtain a watermark scheme, and extract object description instructions, curvature layout patterns and style attributes of the watermark from the watermark scheme.

[0049] The watermark embedding region segmentation module is used to perform region segmentation using the GroundedSAM model according to the image to be protected and the object description instruction to obtain the optimal mask image.

[0050] The edge optimization module is used to optimize the edge of the optimal mask image to obtain a reference closed polygon for watermark positioning.

[0051] The watermark rendering module is used to embed the watermark in the spatial domain according to the image to be protected, the curvature layout mode, the watermark text content, the reference closed polygon and the style attributes of the watermark to obtain an initial embedded watermark image.

[0052] The evaluation and iteration module is used to evaluate the watermark position and size of the initial watermarked image using the VLM, and adjust or fine-tune the watermark position and size according to the obtained position evaluation results and watermark size evaluation results until the preset conditions are met to obtain the final watermarked image.

[0053] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.

[0054] The aforementioned method, device, and computer equipment for generating image watermarks based on a thought chain strategy are based on a visual perception macromodel. After augmenting the macromodel with expert knowledge, the macromodel first analyzes the image content, generates a watermarking scheme, and then invokes a segmentation model and edge optimization module to ultimately render the watermark onto the image. This method fully considers the balance between the visual effects of the artwork and copyright protection during the watermark generation process. From the technical approach of artistic aesthetics, image processing, and watermark embedding, the generated watermark is both highly aesthetically pleasing and effectively maintains visibility and immutability. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 1 is a flow chart of a method for generating an image watermark based on a thought chain strategy in one embodiment; Figure 2 is a flow chart of a method for generating an image watermark based on a thought chain strategy in another embodiment; Figure 3 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0056] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0057] In one embodiment, Figure 1 As shown, a method for generating an image watermark based on a thought chain strategy is provided, and the method comprises the following steps: Step 100: Obtain the image to be protected and the watermark text content.

[0058] Specifically, the image to be protected is an image of an original work of art.

[0059] Step 102: Analyze the image to be protected using a visual language model to obtain a watermark scheme, and extract object description instructions, curvature layout patterns, and style attributes of the watermark from the watermark scheme.

[0060] Specifically, by analyzing aesthetic protection watermarking schemes for original artworks, an external knowledge base is constructed for the VLM (GPT-4o) based on the artist's prior knowledge. On this basis, prompt words are constructed through a thought chain strategy, enabling the VLM to simulate the cognitive process of expert watermark practitioners and generate effective aesthetic protection watermarking schemes, ultimately producing three key outputs: (1) the identification of the main element to be protected, that is, the object description instruction, which serves as the input text prompt of step 104; (2) the curvature layout pattern of the main element, which is used to guide the adaptive layout pattern selection in the stage step 108; and (3) the stylistic attributes of the watermark, including color and transparency, which are applied in step 108.

[0061] Step 104: Based on the image to be protected and the object description instruction, the Grounded SAM model is used to perform region segmentation to obtain an optimal mask image.

[0062] Specifically, the textual description of watermark placement, derived from the watermarking scheme generated in step 102, serves as a prompt input to the open-source framework Grounded SAM. This framework identifies and describes the key visual elements to be watermarked, establishing a precise positioning reference for subsequent processing steps. Among the candidate masks generated by the model, confidence-based semantic matching is used to select the mask with the highest confidence as the optimal mask image.

[0063] Step 106: Optimize the edges of the optimal mask image to obtain a reference closed polygon for watermark positioning.

[0064] Specifically, to improve the quality of the optimal mask image, morphological opening and closing operations are used to smooth its edges and remove small noise artifacts. Subsequently, an adaptive edge extraction algorithm converts the mask boundary into a closed polygon, ensuring accurate representation of the edge contour. Further refinement is achieved through an inward offset algorithm, which shrinks the boundary inward by a distance equal to half the height of the maximum watermark character. This ensures that in step 108, the geometric center of the watermark character is aligned as closely as possible with the fitted line segment, following the edge preservation principle, positioning the watermark near the edge of the original element while avoiding interference with the boundary line. This approach maintains a balance between aesthetic consistency and structural accuracy, thereby enhancing the visual integration of the watermark.

[0065] Step 108: Embed the watermark in the spatial domain according to the image to be protected, the curvature layout pattern, the watermark text content, the reference closed polygon, and the style attributes of the watermark to obtain an initial embedded watermark image.

[0066] Specifically, based on the curvature layout pattern determined in step 102, watermark positioning is performed in two modes: (1) "Edge" mode: For elements with obvious straight line protrusions, the watermark text is placed along the longest line segment of the offset polygon. The direction and length of this line segment determine the baseline for watermark placement. (2) "Curve" mode: For elements lacking obvious straight lines, adjacent line segments are grouped according to the number of characters in the watermark, and the group with the largest minimum internal angle is selected. Once the longest line segment or group is identified, the watermark is rendered at its center, applying the color and style parameters defined in step 102.

[0067] Step 110: Use VLM to evaluate the watermark position and size of the initial watermarked image, and adjust or fine-tune the watermark position and size according to the obtained position evaluation results and watermark size evaluation results until the preset conditions are met to obtain the final watermarked image.

[0068] Specifically, to ensure that the watermark image is consistent with the aesthetic protection watermark scheme outlined in step 102, a final objective visual evaluation is performed using the VLM in step 110. The evaluation focuses on two key aspects: (1) whether the position of the watermark matches the predefined watermark scheme, and (2) whether the size of the watermark is visually significant, ensuring that it remains within the visible watermark range. Feedback from this evaluation is used to adjust the position and size of the watermark in steps 104 and 108, either by major adjustments or fine adjustments. This iterative process continues until both conditions are met, at which point the final embedded watermark image is output. Among them, major adjustments refer to adjusting the approximate watermark embedding area obtained by the region segmentation in stage two. Fine adjustments refer to the watermark position when the four parts of the watermark are rendered in the fine adjustment stage.

[0069] The aforementioned method for generating image watermarks based on a thought chain strategy is based on a visual perception macromodel. After augmenting the macromodel with expert knowledge, the macromodel first analyzes the image's content, proposes a watermarking scheme, and then invokes a segmentation model and edge optimization module to ultimately render the watermark onto the image. This method fully considers the balance between the artwork's visual impact and copyright protection during watermark generation. From the technical approach of artistic aesthetics, image processing, to watermark embedding, it ensures that the generated watermark is both highly aesthetically pleasing and protective of the image's subject matter, effectively guaranteeing the watermark's visibility and immutability.

[0070] In the digital art field, compared to traditional, regular watermarks, this method is more suitable for copyright protection of works of art whose primary purpose is visual communication, as it combines both protective and aesthetic qualities. This method can also be expanded to other fields, such as digital collections, promotional posters, and three-dimensional art, to explore broader application prospects.

[0071] In one embodiment, the style attributes of the watermark include: the color and transparency of the watermark; step 102 includes: using the visual language model GPT-4o to analyze the image to be protected to obtain a watermark scheme; using regular expressions to clean up the watermark scheme and convert it into a structured dictionary, extracting object description instructions, curvature layout patterns, watermark color text descriptions, and watermark transparency text descriptions from the structured dictionary; and converting the watermark color text descriptions into numerical values to obtain the watermark color.

[0072] In one embodiment, the watermark color text description is converted into a numerical value to obtain the watermark color, including: semantically parsing the watermark color text description to obtain a target color; the expression of the target color is:

[0073] in, t is the target color, is a function for converting a hexadecimal color code to an RGB triplet, A function that matches the input to a standard CSS3 color name. is a function for fuzzy semantic matching based on keywords (e.g., "white" corresponds to (255,255,255)). c A text description of the watermark color.

[0074] The KMeans clustering algorithm is used to extract the dominant color set from the image to be protected; the target color is matched and compared with the dominant color set to obtain the matching color; the matching color expression is:

[0075] in, To match the color, is the CIEDE2000 color difference metric, It is a function that converts the original image in RGB mode to Lab mode. C is the dominant color set extracted by the KMeans clustering algorithm, The dominant color set extracted by the KMeans clustering algorithm C One of the colors, Used to compare with the target color t obtained through semantic parsing to find the closest dominant color.

[0076] Apply a tolerance fine-tuning to the matched color to get the color of the watermark.

[0077] Specifically, given an image to be protected , after the GPT-4o model is fine-tuned by instructions, The content is analyzed and the original text feedback R of the watermark scheme is output. Then, the original text feedback R of the watermark scheme is cleaned and converted into a structured dictionary using regular expressions to extract key elements object description instruction T, curvature layout mode L, watermark color text description c and a text description of the watermark transparency For watermark color text description c The numerical conversion of the image to be protected is first performed by semantic parsing; then, the KMeans clustering algorithm is used to extract the Extract the dominant color C ; Dominant color C The expression is:

[0078] Specifically, Represents the saliency map S We perform weighted random sampling in which pixel locations are selected based on saliency weights The color value at Then, the target color t obtained by semantic parsing is matched and compared with The extracted color sets are compared to obtain matching colors as shown in the above matching color expression.

[0079] In addition, the matching colors Apply tolerance fine-tuning to ensure the watermark is aligned with the protected image More natural blending; the expression for the pixel color after tolerance fine-tuning is:

[0080] in, Represents the pixel color after tolerance fine-tuning, 、 、 Represent the blue, green and red channel components after disturbance respectively, This is the matching color before fine-tuning. 、 、 Represent the original blue, green, and red channel components respectively; Indicates clipping of the result to ensure that the color value is always within the legal range [0, 255] to prevent overflow or underflow; represents the uniformly distributed noise disturbance term, , that is, the noise from the interval Sampling from a uniform distribution, Indicates the intensity of the control disturbance. The larger the value, the more obvious the disturbance.

[0081] Color tolerance fine-tuning refers to the process of making small perturbations or adjustments to color values during image processing to control color changes within an allowable range, thereby preventing obvious discontinuities in color edges and ensuring that the added watermark is better integrated with the original image.

[0082] In one embodiment, the Grounded SAM model includes an open-set object detector Grounding DINO and a hint-driven segmentation model SAM; step 104 includes: extracting bounding boxes and semantic associations using the open-set object detector Grounding DINO according to the image to be protected and the object description instruction; filtering the bounding boxes and semantic associations according to a confidence threshold and a text threshold; using the hint-driven segmentation model SAM to perform image segmentation on the passed bounding boxes, generate a mask, and select the optimal mask image based on the text similarity of the filtered semantic associations.

[0083] Specifically, the Grounded SAM model is a visual language model that integrates the open-set object detector Grounding DINO with the cue-driven segmentation model SAM. This hybrid architecture can accurately detect and segment image regions based on arbitrary text descriptions, ensuring adaptability to diverse artworks.

[0084] Using images to be protected And the object description instruction T in step 102 (as a text prompt), the open set target detector Grounding DINO is used to extract the bounding box B and semantic association P, and then the confidence threshold is used to calculate the bounding box B and semantic association P. and text threshold Filter and remove low-confidence results; the specific process is:

[0085] in, is the open set target detector (Grounding DINO), For filtering operations.

[0086] Then, the filtered bounding boxes are segmented using the cue-driven segmentation model SAM to generate a mask M , and select the optimal mask image based on text similarity; the optimal mask image is:

[0087] in, is the optimal mask image; It is the cue-driven segmentation model SAM; 、 They are the bounding box set and the corresponding associated semantic set obtained after filtering by the set threshold; T The text content of the watermark is used to compare with the associated semantic set and filter out the associated semantics with the most similar semantics; Calculates text similarity.

[0088] In one embodiment, step 106 includes: performing morphological aesthetic optimization on the optimal mask image to eliminate noise and smooth edges to obtain an optimized mask image; performing binary threshold processing and external contour detection on the optimized mask image to obtain all detected contours; and applying the Douglas-Peck algorithm to each contour to generate a shape-preserving polygonal representation of the contour as follows:

[0089] in, Maintain a polygonal representation for the shape of the outline, is the adaptive precision dilution, is the Douglas-Peck algorithm, is the smoothing factor (preferably, the smoothing factor is preset to 0.001), For outline The circumference of Represents the minimum smoothing error. As a preference, the minimum smoothing error is set to 1.0 to avoid too small an approximation error.

[0090] For each contour shape, keep each point in the polygonal representation of the point sequence , calculation point and the normal vector of the line segment formed by its adjacent points, and then move the offset distance along the normal vector d , get the offset points; reconstruct the offset contour by calculating the intersection points of the offset line segments; select the offset contour with the largest number of points as the reference closed polygon for watermark positioning.

[0091] Specifically, first, the optimal mask image of the input Perform morphological optimization to remove noise and smooth edges:

[0092] in, K is a 5×5 morphological kernel, and Represent the number of iterations of closing and opening operations, is a standard Gaussian filter used for edge smoothing.

[0093] Then, binary thresholding and external contour detection are applied:

[0094] in, represents all detected contours, It is a function in the OpenCV library used to extract contours from binary images.

[0095] For each contour , performs the Douglas-Peck algorithm to generate shape-preserving polygons for the outline ,contour The shape remains polygonal The shape of the contour generated above remains as shown in the polygonal representation.

[0096] To get an offset contour, keep the polygon for the shape of the contour Each point in the point sequence , calculated by The normal vector of the line segment formed by its adjacent points , and then move an offset distance along the normal vector d :

[0097] Reconstruct the final offset contour by calculating the intersection points of consecutive offset line segments .exist Among all the offset contours in , select the one with the most points A closed polygon used as a reference for positioning the watermark. Refers to the contour with the most vertices in the offset contour set (all contours are closed polygons, C* is also a closed polygon).

[0098] In one embodiment, step 108 includes: when the curvature layout mode is the "edge" mode: placing the watermark text content on the longest line segment of the reference closed polygon edge; wherein the total width of the text is determined by the width of a single character and the spacing between characters; i The actual position of the character and the rotation angle relative to the line segment direction are:

[0099]

[0100] in, For the i The actual position of the characters, is the starting point of the longest line segment, offset is the offset, is the width of the jth character, For the i The width of characters, is the unit direction vector, s is the spacing between characters; is the angle of the longest line segment where the character is located, For the i The rotation angle of the character.

[0101] For the center of rotation The character image after rotation is expressed as:

[0102] in, The center of rotation is The position of the character image after rotation, is the rotation matrix, is the center of rotation, is the position of the character image before rotation.

[0103] Watermark text image Transparently superimpose it on the image to be protected and render it to obtain the initial embedded watermark image; the pixel-by-pixel transparency interpolation formula is:

[0104] in, is the initial watermarked image, is the transparency of the character image, is the watermark text image, This is the image to be protected.

[0105] When the curvature layout mode is "Curve" mode: the reference closed polygon is converted into an equilateral polygon, and then the vector segments are grouped according to the number of characters in the watermark text content; the minimum inner angle is calculated for each group, and the group with the largest minimum inner angle is selected, each character in the watermark text content is regarded as a complete text and rendered onto a line segment, and the operation is repeated in "Edge" mode to obtain the initial embedded watermark image.

[0106] Specifically, after identifying the longest line segment or group, the watermark text will be rendered at its center, applying the color and style parameters defined in step 102. Based on the value of the object description instruction L extracted in step 102, in the "edge" mode, the watermark text The longest line segment of the reference closed polygon placed at the watermark location On, set 、 are the starting point and end point of the longest line segment, then the direction vector of the longest line segment is , the length of the longest line segment is . Watermark text The total width of a single character The width and spacing between characters s Decision, watermark text The total width is:

[0107] in, It is i characters The width of the i characters Actual location for:

[0108] in, is the offset, is the starting position offset to center the text. is the unit direction vector.

[0109] The angle of each character relative to the line segment The direction vector of the line segment can be Use the formula: Calculation, i characters Rotation angle .

[0110] No. i characters Rotation angle The purpose of taking a negative value is to flip the character vertically so that it is suitable for human reading. Watermark character image , and its position after rotation is shown in the above expression of position after rotation.

[0111] Finally, for the watermark color and transparency processing: match the obtained RGB color And the transparency after conversion to numerical value Combined, an RGBA color value with an alpha channel is generated as the fill color for character drawing. It is used to color each character when drawing the watermark text image, so that subsequent characters have the set color and transparency information when rendered to the transparent layer.

[0112] Watermark character image Transparently overlay the original image and render to obtain the initial embedded watermark image The pixel-by-pixel transparency interpolation formula is as follows:

[0113] in, is the initial watermarked image, is the watermark text image, is the image to be protected, is the transparency of the character image. is the transparency of the area outside the character. Note that for the original image data in JPG format, it is assumed that The channel is 1. When outputting the final result, delete channel and save it in JPG format to ensure that metrics can be calculated.

[0114] In "Curve" mode, the reference closed polygon is first converted to an equilateral polygon. Adjacent line segments are then grouped according to the number of watermark text characters. For each group, the minimum internal angle is calculated, and the group with the largest minimum angle is selected. This process ensures consistent character spacing along edges and smooth angles, improving readability. For watermark embedding, each character in the watermark text is treated as a complete text. and render to a line segment, repeating the operation in "edge" mode, where .

[0115] In one embodiment, step 110 includes: using the VLM to evaluate the watermark position and size of the initial embedded watermark image; if the watermark position does not match the predefined watermark scheme, adjusting or fine-tuning the object description instruction; if the size of the watermark is not visually significant, adjusting or fine-tuning the watermark position and size and continuing to generate the watermark image; continuing to generate the watermark image until a preset condition is met to obtain a final embedded watermark image; the preset condition is: the watermark position matches the predefined watermark scheme and the watermark size is visually significant.

[0116] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0117] In one embodiment, Figure 2 As shown in the figure, an image watermark generation method based on the thinking chain strategy is proposed. This method condenses the design patterns of six watermarks and uses them as feature guides to construct a five-stage end-to-end workflow based on the thinking chain strategy. Stage one is the image analysis stage, stage two is the region segmentation stage, stage three is the edge optimization stage, stage four is the watermark rendering stage, and stage five is the evaluation and iteration stage.

[0118] In stage one, the cue words are constructed through a thought chain strategy, which enables the VLM to simulate the cognitive process of expert watermark practitioners and produce effective aesthetic protective watermarking schemes, ultimately producing three key outputs: (1) the identification of the main element to be protected, which serves as the input text cue of stage two; (2) the curvature feature analysis of the main element, which is used to guide the adaptive pattern selection in stage four; and (3) the stylistic attributes of the watermark, including color and transparency, which are applied in stage four.

[0119] The pseudo code of the image watermark generation method based on the thought chain strategy is as follows: Input: Enter the artistic image to be protected and the text content of the watermark t , initialize parameter group day Output: Initial watermarked image Iw The initial number of rounds round_count is set to 1, and the maximum number of rounds max_rounds is set to 10.

[0120] When round_count≤max_rounds, the loop executes: Stage 1: Image Analysis 1: ; / / Use the visual language model optimized by instructions to analyze the image and obtain the watermark scheme R.

[0121] 2: ; / / Extract the object description T, layout mode L, watermark color c, and watermark transparency from the watermark scheme R .

[0122] 3: By target color, matching color, dominant color C And the expression of the pixel color after tolerance fine-tuning calculates the color value c*; / / According to the target color, matching color, dominant color C And the expression of the pixel color after tolerance fine-tuning, convert the watermark color text description c into a numerical value c*.

[0123] Phase 2: Region Segmentation 4: ; / / Taking the art image, object description instruction T, and model parameter day as input, the Grounded SAM model is used to segment the area where the object described by T is located, and obtain the optimal area mask image M*.

[0124] Phase 3: Edge Optimization 5: ; / / Mask image for input , apply the Douglas-Peucker algorithm to extract the edge, and then use morphological image processing operations and edge indentation algorithm to smooth and indent the edge to obtain the reference closed polygon for watermark positioning .

[0125] Stage 4: Watermark text rendering 6: When the layout mode L indicates the straight line mode, execute: 7: ; / / Pick The longest side of the watermark is used as the positioning baseline, and the watermark text is specified according to the t ,color ,transparency , renders the watermark image of the specified style into the art image I On the above, we get the initial embedded watermark image .

[0126] 8: When the layout mode L indicates the curve mode, execute: 9: ; / / According to watermark text t The number of characters in A moderate number of adjacent edges form an edge group, and the starting edge is taken cyclically to obtain multiple edge groups. The edge group with the largest minimum angle among the edge groups is taken as the watermark positioning baseline for the watermark text. t Each character in is rendered onto an edge in the edge group according to the straight line mode. Finally, the initial embedded watermark image is obtained. .

[0127] Phase 5: Evaluation and selection 10: ; / / Use VLM to embed the initial watermark image Evaluate the watermark position and watermark size. The position is evaluated by comparing with the watermark scheme. R The comparison is carried out, and the size evaluation is to judge whether the font size is large enough to make the watermark clearly visible. The text results of the evaluation are and . and These are two status labels, indicating the stage of system selection and return.

[0128] 11: When When executing: Update the object description instruction T and return to stage 2 for region segmentation; / / According to Update the object description pointer T and return to the second iteration of the phase.

[0129] 12: When or When executing: 13: Adjust relevant parameters and return to stage 4 for watermark rendering; / / According to Update the corresponding parameters and return to the fourth iteration.

[0130] 14: If and only if , the entire cycle ends.

[0131] 15: After stage 5 is executed, the round number round_count is increased by 1.

[0132] 16: When the loop ends, return to the initial embedded watermark image .

[0133] Notably, by leveraging the open-set generalization capabilities of Grounded SAM and GPT-4o, our system ensures reliable output without the need for dataset-specific training.

[0134] This method is able to generate a five-stage watermark generation strategy based on knowledge links, which can generate artwork watermarks that take into account both aesthetics and visibility, and provide a reliable research paradigm for copyright protection and infringement avoidance of artworks.

[0135] In a verification embodiment, the experimental datasets include Wikiart dataset, Conllustration data and Finedge dataset; wherein, Wikiart: This is a large-scale art image dataset containing over 80,000 images and metadata of artworks, covering a wide range of styles, genres, and artists. We selected one or two representative works from each of 366 21st-century artists. We further filtered out non-illustration works such as photography, sculpture, and installation, as well as paintings with excessive nudity, resulting in 234 test images. This dataset is based on the paper (Saleh B, Elgammal A. Large-scale classification of fine-art paintings: Learning the right metric on the right feature[J]. arXiv preprint arXiv:1505.00855, 2015).

[0136] Conillustration: This dataset contains 3,238 illustrations by 18 renowned contemporary artists, selected by experienced artists. We removed images such as flatbed drawings and line drawings that are not suitable for watermarking using the edge-to-edge mode. We then selected an average of 13 images from each artist, resulting in a total of 237 test data. This dataset is based on the paper 2 (Ran C, Guo Y, Liu F, et al. FedStyle: Style-Based Federated Learning Crowdsourcing Framework for Art Commissions[C] / / 2024 IEEE International Conference on Multimedia and Expo (ICME). IEEE, 2024: 1-6.).

[0137] Finedge: is a contemporary illustration dataset manually collected from the Internet, containing 128 test cases.

[0138] (1) Comparison method Among existing platform tools, this example uses the representative image editing tool iLoveIMG and the watermarking tool watermarkly (source: https: / / watermarkly.com). Considering the potential of VLM-based image editing agents, we choose the most popular representative: Gemini 2.0 flash exp (source: Team G, Anil R, Borgeaud S, et al. Gemini: a family of highly capable multimodal models[J]. arXiv preprint arXiv:2312.11805, 2023). In addition, to evaluate the degree of integration between the watermark and the original image, we included the hidden watermarking method IRWArt (from the paper: Luo Y, Zhou T, Liu F, et al. IRWArt: Levering watermarking performance for protecting high-quality artwork images[C] / / Proceedings of the ACM web conference 2023. 2023: 2340-2348) for comparison (usually hidden watermarks are more invisible than visible watermarks and can be better integrated into the image).

[0139] (2) Indicators In terms of aesthetics, the ΔScore metric represents the increase in the aesthetic score of the watermarked image compared to the original image. The TANet model is used to evaluate the image's aesthetic score. Furthermore, PSNR and SSIM, commonly used visual similarity assessment metrics in the watermarking field, are used to assess the visual similarity between the images before and after watermarking, indirectly evaluating the degree of integration between the watermark and the visual content. In terms of protection, the effectiveness metric represents the proportion of test cases where the watermark successfully lands on salient areas, measuring the system's ability to protect key visual objects. The BASNet model is used to calculate salient areas. Larger values for these four metrics indicate better performance. The results of the quantitative comparison experiments are shown in Table 1.

[0140] Table 1 Quantitative comparison experimental results

[0141] Among them, the invisible watermark method IRWArt cannot be evaluated for its visual aesthetic score increment and effectiveness because the watermark is invisible.

[0142] As shown in Table 1, our method achieved the best or second-best scores on all indicators in all three datasets, verifying the effectiveness of our method in both aesthetics and watermark protection.

[0143] In one embodiment, an image watermark generation device based on a thought chain strategy is provided, comprising: an image and watermark text acquisition module, an artistic image analysis module, a watermark embedding region segmentation module, an edge optimization module, a watermark rendering module, and an evaluation and iteration module, wherein: The image and watermark text acquisition module is used to obtain the image to be protected and the watermark text content.

[0144] The art image analysis module is used to analyze the image to be protected using a visual language model to obtain a watermark scheme, and extract object description instructions, curvature layout patterns and style attributes of the watermark from the watermark scheme.

[0145] The watermark embedding region segmentation module is used to perform region segmentation using the GroundedSAM model according to the image to be protected and the object description instruction to obtain the optimal mask image.

[0146] The edge optimization module is used to optimize the edge of the optimal mask image to obtain a reference closed polygon for watermark positioning.

[0147] The watermark rendering module is used to embed the watermark in the spatial domain according to the image to be protected, the curvature layout mode, the watermark text content, the reference closed polygon and the style attributes of the watermark to obtain an initial embedded watermark image.

[0148] The evaluation and iteration module is used to evaluate the watermark position and size of the initial watermarked image using the VLM, and adjust or fine-tune the watermark position and size according to the obtained position evaluation results and watermark size evaluation results until the preset conditions are met to obtain the final watermarked image.

[0149] In one embodiment, the style attributes of the watermark include: the color and transparency of the watermark; the artistic image analysis module is also used to analyze the image to be protected using the visual language model GPT-4o to obtain a watermark scheme; the watermark scheme is cleaned and converted into a structured dictionary using regular expressions, and object description instructions, curvature layout patterns, watermark color text descriptions, and watermark transparency text descriptions are extracted from the structured dictionary; the watermark color text descriptions are converted into numerical values to obtain the watermark color.

[0150] In one embodiment, the art image analysis module is further configured to perform semantic analysis on the watermark color text description to obtain the target color:

[0151] in,t is the target color, is a function for converting a hexadecimal color code to an RGB triplet, A function that matches the input to a standard CSS3 color name. is a function for fuzzy semantic matching based on keywords. c A text description of the watermark color.

[0152] The KMeans clustering algorithm is used to extract the dominant color set from the image to be protected; the target color is matched and compared with the dominant color set, and the matching color is obtained as follows:

[0153] in, To match the color, is the CIEDE2000 color difference metric, It is a function that converts the original image in RGB mode to Lab mode. C is the dominant color set extracted by the KMeans clustering algorithm, The dominant color set extracted by the KMeans clustering algorithm C A color in the.

[0154] Apply a tolerance fine-tuning to the matched color to get the color of the watermark.

[0155] In one embodiment, the Grounded SAM model includes an open-set object detector Grounding DINO and a prompt-driven segmentation model SAM; the watermark embedding region segmentation module is further used to extract bounding boxes and semantic associations using the open-set object detector Grounding DINO based on the image to be protected and the object description instructions; the bounding boxes and semantic associations are filtered according to the confidence threshold and the text threshold; the prompt-driven segmentation model SAM is used to perform image segmentation on the passed bounding boxes, generate a mask, and select the optimal mask image based on the text similarity of the filtered semantic associations.

[0156] In one embodiment, the edge optimization module is further configured to perform morphological aesthetic optimization on the optimal mask image to eliminate noise and smooth edges, thereby obtaining an optimized mask image; perform binary threshold processing and external contour detection on the optimized mask image to obtain all detected contours; and apply the Douglas-Peck algorithm to each contour to generate a shape-preserving polygonal representation of the contour as follows:

[0157] in, Maintain a polygonal representation for the shape of the outline, is the adaptive precision dilution, For outline The circumference of is the smoothing factor, is the minimum smoothing error.

[0158] For each contour shape, keep each point in the polygonal representation of the point sequence , calculation point and the normal vector of the line segment formed by its adjacent points, and then move the offset distance along the normal vector d , get the offset points; reconstruct the offset contour by calculating the intersection points of the offset line segments; select the offset contour with the largest number of points as the reference closed polygon for watermark positioning.

[0159] In one embodiment, the watermark rendering module is further configured to, when the curvature layout mode is the "edge" mode: place the watermark text content on the longest line segment of the reference closed polygon edge; wherein the total width of the text is determined by the width of a single character and the spacing between characters; i The actual position of the character and the rotation angle relative to the line segment direction are:

[0160]

[0161] in, For the i The actual position of the characters, is the starting point of the longest line segment, offset is the offset, is the width of the jth character, is the width of the i-th character, is the unit direction vector, s is the spacing between characters; is the angle of the longest line segment where the character is located, For the i The rotation angle of the character.

[0162] For the center of rotation The character image, its position after rotation is shown in the above-mentioned expression of position after rotation.

[0163] Watermark text image Transparently superimpose it on the image to be protected and render it to obtain the initial embedded watermark image; the pixel-by-pixel transparency interpolation formula is:

[0164] in, is the initial watermarked image, is the transparency of the character image, is the watermark text image, This is the image to be protected.

[0165] When the curvature layout mode is "Curve" mode: the reference closed polygon is converted into an equilateral polygon, and then the vector segments are grouped according to the number of characters in the watermark text content; the minimum inner angle is calculated for each group, and the group with the largest minimum inner angle is selected, each character in the watermark text content is regarded as a complete text and rendered onto a line segment, and the operation is repeated in "Edge" mode to obtain the initial embedded watermark image.

[0166] In one embodiment, the evaluation and iteration module is further configured to evaluate the watermark position and size of the initial watermarked image using the VLM; if the watermark position does not match a predefined watermarking scheme, the object description instruction is adjusted or fine-tuned; if the size of the watermark is not visually significant, the watermark position and size are adjusted or fine-tuned, and the watermarked image is continued to be generated; the watermarked image is continued to be generated until a preset condition is met to obtain a final watermarked image; the preset condition is that the watermark position matches the predefined watermarking scheme and the watermark size is visually significant.

[0167] Regarding the specific limitations of the image watermark generation device based on the thought chain strategy, please refer to the limitations of the image watermark generation method based on the thought chain strategy above, and will not be repeated here. The various modules in the above-mentioned image watermark generation device based on the thought chain strategy can be implemented in whole or in part through software, hardware, or a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the corresponding operations of the above modules.

[0168] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 3 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a method for generating an image watermark based on a thought chain strategy is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad provided on the computer device housing, or an external keyboard, touchpad or mouse.

[0169] Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0170] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps in the above method embodiment when executing the computer program.

[0171] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0172] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.

Claims

1. A method for generating image watermark based on thought chain strategy, characterized in that: The method comprises: Get the image to be protected and the watermark text content; Analyzing the image to be protected using a visual language model to obtain a watermark scheme, and extracting object description instructions, curvature layout patterns, and style attributes of the watermark from the watermark scheme; According to the image to be protected and the object description instruction, a Grounded SAM model is used to perform region segmentation to obtain an optimal mask image; Performing edge optimization on the optimal mask image to obtain a reference closed polygon for watermark positioning; Embedding a watermark in a spatial domain according to the image to be protected, the curvature layout pattern, the watermark text content, the reference closed polygon, and the style attribute of the watermark to obtain an initial embedded watermark image; The VLM is used to evaluate the watermark position and size of the initial watermarked image, and the position and size of the watermark are adjusted or fine-tuned according to the obtained position evaluation results and watermark size evaluation results until the preset conditions are met to obtain the final watermarked image.

2. The image watermark generation method based on the thought chain strategy according to claim 1 is characterized in that: The style attributes of a watermark include: the color and transparency of the watermark; The image to be protected is analyzed using a visual language model to obtain a watermark scheme, and object description instructions, curvature layout patterns, and style attributes of the watermark are extracted from the watermark scheme, including: The visual language model GPT-4o is used to analyze the image to be protected and obtain the watermark solution; The watermark scheme is cleaned and converted into a structured dictionary using regular expressions, and object description instructions, curvature layout patterns, watermark color text descriptions, and watermark transparency text descriptions are extracted from the structured dictionary; The watermark color text description is converted into a numerical value to obtain the watermark color.

3. The image watermark generation method based on thought chain strategy according to claim 2 is characterized in that: Convert the watermark color text description into a numerical value to obtain the watermark color, including: Perform semantic analysis on the watermark color text description and obtain the target color: in, t is the target color, is a function for converting a hexadecimal color code to an RGB triplet, A function that matches the input to a standard CSS3 color name. is a function for fuzzy semantic matching based on keywords. c A text description of the watermark color; A KMeans clustering algorithm is used to extract a dominant color set from the image to be protected; The target color is matched and compared with the dominant color set, and the matched color is obtained as follows: in, To match the color, is the CIEDE2000 color difference metric, It is a function that converts the RGB mode to the Lab mode original image. C is the dominant color set extracted by the KMeans clustering algorithm, The dominant color set extracted by the KMeans clustering algorithm C A color in Apply a tolerance fine-tuning to the matched color to obtain the color of the watermark.

4. The image watermark generation method based on thought chain strategy according to claim 1 is characterized in that: The Grounded SAM model includes an open set target detector Grounding DINO and a prompt-driven segmentation model SAM; Based on the image to be protected and the object description instruction, a Grounded SAM model is used to perform region segmentation to obtain an optimal mask image, including: Extracting bounding boxes and semantic associations using the open set object detector Grounding DINO according to the image to be protected and the object description instruction; Filter bounding boxes and semantic associations based on confidence thresholds and text thresholds; A hint-driven segmentation model (SAM) is used to segment the bounding box after image segmentation, generate a mask, and select the optimal mask image based on the text similarity of the filtered semantic association.

5. The image watermark generation method based on thought chain strategy according to claim 1 is characterized in that: Performing edge optimization on the optimal mask image to obtain a reference closed polygon for watermark positioning includes: performing morphological aesthetic optimization on the optimal mask image to eliminate noise and smooth edges, thereby obtaining an optimized mask image; Perform binary threshold processing and external contour detection on the optimized mask image to obtain all detected contours; The Douglas-Peck algorithm is applied to each contour, and the shape-preserving polygonal representation of the generated contour is: in, Maintain a polygonal representation for the shape of the outline, is the adaptive precision dilution, For outline The circumference of is the smoothing factor, is the minimum smoothing error; For each contour shape, keep each point in the polygonal representation of the point sequence , calculation point and the normal vector of the line segment formed by its adjacent points, and then move the offset distance along the normal vector d , get the offset point; Reconstruct the offset contour by calculating the intersection points of the offset line segments; The offset contour with the largest number of points is selected as the reference closed polygon for watermark positioning.

6. The image watermark generation method based on thought chain strategy according to claim 1 is characterized in that: Embedding a watermark in a spatial domain according to the image to be protected, the curvature layout pattern, the watermark text content, the reference closed polygon, and the style attribute of the watermark to obtain an initial embedded watermark image, including: When the curvature layout mode is "edge" mode: The watermark text content is placed on the longest line segment of the reference closed polygon edge; wherein the total width of the text is determined by the width of a single character and the spacing between characters; i The actual position of the character and the rotation angle relative to the line segment direction are: in, For the i The actual position of the characters, is the starting point of the longest line segment, offset is the offset, is the width of the jth character, is the width of the i-th character, is the unit direction vector, s is the spacing between characters; is the angle of the longest line segment where the character is located, For the i The rotation angle of each character; For the center of rotation The character image, its position after rotation is: in, The center of rotation is The position of the character image after rotation, is the rotation matrix, is the center of rotation, is the position of the character image before rotation; The watermark text image is transparently superimposed on the image to be protected and rendered to obtain the initial embedded watermark image; the pixel-by-pixel transparency interpolation formula is: in, is the initial watermarked image, is the transparency of the character image, is the watermark text image, is the image to be protected; When the curvature layout mode is "curve" mode: Converting the reference closed polygon into an equilateral polygon, and then grouping the line segments of the vector according to the number of characters in the watermark text content; Calculate the minimum inner angle for each group and select the group with the largest minimum inner angle. Treat each character in the watermark text content as a complete text and render it onto a line segment. Repeat the operation in the "edge" mode to obtain the initial embedded watermark image.

7. The image watermark generation method based on thought chain strategy according to claim 1 is characterized in that: The VLM is used to evaluate the watermark position and size of the initial watermarked image, and the position and size of the watermark are adjusted or fine-tuned according to the obtained position evaluation results and watermark size evaluation results until preset conditions are met to obtain a final watermarked image, including: Using VLM to evaluate the watermark position and size of the initial watermarked image; If the position of the watermark does not match the predefined watermark scheme, adjusting or fine-tuning the object description instruction; If the size of the watermark is not visually significant, the position and size of the watermark are adjusted or fine-tuned, and the watermark image is continued to be generated; The watermark image is continuously generated until a preset condition is satisfied, thereby obtaining a final embedded watermark image; the preset condition is that the position of the watermark matches a predefined watermark scheme and the size of the watermark is visually significant.

8. An image watermark generation device based on thought chain strategy, characterized in that: The device comprises: Image and watermark text acquisition module, used to obtain the image and watermark text content to be protected; an art image analysis module, configured to analyze the image to be protected using a visual language model to obtain a watermark scheme, and extract object description instructions, curvature layout patterns, and style attributes of the watermark from the watermark scheme; A watermark embedding region segmentation module is used to perform region segmentation using a Grounded SAM model according to the image to be protected and the object description instruction to obtain an optimal mask image; An edge optimization module, configured to perform edge optimization on the optimal mask image to obtain a reference closed polygon for watermark positioning; a watermark rendering module, configured to embed the watermark in the spatial domain according to the image to be protected, the curvature layout pattern, the watermark text content, the reference closed polygon, and the style attributes of the watermark, to obtain an initial embedded watermark image; The evaluation and iteration module is used to evaluate the watermark position and size of the initial watermarked image using the VLM, and adjust or fine-tune the position and size of the watermark according to the obtained position evaluation results and watermark size evaluation results until the preset conditions are met, thereby obtaining the final watermarked image.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the image watermark generation method based on the thought chain strategy described in any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Watermark adaptive placement and fusion method, device and equipment based on perspective constraint

    CN122115187A

  • A method, apparatus, and device for adaptive placement and fusion of watermarks based on perspective constraints.

    CN122115187B