Round seal text recognition method based on color filtering and coordinate transformation

By employing HSV color space segmentation and polar coordinate transformation, the problem of high-precision recognition of circular seals against complex backgrounds was solved, achieving efficient and accurate extraction and recognition of seal text.

CN122090433APending Publication Date: 2026-05-26HUA DATA TECH (SHANGHAI) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUA DATA TECH (SHANGHAI) CO LTD
Filing Date
2026-04-21
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing OCR technology struggles to extract information from circular seals with high precision, especially in complex backgrounds where background noise, geometric curvature, and inaccurate center positioning can cause the seal to unfold distorted.

Method used

A method based on color filtering and coordinate transformation is adopted. Through HSV color space segmentation and geometric analysis transformation, the center of the seal is accurately located, a polar coordinate space is constructed and mapped to a rectangular image, and an OCR engine is used to recognize the seal text.

Benefits of technology

It achieves high-precision seal text recognition, strong noise resistance, high geometric correction accuracy, and high computational efficiency, making it suitable for deployment on mobile devices and high-concurrency servers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122090433A_ABST
    Figure CN122090433A_ABST
Patent Text Reader

Abstract

The invention provides a circular seal text recognition method based on color filtering and coordinate transformation, and relates to the technical field of document image processing. The circular seal text recognition method based on color filtering and coordinate transformation comprises the steps that through nonlinear transformation from RGB to HSV color space, a self-adaptive mask is constructed by means of the specific chromaticity distribution characteristic of a seal, and a seal foreground and a black clutter and noise background are separated; calculating a zero moment and a first moment based on the geometric moment of the binarized image, accurately deducing the center of mass coordinate of the seal, and determining an expansion axis; establishing a reversible mapping relation between a Cartesian coordinate system and a polar coordinate system, and using a bilinear interpolation algorithm to unfold the annularly distributed text region into a rectangular image strip with significant linear features; and finally, performing text extraction on the expanded image. According to the method, the identification accuracy of the circular seal can be remarkably improved, and the method has the technical effects of high noise resistance, high calculation efficiency and high robustness.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of document image processing technology, and in particular to a method for recognizing circular seal text based on color filtering and coordinate transformation. Background Technology

[0002] As enterprises accelerate their digital transformation, automated systems need to extract circular seal information from massive amounts of scanned documents for automatic reconciliation, risk control, and compliance checks.

[0003] Current mainstream OCR technologies are mainly designed for rectangular text and are difficult to handle the unique circular layout and complex scenarios of seals. When processing circular seals, they face unique issues such as curved character arrangement, background noise interference, uncertain rotation angle, and deviation in center positioning, which lead to technical problems such as seal unfolding distortion.

[0004] Therefore, there is an urgent need for a technology that can solve the problem of high-precision seal information extraction in complex backgrounds. Summary of the Invention

[0005] To address the shortcomings of existing technologies, this invention proposes a circular seal text recognition method based on color filtering and coordinate transformation. By fusing color segmentation and geometric analysis transformation, high-precision seal text recognition is achieved. This aims to solve the problem of low recognition rates in existing technologies when processing seal text due to significant background noise interference, geometric curvature, and inaccurate center positioning.

[0006] In a first aspect, the present invention provides a method for recognizing circular seal text based on color filtering and coordinate transformation, comprising the following steps:

[0007] S1. Convert the red stamp image to the HSV color space, set the hue threshold range to [170, 180]∪[0,10], and use this to filter the foreground image to generate a binary mask image with the stamp image as the foreground, where the pixel value of the foreground image is 1 and the pixel value of the background image is 0.

[0008] S2. Extract the contour information from the mask image, further filter the outer contour of the seal and obtain the seal radius, filter the central graphic contour of the seal and obtain the seal center.

[0009] Based on the pixel values ​​of the mask image, calculate the zeroth moment of the image and its first moments in the x and y directions respectively. The centroid coordinates of the seal are obtained by the proportion of the first moment in the zeroth moment.

[0010] Establish a polar coordinate space with the center of the circle as the pole and the backward extension of the line connecting the center of the circle and the center of mass as the polar axis;

[0011] S3. Construct a coordinate transformation between polar coordinate space and Cartesian coordinate space, and use bilinear interpolation algorithm to map the seal image with the central graphic removed into a rectangular image. This mapping process first determines each pixel of the rectangular image, and then determines its pixel value through coordinate transformation.

[0012] S4. Use the OCR engine to recognize the rectangular image and obtain the stamp text.

[0013] As a further improvement of the present invention, the method for setting the hue, saturation, and brightness thresholds in step S1 includes:

[0014] Based on the tonal characteristics of the seal, adaptively set a tonal threshold range that can encompass its tonal range;

[0015] Set the saturation threshold range with the saturation of the paper and the gray noise on it as the lower limit;

[0016] Set the brightness threshold range with the brightness of other text and shadows as the lower limit.

[0017] As a further improvement of the present invention

[0018] For light-colored stamps, the hue threshold range is set to [170, 180]∪[0, 20].

[0019] For dark-colored stamps, the hue threshold range is set to [160, 180]∪[0, 10].

[0020] Set the saturation threshold range to [43, 255];

[0021] The brightness threshold range is set to [46, 255].

[0022] As a further improvement of the present invention, the method for obtaining the seal radius and the seal center in step S2 includes:

[0023] Perform contour detection on the mask image, calculate the area of ​​all contours, select the contour with the largest area as the outer edge of the stamp, and take the radius of its circumcircle as the radius Rmax of the stamp.

[0024] Sort all contours by area from largest to smallest, take the first circumcircle with a radius less than 0.8Rmax, and use its center as the center of the stamp shape.

[0025] As a further improvement of the present invention, the method for calculating the centroid position of the seal in step S2 includes:

[0026] For the masked image, first remove the central graphic portion of the stamp, then calculate the centroid coordinates (Gx, Gy);

[0027] Where Gx=M10 / M 00 Gy=M 01 / M 00 ;

[0028] Zeroth moment M 00 and the first moment M 10 and M 01 The calculation formula is:

[0029] ;

[0030] Where p and q represent the order of the moments in the x and y directions, respectively, x and y represent the two-dimensional planar coordinates of the pixels in the mask image, and M(x,y) represents the pixel value of the mask image at coordinates (x,y).

[0031] As a further improvement of the present invention, the mapping method in step S3 includes:

[0032] The input image is a seal image with the central graphic removed;

[0033] Construct a rectangular region for the output image, with its width corresponding to the perimeter of the seal and its height corresponding to the radius of the seal;

[0034] Iterate through each known pixel in the output image, use coordinate transformation to calculate its corresponding coordinate value in the polar coordinate system, map it to the corresponding pixel in the input image, and return its pixel value to the pixel in the output image.

[0035] As a further improvement of the present invention, the coordinate transformation method is as follows:

[0036] ;

[0037] Where (x,y) are the coordinates of a pixel in the input image, and (u,v) are the coordinates of a pixel in the output image. These are the pixel coordinates of the center of the circle in the input image; It is the polar radius in polar coordinates, representing the distance from the current calculation point to the center of the circle, and W is the circumference of the seal; It is the polar angle in polar coordinates, representing the rotation of the current calculation point in radians relative to the zero-degree polar axis, with a value range of... H is the radius of the stamp;

[0038] In this process, the floating-point coordinates (x, y) obtained by the reverse calculation are used to determine the corresponding pixel position in the input image using nearest neighbor interpolation.

[0039] As a further improvement of the present invention, step S3 further includes: adjusting the angle of the rectangular image so that the text in it remains upright and horizontal.

[0040] In a second aspect, the present invention provides a computer device including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described in the first aspect.

[0041] Thirdly, the present invention provides a computer program product that, when executed by a processor, implements the steps of the method described in the first aspect.

[0042] Compared with the prior art, the present invention has the following significant advantages:

[0043] Strong noise resistance: By accurately segmenting the HSV color space, black signatures, printed fonts and table lines near the seal are removed, solving the problem of low OCR recognition rate caused by "red and black overlap" and greatly improving the signal-to-noise ratio of the image.

[0044] High geometric correction accuracy: The centroid is calculated using image moments, and the center of the circle is accurately located using the image of the center, which greatly reduces the wavy distortion caused by polar coordinate unfolding, thus ensuring the integrity of the topological structure of the unfolded character.

[0045] High computational efficiency: The entire preprocessing process is based on deterministic algebraic operations and matrix transformations, without the need for complex deep learning segmentation models, resulting in extremely low computational overhead and making it suitable for deployment on mobile devices or high-concurrency servers. Attached Figure Description

[0046] Figure 1 This is a flowchart of a circular seal text recognition method based on color filtering and coordinate transformation disclosed in this invention.

[0047] Figure 2 In one embodiment, a stamp with a rotation angle is to be identified.

[0048] Figure 3 To Figure 2 The mask image is obtained by preprocessing the seal to be identified.

[0049] Figure 4 A mask image to remove the center image.

[0050] Figure 5 This is a stamp diagram that includes the polar coordinate unfolded poles and unfolded axes.

[0051] Figure 6 This is a diagram of the seal text after being expanded in polar coordinates and the angle adjusted. Detailed Implementation

[0052] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Steps S1, S2… in the described embodiments of the present invention do not limit the scope of execution of the present invention; the various models, simulation environments, and software described in the present invention are not considered as the only limiting methods of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.

[0053] In this invention, computer device / equipment / system refers to a related entity applied to a computer, such as hardware, a combination of hardware and software, software, or software in execution. More specifically, for example, software includes, but is not limited to, a process running on a processor, a processor, an object, executable software, an execution thread, a program, and / or a computer. Furthermore, an application program or script running on a server, and the server itself, can also be software. One or more software programs may be in an execution process and / or thread, and the software may be localized on one computer and / or distributed across two or more computers, and may be run on various computer-readable media.

[0054] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other.

[0055] In a first aspect, the present invention provides an embodiment of a circular seal text recognition method based on color filtering and coordinate transformation, such as... Figure 1 As shown, the specific process can be as follows:

[0056] S1. Image preprocessing and noise removal; including:

[0057] S11, Color Space Conversion;

[0058] In RGB images, the R, G, and B components are highly correlated and greatly affected by illumination. To eliminate these adverse factors, this step uses a non-linear transformation formula to convert the original color image containing the stamp from the RGB color space to the HSV color space. The HSV space can separate color information from luminance information, better handle uneven illumination, and distinguish between the red stamp and the black interfering text.

[0059] S12, Seal mask extraction;

[0060] Within the HSV color space, a specific threshold range for the seal color is set, a binary mask is generated, and pixels that match the seal color characteristics are set as the foreground, while the remaining pixels (including black text, white background, blue signature, etc.) are set as the background.

[0061] Preferably, for the most common red stamp, the HSV threshold range setting and mask extraction method are as follows:

[0062] Since red spans 0 degrees on the HSV color wheel, two consecutive threshold ranges need to be set to cover the full red feature. Specifically, the criteria for setting the HSV threshold range include:

[0063] (1) Adaptive standard for hue (H): The default hue range for red is usually distributed within [0, 10] and [170, 180]. In actual processing, the range above and below 0 degrees can be dynamically adjusted using an adaptive standard based on image characteristics (such as lighting conditions or the degree of ink aging). For example, if the ink fades to a yellowish or orange hue, the upper limit of the upper half of the range can be expanded to a higher value (such as expanding it to 15 or 20); if the ink color is dark red or purplish-red, the lower limit of the lower half of the range can be expanded to a lower value (such as lowering it to 160).

[0064] (2) Criteria for determining saturation (S) and brightness (V): The lower limits of the second (S) and third (V) values ​​in the HSV value are mainly used to exclude interference from non-target pixels. Specifically, the lower limit of saturation (S) aims to filter out low-saturation backgrounds such as white paper and gray noise to retain brightly colored stamp areas; the lower limit of brightness (V) aims to exclude interference from low-brightness black or blue printed text and shadows in dark areas; the upper limits of S and V are usually set to a maximum value of 255. Preferably, the lower limits of S and V can be adaptively set by statistically analyzing the average S and V values ​​of the background area of ​​the image and combining them with empirical offsets, thereby achieving more accurate background stripping.

[0065] As a preferred embodiment, for a standard red stamp, two reference threshold ranges are set as follows: Range 1 is [0, 43, 46] to [10, 255, 255]; Range 2 is [170, 43, 46] to [180, 255, 255]. Note: For stamps of different colors, the threshold range needs to be adjusted accordingly in this step based on the above standards.

[0066] The process of calculating and extracting the mask specifically includes:

[0067] For the stamp image converted to the HSV color space, independent mask calculations are performed using the two set threshold intervals. The H, S, and V channel values ​​of each pixel in the image are extracted pixel-by-pixel and compared with the set threshold intervals: if the HSV value of a pixel falls within the upper and lower limits of interval one, it is marked as a foreground pixel in the first mask (e.g., pixel value set to 255); otherwise, it is marked as a background pixel (e.g., pixel value set to 0). Similarly, a second mask is independently generated using interval two. Finally, a pixel-level bitwise OR operation is performed on the first and second masks, i.e., the union of the two is taken, and the two red pixels spanning the 0-degree color wheel are concatenated to obtain the final red pixel mask M.

[0068] Figure 2 The red stamp pattern in one embodiment of the present invention is used to calculate the corresponding mask M image, as shown below. Figure 3 As shown.

[0069] S2. Locate the polar coordinate expansion axis through geometric analysis;

[0070] In order to accurately locate the seal, this step uses the mask M obtained in step S1 to perform geometric analysis, find and delete the image at the center of the seal (such as a pentagram), find the geometric center of the seal and the centroid of the seal pattern, and locate the pole and the axis of the polar coordinate unfolding.

[0071] This step utilizes the distribution information of foreground pixels to ensure that the unfolding axis, determined by the center and centroid, does not cut off the Chinese characters in the seal, thus ensuring that the Chinese characters are arranged in the same order after unfolding. Even if the seal boundary is incomplete or has local noise, it will not significantly affect the positioning of the unfolding axis.

[0072] The specific steps are as follows:

[0073] S21. Outline search and center determination;

[0074] Perform contour detection on the mask M, calculate the area of ​​all contours, select the contour with the largest area as the outer edge of the stamp, and take its circumscribed circle radius Rmax as the reference radius.

[0075] After sorting all contours by area from largest to smallest, calculate the circumcircle of all contours. Take the center O and radius R of the circumcircle corresponding to the first circumcircle with a radius less than 0.8Rmax (the purpose of adding the coefficient 0.8 is to exclude the inner circle contour of the seal ring; the specific value can be adjusted according to different seal types). These are the center and radius of the circumcircle of the seal's central graphic (such as a five-pointed star).

[0076] The outer edge contour of the stamp is not used to obtain the center of the circle in this step because other content around the stamp may affect the detection of the outer edge contour. The probability of the central pentagon being affected is much lower.

[0077] S22. Determination of the expansion axis based on the centroid of the mask;

[0078] To eliminate the interference of the seal center image on the centroid calculation, the mask M is manipulated to retain only the parts other than the seal center image (including the seal text, outer contour, and other possible noise), such as... Figure 4 As shown.

[0079] Calculate the zero-order moment M of the image using the mask M. 00 (Representing area), first moment M 10 and M 01 (Representing the mass distribution). Using the formula Gx=M 10 / M 00 Gy=M 01 / M 00 Calculate the physical centroid G=(Gx, Gy) of the seal pattern. Let p be the p+q order geometric moments of the image.

[0080] The calculation formula is:

[0081] ;

[0082] Where p and q are non-negative integers (i.e., 0, 1, 2...), representing the order of the moments in the x and y directions, respectively; x and y represent the two-dimensional planar coordinates of the pixels in the image; M(x,y) represents the pixel value of the mask image at coordinates (x,y) (for a binary mask, the pixel value of the target area is usually 1, and the pixel value of the background area is usually 0).

[0083] Connect the center O of the circle to the centroid G, and use the backward extension of the centroid G as the axis of polar coordinate expansion. Take the center O as the polar pole. For example... Figure 5 As shown.

[0084] This step utilizes the integral information of all foreground pixels, so even if the stamp boundary is incomplete or there is local noise, the resulting unfolding axis can still ensure that the target text area is not cut off.

[0085] S3, unfold the seal;

[0086] S31, Coordinate Transformation;

[0087] Construct a target rectangular image, where the width corresponds to the perimeter of the seal and the height corresponds to the radius of the seal. Use trigonometric functions to transform the circular region of the seal into linear strips, mapping the circular image to a rectangular image. The transformation method is as follows:

[0088] Let the pixel coordinates of the output image (the unfolded rectangle) be (u, v), and the pixel coordinates of the input image (the circle) be (x, y). The width W of the output image is set to the circumference of the circle. The height H of the output image is set to the radius of the circle: .

[0089] To avoid pixel holes in the output image during coordinate transformation, a reverse mapping method is used in actual processing. That is, for each known pixel (u,v) on the output image (rectangle), the corresponding parameters in the polar coordinate system are calculated, and then mapped back to the input image (circle) to find the corresponding coordinates (x,y), instead of solving for (u,v) through a system of equations from the input (x,y).

[0090] The relationship between the unfolded axis of the output image and the polar coordinate system is as follows: The horizontal unfolded axis (u-axis) corresponds to the polar angle in the polar coordinate system. The vertical unfolding axis (v-axis) corresponds to the polar radius in the polar coordinate system. .

[0091] The coordinate transformation formula is:

[0092] ;

[0093] in, These are the center pixel coordinates of the input image (circular region); This is the polar radius in polar coordinates, representing the distance from the current calculation point to the center of the circle. It is mapped from the vertical coordinate v of the output image, and the unit is pixels. This is the polar angle in polar coordinates, representing the rotation angle of the current calculation point relative to the zero-degree polar axis. It is obtained by linearly mapping the horizontal coordinate u of the output image along the circumference direction, with units in radians, and a typical value range of 100°. .

[0094] Subsequently, since (x,y) calculated by the above reverse mapping formula is usually a floating-point number containing decimals, and not the actual integer pixel position of the input image, nearest neighbor interpolation is needed to determine the color value of the real point (x,y) in the input image, and finally assign it to the pixel (u,v) on the output image.

[0095] S32, Direction Adjustment;

[0096] Adjust the angle of the rectangular image obtained in step S31 so that the text in it remains upright and horizontal, which conforms to reading habits and the input habits of the OCR engine.

[0097] In one embodiment of the present invention, the image generated in step S31 is a vertical strip. Rotating it counterclockwise by 90 degrees yields a horizontally elongated strip of the seal. At this point, the circular characters in the seal are straightened into a single line of horizontal characters arranged sequentially from left to right, facilitating subsequent identification. The image after orientation adjustment is shown below. Figure 6 As shown.

[0098] S4. Use OCR to recognize high-precision seal text;

[0099] The expanded elongated image is then input into a pre-trained OCR engine. Since the text has now been corrected to be horizontally aligned and background noise has been filtered out, a general OCR model can achieve high-precision character recognition.

[0100] In a second aspect, the present invention provides an embodiment of a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described in the first aspect.

[0101] Thirdly, the present invention provides a computer program product embodiment, which, when executed by a processor, implements the steps of the method described in the first aspect.

Claims

1. A method for recognizing text on circular seals based on color filtering and coordinate transformation, characterized in that, Includes the following steps: S1. Convert the red stamp image to the HSV color space, set the hue threshold range to [170, 180]∪[0, 10], and use this to filter the foreground image to generate a binary mask image with the stamp image as the foreground, where the pixel value of the foreground image is 1 and the pixel value of the background image is 0. S2. Extract the contour information from the mask image, further filter the outer contour of the seal and obtain the seal radius, filter the central graphic contour of the seal and obtain the seal center. Based on the pixel values ​​of the mask image, calculate the zeroth moment of the image and its first moments in the x and y directions respectively. The centroid coordinates of the seal are obtained by the proportion of the first moment in the zeroth moment. A polar coordinate space is established with the center of the circle as the pole and the backward extension of the line connecting the center of the circle and the center of mass as the polar axis. S3. Construct a coordinate transformation between polar coordinate space and Cartesian coordinate space, and use bilinear interpolation algorithm to map the seal image with the central graphic removed into a rectangular image. This mapping process first determines each pixel of the rectangular image, and then determines its pixel value through coordinate transformation. S4. Use the OCR engine to recognize the rectangular image and obtain the stamp text.

2. The method according to claim 1, characterized in that, In step S1, the method for setting the hue threshold is as follows: Based on the tonal characteristics of the seal, adaptively set a tonal threshold range that can encompass its tonal range; Step S1 also includes: Set the saturation threshold range with the saturation of the paper and the gray noise on it as the lower limit; Set the brightness threshold range with the brightness of other text and shadows as the lower limit.

3. The method according to claim 2, characterized in that, For light-colored stamps, the hue threshold range is set to [170, 180]∪[0, 20]. For dark-colored stamps, the hue threshold range is set to [160, 180]∪[0, 10]. Set the saturation threshold range to [43, 255]; The brightness threshold range is set to [46, 255].

4. The method according to claim 1, characterized in that, In step S2, the methods for obtaining the radius and center of the seal include: Perform contour detection on the mask image, calculate the area of ​​all contours, select the contour with the largest area as the outer edge of the stamp, and take the radius of its circumcircle as the radius Rmax of the stamp. Sort all contours by area from largest to smallest, take the first circumcircle with a radius less than 0.8Rmax, and use its center as the center of the stamp shape.

5. The method according to claim 1, characterized in that, In step S2, the method for calculating the centroid position of the seal includes: For the masked image, first remove the central graphic portion of the stamp, then calculate the centroid coordinates (Gx, Gy); Where Gx=M 10 / M 00 Gy=M 01 / M 00 ; Zeroth moment M 00 and the first moment M 10 and M 01 The calculation formula is: ; Where p and q represent the order of the moments in the x and y directions, respectively, x and y represent the two-dimensional planar coordinates of the pixels in the mask image, and M(x,y) represents the pixel value of the mask image at coordinates (x,y).

6. The method according to claim 1, characterized in that, In step S3, the mapping method includes: The input image is a seal image with the central graphic removed; Construct a rectangular region for the output image, with its width corresponding to the perimeter of the seal and its height corresponding to the radius of the seal; Iterate through each known pixel in the output image, use coordinate transformation to calculate its corresponding coordinate value in the polar coordinate system, map it to the corresponding pixel in the input image, and return its pixel value to the pixel in the output image.

7. The method according to claim 6, characterized in that, The coordinate transformation method is as follows: ; Where (x, y) are the coordinates of a pixel in the input image, and (u, v) are the coordinates of a pixel in the output image. These are the pixel coordinates of the center of the circle in the input image; It is the polar radius in polar coordinates, representing the distance from the current calculation point to the center of the circle, and W is the circumference of the seal; It is the polar angle in polar coordinates, representing the rotation of the current calculation point in radians relative to the zero-degree polar axis, with a value range of... H is the radius of the stamp; In this process, the floating-point coordinates (x, y) obtained by the reverse calculation are used to determine the corresponding pixel position in the input image using nearest neighbor interpolation.

8. The method according to claim 1, characterized in that, Step S3 further includes: adjusting the angle of the rectangular image so that the text in it remains upright and horizontal.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1-8.

10. A computer program product, characterized in that, When executed by a processor, the computer program implements the steps of the method described in any one of claims 1-8.