Disclosure of Invention
The application provides a feature extraction method, a system and a device for font classification, which are used for solving the problem that the existing font classification and identification process has fewer feature types and cannot meet the use requirements of different use scenes.
The application provides a feature extraction method for font classification, which comprises the following steps:
Acquiring an image to be detected;
Preprocessing the image to be detected to obtain a preprocessed image;
extracting basic features of the preprocessed image to obtain basic features of the image, wherein the basic features of the image comprise gray level features and aspect ratio features;
extracting advanced features of the preprocessed image to obtain advanced features of the image, wherein the advanced features of the image comprise outer contour features, gradient features, local binary features, scale invariant features and geometric moment features;
a feature space is generated from the image base features and the image high-level features, the feature space including at least one image base feature and at least one image high-level feature.
The image to be detected is preprocessed to obtain a preprocessed image, and the method specifically comprises the following steps:
Carrying out pixel normalization processing on the image to be detected to obtain the image to be detected after the pixel normalization processing;
and carrying out size normalization processing on the image to be detected after pixel normalization processing to obtain a preprocessed image.
Extracting basic features of the preprocessed image to obtain image basic features, wherein the image basic features comprise gray level features and aspect ratio features, and specifically comprise the following steps:
Extracting gray information of each pixel point in the preprocessed image as a feature vector to obtain gray features;
Extracting the ratio of the width to the height of the preprocessed image as a feature vector to obtain aspect ratio features;
And combining the gray scale features and the aspect ratio features to obtain image basic features.
The preprocessing image is subjected to advanced feature extraction to obtain image advanced features, wherein the image advanced features comprise outer contour features, gradient features, local binary features, scale invariant features and geometric moment features, and specifically comprise the following steps:
Obtaining outer contour features according to the preprocessed images;
obtaining gradient characteristics and local binary characteristics according to the preprocessed image;
obtaining scale invariant features and geometric moment features according to the preprocessed images;
And combining the outer contour feature, the gradient feature, the local binary feature, the scale invariant feature and the geometric moment feature to obtain an image advanced feature.
Obtaining outer contour features according to the preprocessed images, wherein the outer contour features specifically comprise the following steps:
acquiring a character area in the preprocessed image;
extracting character outlines in the character areas;
and recording boundary azimuth information from the character outline to the preprocessing image as a feature vector to obtain an outline feature.
Obtaining gradient characteristics and local binary characteristics according to the preprocessed image, and specifically comprising the following steps:
dividing the preprocessed image into image blocks with the same size;
Counting a gradient histogram and a local binary histogram by taking the image block as a unit;
Cascading all gradient histograms as feature vectors to obtain gradient features;
and cascading all local binary histograms to obtain local binary features as feature vectors.
Obtaining gradient characteristics and local binary characteristics according to the preprocessed image, and specifically comprising the following steps:
dividing the preprocessed image into image blocks with the same size;
Counting a local binary histogram by taking the image block as a unit;
Cascading all local binary histograms to obtain local binary features as feature vectors;
and extracting the gradient of each pixel point in the preprocessed image as a feature vector to obtain gradient features.
Obtaining scale invariant features and geometric moment features according to the preprocessed images, wherein the method specifically comprises the following steps:
Performing scale-invariant feature transformation on the preprocessed image, extracting scale-invariant feature points as feature vectors, and obtaining scale-invariant features
And applying the moment of inertia to the preprocessed image as a feature vector to obtain a geometric moment feature.
In a second aspect, the present application provides a feature extraction system for font classification, the system comprising:
an image acquisition module: acquiring an image to be detected;
an image preprocessing module: preprocessing the image to be detected to obtain a preprocessed image;
the basic feature extraction module: extracting basic features of the preprocessed image to obtain basic features of the image, wherein the basic features of the image comprise gray level features and aspect ratio features;
advanced feature extraction module: extracting advanced features of the preprocessed image to obtain advanced features of the image, wherein the advanced features of the image comprise outer contour features, gradient features, local binary features, scale invariant features and geometric moment features;
The feature space generation module: a feature space is generated from the image base features and the image high-level features, the feature space including at least one image base feature and at least one image high-level feature.
In a third aspect, the present application provides a feature extraction apparatus for font classification, the apparatus comprising: at least one processor, memory, and input output unit; the memory is used for storing a computer program, and the processor is used for calling the computer program stored in the memory to execute the method.
As can be seen from the above technical solutions, the present application discloses a feature extraction method, system and device for font classification, where the method includes: the method comprises the steps of obtaining an image to be detected, preprocessing the image to be detected to obtain a preprocessed image, extracting basic features of the preprocessed image to obtain image basic features, wherein the image basic features comprise gray level features and aspect ratio features, extracting the advanced features of the preprocessed image to obtain image advanced features, the image advanced features comprise outer contour features, gradient features, local binary features, scale invariant features and geometric moment features, and generating a feature space according to the image basic features and the image advanced features, wherein the feature space comprises at least one image basic feature and at least one image advanced feature. Through the image basic features and the image advanced features contained in the image set, the use requirements under different use conditions can be met, and the applicability of the feature space in a special scene is improved. The method and the device have the advantages that the characteristics of the preprocessed image are acquired, the characteristic space is generated, and the problems that in the existing font classification and identification process, the types of the characteristics contained in the characteristic space are fewer and the use requirements of different use scenes cannot be met are solved.
Detailed Description
In order to overcome the problems in the prior art, the application provides a feature extraction method, a system and a device for font classification, which are used for solving the problems that in the existing font classification and identification process, the number of feature types contained in a feature space is less and the use requirements of different use scenes cannot be met.
Referring to fig. 1, for an application scenario diagram of a feature extraction method for font classification according to the present application, an image to be detected is normalized to obtain a preprocessed image, the preprocessed image is subjected to primary feature extraction and advanced feature extraction simultaneously to obtain an image base feature and an image advanced feature, the image base feature includes a gray scale feature and an aspect ratio feature, the image advanced feature includes an outer contour feature, a gradient feature, a local binary feature, a scale invariant feature and a geometric moment feature, and a feature space is generated according to the image base feature and the image advanced feature, the feature space includes at least one image base feature and at least one image advanced feature. The use requirements under different use scenes are realized through the feature space of the free combination of various features.
In a first aspect, referring to fig. 2, the present application provides a feature extraction method for font classification, the method comprising:
S100: acquiring an image to be detected;
S110: preprocessing the image to be detected to obtain a preprocessed image;
in some embodiments, pixel normalization processing is performed on the image to be detected to obtain a pixel normalized image to be detected, and size normalization processing is performed on the pixel normalized image to be detected to obtain a preprocessed image. It should be noted that, the image to be detected may be a gray level image or a color image, the gray level image is composed of a single pixel matrix, the color image is composed of three matrices, the value of each pixel matrix is an integer between 0 and 255, although the image to be detected can be directly subjected to feature extraction, the feature extraction efficiency is seriously affected when the value of the training data is a larger integer value due to the fact that the feature extraction process is generally performed by using a smaller weight value, and the feature extraction efficiency can be effectively improved by preprocessing the image to be detected.
S120: extracting basic features of the preprocessed image to obtain basic features of the image, wherein the basic features of the image comprise gray level features and aspect ratio features;
s130: extracting advanced features of the preprocessed image to obtain advanced features of the image, wherein the advanced features of the image comprise outer contour features, gradient features, local binary features, scale invariant features and geometric moment features;
In some embodiments, the preprocessing image is subjected to advanced feature extraction to obtain image advanced features, where the image advanced features include outer contour features, gradient features, local binary features, scale invariant features and geometric moment features, and specifically include the following steps: obtaining an outer contour feature according to the preprocessed image, obtaining a gradient feature and a local binary feature according to the preprocessed image, obtaining a scale invariant feature and a geometric moment feature according to the preprocessed image, and combining the outer contour feature, the gradient feature, the local binary feature, the scale invariant feature and the geometric moment feature to obtain an image advanced feature.
S140: a feature space is generated from the image base features and the image high-level features, the feature space including at least one image base feature and at least one image high-level feature.
Through carrying out arbitrary combination to multiple image basic feature and image advanced feature, can satisfy the user demand under the different use scenes, promote the suitability of method, promote user experience.
In some embodiments, referring to fig. 3, the preprocessing the image to be detected to obtain a preprocessed image specifically includes the following steps:
s111, carrying out pixel normalization processing on the image to be detected to obtain the image to be detected after the pixel normalization processing;
s112: and carrying out size normalization processing on the image to be detected after pixel normalization processing to obtain a preprocessed image.
In some embodiments, referring to fig. 4, the extracting basic features of the preprocessed image to obtain basic features of the image, where the basic features of the image include gray scale features and aspect ratio features specifically includes the following steps:
S121: extracting gray information of each pixel point in the preprocessed image as a feature vector to obtain gray features;
s122: extracting the ratio of the width to the height of the preprocessed image as a feature vector to obtain aspect ratio features;
s123: and combining the gray scale features and the aspect ratio features to obtain image basic features.
In some embodiments, referring to fig. 5, the performing advanced feature extraction on the preprocessed image to obtain image advanced features, where the image advanced features include an outer contour feature, a gradient feature, a local binary feature, a scale invariant feature, and a geometric moment feature, and specifically includes the following steps:
S131: obtaining outer contour features according to the preprocessed images;
s132: obtaining gradient characteristics and local binary characteristics according to the preprocessed image;
s133: obtaining scale invariant features and geometric moment features according to the preprocessed images;
S134: and combining the outer contour feature, the gradient feature, the local binary feature, the scale invariant feature and the geometric moment feature to obtain an image advanced feature.
In some embodiments, the method for obtaining the outer contour feature according to the preprocessed image specifically includes the following steps:
acquiring a character area in the preprocessed image;
extracting character outlines in the character areas;
and recording boundary azimuth information from the character outline to the preprocessing image as a feature vector to obtain an outline feature.
In some embodiments, gradient features and local binary features are obtained according to the preprocessed image, and the method specifically comprises the following steps:
dividing the preprocessed image into image blocks with the same size;
Counting a gradient histogram and a local binary histogram by taking the image block as a unit;
Cascading all gradient histograms as feature vectors to obtain gradient features;
and cascading all local binary histograms to obtain local binary features as feature vectors.
In another embodiment, gradient features and local binary features are obtained according to the preprocessed image, and the method specifically comprises the following steps:
dividing the preprocessed image into image blocks with the same size;
Counting a local binary histogram by taking the image block as a unit;
Cascading all local binary histograms to obtain local binary features as feature vectors;
and extracting the gradient of each pixel point in the preprocessed image as a feature vector to obtain gradient features.
The gradient of each pixel point in the preprocessed image is used as a feature vector, so that the processing efficiency can be effectively improved, and the efficiency advantage is more obvious when the sample amount is more.
In some embodiments, the method for obtaining the scale invariant feature and the geometric moment feature according to the preprocessed image specifically comprises the following steps:
Performing scale-invariant feature transformation on the preprocessed image, extracting scale-invariant feature points as feature vectors, and obtaining scale-invariant features
And applying the moment of inertia to the preprocessed image as a feature vector to obtain a geometric moment feature.
In a second aspect, referring to fig. 6, the present application provides a feature extraction system for font classification, the system comprising:
an image acquisition module: acquiring an image to be detected;
an image preprocessing module: preprocessing the image to be detected to obtain a preprocessed image;
the basic feature extraction module: extracting basic features of the preprocessed image to obtain basic features of the image, wherein the basic features of the image comprise gray level features and aspect ratio features;
advanced feature extraction module: extracting advanced features of the preprocessed image to obtain advanced features of the image, wherein the advanced features of the image comprise outer contour features, gradient features, local binary features, scale invariant features and geometric moment features;
The feature space generation module: a feature space is generated from the image base features and the image high-level features, the feature space including at least one image base feature and at least one image high-level feature.
In a third aspect, the present application provides a feature extraction apparatus for font classification, the apparatus comprising: at least one processor, a memory, and an input output unit. The memory is used for storing a computer program, and the processor is used for calling the computer program stored in the memory to execute the method.
As can be seen from the above technical solutions, the present application discloses a feature extraction method, system and device for font classification, where the method includes: the method comprises the steps of obtaining an image to be detected, preprocessing the image to be detected to obtain a preprocessed image, extracting basic features of the preprocessed image to obtain image basic features, wherein the image basic features comprise gray level features and aspect ratio features, extracting the advanced features of the preprocessed image to obtain image advanced features, the image advanced features comprise outer contour features, gradient features, local binary features, scale invariant features and geometric moment features, and generating a feature space according to the image basic features and the image advanced features, wherein the feature space comprises at least one image basic feature and at least one image advanced feature. Through the image basic features and the image advanced features contained in the image set, the use requirements under different use conditions can be met, and the applicability of the feature space in a special scene is improved.
The method and the device have the advantages that the characteristics of the preprocessed image are acquired, the characteristic space is generated, and the problems that in the existing font classification and identification process, the types of the characteristics contained in the characteristic space are fewer and the use requirements of different use scenes cannot be met are solved.
Further, noise robustness of feature space containing various advanced features is greatly improved, as well as geometrical, illumination and scale invariance. Meanwhile, several advanced features can be combined at will according to the actual scene and the user requirement, and the method has stronger adaptability. Finally, the feature extraction method is not only suitable for character samples, but also suitable for general target detection, image classification and semantic segmentation, and has a wider application range.
Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains.
It is to be understood that the application is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof.