CN-122024251-A - Font identification method, device, equipment and medium based on self-adaptive preprocessing
Abstract
The invention provides a font identification method, device, equipment and medium based on self-adaptive preprocessing, which comprises the steps of carrying out self-adaptive preprocessing on an acquired font image, wherein the preprocessing comprises dynamic noise suppression, uneven illumination correction and sub-pixel level geometric correction to obtain a corrected text image, carrying out multidimensional feature extraction on the corrected text image to construct a fusion feature vector containing local detail features, global style features and geometric correction features, carrying out dynamic weight matching based on a feature contribution degree evaluation model, calculating the similarity of characters to be matched and candidate fonts, outputting the identified font types according to a similarity result, and ensuring the accuracy of font identification.
Inventors
- LIU ZHIHAI
- LIU YIMIN
- TONG ZHEN
Assignees
- 福建紫讯信息科技有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20251223
Claims (10)
- 1. A font identification method based on self-adaptive preprocessing is characterized by comprising the following steps: Step S1, carrying out self-adaptive preprocessing on an acquired font image, wherein the preprocessing comprises dynamic noise suppression, uneven illumination correction and sub-pixel level geometric correction to obtain a corrected text image; S2, extracting multidimensional features from the corrected text image, and constructing a fusion feature vector containing local detail features, global style features and geometric correction features; And S3, carrying out dynamic weight matching based on the characteristic contribution degree evaluation model, calculating the similarity between the characters to be matched and the candidate fonts, and outputting the identified font types according to the similarity result.
- 2. The method for recognizing fonts based on adaptive preprocessing as recited in claim 1, wherein in step S1, the dynamic noise suppression specifically comprises: Gray level histogram analysis is carried out on the patch of the text image; If a discrete extreme point with gray level difference value between extreme points exceeding a preset threshold exists in the gray level histogram, judging that the gray level difference value is spiced salt noise, adopting self-adaptive median filtering to remove noise, and dynamically adjusting the size of a filtering window according to the noise ratio, wherein in the self-adaptive median filtering to remove noise, a 3X 3 window is adopted when the noise ratio is smaller than 5 percent, a 5X 5 window is adopted when the noise ratio is 5% -15 percent, a 7X 7 window is adopted when the noise ratio is larger than 15 percent, and the spatial domain standard deviation is 1.5 and the gray domain standard deviation is 20 in the bilateral filtering to remove noise; Otherwise, judging the noise to be Gaussian noise, denoising by adopting bilateral filtering, controlling the influence range of the neighborhood pixels by using the spatial domain weight, and reserving the edge gray difference by using the gray domain weight; The illumination unevenness correction and sub-pixel level geometric correction specifically include: adopting a Retinex image enhancement algorithm to decompose an image into an illumination component and a reflection component, smoothing the illumination component and then re-fusing the illumination component and the reflection component; Detecting coordinates of four vertexes of the text, if perspective distortion exists, constructing a perspective transformation matrix, and mapping the distorted image into a rectangular area by adopting a bilinear interpolation algorithm.
- 3. The method for recognizing fonts based on adaptive preprocessing as recited in claim 2, wherein in step S2, the multi-dimensional feature extraction specifically comprises: Extracting local detail features, namely extracting end point, corner and intersection point features of character strokes by utilizing an improved LBP operator to obtain the local detail features, wherein the improved LBP operator adopts a rotation-invariant LBP combined uniform mode; The method comprises the steps of extracting global style characteristics, namely inputting font images into a pre-constructed CNN style classifier, outputting style labels and style characteristic vectors, and quantizing key parameters in the style characteristic vectors to form style characteristic sub-vectors; extracting geometric correction features, namely taking the inclination angle obtained in the geometric correction process in the step S1 and the mapping coefficient in the perspective distortion correction matrix as auxiliary features; and connecting the local detail features, the style feature sub-vectors and the geometric correction features in series to construct the fusion feature vector.
- 4. The method for recognizing fonts based on adaptive preprocessing of claim 1, wherein the step S3 of performing dynamic weight matching based on the feature contribution evaluation model specifically comprises: Determining style labels of the characters to be matched through a global style classifier; invoking a pre-constructed feature contribution evaluation model, and dynamically adjusting the weight of each dimension feature according to the style label; and calculating the similarity between the characters to be matched and the candidate fonts, wherein the similarity is calculated by adopting the following formula: Sim=0.6×cos (a, B) +0.4× (1-Euclid (a, B)/max_distance), where Sim is similarity, a is a text weighted feature vector to be matched, B is a candidate font feature vector, cos (a, B) is cosine similarity, euclid (a, B) is euclidean Distance, max_distance is a preset maximum euclidean Distance threshold; The step S3 further comprises a similar font secondary verification step: If the character to be matched and the candidate fonts belong to the preset highly similar font group in the initial matching result, extracting stroke curvature characteristics of the character to be matched and the candidate fonts and calculating curvature characteristic similarity sim_curvature, and updating the total similarity according to the following formula: Sim_final=0.8×Sim_initial+0.2×Sim_curvature Wherein sim_final is the final similarity, and sim_initial is the initial calculated similarity.
- 5. A font recognition device based on adaptive preprocessing is characterized by comprising: The self-adaptive preprocessing module is used for carrying out self-adaptive preprocessing on the acquired font image, wherein the preprocessing comprises dynamic noise suppression, uneven illumination correction and sub-pixel level geometric correction, so as to obtain a corrected text image; The multidimensional feature extraction module is used for carrying out multidimensional feature extraction on the corrected text image and constructing a fusion feature vector containing local detail features, global style features and geometric correction features; And the dynamic weight matching module is used for carrying out dynamic weight matching based on the characteristic contribution degree evaluation model, calculating the similarity between the characters to be matched and the candidate fonts, and outputting the identified font types according to the similarity result.
- 6. The font recognition device based on adaptive preprocessing of claim 5, wherein in the adaptive preprocessing module, the dynamic noise suppression specifically comprises: Gray level histogram analysis is carried out on the patch of the text image; If a discrete extreme point with gray level difference value between extreme points exceeding a preset threshold exists in the gray level histogram, judging that the gray level difference value is spiced salt noise, adopting self-adaptive median filtering to remove noise, and dynamically adjusting the size of a filtering window according to the noise ratio, wherein in the self-adaptive median filtering to remove noise, a 3X 3 window is adopted when the noise ratio is smaller than 5 percent, a 5X 5 window is adopted when the noise ratio is 5% -15 percent, a 7X 7 window is adopted when the noise ratio is larger than 15 percent, and the spatial domain standard deviation is 1.5 and the gray domain standard deviation is 20 in the bilateral filtering to remove noise; Otherwise, judging the noise to be Gaussian noise, denoising by adopting bilateral filtering, controlling the influence range of the neighborhood pixels by using the spatial domain weight, and reserving the edge gray difference by using the gray domain weight; The illumination unevenness correction and sub-pixel level geometric correction specifically include: adopting a Retinex image enhancement algorithm to decompose an image into an illumination component and a reflection component, smoothing the illumination component and then re-fusing the illumination component and the reflection component; Detecting coordinates of four vertexes of the text, if perspective distortion exists, constructing a perspective transformation matrix, and mapping the distorted image into a rectangular area by adopting a bilinear interpolation algorithm.
- 7. The font recognition device based on adaptive preprocessing of claim 6, wherein in the multi-dimensional feature extraction module, the multi-dimensional feature extraction specifically comprises: Extracting local detail features, namely extracting end point, corner and intersection point features of character strokes by utilizing an improved LBP operator to obtain the local detail features, wherein the improved LBP operator adopts a rotation-invariant LBP combined uniform mode; The method comprises the steps of extracting global style characteristics, namely inputting font images into a pre-constructed CNN style classifier, outputting style labels and style characteristic vectors, and quantizing key parameters in the style characteristic vectors to form style characteristic sub-vectors; Extracting geometric correction features, namely taking an inclination angle obtained in the geometric correction process in the adaptive preprocessing module and a mapping coefficient in the perspective distortion correction matrix as auxiliary features; and connecting the local detail features, the style feature sub-vectors and the geometric correction features in series to construct the fusion feature vector.
- 8. The font recognition device based on adaptive preprocessing of claim 5, wherein the dynamic weight matching based on the feature contribution evaluation model in the dynamic weight matching module specifically comprises: Determining style labels of the characters to be matched through a global style classifier; invoking a pre-constructed feature contribution evaluation model, and dynamically adjusting the weight of each dimension feature according to the style label; Weighting the fusion feature vector according to the adjusted weight to obtain a weighted feature vector; and calculating the similarity between the characters to be matched and the candidate fonts, wherein the similarity is calculated by adopting the following formula: Sim=0.6×cos (a, B) +0.4× (1-Euclid (a, B)/max_distance), where Sim is similarity, a is a text weighted feature vector to be matched, B is a candidate font feature vector, cos (a, B) is cosine similarity, euclid (a, B) is euclidean Distance, max_distance is a preset maximum euclidean Distance threshold; The dynamic weight matching module further comprises a similar font secondary verification step: If the character to be matched and the candidate fonts belong to the preset highly similar font group in the initial matching result, extracting stroke curvature characteristics of the character to be matched and the candidate fonts and calculating curvature characteristic similarity sim_curvature, and updating the total similarity according to the following formula: Sim_final=0.8×Sim_initial+0.2×Sim_curvature Wherein sim_final is the final similarity, and sim_initial is the initial calculated similarity.
- 9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any one of claims 1 to 4 when the program is executed by the processor.
- 10. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any one of claims 1 to 4.
Description
Font identification method, device, equipment and medium based on self-adaptive preprocessing Technical Field The present invention relates to the field of font identification technologies, and in particular, to a font identification method, apparatus, device, and medium based on adaptive preprocessing. Background In the field of font identification and matching, such as typesetting restoration of a file, font copyright tracing, quality detection of a printing quality and the like, the method has important significance in performing high-precision matching on the fonts. However, the current conventional font matching method has a number of drawbacks. On one hand, the traditional method is mostly dependent on single characteristics (such as stroke weight and font style) for matching, and is difficult to distinguish highly similar fonts (such as Microsoft black and Sitting black bodies, times New Roman and Georgia), the mismatching rate is higher, and the requirement of high-precision matching cannot be met, on the other hand, the robustness of the traditional algorithm to image noise, geometric deformation (such as inclination and perspective distortion) and uneven illumination is poor, and the matching precision is greatly reduced under complex scenes (such as noise interference of scanned documents and character inclination caused by shooting angles). In addition, the traditional algorithm has low processing efficiency, when facing a large number of candidate font libraries, the target fonts cannot be screened out quickly, an effective spam mechanism is lacking, when the confidence of the matching result is low, invalid results are easy to output, and the dual requirements of efficiency and reliability in practical application are difficult to meet. Disclosure of Invention The invention aims to solve the technical problems of single characteristic, weak anti-interference capability, low efficiency, lack of a spam mechanism and the like in the traditional font matching method, and aims to solve the technical problems of the self-adaptive preprocessing-based font identification method, the device, the equipment and the medium, realize accurate noise reduction and geometric correction through the self-adaptive preprocessing, construct omnibearing font characterization by combining multi-dimensional characteristic extraction, improve similarity calculation precision by utilizing dynamic weight matching, match the matching precision and efficiency by matching with an intelligent optimization strategy, simultaneously establish a spam and iterative optimization mechanism to ensure result reliability, finally realize high-precision and high-efficiency matching of different scenes and different types of fonts, and meet the diversified application requirements of document typesetting, copyright tracing, printing detection and the like. In a first aspect, the present invention provides a font identification method based on adaptive preprocessing, including the steps of: Step S1, carrying out self-adaptive preprocessing on an acquired font image, wherein the preprocessing comprises dynamic noise suppression, uneven illumination correction and sub-pixel level geometric correction to obtain a corrected text image; S2, extracting multidimensional features from the corrected text image, and constructing a fusion feature vector containing local detail features, global style features and geometric correction features; And S3, carrying out dynamic weight matching based on the characteristic contribution degree evaluation model, calculating the similarity between the characters to be matched and the candidate fonts, and outputting the identified font types according to the similarity result. In a second aspect, the present invention provides a font recognition device based on adaptive preprocessing, including: The self-adaptive preprocessing module is used for carrying out self-adaptive preprocessing on the acquired font image, wherein the preprocessing comprises dynamic noise suppression, uneven illumination correction and sub-pixel level geometric correction, so as to obtain a corrected text image; The multidimensional feature extraction module is used for carrying out multidimensional feature extraction on the corrected text image and constructing a fusion feature vector containing local detail features, global style features and geometric correction features; And the dynamic weight matching module is used for carrying out dynamic weight matching based on the characteristic contribution degree evaluation model, calculating the similarity between the characters to be matched and the candidate fonts, and outputting the identified font types according to the similarity result. In a third aspect, the invention provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the method of the first aspect when executing the pro