A seal homology recognition method and system based on multi-space consistency
Patent Information
- Application Number
- CN202610923482.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-25
- Publication Date
- 2026-09-18
AI Technical Summary
[0010]本发明旨在解决现有公章识别方法难以处理透视畸变、缺乏同源性判定能力、像素级对齐精度不足及对遮挡敏感等问题
1、本发明首次将基于单应性矩阵和RANSAC算法的透视变换引入公章识别领域,专门用于解决因相机拍摄角度造成的透视畸变问题。相比于仅能处理平面旋转和缩放的仿射变换,8自由度的透视变换能够精确描述三维空间到二维平面的投影关系,提升了不同视角下拍摄的公章图像的对齐精度。
Smart Images

Figure CN122780980A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of image processing and computer vision technology, specifically to a method and system for identifying the origin of official seals based on multi-spatial consistency. Background Technology
[0002] With the rapid development of information technology, e-government, electronic contracts, and online approval systems have been widely adopted globally. Although paperless office practices have become a trend, paper documents remain widely used as a core means of confirming legal validity in key scenarios such as contract signing, judicial evidence collection, administrative management, and business transactions. The official seal, as the legally recognized seal of an organization or institution to confirm the authenticity of documents, holds an irreplaceable legal status. Against this backdrop, paper documents typically need to be digitally stored, transmitted, and archived through scanning or photography, resulting in massive amounts of official seal image data.
[0003] This has led to a significant demand for automated, high-precision, and highly reliable identification and comparison of official seal images. These demands are specifically reflected in the following core scenarios: 1) Verification of contract document authenticity: When signing multi-party contracts or agreements, it is necessary to verify whether the official seals affixed to each document come from the same physical seal to prevent substitution or forgery. 2) Consistency comparison of official seals in different documents: When handling multiple business transactions such as company registration, changes, and cancellations, it is necessary to compare whether the official seals used by the same company in different documents and at different times are consistent. 3) Auxiliary analysis in judicial appraisal: In legal proceedings and arbitration, authenticating the official seals on documents used as evidence is a crucial step in determining the legal validity of the documents.
[0004] Therefore, how to accurately detect, align, and determine the homology of official seal images under complex and variable imaging conditions (such as different lighting, shooting angles, background interference, etc.) has become a key technical problem that urgently needs to be solved in the fields of image processing and computer vision.
[0005] Currently, existing technologies for the recognition and comparison of official seal images mainly propose the following implementation schemes: (1) Template matching based method: This method is a relatively traditional solution. Its core idea is to perform pixel-by-pixel or block-based sliding window matching between the image of the seal to be detected and a pre-stored, standard seal template. Commonly used similarity metrics include Normalized Cross-Correlation (NCC) and Sum of Squared Differences (SSD). This method is simple in structure, easy to implement, and has relatively low computational complexity. However, its fatal flaw lies in its extreme sensitivity to geometric transformations of the image. Even slight rotations, scaling, or changes in shooting angle can lead to matching failures. In practical applications, due to differences in document placement angles and shooting device postures, seal images almost inevitably exhibit geometric deformations. Therefore, template matching methods have extremely poor robustness and cannot meet practical needs.
[0006] (2) Methods based on local feature matching: To overcome the sensitivity of template matching to geometric transformations, existing techniques propose methods based on local feature extraction and matching. These methods first detect scale-invariant or rotation-invariant keypoints in the image (e.g., scale-invariant feature transform keypoints from the SIFT algorithm, or orientation fast feature points from the ORB algorithm), and generate a descriptor for each keypoint (e.g., the SIFT descriptor, or the ORB rotation briefing descriptor). Then, by comparing the Euclidean or Hamming distance between the descriptors in two images, a correspondence between the keypoints is established, thus achieving image matching. These methods possess a certain degree of resistance to scale and rotation changes, representing a significant improvement over template matching. However, they still have fundamental shortcomings: First, methods such as SIFT are computationally intensive and have poor real-time performance; second, they can only handle affine transformations (such as rotation, scaling, and shearing), and are not capable of modeling more complex perspective distortions (such as the near-large and far-small effect) that are common in actual shooting; most importantly, these methods can only give a "similarity" score based on feature point pairs, and cannot directly answer the essential question of "whether two seals come from the same physical mold"—the question of "homology."
[0007] (3) Image alignment method based on affine transformation: As an improvement strategy, some schemes introduce more complex geometric transformation models on top of feature matching in order to align images more accurately. Affine transformation describes the geometric relationships between images through linear combinations of operations such as translation, rotation, scaling, and shearing. Compared to simple rotation or scaling, affine transformation can better correct linear deformations between images. However, affine transformation is essentially a linear transformation from one two-dimensional plane to another, and it cannot describe the "near objects appear larger, far objects appear smaller" effect caused by changes in viewing angle in three-dimensional space, i.e., perspective projection relationships. When there is a significant tilt angle between the camera and the paper, the circular outline of the seal will become an ellipse, and the text and patterns inside will also undergo nonlinear distortion. Affine transformation cannot accurately model this nonlinear deformation, resulting in a large error after alignment, which directly affects the accuracy of subsequent comparisons.
[0008] (4) Deep learning-based methods: In recent years, with the explosive development of deep learning technology, methods based on convolutional neural networks (CNNs) or Siamese networks have also been attempted for seal recognition. These methods construct a deep neural network and train it using a large number of labeled pairs of "same" and "different" seal images, allowing the network to automatically learn high-level semantic features that distinguish between them. During testing, the two seal images to be compared are input into the network, directly yielding a similarity score or a probability score indicating similarity. Deep learning methods perform well on specific datasets, demonstrating powerful automatic feature learning capabilities. However, their drawbacks are equally significant: First, their performance is highly dependent on massive amounts of high-quality, diverse labeled data, while in practical applications, obtaining large-scale, comprehensive samples of same-origin seals covering various imaging conditions is extremely difficult; second, deep learning models are typically "black boxes," lacking interpretability in their decision-making process, which is unacceptable for serious scenarios such as forensic identification that require clear and traceable judgment criteria; finally, the model's generalization ability is limited, and performance may drop sharply for entirely new seal styles or imaging conditions outside the training data distribution.
[0009] In summary, while existing technologies can achieve basic seal image matching under some ideal or constrained conditions, they all exhibit significant shortcomings and deficiencies when facing complex real-world challenges such as perspective distortion, accurate identification of origin, pixel-level precise alignment, robustness to structural rotation, and sensitivity to occlusion and complex backgrounds. Therefore, a new method for seal origin identification that can overcome these problems and achieve high accuracy, high robustness, and high interpretability is urgently needed. Summary of the Invention
[0010] This invention aims to address the problems of existing official seal recognition methods, such as difficulty in handling perspective distortion, lack of homology determination capability, insufficient pixel-level alignment accuracy, and sensitivity to occlusion. By constructing a sequential coupling mechanism based on perspective alignment and polar coordinate expansion, and integrating consistency indicators of feature, structure, and pixel three-layer spaces, high-precision official seal image alignment and accurate physical homology determination are achieved, while enhancing the system's robustness and interpretability under complex imaging conditions.
[0011] To address the aforementioned technical problems, embodiments of the present invention provide the following technical solution: a method for identifying the origin of official seals based on multi-space consistency, comprising the following steps: Step S1: Obtain the first official seal image and the second official seal image to be compared, wherein the first official seal image usually refers to the reference official seal image used as the comparison benchmark, and the second official seal image refers to the official seal image to be detected; Step S2: Preprocess the first seal image and the second seal image respectively, extract the seal area, and generate an ink intensity map to enhance the ink area and suppress background interference; Step S3: Extract local features from the first official seal image and the second official seal image respectively, establish a set of feature matching point pairs between the first official seal image and the second official seal image, and calculate the feature space consistency index based on the set of feature matching point pairs; Step S4: Based on the set of feature matching point pairs, use a robust estimation algorithm to calculate the homography matrix representing the perspective transformation relationship between the second official seal image and the first official seal image, and perform perspective correction on the second official seal image according to the homography matrix to obtain an aligned image; Step S5: Using the center of the seal as the pole, transform the first seal image and the aligned image to polar coordinate space respectively to obtain the first polar coordinate image and the second polar coordinate image, and calculate the structural consistency index between the two. Step S6: Calculate the pixel-level overlap index between the first official seal image and the aligned image on the ink intensity map; Step S7: Construct a multi-space consistency fusion model, weightedly fuse the feature space consistency index, the structural consistency index and the pixel-level overlap index, and introduce a nonlinear constraint term to calculate the homology score; Step S8: Determine whether the homology score is greater than or equal to a preset threshold. If yes, determine that the first seal image and the second seal image originate from the same physical imprint, i.e., they are homologous seals; otherwise, determine that they are non-heterogeneous seals.
[0012] Furthermore, the homology score S of the multi-space consistency fusion model constructed in step S7 is calculated using the following formula: S=w1·F+w2·G+w3·D+λ·min(F, G, D), Wherein, F is the feature space consistency index, specifically the proportion of inliers obtained when estimating the homography matrix using the random sampling consistency algorithm; G is the structural consistency index, specifically the difference variance index calculated based on the first polar coordinate image and the second polar coordinate image, G=exp(- ), Var is the polar coordinate image difference variance; D is the pixel-level overlap index, specifically the Dice coefficient calculated based on the ink intensity map; w1, w2, and w3 are weighting coefficients, satisfying w1+w2+w3=1; λ is the nonlinear enhancement coefficient.
[0013] Furthermore, the method for generating the ink intensity map in step S2 specifically involves constructing an ink intensity model based on color differences, using the following formula: clean_gray=Normalize(max(0,R-α·G-β·B)), Where R, G, and B are the pixel values of the red, green, and blue channels of the image, respectively; α and β are preset weight coefficients with values ranging from [0.3 to 0.7]; Normalize means normalizing the calculation results to a grayscale range of 0-255; and clean_gray is the output ink intensity map.
[0014] Further, step S4 specifically employs the Random Sample Consensus Algorithm (RANSAC) to filter feature matching point pairs, and estimates a homography matrix with 8 degrees of freedom based on the filtered interior points to correct perspective distortion in the official seal image. After perspective correction of the second official seal image based on the homography matrix, the circularity of the corrected seal image's outline is calculated, where circularity is defined as the ratio of the minor axis to the major axis of the fitted ellipse of the seal outline. When the circularity is greater than or equal to a preset circularity threshold, the polar coordinate expansion in step S5 is executed. When the circularity is less than the preset threshold, an alignment failure signal is output, and the homology determination is terminated.
[0015] Furthermore, in step S6, the pixel-level overlap index uses the Dice coefficient, calculated as follows: D=2 |A∩B| / (|A|+|B|), where A and B are the sets of pixels in the seal area obtained by binarization from the ink intensity maps of the first seal image and the aligned image, respectively.
[0016] This invention also proposes a seal origination identification system based on multi-space consistency, used to implement the method described in any of the above embodiments, comprising: The image input module is used to receive the first official seal image and the second official seal image to be compared. The first official seal image usually refers to the reference official seal image used as the comparison benchmark, and the second official seal image refers to the official seal image to be detected. The preprocessing module, connected to the image input module, is used to detect and crop the seal area of the first seal image and the second seal image respectively, and generate an ink intensity map to enhance the ink area and suppress background interference. The feature extraction and matching module, connected to the preprocessing module, is used to extract local features of the first and second official seal images processed by the preprocessing module, establish a set of feature matching point pairs between the two images, and calculate the feature space consistency index based on the set of feature matching point pairs. The perspective alignment module, connected to the feature extraction and matching module, is used to estimate the homography matrix based on the feature matching point pair set, and to perform perspective correction on the second official seal image according to the homography matrix to obtain an aligned image; The polar coordinate unfolding and structural analysis module is connected to the perspective alignment module. It is used to convert the first official seal image and the aligned image processed by the perspective alignment module to polar coordinate space with the center of the seal as the pole, respectively, to obtain the first polar coordinate image and the second polar coordinate image, and calculate the structural consistency index between the two. A pixel overlap calculation module, connected to the preprocessing module and the perspective alignment module, is used to calculate the pixel-level overlap index between the first official seal image and the alignment image on the ink intensity map generated by the preprocessing module. The multi-space fusion determination module is connected to the feature extraction and matching module, the polar coordinate expansion and structural analysis module, and the pixel overlap calculation module. It is used to perform weighted fusion of the received feature space consistency index, structural consistency index, and pixel-level overlap index, introduce nonlinear constraint terms, calculate the homology score, determine whether the homology score is greater than or equal to a preset threshold, and output the homology determination result.
[0017] Furthermore, the perspective alignment module specifically employs the Random Sample Consensus Algorithm (RANSAC) to filter feature matching point pairs, and estimates a homography matrix with 8 degrees of freedom based on the filtered interior points to correct perspective distortion in the official seal image. After perspective correction of the second official seal image based on the homography matrix, the circularity of the corrected seal image's outline is calculated. The circularity is defined as the ratio of the minor axis to the major axis of the fitted ellipse of the seal outline. When the circularity is greater than or equal to a preset circularity threshold, the polar coordinate expansion in step S5 is executed. When the circularity is less than the preset threshold, an alignment failure signal is output and the homology determination is terminated.
[0018] Furthermore, the polar coordinate unpacking and structural analysis module maps the image pixel coordinates (x, y) in the Cartesian coordinate system to polar coordinates (r, θ) with the center of the seal as the pole. Here, (x, y) represents the x and y coordinates of any pixel in the image in the Cartesian coordinate system, r represents the polar radius distance from the pixel to the center of the seal, and θ represents the polar angle of the pixel relative to the polar axis. A polar coordinate image is reconstructed based on this mapping, and the variance of the pixel-by-pixel grayscale difference between the two polar coordinate images is calculated. The structural consistency index G is calculated using the following formula: G=exp(- ), Where Var is the variance of the pixel-by-pixel grayscale difference between the two polar coordinate images. This represents the arithmetic square root of the variance.
[0019] Furthermore, the homology scoring function constructed by the multi-space fusion determination module is as follows: S=w1·F+w2·G+w3·D+λ·min(F, G, D), Wherein, F is the feature space consistency index, specifically the proportion of inliers obtained when estimating the homography matrix using the random sampling consistency algorithm; G is the structural consistency index, specifically the difference variance index calculated based on the first polar coordinate image and the second polar coordinate image, G=exp(- ), Var is the polar coordinate image difference variance; D is the pixel-level overlap index, specifically the Dice coefficient calculated based on the ink intensity map; w1, w2, and w3 are weighting coefficients, satisfying w1+w2+w3=1; λ is the nonlinear enhancement coefficient.
[0020] Furthermore, the multi-space fusion determination module also includes an adaptive weight adjustment unit, which is used for: Obtain the spatial distribution density of feature matching point pairs output by the feature extraction and matching module, and the edge complexity of connected components in the binarized image output by the pixel overlap calculation module; When the spatial distribution density of the feature matching point pairs in a local area of the image is lower than the first threshold, and the edge complexity of the connected components in the binarized image is higher than the second threshold, it is determined that there is local occlusion. In response to the determination that there is local occlusion, the adaptive weight adjustment unit reduces the weight coefficient w3 of the pixel-level overlap index in the homology score calculation, and correspondingly increases the weight coefficient w2 of the structural consistency index, while setting the nonlinear enhancement coefficient λ to zero. The multi-space fusion determination module recalculates the homology score based on the adjusted weight coefficients.
[0021] The beneficial effects of the above-described technical solution of the present invention are as follows: 1. This invention is the first to introduce perspective transformation based on homography matrix and RANSAC algorithm into the field of official seal recognition, specifically designed to solve the perspective distortion problem caused by camera shooting angle. Compared to affine transformation, which can only handle planar rotation and scaling, the 8-DOF perspective transformation can accurately describe the projection relationship from three-dimensional space to a two-dimensional plane, improving the alignment accuracy of official seal images captured from different viewpoints.
[0022] 2. This invention constructs a consistency constraint model in a three-layer space of "feature-geometry-pixel," and in particular, introduces strict pixel-level Dice overlap and structural consistency indices, forcing the judgment to be based on physical consistency evidence across multiple dimensions. Only when all layers are highly consistent can a high score be obtained, thus improving the credibility of the judgment.
[0023] 3. This invention achieves unprecedented pixel-level alignment accuracy. Perspective alignment ensures complete geometric registration of the image, and the clean_gray model maximizes the highlighting of the intrinsic signal of the stamp ink while suppressing background interference. The Dice coefficient calculated based on this becomes a highly stable and reliable indicator of pixel overlap, truly serving as strong evidence for distinguishing between homologous and heterologous sources, rather than a noise indicator that is unreliable due to alignment inaccuracies and background interference in existing technologies.
[0024] 4. This invention innovatively designs a sequential coupling processing mechanism of "perspective alignment first, then polar coordinate unwrapping." This mechanism fully utilizes the inherent circular / elliptical structure of the official seal. Perspective alignment first corrects the shape distortion caused by the shooting angle, restoring the seal to a perfect circle. Then, polar coordinate unwrapping elegantly transforms the remaining rotational differences within the document plane into simple translations in the polar coordinate image. By analyzing the variance of the polar coordinate image, this invention can evaluate the global structural consistency of the seal in a mathematically concise, computationally efficient, and physically intuitive way, solving the problem of rotation sensitivity in traditional methods.
[0025] 5. This invention incorporates strong robustness through multi-spatial information fusion. For example, when the official seal and text or signature on a document are partially occluded, the indices of the feature space (F) and pixel space (D) may be affected, but the structure space (G), through global structure analysis, can still provide important judgment criteria. Conversely, if uneven lighting causes clean_gray Figure 2Minor errors in value-based methods may slightly decrease pixel overlap (D), but as long as the feature and structural consistency remains high, other metrics in the fusion model can compensate for this. The combined effect of these three factors enables the system of this invention to exhibit robustness far exceeding that of any single method or simple concatenation method when facing real-world noise such as local occlusion, nonlinear illumination variations, and complex backgrounds. Attached Figure Description
[0026] Figure 1 This is a system composition block diagram of the present invention; Figure 2 This is a flowchart of the method of the present invention. Detailed Implementation
[0027] To make the technical problems, technical solutions and advantages of the present invention clearer, a detailed description will be given below in conjunction with the accompanying drawings and specific embodiments.
[0028] Example 1 This invention proposes a method for identifying the origin of official seals based on multi-space consistency and perspective alignment. Its core idea is to construct a three-layer collaborative analysis framework of "feature space - geometric structure space - pixel space," achieve high-precision structural alignment through sequentially coupled perspective transformation and polar coordinate expansion, and design a nonlinear scoring model that integrates multi-dimensional consistency information, ultimately realizing a technological leap from image similarity judgment to physical origin determination.
[0029] The technical solution of the present invention will be described in detail below with reference to specific implementation steps and functional modules.
[0030] (I) Overall Technical Approach The overall process of the technical solution of this invention is as follows, which can be summarized into three main stages: Preprocessing and feature extraction stage: The two input official seal images are detected and cropped, and an enhanced ink intensity map is generated. At the same time, local features of the images are extracted.
[0031] Geometric alignment and structural analysis stage: Based on feature matching, the homography matrix between the two images is calculated using the robust estimation algorithm (RANSAC), and perspective transformation is performed to achieve accurate alignment. Following alignment, the images are transformed to polar coordinate space, and the stability of their ring structures is analyzed.
[0032] Multi-space fusion and decision-making stage: The consistency index of feature space, geometric structure space and pixel space are calculated separately, and these three indices are fused through a weighted model with nonlinear enhancement term to obtain the final homology score, and the judgment result is output according to the threshold.
[0033] (II) System Device Structure like Figure 1 As shown, this invention also provides a seal homology identification system based on multi-space consistency for implementing the above method, the core module of which includes: Image input module 101: Responsible for receiving images of official seals to be compared from various formats and sources.
[0034] Preprocessing module 102 includes a stamp area detection and trimming submodule and an ink strength modeling submodule.
[0035] Feature extraction and matching module 103: includes a local feature extraction submodule (such as ORB, HOG, LBP features) and a feature matching submodule.
[0036] Perspective Alignment Module 104: Includes a homography matrix estimation submodule (based on the RANSAC algorithm) and a perspective transformation submodule.
[0037] Polar coordinate expansion and structural analysis module 105: includes a Cartesian coordinate to polar coordinate transformation submodule and a structural consistency calculation submodule.
[0038] Pixel overlap calculation module 106: Dice coefficient calculation submodule based on ink intensity map.
[0039] Multi-space fusion judgment module 107: includes a multi-index weighted fusion calculation submodule, an adaptive weight adjustment unit, and a threshold comparison output submodule.
[0040] These modules work together to form a complete automated processing pipeline from raw image input to homology label output.
[0041] (III) Specific technical implementation of each functional module The following section will provide a more detailed technical implementation description of each module of the above system and the methods and steps they execute.
[0042] 1. Image Input Module (1) Function: Receive two or more official seal images to be compared, denoted as image A (reference image) and image B (image to be registered).
[0043] (2) Technical implementation: It supports a variety of common image formats, including but not limited to JPEG, PNG, BMP, and TIFF.
[0044] It supports multiple input sources, such as scanned documents from a scanner, images taken with a mobile phone, and archived images from a database.
[0045] To ensure consistent scaling in subsequent processing, the module includes an optional resolution normalization unit to scale all input images to a preset size, such as 512×512 pixels or 768×768 pixels. The scaling algorithm can employ bilinear or bicubic interpolation to maintain image quality.
[0046] 2. Stamp Area Detection and Cropping Module (1) Function: Automatically and accurately locate and extract the area where the seal is located from the original input image containing complex backgrounds (such as document paper, text, signature, lines, etc.).
[0047] (2) Technical implementation: Initial color space screening: Most official seals use red ink. Therefore, color information is used for coarse positioning. In a preferred embodiment, a red channel enhancement technique is used, which calculates the difference between the red channel value of a pixel and the average values of the green and blue channels to generate a response map. Areas with high response values are candidate seal areas.
[0048] Edge detection and contour extraction: The Canny edge detection operator is used to extract edges from the initially screened binary image. The Canny operator effectively extracts continuous, single-pixel edges through Gaussian filtering, gradient calculation, non-maximum suppression, and double threshold detection. Subsequently, a contour finding algorithm is executed on the edge image to extract all closed contours.
[0049] Ellipse Fitting and Filtering: Official seals are mostly circular or elliptical in shape. For all extracted closed contours, a least-squares ellipse fitting algorithm is used to fit an optimal ellipse for each contour. The parameters of the fitted ellipse include the coordinates of the center point, the radius of the major axis, the radius of the minor axis, and the rotation angle. Then, the fitted ellipse is filtered based on its size (such as perimeter and area) and shape (such as the ratio of the major and minor axes), selecting the largest ellipse with a reasonable ratio of the major and minor axes as the final seal contour.
[0050] Cropping and Normalization: The stamp area is cropped from the original image based on the center and circumscribed rectangle of the fitted ellipse. This area is then affine normalized, for example by rotating to align the major axis of the ellipse horizontally and scaling it to a fixed size (e.g., 256×256 pixels), resulting in a normalized stamp image.
[0051] 3. Ink Strength Modeling Module (1) Function: Generate a grayscale image. Its core function is to maximize the signal intensity of the stamp ink area while greatly suppressing interference from paper background, stains, uneven lighting, etc. This is a key preprocessing step for subsequent high-precision pixel overlap calculation.
[0052] (2) Technical Implementation: This invention proposes a novel ink intensity model based on color difference. This model utilizes the physical property of red ink in the RGB color space: "high red, low green, low blue." Its mathematical expression is as follows: clean_gray=Normalize(max(0,R-α·G-β·B)) in: R, G, and B represent the pixel values of the input image in the red, green, and blue channels, respectively (usually integers between 0 and 255 or floating-point numbers between 0 and 1).
[0053] α and β are pre-set weighting coefficients used to control the suppression intensity of the green and blue channels on the background. In a preferred embodiment, the values of α and β are both in the range of [0.3, 0.7], and the specific values can be fine-tuned according to the type of ink pad (such as vermilion, dark red) or determined by an adaptive algorithm. For example, typical empirical values are α=0.5 and β=0.4.
[0054] The max(0, ...) operation ensures that the calculation result is non-negative, because any negative value is treated as 0, indicating no ink response.
[0055] Normalize(...) maps all computation results linearly or non-linearly to the standard grayscale range [0, 255] to generate the final 8-bit grayscale image clean_gray.
[0056] (3) Technical effect: Through the above nonlinear difference operation, the model can output a high-contrast image, in which the stamp area is bright white or light gray, while non-red elements such as paper background, black text, and blue signature are effectively suppressed to dark tones close to black.
[0057] 4. Feature Extraction Module (1) Function: Extract stable and representative local features from the standardized stamp image (or optionally on the clean_gray image) to find corresponding points between images.
[0058] (2) Technical Implementation: To improve robustness and computational efficiency, this invention does not rely on a single feature, but instead employs a multi-feature collaborative strategy. In one specific embodiment, the following three features are extracted in combination: ORB features: Short for Oriented Fast and Rotational Briefing features. It first uses the FAST algorithm to quickly detect keypoints and then adds orientation information using the gray-scale centroid method to achieve rotation invariance. Then, it uses the oriented BRIEF algorithm to generate binary feature descriptors. ORB features have advantages such as fast computation speed, rotation invariance, and robustness to noise.
[0059] HOG features: Histogram of Oriented Gradients (HOG) features. These features are constructed by calculating and statistically analyzing the histogram of gradient directions in local regions of an image. HOG is particularly adept at describing the edges and shape structure of an image, and is very effective at depicting the geometric structures such as the outer ring of a seal or the edges of text.
[0060] LBP features: short for Local Binary Pattern Feature. It is an operator used to describe local texture features of an image, with advantages such as rotation invariance and grayscale invariance. LBP can capture subtle texture patterns inside a seal, such as pentagrams or the strokes of characters.
[0061] In practical processing, these features can be concatenated into a high-dimensional feature vector, or used separately for matching and then fused into a result.
[0062] 5. Feature Matching Module (1) Function: Establish a correspondence between the feature point sets extracted from image A and image B, that is, find the projection of the same point in the physical world onto the two images.
[0063] (2) Technical implementation: Preliminary matching: For each feature descriptor in image A, calculate the distance between it and all feature descriptors in image B (use Hamming distance for binary descriptors like ORB and Euclidean distance for floating-point descriptors like HOG), and find the closest one as a candidate matching point.
[0064] Ratio Test Filtering: To eliminate false matches, Lowe's ratio test is used. For each feature point, its nearest neighbor distance d1 and second nearest neighbor distance d2 are found. If d1 / d2 is less than a preset ratio threshold (usually set between 0.6 and 0.8, preferably 0.75), the match is considered reliable; otherwise, it is discarded as a fuzzy match or a false match. This operation effectively filters out a large number of false matches caused by repetitive textures or similar structures.
[0065] Symmetry test (optional): To further improve matching quality, bidirectional matching can be performed. That is, matching is performed not only from A to B, but also from B to A, retaining only point pairs that match successfully in both directions. After the above filtering, a high-quality set of feature-matched point pairs is output.
[0066] 6. Homography Matrix Estimation Module (1) Function: Based on the set of feature matching point pairs obtained in the previous step, calculate the mathematical transformation model and homography matrix that can accurately describe the perspective projection relationship from image B to image A.
[0067] (2) Technical implementation: Model definition: The homography matrix H is a 3×3 matrix with 8 degrees of freedom (because the scale is homogeneous). It describes the perspective projection relationship from plane to plane, and its mathematical form is: Where (x, y) is the homogeneous coordinate of a point in image B, and (x', y') is the homogeneous coordinate of that point mapped to the coordinate system of image A. The linear components representing rotation, scaling, and shearing transformations are 2×2 matrices that describe the rotation angle, isotropic / anisotropic scaling, and shearing deformation of the image. This represents the horizontal translation. This represents the vertical translation amount. , These represent the perspective projection distortion components, which affect the perspective scaling in the x and y directions, respectively, and are key to producing the "nearer objects appear larger, farther objects appear smaller" perspective effect. The overall scaling factor (normalization factor in homogeneous coordinates). Since the homography matrix is defined in homogeneous coordinates, It is usually normalized to 1, or scaled together with other parameters.
[0068] Robust estimation: Since there may still be a small number of mismatches (outsides) in feature matching point pairs, directly using all points for least squares estimation will lead to huge errors. Therefore, this invention uses the Random Sample Consensus (RANSAC) algorithm to robustly estimate the H matrix. The RANSAC algorithm process is as follows: ① Randomly sample 4 sets of non-collinear point pairs from the set of matching point pairs (because solving an 8-DOF homography matrix requires at least 4 point pairs).
[0069] ② Calculate a candidate homography matrix H using these 4 point pairs.
[0070] ③ Use this H matrix to perform a projection transformation on all other matching point pairs, and calculate the error between the coordinates of each point projected from B to A and its actual matching point coordinates. Points with an error less than a preset threshold (e.g., 3 pixels) are called "interior points".
[0071] ④ Repeat the above steps N times (N is dynamically determined by the preset confidence level and the proportion of outliers), and retain the H matrix that can generate the most inliers.
[0072] ⑤ Finally, using all high-quality matching point pairs marked as "interior points", the value of the H matrix is finally optimized by least squares or a more robust method (such as M-estimator).
[0073] (3) Technical effect: Through the RANSAC algorithm, the present invention can effectively resist the residual erroneous matching in the feature matching stage and estimate the high-precision perspective transformation matrix, laying a solid foundation for subsequent fine alignment.
[0074] 7. Perspective Alignment Module (1) Function: Using the homography matrix H estimated in the previous step, perform perspective transformation on the image B to be registered so that it is precisely aligned with the reference image A in geometric space at the pixel level.
[0075] (2) Technical implementation: The core operation of this module is perspective transformation. For each pixel (x, y) in image B, its new coordinates (x', y') in the coordinate system of image A are calculated using the homography matrix H. Since (x', y') are usually not integer coordinates, an interpolation algorithm (such as bilinear interpolation or bicubic interpolation) is needed to fill the pixel values of the transformed image B'.
[0076] The output image B' (called the "aligned image") is in the same coordinate system as the reference image A, and all corresponding points (theoretically) completely coincide in spatial position. This is a necessary prerequisite for subsequent pixel-level overlap calculation.
[0077] Quality Verification: After perspective correction, the circularity of the corrected seal image's outline is calculated. Specifically, the outer contour of the seal region in the aligned image is extracted, and the ratio of the major and minor axes of the ellipse fitted by this contour is calculated. Circularity is defined as the ratio of the minor axis to the major axis. When this ratio is greater than or equal to a preset circularity threshold, the perspective alignment quality is considered acceptable, and polar coordinate unfolding continues; otherwise, an alignment failure signal is output, and the homology determination is terminated. This step ensures that only high-quality alignment results are included in subsequent analysis, avoiding misjudgments due to alignment failures.
[0078] 8. Polar coordinate expansion module (1) Function: Transform the images (image A and image B') in the Cartesian coordinate system after perspective alignment to the polar coordinate system, thereby transforming the inherent rotational differences of the seal into translational relationships in the polar coordinate image, which greatly simplifies the analysis of structural consistency.
[0079] (2) Technical implementation: Key Note: This must be executed after the perspective alignment module. If polar coordinate unwrapping is performed before perspective distortion is corrected, the stamp's distortion will propagate and amplify in polar coordinate space, causing subsequent analysis to fail. The order of "perspective alignment first, then polar coordinate unwrapping" in this invention is crucial to ensuring the algorithm's success.
[0080] Mathematical mapping: A polar coordinate system is established with the center point of the seal (obtained by the ellipse fitting module) as the pole O, and the horizontal direction to the right as the positive polar axis. For a pixel (x, y) in the Cartesian coordinate system, its polar coordinates (r, θ) are calculated as follows: in, It is a two-parameter arctangent function, and its return value ranges from (-π, π] to [0, 2π), depending on the implementation. , The coordinates of the center point of the stamp are obtained by the ellipse fitting module. r represents the polar radius distance from the pixel to the center point of the stamp, and θ represents the polar angle of the pixel relative to the polar axis.
[0081] Image reconstruction: Create a new rectangular image (polar coordinate graph) with a width corresponding to the maximum angle range [0, 2π). Typically, the angle is mapped to the X-axis (column coordinates) of the image, and the radius is mapped to the Y-axis (row coordinates). Then, the pixel value of the polar coordinate graph is equal to the pixel value at (x, y) in the Cartesian coordinate system.
[0082] (3) Technical effect: In the Cartesian coordinate system, a seal rotated by an angle Δθ undergoes a rotational transformation of its overall image. After polar coordinate expansion, this rotation will manifest as a cyclic translation of the polar coordinate image in the horizontal direction (angular dimension). Therefore, evaluating the structural consistency of two seals is transformed into evaluating the degree of translational alignment of the two polar coordinate images, which can be easily achieved by calculating the difference variance and other methods.
[0083] 9. Structural Consistency Calculation Module (1) Function: In polar coordinate space, quantize the overall structural similarity of two aligned seal images in the radial and angular directions.
[0084] (2) Technical implementation: First, to suppress noise and minor deformations, a light Gaussian filter can be applied to the generated polar coordinate images. Then, the variance of the pixel-by-pixel grayscale difference between the two polar coordinate images is calculated. Let the two polar coordinate images both be M×N in size, denoted as P_A(i,j) and P_B(i,j) respectively. The formula for calculating the variance Var is: The structural consistency index G is calculated using the following formula: G=exp(- ) in, G represents the arithmetic square root of the variance, i.e., the standard deviation. This exponential function maps structural differences to the interval [0, 1], and the smaller the difference, the closer G is to 1.
[0085] 10. Pixel Overlap Calculation Module (1) Function: Calculates the degree of physical overlap of the areas covered by stamp ink in two images directly at the pixel level. This is the most direct and rigorous measure of physical consistency.
[0086] (2) Technical implementation: Binarization: Thresholding is performed on the clean_gray images of the reference image A and the aligned image B'. Since the stamp area in the clean_gray image is light and the background is dark, a global threshold (such as the threshold automatically calculated by the Otsu algorithm) or a fixed high threshold can be used to convert the image into a binary image. In the binary image, "1" represents the stamp ink pixel and "0" represents the background.
[0087] Dice Coefficient Calculation: This invention uses the Dice coefficient as a measure of overlap. Compared to the more common IoU (Intersection over Union), the Dice coefficient is more sensitive to the overlap assessment of small target regions. Its calculation formula is as follows: D=2 |BW_A∩BW_B'| / (|BW_A|+|BW_B'|) Where |BW_A∩BW_B'| represents the number of pixels in two binary images that are both "1" (both identified as ink), i.e., the intersection; |BW_A| and |BW_B'| represent the total number of ink pixels in each image, respectively. The Dice coefficient ranges from [0, 1], where 1 represents that the two regions completely overlap, and 0 represents that there is no overlap at all.
[0088] (3) Technical effect: This module operates on a specially enhanced ink intensity map, which can effectively resist background interference. The Dice coefficient provides a high-precision, physically meaningful pixel-level consistency index, which is a powerful supplement to feature-level and structural-level consistency.
[0089] 11. Multi-space consistency fusion module (1) Function: This is the core of the invention. Its function is to intelligently and non-linearly fuse three consistency indicators from different analysis spaces: feature space consistency (F), geometric structure space consistency (G), and pixel space consistency (D), and finally output a comprehensive score that can accurately reflect physical homology.
[0090] (2) Technical implementation: Input indicator definition: F (Feature Space Consistency): Derived from the feature matching module and the homography matrix estimation module. Specifically defined as the ratio of the number of inliers finally determined by the RANSAC algorithm to the total number of initial matching points. The higher the inlier ratio, the stronger the geometric correspondence between the two images at the local feature level.
[0091] G (Structured Space Consistency): Derived from the structure consistency calculation module. As mentioned above, G = exp(- ), used to measure the global structural similarity after perspective alignment and polar coordinate unfolding.
[0092] D (Pixel Spatial Consistency): Derived from the pixel overlap calculation module. It is the calculated Dice coefficient D, used to measure the degree of overlap of the physically covered ink areas.
[0093] Fusion Strategy: This invention proposes an innovative fusion function that not only performs a weighted summation of the indicators but also introduces a nonlinear enhancement term to emphasize the "synergistic" situation where all indicators are high. The final fusion score S is calculated as follows: S=w1·F+w2·G+w3·D+λ·min(F, G, D) Where w1, w2, and w3 are weighting coefficients, satisfying w1 + w2 + w3 = 1. In a preferred embodiment, considering that pixel-level consistency is the strongest evidence of final physical identity, w3 (pixel weight) can be set to the maximum, such as w1 = 0.2, w2 = 0.2, and w3 = 0.6. These coefficients can be adjusted according to specific application scenarios.
[0094] λ is the nonlinear enhancement coefficient, typically ranging from [0.1, 0.5]. The min(F, G, D) term represents the lowest value among the three metrics. The purpose of this term is to ensure that only when F, G, and D are all high (i.e., their min values are also high) will the score S receive a "reward" by adding λ·min(...), making it easier to exceed the threshold. Conversely, if any one metric is low (e.g., poor pixel overlap), even if the other two metrics are high, the min term will be small, failing to provide a reward and resulting in a low overall score. This cleverly achieves the "barrel effect" or the logical "AND" effect, forcing the consistency of the three spaces to be satisfied simultaneously.
[0095] Adaptive weight adjustment: the multi-space fusion determination module further comprises an adaptive weight adjustment unit. The unit obtains the spatial distribution density of feature matching point pairs and the edge complexity of connected domains in the binarized image. When the spatial distribution density of feature matching point pairs in a local area of the image is lower than a first threshold (for example, less than 2 matching points per hundred square pixels on average), and the edge complexity of connected domains in the binarized image is higher than a second threshold, it is determined that local occlusion exists. In response to determining that local occlusion exists, the unit reduces the weight coefficient w3 of the pixel-level overlap index, correspondingly increases the weight coefficient w2 of the structure consistency index, and simultaneously sets the nonlinear enhancement coefficient λ to zero. The multi-space fusion determination module recalculates the homology score based on the adjusted weight coefficients. This mechanism enables the system to reduce reliance on pixel overlap and make more use of global structure consistency for judgment when the official seal is partially occluded by text, signatures or stains, thereby significantly improving robustness.
[0096] Output: the module outputs a final homology score S ranging from 0 to 1.
[0097] 12. Judgment and Output Module (1) Function: based on the homology score S output by the multi-space fusion module, make a final binary decision and output the result.
[0098] (1) Technical implementation: Threshold comparison: compare the score S with a preset judgment threshold T. The threshold T is an empirical value, and it is necessary to strike a balance between "recall" and "precision" through experiments. According to experimental verification, preferably, the value range of T is [0.6, 0.8].
[0099] Decision logic: If S≥T, the system determines that "the two seals come from the same physical stamp" and outputs "homologous".
[0100] If S<T, the system determines that "the two seals come from different physical stamps" and outputs "heterologous".
[0101] Output form: the judgment result can be presented in various forms, for example, displaying a "homologous" / "heterologous" label on the software interface, returning a boolean value or a score through an API interface, or generating a structured report containing the score and judgment reasons.
[0102] Example 2 As Figure 2 shows, the present invention provides an official seal homology identification method based on multi-space consistency, comprising the following steps: Step S1: Obtain the first official seal image and the second official seal image to be compared, wherein the first official seal image usually refers to the reference official seal image used as the comparison benchmark, and the second official seal image refers to the official seal image to be detected; Step S2: Preprocess the first seal image and the second seal image respectively, extract the seal area, and generate an ink intensity map to enhance the ink area and suppress background interference; Step S3: Extract local features from the first official seal image and the second official seal image respectively, establish a set of feature matching point pairs between the first official seal image and the second official seal image, and calculate the feature space consistency index based on the set of feature matching point pairs; Step S4: Based on the set of feature matching point pairs, use a robust estimation algorithm to calculate the homography matrix representing the perspective transformation relationship between the second official seal image and the first official seal image, and perform perspective correction on the second official seal image according to the homography matrix to obtain an aligned image; Step S5: Using the center of the seal as the pole, transform the first seal image and the aligned image to polar coordinate space respectively to obtain the first polar coordinate image and the second polar coordinate image, and calculate the structural consistency index between the two. Step S6: Calculate the pixel-level overlap index between the first official seal image and the aligned image on the ink intensity map; Step S7: Construct a multi-space consistency fusion model, weightedly fuse the feature space consistency index, the structural consistency index and the pixel-level overlap index, and introduce a nonlinear constraint term to calculate the homology score; Step S8: Determine whether the homology score is greater than or equal to a preset threshold. If yes, determine that the first seal image and the second seal image originate from the same physical imprint, i.e., they are homologous seals; otherwise, determine that they are non-heterogeneous seals.
[0103] The formula for calculating the homology score S of the multi-space consistency fusion model constructed in step S7 is as follows: S=w1·F+w2·G+w3·D+λ·min(F, G, D), Wherein, F is the feature space consistency index, specifically the proportion of inliers obtained when estimating the homography matrix using the random sampling consistency algorithm; G is the structural consistency index, specifically the difference variance index calculated based on the first polar coordinate image and the second polar coordinate image, G=exp(- ), Var is the polar coordinate image difference variance; D is the pixel-level overlap index, specifically the Dice coefficient calculated based on the ink intensity map; w1, w2, and w3 are weighting coefficients, satisfying w1+w2+w3=1; λ is the nonlinear enhancement coefficient.
[0104] Specifically, the method for generating the ink intensity map in step S2 is as follows: An ink intensity model is constructed based on color differences, and the formula is: clean_gray=Normalize(max(0,R-α·G-β·B)), Where R, G, and B are the pixel values of the red, green, and blue channels of the image, respectively; α and β are preset weight coefficients with values ranging from [0.3 to 0.7]; Normalize means normalizing the calculation results to a grayscale range of 0-255; and clean_gray is the output ink intensity map.
[0105] Step S4 further includes: after performing perspective correction on the second seal image based on the homography matrix, calculating the outline roundness of the corrected seal image, wherein the outline roundness is defined as the ratio of the minor axis to the major axis of the fitted ellipse of the seal outline; when the roundness is greater than or equal to a preset roundness threshold, performing the polar coordinate expansion in step S5; when the roundness is less than the preset threshold, outputting an alignment failure signal and terminating the homology determination.
[0106] In step S6, the pixel-level overlap index uses the Dice coefficient, calculated as follows: D=2 |A∩B| / (|A|+|B|), where A and B are the sets of pixels in the seal area obtained by binarization from the ink intensity maps of the first seal image and the aligned image, respectively.
[0107] Example 3 This embodiment describes the specific implementation process of a seal homology identification method based on multi-space consistency, according to the method steps of embodiment 2 and combined with specific data: Step S101: Image acquisition and preprocessing.
[0108] First, the system receives two color images of official seals to be compared, denoted as Image A (reference image) and Image B (image to be tested), through the image input module. Both images are in JPEG format, with resolutions of 1200×800 and 1000×700, respectively.
[0109] To ensure consistent processing, the system first scales and normalizes the two images, scaling the longer side to 1024 pixels while maintaining the aspect ratio. Then, it calls the preprocessing module.
[0110] The preprocessing module first performs stamp region detection on images A and B. Taking A as an example, the module converts it from the RGB color space to the HSV space and generates masks in the red range of 0-10 degrees and 160-180 degrees using the H (hue) channel to initially locate the red area. Next, the Canny operator is used on this mask to extract edges and find all external contours. By calculating the area of each contour, the top three contours with the largest areas are selected. For each candidate contour, an ellipse is fitted using the least squares method, and the ratio of the area of the fitted ellipse to the area of the original contour is calculated. The contour with the ratio closest to 1 (i.e., the shape closest to an ellipse) and the largest area is selected as the stamp boundary. Based on the center and circumscribed rectangle of the fitted ellipse, the stamp image is cropped from the original image. Finally, the image is affinely transformed into a 256×256 pixel square image, where the major axis of the ellipse is rotated to the horizontal direction.
[0111] Step S102: Generate ink intensity map (clean_gray).
[0112] The two color stamp images, cropped and normalized in step S101, are input into the ink intensity modeling module. The module performs the following calculations for each pixel: clean_gray=Normalize(max(0,R-0.5·G-0.4·B)) Where R, G, and B are the channel values of the color image. The calculated values are linearly normalized to the [0, 255] interval, and the output is a grayscale image of the same size as the input image. In this image, the red stamp area is highlighted, while the paper background and other non-red content are strongly suppressed to a darker color. This clean_gray image will be used for subsequent pixel-level overlap calculations.
[0113] Step S103: Feature extraction and matching.
[0114] Feature extraction is performed on the color-normalized stamp image output in step S101 (or optionally the clean_gray image output in S102). This embodiment uses ORB features. The ORB_create function from the OpenCV library is used, with the maximum number of keypoints set to 2000 and the scale factor pyramid layer set to 8. Keypoints are detected on both images, and their 256-bit binary descriptors are calculated.
[0115] Then, a brute-force matcher is used to match the descriptors of the two images, resulting in an initial set of matches. Next, Lowe's ratio test is applied, with a ratio threshold set to 0.75, retaining only the matches that meet the criteria. After filtering, a set M containing approximately 150-300 high-quality matching points is obtained.
[0116] Step S104: Homography matrix estimation, perspective alignment and quality verification.
[0117] The matching point set M obtained in step S103 is input into the perspective alignment module. The module calls the RANSAC algorithm to estimate the homography matrix H. The parameters are set as follows: maximum number of iterations is 2000, and reprojection error threshold is 3.0 pixels. After removing outliers, the RANSAC algorithm determines a set of inliers from M. The ratio of the number of inliers to the total number of inliers in M is recorded as the feature space consistency index F, for example, F=0.85.
[0118] Based on the homography matrix H returned by RANSAC, this module applies a perspective transformation to the image B to be tested. Using OpenCV's `warpPerspective` function, the output image size is 512×512, with bilinear interpolation and constant (black) boundary padding. The transformed image is denoted as `B_aligned`.
[0119] After perspective correction, the circularity of the stamp image's outline is calculated. The outer contour of the stamp region in B_aligned is extracted, and an ellipse is fitted to obtain the major and minor axes. Circularity = minor axis / major axis. If the circularity is ≥ 0.85, the process continues; otherwise, an alignment failure signal is output and the process terminates. In this embodiment, the calculated circularity is 0.92, which meets the condition. At this point, B_aligned and A are geometrically precisely aligned.
[0120] Step S105: Polar coordinate expansion and structural consistency calculation.
[0121] This step must be performed strictly after step S104. First, using the stamp center point (xc, yc) obtained in step S101 (for the reference image) and the center point of the test image after H matrix transformation, images A and B_aligned are transformed to polar coordinate space. A polar coordinate image with a width of 360 (corresponding to an angle of 0-359 degrees) and a height of 128 (corresponding to 128 pixels from the center to the farthest edge) is constructed. By traversing the target pixels of the polar coordinate image, the corresponding Cartesian coordinates (x, y) are calculated, and pixel values are sampled from the original image to fill the space.
[0122] After obtaining two polar coordinate images, a Gaussian filter (kernel size 3×3) is applied to them. Then, the variance Var of the pixel-by-pixel gray-level difference between the two images is calculated. Assuming Var = 0.0225, the standard deviation is... =0.15, structural consistency index G=exp(-0.15)≈0.86.
[0123] Step S106: Pixel-level overlap calculation.
[0124] This step is performed on the clean_gray image generated in step S102, and after the perspective alignment in step S104. Otsu global thresholding binarization is applied to the clean_gray images of the reference image and the test image (which also need to undergo perspective transformation using the H matrix, or directly use the clean_gray image corresponding to B_aligned) to obtain a binary image. Finally, the pixel overlap index D is calculated according to the Dice coefficient formula; assuming the pixel overlap D = 0.91.
[0125] Step S107: Multi-space consistency fusion.
[0126] Based on the above steps, three metrics are obtained: feature consistency F=0.85, structural consistency G=0.86, and pixel overlap D=0.91. These metrics are then input into the multi-space fusion decision module.
[0127] The preset weighting coefficients are: w1=0.2, w2=0.2, w3=0.6. The nonlinear enhancement coefficient λ=0.3. The homology score S is calculated according to the fusion formula. S=0.2 0.85 + 0.2 0.86 + 0.6 0.91 + 0.3 min(0.85, 0.86, 0.91) =0.17 + 0.172 + 0.546 + 0.3 0.85 =0.888 + 0.255 = 1.143 Since the value of S is greater than 1, it is ultimately truncated to the upper limit of 1.0, i.e., S=1.0.
[0128] Step S108: Determine and output the result.
[0129] The system's preset homology threshold is T=0.75. Since the calculated final score S=1.0 is greater than 0.75, the judgment module outputs the final conclusion: "The two seals are official seals of the same origin." This result, along with the intermediate scores (F, G, D) and the final score S, is packaged into JSON format, returned to the caller via API, and visualized on the front-end interface in the form of "Homology (Confidence: High)".
[0130] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A method for identifying the origin of official seals based on multi-space consistency, characterized in that, Includes the following steps: Step S1: Obtain the first official seal image and the second official seal image to be compared, wherein the first official seal image usually refers to the reference official seal image used as the comparison benchmark, and the second official seal image refers to the official seal image to be detected; Step S2: Preprocess the first seal image and the second seal image respectively, extract the seal area, and generate an ink intensity map to enhance the ink area and suppress background interference; Step S3: Extract local features from the first official seal image and the second official seal image respectively, establish a set of feature matching point pairs between the first official seal image and the second official seal image, and calculate the feature space consistency index based on the set of feature matching point pairs; Step S4: Based on the set of feature matching point pairs, use a robust estimation algorithm to calculate the homography matrix representing the perspective transformation relationship between the second official seal image and the first official seal image, and perform perspective correction on the second official seal image according to the homography matrix to obtain an aligned image; Step S5: Using the center of the seal as the pole, transform the first seal image and the aligned image to polar coordinate space respectively to obtain the first polar coordinate image and the second polar coordinate image, and calculate the structural consistency index between the two. Step S6: Calculate the pixel-level overlap index between the first official seal image and the aligned image on the ink intensity map; Step S7: Construct a multi-space consistency fusion model, weightedly fuse the feature space consistency index, the structural consistency index and the pixel-level overlap index, and introduce a nonlinear constraint term to calculate the homology score; Step S8: Determine whether the homology score is greater than or equal to a preset threshold. If so, determine that the first official seal image and the second official seal image originate from the same physical imprint, i.e., they are homologous official seals. If not, it is determined to be a non-originating official seal.
2. The method for identifying the origin of official seals based on multi-space consistency according to claim 1, characterized in that, The homology score S of the multi-space consistency fusion model constructed in step S7 is calculated using the following formula: S=w1·F+w2·G+w3·D+λ·min(F, G, D), Wherein, F is the feature space consistency index, specifically the proportion of inliers obtained when estimating the homography matrix using the random sampling consistency algorithm; G is the structural consistency index, specifically the difference variance index calculated based on the first polar coordinate image and the second polar coordinate image, G=exp(- ), Var is the polar coordinate image difference variance; D is the pixel-level overlap index, specifically the Dice coefficient calculated based on the ink intensity map; w1, w2, and w3 are weighting coefficients, satisfying w1+w2+w3=1; λ is the nonlinear enhancement coefficient.
3. The method for identifying the origin of official seals based on multi-space consistency according to claim 1, characterized in that, The method for generating the ink intensity map in step S2 is as follows: An ink intensity model is constructed based on color difference, using the following formula: clean_gray=Normalize(max(0,R-α·G-β·B)), Where R, G, and B are the pixel values of the red, green, and blue channels of the image, respectively; α and β are preset weight coefficients with values ranging from [0.3 to 0.7]; Normalize means normalizing the calculation results to a grayscale range of 0-255; and clean_gray is the output ink intensity map.
4. The method for identifying the origin of official seals based on multi-space consistency according to claim 1, characterized in that, Step S4 specifically employs the Random Sample Consensus Algorithm (RANSAC) to filter feature matching point pairs, and estimates a homography matrix with 8 degrees of freedom based on the filtered interior points to correct perspective distortion in the official seal image. After perspective correction of the second official seal image based on the homography matrix, the circularity of the corrected seal image's outline is calculated. The circularity is defined as the ratio of the minor axis to the major axis of the fitted ellipse of the seal outline. When the circularity is greater than or equal to a preset circularity threshold, the polar coordinate expansion in step S5 is executed. When the circularity is less than the preset threshold, an alignment failure signal is output and the homology determination is terminated.
5. The method for identifying the origin of official seals based on multi-space consistency according to claim 1, characterized in that, In step S6, the pixel-level overlap index uses the Dice coefficient, calculated as follows: D=2 |A∩B| / (|A|+|B|), where A and B are the sets of pixels in the seal area obtained by binarization from the ink intensity maps of the first seal image and the aligned image, respectively.
6. A system for identifying the origin of official seals based on multi-space consistency, used to implement the method according to any one of claims 1 to 5, characterized in that, include: The image input module is used to receive the first official seal image and the second official seal image to be compared. The first official seal image usually refers to the reference official seal image used as the comparison benchmark, and the second official seal image refers to the official seal image to be detected. The preprocessing module, connected to the image input module, is used to detect and crop the seal area of the first seal image and the second seal image respectively, and generate an ink intensity map to enhance the ink area and suppress background interference. The feature extraction and matching module, connected to the preprocessing module, is used to extract local features of the first and second official seal images processed by the preprocessing module, establish a set of feature matching point pairs between the two images, and calculate the feature space consistency index based on the set of feature matching point pairs. The perspective alignment module, connected to the feature extraction and matching module, is used to estimate the homography matrix based on the feature matching point pair set, and to perform perspective correction on the second official seal image according to the homography matrix to obtain an aligned image; The polar coordinate unfolding and structural analysis module is connected to the perspective alignment module. It is used to convert the first official seal image and the aligned image processed by the perspective alignment module to polar coordinate space with the center of the seal as the pole, respectively, to obtain the first polar coordinate image and the second polar coordinate image, and calculate the structural consistency index between the two. A pixel overlap calculation module, connected to the preprocessing module and the perspective alignment module, is used to calculate the pixel-level overlap index between the first official seal image and the alignment image on the ink intensity map generated by the preprocessing module. The multi-space fusion determination module is connected to the feature extraction and matching module, the polar coordinate expansion and structural analysis module, and the pixel overlap calculation module. It is used to perform weighted fusion of the received feature space consistency index, structural consistency index, and pixel-level overlap index, introduce nonlinear constraint terms, calculate the homology score, determine whether the homology score is greater than or equal to a preset threshold, and output the homology determination result.
7. The seal origin identification system based on multi-space consistency according to claim 6, characterized in that, The perspective alignment module specifically employs the Random Sample Consensus Algorithm (RANSAC) to filter feature matching point pairs and estimates a homography matrix with 8 degrees of freedom based on the filtered interior points to correct perspective distortion in the official seal image. After perspective correction of the second official seal image based on the homography matrix, the circularity of the corrected seal image's outline is calculated. The circularity is defined as the ratio of the minor axis to the major axis of the fitted ellipse of the seal outline. When the circularity is greater than or equal to a preset circularity threshold, the polar coordinate expansion in step S5 is executed. When the circularity is less than the preset threshold, an alignment failure signal is output and the homology determination is terminated.
8. The seal origination identification system based on multi-space consistency according to claim 6, characterized in that, The polar coordinate unpacking and structural analysis module uses the center of the seal as the pole, mapping the image pixel coordinates (x, y) in the Cartesian coordinate system to polar coordinates (r, θ), where (x, y) represents the x and y coordinates of any pixel in the image in the Cartesian coordinate system, r represents the polar radius distance from the pixel to the center of the seal, and θ represents the polar angle of the pixel relative to the polar axis. A polar coordinate image is reconstructed based on this mapping, and the variance of the pixel-by-pixel grayscale difference between the two polar coordinate images is calculated. The structural consistency index G is calculated using the following formula: G=exp(- ), Where Var is the variance of the pixel-by-pixel grayscale difference between the two polar coordinate images. This represents the arithmetic square root of the variance.
9. The seal origination identification system based on multi-space consistency according to claim 6, characterized in that, The homology scoring function constructed by the multi-space fusion determination module is as follows: S=w1·F+w2·G+w3·D+λ·min(F, G, D), Wherein, F is the feature space consistency index, specifically the proportion of inliers obtained when estimating the homography matrix using the random sampling consistency algorithm; G is the structural consistency index, specifically the difference variance index calculated based on the first polar coordinate image and the second polar coordinate image, G=exp(- ), Var is the polar coordinate image difference variance; D is the pixel-level overlap index, specifically the Dice coefficient calculated based on the ink intensity map; w1, w2, and w3 are weighting coefficients, satisfying w1+w2+w3=1; λ is the nonlinear enhancement coefficient.
10. The seal origination identification system based on multi-space consistency according to claim 9, characterized in that, The multi-space fusion determination module further includes an adaptive weight adjustment unit, which is used for: Obtain the spatial distribution density of feature matching point pairs output by the feature extraction and matching module, and the edge complexity of connected components in the binarized image output by the pixel overlap calculation module; When the spatial distribution density of the feature matching point pairs in a local area of the image is lower than the first threshold, and the edge complexity of the connected components in the binarized image is higher than the second threshold, it is determined that there is local occlusion. In response to the determination that there is local occlusion, the adaptive weight adjustment unit reduces the weight coefficient w3 of the pixel-level overlap index in the homology score calculation, and correspondingly increases the weight coefficient w2 of the structural consistency index, while setting the nonlinear enhancement coefficient λ to zero. The multi-space fusion determination module recalculates the homology score based on the adjusted weight coefficients.