Electronic rotary sewing stamp visual implementation method
By employing image preprocessing, geometric modeling, and precise mounting techniques, the problem of the abrupt visual effect of electronic seals has been solved, achieving visual continuity and formal compliance, and meeting the high requirements of government and taxation sectors.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHUGEYUN (SICHUAN) DIGITAL TECHNOLOGY CO LTD
- Filing Date
- 2026-01-21
- Publication Date
- 2026-04-28
AI Technical Summary
Existing electronic seal technology lacks systematic collaborative design when processing multi-page documents, and cannot simulate the natural rotation shape of physical seals. This results in a stiff visual effect of the generated electronic seals, which cannot meet the high requirements for formal compliance in government affairs and taxation.
By image preprocessing, geometric modeling, non-uniform cutting, and precise mounting, a geometric model for uniform page unfolding is constructed. The rotation angle is derived and sub-image rotation correction is performed to ensure that the effective area of the seal fits the edge of the document page. The rotation angle is solved using Newton's iterative method to achieve precise mounting of the seal.
It simulates the natural unfolding state of a physical seal, enhancing the visual continuity and realism of the electronic seal, meeting the formal compliance requirements of electronic documents, and improving visual fidelity and scene adaptability.
Smart Images

Figure CN121582382B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electronic signature technology, and in particular to a method for visualizing an electronic rotating seal across the seam. Background Technology
[0002] With the deepening of paperless office practices, electronic signature technology has become a key support for achieving end-to-end digitalization in government, commerce, and finance, playing an increasingly prominent role in ensuring the legality and credibility of electronic documents. At the technological development level, electronic signatures rely on mature asymmetric encryption digital signature technology to build a strong data security defense, and continue to deeply integrate with new technologies such as blockchain and cloud computing, constantly optimizing reliability, convenience, and anti-counterfeiting capabilities. Currently, electronic signatures are widely used in various scenarios such as contract signing, audit report issuance, and the circulation of financial and tax documents, becoming an indispensable core tool in the process of digital transformation. In multi-page document processing scenarios, the cross-sealing seal, as an important identifier with both anti-counterfeiting and compliance attributes, is experiencing increasing application demand. Existing technologies have accumulated certain technical expertise in basic seal image processing and simple cross-sealing seal generation, meeting the needs of some basic application scenarios and providing basic support for large-scale industry applications.
[0003] However, current electronic seal technologies still have significant shortcomings, failing to meet the high requirements of various fields for the realism and formal compliance of signature visualization. Existing solutions lack systematic collaborative design when handling multi-page document seals. They do not construct geometric models adapted to the natural unfolding state of the document, nor do they derive the precise rotation angles corresponding to each page using scientific methods. This results in rotation angle settings lacking theoretical basis and relying solely on empirical values or fixed parameters. Furthermore, the segmentation of the seal image often uses a simple proportional division method, without considering the document's rotation state for targeted non-proportional segmentation. The segmented sub-images do not undergo rotation correction processing to adapt to the page edges, and the derivation of the mounting coordinates does not form a logical closed loop with the segmentation and rotation processes, only performing simple position mapping. These problems directly result in the generated electronic seal having a static and rigid visual effect, failing to simulate the continuous rotation of a physical seal when the document is naturally unfolded. The effective area of the seal does not fit well with the edge of the document, easily leading to misalignment, blank spaces, and other issues. It is difficult to reproduce the real visual experience of a physical seal, which in turn affects the formal standardization of electronic documents and fails to meet the application needs of government affairs, finance and taxation, and other fields that have high requirements for the rigor of document format. Summary of the Invention
[0004] The purpose of this invention is to overcome the shortcomings of the prior art and provide a method for visualizing the electronic rotating seal.
[0005] The objective of this invention is achieved through the following technical solution:
[0006] A method for visualizing an electronic rotating seal is provided, which includes the following steps:
[0007] S1. Preprocess and adjust the pixels of the seal image to obtain a processed seal image that matches the proportions of the physical seal.
[0008] S2. Based on the size of the processed stamp image and the number of document pages, construct a geometric model for uniformly unfolding the pages, derive the rotation angle equation, and solve for the rotation angle corresponding to each page of the document.
[0009] S3. Based on the rotation angle obtained from the solution and the size of the processed seal image, the processed seal image is divided according to the non-uniform cutting general formula to obtain a sub-image containing the effective area;
[0010] S4. Rotate and correct the sub-images according to the rotation angles corresponding to each page, deduce the mounting coordinates based on the coordinate information during the segmentation process, and mount the corrected sub-images to the corresponding document pages according to the mounting coordinates.
[0011] Furthermore, in step S1, step S1 includes:
[0012] S1.1. Convert the RGB color space of the original seal image to the HSV color space, identify the target color area based on the preset range of hue, saturation and lightness, scan the image line by line to detect the continuously appearing target color pixels, determine the left, right, top and bottom edge coordinates of the valid seal, perform edge removal processing on the image to remove the redundant background outside the edge, use a noise reduction algorithm to eliminate isolated noise pixels in the image, and set the non-target color area to transparent.
[0013] S1.2. Based on the actual size of the physical seal, calculate the pixel adjustment ratio, enlarge the number of pixels in the effective seal area, and compress multiple consecutive pixels into a single display point during document rendering to maintain the same ratio as the physical seal, thereby obtaining a processed seal image containing width and height parameters. The width and height parameters of the processed seal image provide basic parameters for geometric modeling.
[0014] Furthermore, step S2 includes:
[0015] S2.1. Construct a uniformly unfolded page geometric model. The uniformly unfolded page geometric model includes a document unfolding constraint module and a stamp distribution constraint module. The document unfolding constraint module sets the document to unfold uniformly with the lower left corner as the rotation center, and the rotation angle between adjacent documents remains the same, clarifying the coordinate reference of the rotation center and the requirement for angle consistency. The stamp distribution constraint module sets the processed stamp image to be uniformly distributed on each page of the document, and the right edge of each page of the document passes through the center line of the bisector of the stamp image. The output parameters of the two constraint modules together form the constraint conditions of the model. The constraint conditions clarify the relationship between the width and height parameters and the position of the document page, and the correspondence between the bisector of the stamp and the edge of the document.
[0016] S2.2. Based on the constraints and the width and height parameters of the processed seal image, the rotation angle equation is derived through the rotation angle equation derivation module. The equation is then passed to the numerical solution module, which uses Newton's iteration method to solve for the rotation angle corresponding to each page. This rotation angle provides angle parameters for image segmentation and sub-image rotation.
[0017] Furthermore, in step S3, the calculation of the parameters related to the segmentation point is as follows:
[0018] ;
[0019] in, For the first The horizontal coordinates of the left segmentation point in Zhang Zi's image. For the first The horizontal coordinates of the right segmentation point in Zhang Zi's image. For the first Intermediate segmentation parameters of the Zhangzi image, For the first The horizontal parameter of the left segmentation line in the image of Zhang Zi. For sub-image sequence number, The width of the processed seal image. For the number of document pages, The height of the processed seal image. The rotation angle is output by the numerical solution module; the vertical coordinates of the segmentation points are determined based on the uniform distribution of the height of the processed seal image. The vertical coordinates are calculated according to the equal division ratio of the image height. The segmentation line covers the entire effective area of the seal image in the vertical direction. The horizontal and vertical coordinates of the segmentation points together constitute the key parameters of the segmentation line. The segmentation line segments the seal image according to the non-uniform cutting formula.
[0020] Furthermore, in step S3, after segmenting the stamp image, the generated sub-images are scanned pixel by pixel in a left-to-right, top-to-bottom order. The equations of the left and right segmentation lines are determined based on the coordinates of the segmentation points and the height of the processed stamp image, as follows:
[0021] The equations for the left and right dividing lines are:
[0022] ;
[0023] Pixels located to the left of the left dividing line or to the right of the right dividing line are made transparent. The parameters of the dividing line equation are related to the geometric model constraints. The sub-image after transparency processing only retains the pixels in the effective area of the stamp.
[0024] Furthermore, in step S4, the formula for calculating the sub-image rotation angle is:
[0025] ;
[0026] in, Rotation angle of the sub-image For the number of document pages, For sub-image sequence number, This is the rotation angle output by the numerical solution module. During the rotation process, the top left corner of the sub-image is used as the rotation center, and the sub-image is rotated clockwise according to the calculated rotation angle. After the rotation, the size of the sub-image is recalculated. The effective area of the sub-image fits the edge of the document page. The rotated sub-image retains the original pixel color information and relative position relationship.
[0027] Furthermore, in step S4, the derivation of the mounting coordinates requires first converting the coordinates of the segmentation point into the first... The coordinates of the page document relative to a reference point, where the reference point is set to the [page number]. In the bottom left corner of the document, during the conversion process, the positional offset relationship between the split point coordinates and the reference point is clearly defined. Then, according to the document expansion constraint module's requirements of uniformly expanding the document with the bottom left corner as the center and adjacent documents rotating at the same angle, the converted coordinates are calculated using the rotation angle output by the numerical solution module. Perform a counter-clockwise rotation and use coordinate rotation calculations to obtain the mounting coordinates of the sub-image on the corresponding document page. The mounting coordinates determine the specific position of the sub-image on the document page.
[0028] Furthermore, in step S1.2, when adjusting the pixels of the effective stamp area, the pixel magnification factor is determined based on the actual size of the physical stamp and the pixel ratio of the original stamp image, and the number of pixels in the effective stamp area is magnified. During the magnification process, the color information and relative position of the pixels remain unchanged. During document rendering, multiple consecutive pixels are compressed into a single display point by the magnification factor to maintain the same ratio as the physical stamp. The width and height parameters of the adjusted and processed stamp image are directly passed into the geometric model as input parameters for the document expansion constraint module and the stamp distribution constraint module.
[0029] Furthermore, in step S2.2, the equation for calculating the rotation angle is:
[0030] ;
[0031] in, The width of the processed seal image. The height of the processed seal image. This is the distance between the stamp image and the top right edge of the last page of the document. For the height of the stamped document, The width of the stamp document; the key parameters of the numerical solution module include the initial iteration value and the iteration error threshold. The solution steps are as follows: set the initial iteration value, substitute it into the iteration formula to calculate the new rotation angle, compare the difference between the rotation angles obtained from two adjacent calculations with the iteration error threshold. If the difference is less than the threshold, output the rotation angle. If the difference is greater than or equal to the threshold, use the new rotation angle as the initial value to repeat the iteration calculation until the error requirement is met.
[0032] Furthermore, in step S2.1, the document expansion constraint module and the stamp distribution constraint module are hierarchically related. The document expansion constraint module outputs basic constraint parameters relating the rotation center and the rotation angle of adjacent documents. These output parameters serve as input to the stamp distribution constraint module. The stamp distribution constraint module, in conjunction with the width and height parameters of the processed stamp image, outputs constraint parameters relating the position of the stamp dividing line and the correspondence between the document edge and the dividing line. The constraint conditions output by the two modules together include the positional association between the width and height of the processed stamp image and the document page, and the correspondence between the stamp dividing line and the document edge.
[0033] The beneficial effects of this invention are:
[0034] (1) Based on image preprocessing, geometric modeling, non-proportional cutting and precise mounting, the physical seal is simulated to unfold naturally, so that the electronic seal is visually continuous and realistic, which meets the compliance requirements of electronic document format.
[0035] (2) The application of precise technologies such as color space conversion and numerical solution of rotation angle effectively solves the problems of rigid segmentation and size distortion of traditional signatures, and improves the visual fidelity and scene adaptability of electronic signatures;
[0036] (3) Modular algorithm design and parameter verification mechanism are compatible with various document formats and operating systems, ensuring the stability and reliability of the signing process and providing efficient and standardized technical support for electronic document processing. Attached Figure Description
[0037] Figure 1 A flowchart illustrating the steps of a method for visualizing an electronic rotating seal.
[0038] Figure 2 The example image shows the effect of directly pasting the cut stamp.
[0039] Figure 3 The image provided is an example of the effect after self-image rotation;
[0040] Figure 4 The image provided in this embodiment shows the effect of removing the edges from the stamp image;
[0041] Figure 5 Example diagram of enhanced and compressed display of a seal image provided in the embodiment;
[0042] Figure 6 A schematic diagram of document rotation provided for an embodiment;
[0043] Figure 7 The provided example provides a schematic diagram of seal cutting.
[0044] Figure 8 The provided example is a diagram of the rotation angle calculation model;
[0045] Figure 9 The provided example is a diagram of a model for calculating the coordinates of a seal sub-image.
[0046] Figure 10 A diagram illustrating the model for calculating the size of a rotated image of a seal, provided in this embodiment.
[0047] Figure 11 This is a schematic diagram illustrating the calculation of document mount point coordinates for an example. Detailed Implementation
[0048] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0049] Example 1
[0050] See Figure 1 This paper provides a method for visualizing an electronic rotating seal, which includes the following steps:
[0051] S1. Preprocess and adjust the pixels of the seal image to obtain a processed seal image that matches the proportions of the physical seal.
[0052] S2. Based on the size of the processed stamp image and the number of document pages, construct a geometric model for uniformly unfolding the pages, derive the rotation angle equation, and solve for the rotation angle corresponding to each page of the document.
[0053] S3. Based on the rotation angle obtained from the solution and the size of the processed seal image, the processed seal image is divided according to the non-uniform cutting general formula to obtain a sub-image containing the effective area;
[0054] S4. Rotate and correct the sub-images according to the rotation angles corresponding to each page, deduce the mounting coordinates based on the coordinate information during the segmentation process, and mount the corrected sub-images to the corresponding document pages according to the mounting coordinates.
[0055] In step S1, step S1 includes:
[0056] S1.1. Convert the RGB color space of the original seal image to the HSV color space, identify the target color area based on the preset range of hue, saturation and lightness, scan the image line by line to detect the continuously appearing target color pixels, determine the left, right, top and bottom edge coordinates of the valid seal, perform edge removal processing on the image to remove the redundant background outside the edge, use a noise reduction algorithm to eliminate isolated noise pixels in the image, and set the non-target color area to transparent.
[0057] S1.2. Based on the actual size of the physical seal, calculate the pixel adjustment ratio, enlarge the number of pixels in the effective seal area, and compress multiple consecutive pixels into a single display point during document rendering to maintain the same ratio as the physical seal, thereby obtaining a processed seal image containing width and height parameters. The width and height parameters of the processed seal image provide basic parameters for geometric modeling.
[0058] Step S2 includes:
[0059] S2.1. Construct a uniformly unfolded page geometric model. The uniformly unfolded page geometric model includes a document unfolding constraint module and a stamp distribution constraint module. The document unfolding constraint module sets the document to unfold uniformly with the lower left corner as the rotation center, and the rotation angle between adjacent documents remains the same, clarifying the coordinate reference of the rotation center and the requirement for angle consistency. The stamp distribution constraint module sets the processed stamp image to be uniformly distributed on each page of the document, and the right edge of each page of the document passes through the center line of the bisector of the stamp image. The output parameters of the two constraint modules together form the constraint conditions of the model. The constraint conditions clarify the relationship between the width and height parameters and the position of the document page, and the correspondence between the bisector of the stamp and the edge of the document.
[0060] S2.2. Based on the constraints and the width and height parameters of the processed seal image, the rotation angle equation is derived through the rotation angle equation derivation module. The equation is then passed to the numerical solution module, which uses Newton's iteration method to solve for the rotation angle corresponding to each page. This rotation angle provides angle parameters for image segmentation and sub-image rotation.
[0061] In step S3, the parameters related to the segmentation point are calculated as follows:
[0062] ;
[0063] in, For the first The horizontal coordinates of the left segmentation point in Zhang Zi's image. For the first The horizontal coordinates of the right segmentation point in Zhang Zi's image. For the first Intermediate segmentation parameters of the Zhangzi image, For the first The horizontal parameter of the left segmentation line in the image of Zhang Zi. For sub-image sequence number, The width of the processed seal image. For the number of document pages, The height of the processed seal image. The rotation angle is output by the numerical solution module; the vertical coordinates of the segmentation points are determined based on the uniform distribution of the height of the processed seal image. The vertical coordinates are calculated according to the equal division ratio of the image height. The segmentation line covers the entire effective area of the seal image in the vertical direction. The horizontal and vertical coordinates of the segmentation points together constitute the key parameters of the segmentation line. The segmentation line segments the seal image according to the non-uniform cutting formula.
[0064] In step S3, after segmenting the stamp image, the generated sub-images are scanned pixel by pixel from left to right and from top to bottom. The equations of the left and right segmentation lines are determined based on the coordinates of the segmentation points and the height of the processed stamp image, as follows:
[0065] The equations for the left and right dividing lines are:
[0066] ;
[0067] Pixels located to the left of the left dividing line or to the right of the right dividing line are made transparent. The parameters of the dividing line equation are related to the geometric model constraints. The sub-image after transparency processing only retains the pixels in the effective area of the stamp.
[0068] In step S4, the formula for calculating the sub-image rotation angle is:
[0069] ;
[0070] in, Rotation angle of the sub-image For the number of document pages, For sub-image sequence number, This is the rotation angle output by the numerical solution module. During the rotation process, the top left corner of the sub-image is used as the rotation center, and the sub-image is rotated clockwise according to the calculated rotation angle. After the rotation, the size of the sub-image is recalculated. The effective area of the sub-image fits the edge of the document page. The rotated sub-image retains the original pixel color information and relative position relationship.
[0071] In step S4, the derivation of the mounting coordinates requires first converting the coordinates of the segmentation point to the first... The coordinates of the page document relative to a reference point, where the reference point is set to the [page number]. In the bottom left corner of the document, during the conversion process, the positional offset relationship between the split point coordinates and the reference point is clearly defined. Then, according to the document expansion constraint module's requirements of uniformly expanding the document with the bottom left corner as the center and adjacent documents rotating at the same angle, the converted coordinates are calculated using the rotation angle output by the numerical solution module. Perform a counter-clockwise rotation and use coordinate rotation calculations to obtain the mounting coordinates of the sub-image on the corresponding document page. The mounting coordinates determine the specific position of the sub-image on the document page.
[0072] In step S1.2, when adjusting the pixels of the effective stamp area, the pixel magnification factor is determined based on the actual size of the physical stamp and the pixel ratio of the original stamp image. The number of pixels in the effective stamp area is magnified, and the color information and relative position of the pixels are kept unchanged during the magnification process. During document rendering, multiple consecutive pixels are compressed into a single display point by the magnification factor to maintain the same ratio as the physical stamp. The width and height parameters of the adjusted and processed stamp image are directly passed into the geometric model as input parameters for the document expansion constraint module and the stamp distribution constraint module.
[0073] In step S2.2, the equation for calculating the rotation angle is:
[0074] ;
[0075] in, The width of the processed seal image. The height of the processed seal image. This is the distance between the stamp image and the top right edge of the last page of the document. For the height of the stamped document, The width of the stamp document; the key parameters of the numerical solution module include the initial iteration value and the iteration error threshold. The solution steps are as follows: set the initial iteration value, substitute it into the iteration formula to calculate the new rotation angle, compare the difference between the rotation angles obtained from two adjacent calculations with the iteration error threshold. If the difference is less than the threshold, output the rotation angle. If the difference is greater than or equal to the threshold, use the new rotation angle as the initial value to repeat the iteration calculation until the error requirement is met.
[0076] In step S2.1, the document expansion constraint module and the stamp distribution constraint module are hierarchically related. The document expansion constraint module outputs basic constraint parameters relating the rotation center and the rotation angle of adjacent documents. These output parameters serve as input to the stamp distribution constraint module. The stamp distribution constraint module, in conjunction with the width and height parameters of the processed stamp image, outputs constraint parameters relating the position of the stamp dividing line and the correspondence between the document edge and the dividing line. The constraint conditions output by the two modules together include the positional association between the width and height of the processed stamp image and the document page, and the correspondence between the stamp dividing line and the document edge.
[0077] Example 2
[0078] This embodiment provides a specific implementation process for a method to visualize an electronic rotating seal across the seam. This process, through image preprocessing, pixel adjustment, rotation angle calculation, non-proportional cutting of the seal, sub-image rotation correction, and precise mounting, simulates the natural unfolding effect of a physical seal, ensuring the visual continuity and realism of the electronic seal across the seam, and meeting the compliance requirements for electronic document formats. The specific implementation is as follows:
[0079] See Figure 2 After the seal image is cut into non-proportional dimensions, due to the limitations of computer rectangular storage, all sub-images must be saved in rectangular format. In addition to the effective area of the seal composed of red pixels, it also contains a large amount of transparent fill due to rectangular storage. If it is directly pasted into the document page, it will result in misalignment and blank space, which will destroy the visual continuity of the seal across the seam.
[0080] See Figure 3 After the sub-image is corrected by clockwise rotation, the effective area can closely fit the right edge of the document page, the interference of the transparent filling part is avoided, the visual continuity of the seal is guaranteed, and the pixel color information and relative position relationship remain unchanged during the rotation process.
[0081] In some embodiments, the image preprocessing noise reduction algorithm can be flexibly selected according to the type of noise in the seal image. In addition to median filtering, Gaussian filtering can be used to process uniformly distributed fine noise, or bilateral filtering can be used to preserve the details of the seal edge while reducing noise. When the seal image has a lot of high-frequency noise, grayscale preprocessing can be performed first, followed by noise reduction, to ensure the accuracy of target color region recognition without changing the core logic of color space conversion and edge detection.
[0082] In some embodiments, image preprocessing is a crucial step in refining the effective area of the stamp. Through color space conversion, target region identification, edge detection, edge removal and noise reduction, and transparency processing, redundant information in the original image is removed, providing high-quality data for subsequent operations. For example... Figure 4The image shown illustrates the edge removal effect of a stamp image. Assuming the top-left vertex of the image is the origin, the starting y-coordinate of the effective area is calculated as the distance from the top edge of the original image. Starting from y=0, each row searches for a red pixel in the HSV space within a preset red interval. If no red pixel is found, the scan line moves down one pixel. If a red pixel is found and the next scan line also finds a red pixel, the pixel that the scan line moved down is recorded as the y-coordinate of the top edge of the effective area. This method can remove interference from isolated pixels in the white area. The same method can be used to detect the left, right, and bottom edge coordinates of the effective area. The detection of the four edge coordinates is independent of each other, and four independent threads can be used for parallel processing to improve efficiency.
[0083] In some embodiments, the magnification factor of pixel adjustment The DPI (dots per inch) parameter can be automatically calculated based on the document rendering resolution, eliminating the need for manual configuration. Specifically, it obtains the document's DPI parameter and, combined with the physical dimensions of the physical stamp, calculates it using the following formula: The calculations ensure that the enlarged seal image remains clearly displayed in documents of different resolutions and is compatible with the rendering features of different document processing libraries such as itextPDF and PDFBox.
[0084] Color space conversion follows the formula:
[0085] set up ,in After conversion The calculation methods for each parameter are as follows:
[0086] The formula for calculating M is:
[0087] ;
[0088] The formula for calculating m is:
[0089] ;
[0090] The formula for calculating V is:
[0091] ;
[0092] The formula for calculating S is:
[0093] ;
[0094] The calculation of H involves three cases, and the calculation formulas are as follows:
[0095] When r=M, the calculation formula is:
[0096] ;
[0097] When g=M, the calculation formula is:
[0098] ;
[0099] When b=M, the calculation formula is:
[0100] ;
[0101] If H < 0, then the calculation formula is:
[0102] ;
[0103] After converting to HSV color space, referencing OpenCV's color gamut setting standards, define the range of the target color (red) for the stamp. The calculation formula is as follows:
[0104] ;
[0105] After determining the edge coordinates, edge removal is performed according to the coordinates, cropping excess background pixels, using a median filtering algorithm to eliminate isolated noise, and finally setting non-red area pixels to complete transparency to obtain a clean image of the effective red area. Simultaneously, the pixel adjustment ratio is calculated based on the actual size of the physical seal, enlarging the number of pixels in the effective seal area. During document rendering, multiple consecutive pixels are compressed into a single display point to maintain the same proportion as the physical seal, resulting in a processed seal image with width and height parameters. These parameters provide the basic input for subsequent geometric modeling.
[0106] In some embodiments, the method can be adapted to various electronic document formats such as PDF and OFD. The core algorithm logic remains unchanged. It only needs to obtain parameters such as document page size and margin by calling the corresponding format parsing library (such as OFD parsing library, PDFBox, etc.), and then calculate the rotation angle, split point coordinates and mounting coordinates according to the same rules to ensure that documents of different formats can generate a consistent rotating seal effect.
[0107] Pixel adjustment uses a "enlarge first, compress later" logic to solve the problem of incompatibility between pixels and document page units, achieving proportional matching between the seal image and the actual seal, while improving rendering quality.
[0108] In some embodiments, such as Figure 5The image shown is an example of compressed display after stamp image enhancement. Computers read documents in units of points (points). A standard A4 document page size is 595×842 points, while stamp images are stored in units of pixels. Pixels and points have no direct physical relationship; for example, a 42mm×42mm stamp will display poorly when converted to 119×119 pixels by default. By enlarging the stamp image by a factor of p, the pixel size becomes 119p×119p. During rendering, p pixels are compressed into a single display point, improving rendering quality while ensuring the stamp size meets requirements. During the adjustment process, the magnification factor is determined based on the pixel ratio between the actual size of the physical stamp and the original stamp image. The color information and relative position of the pixels remain unchanged during magnification. The adjusted width and height parameters of the processed stamp image are directly input into the geometric model as input parameters for the document expansion constraint module and the stamp distribution constraint module, ensuring accurate matching between subsequent modeling and the actual stamp size.
[0109] In some embodiments, the initial iterative values for solving the rotation angle can be based on the document page number. Dynamic adjustment, rather than fixed. When the document page number When, the initial value is set to To accelerate convergence; when When, the initial value is set to Adapt to a wider angle range, iteration error threshold It can also be adjusted according to accuracy requirements. or It flexibly balances computational efficiency and angular accuracy without changing the core solution logic of Newton's iterative method.
[0110] The uniform page unfolding geometric model provides the spatial constraint foundation for the entire algorithm. Through two main constraint modules—document unfolding and stamp distribution—the spatial relationship between the document and the stamp is clarified, providing a theoretical basis for subsequent parameter calculations. In some embodiments, such as… Figure 6 As shown, this is a schematic diagram of document rotation. The document pages are set to be evenly unfolded, and each adjacent document is rotated by the same angle ∠α with the lower left corner of the document as the rotation center. The rectangle of the stamp image coincides with the edge of the last page of the document. The coordinate reference of the rotation center and the requirement for consistency of the angle are clearly defined, providing a spatial reference for the calculation of the rotation angle.
[0111] In some embodiments, such as Figure 7 The diagram shows a schematic of stamp cutting. The stamp is evenly distributed across all pages of the document, with the right edge of each page passing through the center line of the stamp image's dividing line. At this point, each page receives an equal area of stamp. Page to page The right edge of the document forms the following angles with the vertical angle of the stamp image: This provides a distribution basis for the design of the general cutting pattern.
[0112] In some embodiments, pixel-level verification is performed after the sub-image is mounted. This involves comparing the fitting distance between the effective area of the sub-image and the edge of the document page (a preset threshold of 1-2 pixels). If the threshold is exceeded, the mounting coordinates are recalculated. At the same time, the overlapping pixels of sub-images on adjacent pages are checked to ensure the overall visual continuity of the seal. This verification process can be considered as an optional step and does not affect the core mounting logic.
[0113] The document expansion constraint module and the stamp distribution constraint module are hierarchically related. The former outputs basic constraint parameters relating the rotation center to the rotation angles of adjacent documents, serving as input to the latter. The latter, combined with the processed stamp image's width and height parameters, outputs constraint parameters defining the positions of the stamp's dividing lines and the correspondence between the document edges and these lines. The constraints output by the two modules collaboratively clarify the positional relationship between the processed stamp image's width and height and the document page, as well as the correspondence between the stamp's dividing lines and the document edges. Based on these constraints and the processed stamp image's width and height parameters, the rotation angle equation is derived through the rotation angle equation derivation module. This equation is then passed to the numerical solution module, where Newton's iteration method is used to solve for the rotation angles corresponding to each page. These rotation angles provide precise angle parameters for subsequent image segmentation and sub-image rotation.
[0114] In some embodiments, the method supports seal image processing in a multilingual environment. For seal images with different encoding formats (such as UTF-8 and GBK), the method automatically performs encoding conversion when reading the image to ensure the accuracy of RGB color space conversion. At the same time, it is compatible with the image processing interfaces of different operating systems (Windows, Linux, macOS). By calling the system's native graphics processing library, the method improves the efficiency of color recognition and pixel operation, while keeping the core algorithm logic consistent.
[0115] The rotation angle is solved by deriving equations based on geometric model constraints and obtaining a unique solution through Newton's iteration method, providing accurate angle parameters for cutting and rotation.
[0116] In some embodiments, such as Figure 8 The diagram shown is a model for calculating the rotation angle. It includes auxiliary lines, parameter labels, and the basis for geometric derivations. Using a two-page document as a special case, point B is the point where the extended edge GC intersects edge AE, and point D is the point where the extended edge OC intersects edge AE. Based on the geometric derivations, the following is derived: , A series of relational expressions, ultimately through The equivalence relation was generalized to obtain The equation for the rotation angle of the page document, the equation is in There is a unique solution within the range, making it suitable for solving using Newton's iteration method.
[0117] The equation for calculating the rotation angle is:
[0118] ;
[0119] in, The width of the processed seal image. The height of the processed seal image. This is the distance between the stamp image and the top right edge of the last page of the document. For the height of the stamped document, This refers to the width of the document containing the seal.
[0120] To facilitate numerical solutions, the equation for the rotation angle is transformed into a function f(α) = 0, and the formula for calculating the function f(α) is:
[0121] ;
[0122] The formula for calculating the first derivative f'(α) of the function f(α) is:
[0123] ;
[0124] in, , It is the square of the secant function.
[0125] The key parameters of the numerical solution module include the initial iteration value and the iteration error threshold. The specific solution steps are as follows:
[0126] Step 1: Set initial iteration values ;
[0127] Step 2: Calculate the new rotation angle α using the iterative formula, which is:
[0128] ;
[0129] Step 3: Set the iteration error threshold Calculate the difference between the results of two adjacent iterations. ;
[0130] Step 4: If the difference is less than the threshold, output the rotation angle; otherwise, repeat the iteration with the new rotation angle as the initial value until the error requirement is met.
[0131] The non-uniform segmentation of the seal is based on the rotation angle and the size of the seal image. By accurately calculating the segmentation point parameters and constructing the segmentation line equation, the seal image is segmented into sub-images containing effective regions, laying the foundation for subsequent rotation correction.
[0132] In some embodiments, such as Figure 9As shown, assuming the seal image has pixels of w×h, the image contains n equal division lines and coordinate labels for each division point. After cutting according to the division point parameters and the division line equation, a result is generated with Ai as the top-left vertex and dimensions (x, h ... i2 -x i1 The sub-image of )×h is scanned pixel by pixel, and the non-valid areas are made transparent to obtain a sub-image containing only the valid area of the stamp.
[0133] The parameters related to the segmentation point are calculated as follows:
[0134] The horizontal coordinate of the left dividing point is x i1 The formula for calculation is:
[0135] ;
[0136] The horizontal coordinate of the right dividing point is x i2 The formula for calculation is:
[0137] ;
[0138] Intermediate splitting parameter x i3 The formula for calculation is:
[0139] ;
[0140] Horizontal parameter x of the left dividing line i4 The formula for calculation is:
[0141] ;
[0142] in, For sub-image sequence number, The width of the processed seal image. For the number of document pages, The height of the processed seal image. This is the rotation angle output by the numerical solution module. The vertical coordinates of the segmentation points are determined based on the uniform distribution of the height of the processed stamp image, calculated according to the equal division ratio of the image height. The segmentation line covers the entire effective area of the stamp image vertically. The horizontal and vertical coordinates of the segmentation points together constitute the key parameters of the segmentation line. The segmentation line segments the stamp image according to a non-uniform cutting formula.
[0143] After segmenting the stamp image, the generated sub-images are scanned pixel by pixel from left to right and top to bottom. The equations of the left and right segmentation lines are determined based on the coordinates of the segmentation points and the height of the processed stamp image, as follows:
[0144] The equation for the left dividing line is:
[0145] ;
[0146] The equation for the right dividing line is:
[0147] ;
[0148] Pixels located to the left of the left dividing line or to the right of the right dividing line are made transparent. The parameters of the dividing line equation are related to the geometric model constraints. The sub-image after transparency processing only retains the pixels in the effective area of the stamp.
[0149] Sub-image rotation correction involves rotating the image clockwise at a specific angle to ensure that the effective area fits the document margins. Before rotation, the dimensions after rotation must be calculated to ensure that the effective area is fully accommodated.
[0150] In some embodiments, such as Figure 10 As shown, the height and pixel dimensions of the rotated image are derived based on geometric relationships, and the calculation formulas are as follows:
[0151] Rotated sub-image width The formula for calculation is:
[0152] ;
[0153] Rotated sub-image height The formula for calculation is:
[0154] ;
[0155] in Width of the stamp image (in pixels). It is the rotation angle.
[0156] The formula for calculating the sub-image rotation angle is:
[0157] ;
[0158] in, Rotation angle of the sub-image For the number of document pages, Let be the sub-image index. During the rotation, the top-left corner of the sub-image is used as the rotation center, and the image is rotated clockwise according to the calculated rotation angle. A rotation matrix is used to transform the pixel coordinates. Let the coordinates of a pixel before rotation be . The corresponding pixel coordinates after rotation are The formula for calculating the rotation matrix is:
[0159] ;
[0160] At the same time, the color information of the rotated pixels remains unchanged, that is: By combining bilinear interpolation algorithms, image distortion is avoided, ensuring smooth and clear edges. After rotation, the size of the sub-image is recalculated so that the effective area of the sub-image fits the edge of the document page, preserving the original pixel color information and relative positional relationships.
[0161] Precise sub-image mounting uses coordinate transformation and rotation calculations to determine the mounting position of the sub-image on the corresponding document page, ensuring seamless connection of effective areas on each page.
[0162] In some embodiments, such as Figure 11 As shown, the top-left corner of the rotated sub-image is the effective stamp image pixel. The mount point for the page document is point A in the diagram. The derivation of the mount coordinates requires first converting the coordinates of the split point to the first... The coordinates of the page document relative to a reference point, where the reference point is set to the [page number]. In the lower left corner of the document, during the conversion process, the positional offset relationship between the coordinates of the dividing point and the reference point is clearly defined, thus obtaining the coordinates of point A relative to point P. Then convert it to the first The coordinates of the page document relative to point O The calculation formula is:
[0163] ;
[0164] ;
[0165] Then, following the rules set by the document expansion constraint module, the transformed coordinates were adjusted according to the rotation angle output by the numerical solution module. Perform a counter-clockwise rotation and obtain the mounting coordinates of the sub-image on the corresponding document page through coordinate rotation calculations. The calculation formula is:
[0166] ;
[0167] in, , That is, the first The mounting point for the sub-image of the document stamp on each page, and the mounting coordinates, clearly define the specific location of the sub-image on the document page. Mounting it according to these coordinates ensures that the effective areas of sub-images on each page are seamlessly connected.
[0168] In this embodiment, the image preprocessing stage effectively eliminates redundant backgrounds and isolated noise in the original seal image through HSV color space conversion, precise color range definition, and line-by-line scanning edge detection. This ensures that the processed seal image retains only the pure and effective area, laying a good foundation for subsequent size adjustment and cutting operations. The application of the HSV color space significantly improves the accuracy of target color region recognition and avoids the problem of color mapping in the RGB color space being inconsistent with human visual perception.
[0169] The pixel adjustment process adopts a "magnification followed by compression" approach, combined with a bilinear interpolation algorithm. This ensures both the display resolution of the seal image and the proportional consistency with the actual seal, effectively solving the problems of blurry seal display and size distortion in traditional processing methods. The application of multi-threaded parallel processing technology improves the processing efficiency of operations such as edge detection and shortens the overall processing time.
[0170] The rotation angle calculation process employs rigorous geometric modeling to derive the rotation angle equation, combined with Newton's iteration method for numerical solution, ensuring the accuracy and convergence speed of the rotation angle calculation. The reasonable setting of the iteration error threshold and the optimized selection of the initial value further enhance the stability and efficiency of the solution process, providing accurate angular basis for subsequent seal cutting and sub-image rotation.
[0171] The seal cutting process, based on the segmentation point parameter formula and segmentation line equation, achieves non-uniform segmentation of the seal image. Pixel-by-pixel transparency processing ensures that only the effective area is retained in the sub-image. The calculation logic of the segmentation parameters closely follows the constraints of the geometric model, ensuring a balanced distribution of the effective area of each page's sub-image, thus providing a guarantee for subsequent continuous connection.
[0172] The sub-image rotation correction process ensures the visual quality of the rotated image through rotation matrix and bilinear interpolation algorithm. The accurate calculation of the size after rotation avoids cropping or redundancy of the effective area. The derivation process of the mounting coordinates achieves accurate positioning of the sub-image in the document page through coordinate transformation and rotation operation. The effective areas of the sub-images on each page are seamlessly connected, ultimately presenting a natural and realistic rotating seal effect.
[0173] The technical solution of this embodiment can be implemented using programming languages such as Java and Python. The core algorithm module can employ multi-threaded programming to improve processing efficiency. For example, independent operations such as edge detection, sub-image segmentation, and rotation can be assigned to different threads for parallel execution. Simultaneously, parameter verification mechanisms are set up at each stage, including verification of the pixel adjustment ratio, the range of rotation angles, the rationality of the segmentation point coordinates, and the boundary verification of the mounting coordinates, ensuring the stability and reliability of the entire implementation process and avoiding signature failures or effect distortions caused by abnormal parameters.
[0174] Furthermore, the technical solution of this embodiment has good scalability and adaptability. It can flexibly adjust relevant parameters according to different physical seal sizes, document page counts, rendering resolutions, and other requirements. It is applicable to various types of multi-page electronic documents such as government documents, business contracts, audit reports, and financial and tax vouchers. It meets the requirements of various fields for the rigor and visual authenticity of electronic document signatures, provides a feasible implementation path for the optimization and upgrading of electronic signature technology, and promotes the digitalization of electronic document processing towards a more standardized, efficient, and authentic direction.
[0175] The above description is merely a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the forms disclosed herein and should not be construed as excluding other embodiments. It can be used in various other combinations, modifications, and environments, and can be altered within the scope of the concept described herein through the above teachings or related technologies or knowledge. Modifications and variations made by those skilled in the art that do not depart from the spirit and scope of the present invention should be within the protection scope of the appended claims.
Claims
1. A method for visualizing an electronic rotating seal across the seam, characterized in that, Includes the following steps: S1. Preprocess and adjust the pixels of the seal image to obtain a processed seal image that matches the proportions of the physical seal. S2. Based on the size of the processed stamp image and the number of document pages, construct a geometric model for uniformly unfolding the pages, derive the rotation angle equation, and solve for the rotation angle corresponding to each page of the document. S3. Based on the rotation angle obtained from the solution and the size of the processed seal image, the processed seal image is divided according to the non-uniform cutting general formula to obtain a sub-image containing the effective area; S4. Rotate and correct the sub-images according to the rotation angles corresponding to each page, deduce the mounting coordinates by combining the coordinate information in the segmentation process, and mount the corrected sub-images to the corresponding document pages according to the mounting coordinates; In step S3, the calculation of the parameters related to the segmentation point is as follows: ; in, For the first The horizontal coordinates of the left segmentation point in Zhang Zi's image. For the first The horizontal coordinates of the right segmentation point in Zhang Zi's image. For the first Intermediate segmentation parameters of the Zhangzi image, For the first The horizontal parameter of the left segmentation line in the image of Zhang Zi. For sub-image sequence number, The width of the processed seal image. For the number of document pages, The height of the processed seal image. The rotation angle is output by the numerical solution module; the vertical coordinate of the segmentation point is determined based on the uniform distribution of the height of the processed seal image. The vertical coordinate is calculated according to the equal division ratio of the image height. The segmentation line covers the entire effective area of the seal image in the vertical direction. The horizontal and vertical coordinates of the segmentation point together constitute the key parameters of the segmentation line. The segmentation line segments the seal image according to the non-uniform cutting formula. In step S3, after segmenting the stamp image, the generated sub-images are scanned pixel by pixel from left to right and from top to bottom. The equations of the left and right segmentation lines are determined based on the coordinates of the segmentation points and the height of the processed stamp image, as follows: The equations for the left and right dividing lines are: ; Pixels located to the left of the left dividing line or to the right of the right dividing line are made transparent. The parameters of the dividing line equation are related to the geometric model constraints. The sub-image after transparency processing only retains the pixels in the effective area of the stamp.
2. The method according to claim 1, characterized in that, In step S1, step S1 includes: S1.
1. Convert the RGB color space of the original seal image to the HSV color space, identify the target color area based on the preset range of hue, saturation and lightness, scan the image line by line to detect the continuously appearing target color pixels, determine the left, right, top and bottom edge coordinates of the valid seal, perform edge removal processing on the image to remove the redundant background outside the edge, use a noise reduction algorithm to eliminate isolated noise pixels in the image, and set the non-target color area to transparent. S1.
2. Based on the actual size of the physical seal, calculate the pixel adjustment ratio, enlarge the number of pixels in the effective seal area, and compress multiple consecutive pixels into a single display point during document rendering to maintain the same ratio as the physical seal, thereby obtaining a processed seal image containing width and height parameters. The width and height parameters of the processed seal image provide basic parameters for geometric modeling.
3. The method according to claim 1, characterized in that, Step S2 includes: S2.
1. Construct a uniformly unfolded page geometric model. The uniformly unfolded page geometric model includes a document unfolding constraint module and a stamp distribution constraint module. The document unfolding constraint module sets the document to unfold uniformly with the lower left corner as the rotation center, and the rotation angle between adjacent documents remains the same, clarifying the coordinate reference of the rotation center and the requirement for angle consistency. The stamp distribution constraint module sets the processed stamp image to be uniformly distributed on each page of the document, and the right edge of each page of the document passes through the center line of the bisector of the stamp image. The output parameters of the two constraint modules together form the constraint conditions of the model. The constraint conditions clarify the relationship between the width and height parameters and the position of the document page, and the correspondence between the bisector of the stamp and the edge of the document. S2.
2. Based on the constraints and the width and height parameters of the processed seal image, the rotation angle equation is derived through the rotation angle equation derivation module. The equation is then passed to the numerical solution module, which uses Newton's iteration method to solve for the rotation angle corresponding to each page. This rotation angle provides angle parameters for image segmentation and sub-image rotation.
4. The method according to claim 1, characterized in that, In step S4, the formula for calculating the sub-image rotation angle is: ; in, Rotation angle of the sub-image For the number of document pages, For sub-image sequence number, This is the rotation angle output by the numerical solution module. During the rotation process, the top left corner of the sub-image is used as the rotation center, and the sub-image is rotated clockwise according to the calculated rotation angle. After the rotation, the size of the sub-image is recalculated. The effective area of the sub-image fits the edge of the document page. The rotated sub-image retains the original pixel color information and relative position relationship.
5. The method according to claim 1, characterized in that, In step S4, the derivation of the mounting coordinates requires first converting the coordinates of the segmentation point to the first... The coordinates of the page document relative to a reference point, where the reference point is set to the [page number]. In the bottom left corner of the document, during the conversion process, the positional offset relationship between the split point coordinates and the reference point is clearly defined. Then, according to the document expansion constraint module's requirements of uniformly expanding the document with the bottom left corner as the center and adjacent documents rotating at the same angle, the converted coordinates are calculated using the rotation angle output by the numerical solution module. Perform a counter-clockwise rotation and use coordinate rotation calculations to obtain the mounting coordinates of the sub-image on the corresponding document page. The mounting coordinates determine the specific position of the sub-image on the document page.
6. The method according to claim 2, characterized in that, In step S1.2, when adjusting the pixels of the effective stamp area, the pixel magnification factor is determined based on the actual size of the physical stamp and the pixel ratio of the original stamp image. The number of pixels in the effective stamp area is magnified, and the color information and relative position of the pixels are kept unchanged during the magnification process. During document rendering, multiple consecutive pixels are compressed into a single display point by the magnification factor to maintain the same ratio as the physical stamp. The width and height parameters of the adjusted and processed stamp image are directly passed into the geometric model as input parameters for the document expansion constraint module and the stamp distribution constraint module.
7. The method according to claim 3, characterized in that, In step S2.2, the equation for calculating the rotation angle is: ; in, The width of the processed seal image. The height of the processed seal image. This is the distance between the stamp image and the top right edge of the last page of the document. For the height of the stamped document, The width of the stamp document; the key parameters of the numerical solution module include the initial iteration value and the iteration error threshold. The solution steps are as follows: set the initial iteration value, substitute it into the iteration formula to calculate the new rotation angle, compare the difference between the rotation angles obtained from two adjacent calculations with the iteration error threshold. If the difference is less than the threshold, output the rotation angle. If the difference is greater than or equal to the threshold, use the new rotation angle as the initial value to repeat the iteration calculation until the error requirement is met.
8. The method according to claim 3, characterized in that, In step S2.1, the document expansion constraint module and the stamp distribution constraint module are hierarchically related. The document expansion constraint module outputs basic constraint parameters relating the rotation center and the rotation angle of adjacent documents. These output parameters serve as input to the stamp distribution constraint module. The stamp distribution constraint module, in conjunction with the width and height parameters of the processed stamp image, outputs constraint parameters relating the position of the stamp dividing line and the correspondence between the document edge and the dividing line. The constraint conditions output by the two modules together include the positional association between the width and height of the processed stamp image and the document page, and the correspondence between the stamp dividing line and the document edge.
Citation Information
Patent Citations
Method and system for generating paging seal of electronic contract
CN118154723A
Method for stamping paging seal, storage medium, electronic equipment and product
CN119478133A