An image classification method, device, terminal device and storage medium
By acquiring gradient data and waveform features of images, the problem of low efficiency in image classification in existing technologies is solved, and fast and accurate image classification is achieved.
Patent Information
- Application Number
- CN202110394007.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-13
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2041-04-13
AI Technical Summary
Existing deep learning-based image classification methods require a large number of sample images and are slow to run, resulting in low classification efficiency.
By acquiring gradient data of the image to be classified, the gradient magnitude and direction information of the target region in the frequency domain are determined, gradient direction histogram information is generated, and waveform features are extracted through Gaussian smoothing. The image category is then determined based on the waveform features.
It achieves fast and accurate image classification without requiring a large number of sample images and deep learning; the classification method is simple and efficient.
Smart Images

Figure CN115205571B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image classification, and particularly relates to an image classification method and device, a terminal device and a storage medium. BACKGROUND
[0002] In the prior art, image classification is basically realized based on a deep learning method, but a large number of sample images are required to achieve significant classification effect, and the running speed is slow, which seriously affects the efficiency of image classification.
[0003] Therefore, the prior art still needs to be improved and enhanced. SUMMARY
[0004] The present application aims to solve the problem of low classification efficiency of the prior art method of realizing image classification based on deep learning.
[0005] To solve the above technical problems, the technical scheme adopted by the present application is as follows:
[0006] In a first aspect, the present application provides an image classification method, wherein the method comprises:
[0007] obtaining an image to be classified, and determining gradient data information corresponding to the image to be classified, the gradient data information being used to reflect gradient amplitude information and gradient direction information of a target region in a frequency domain of the image to be classified;
[0008] determining a waveform feature corresponding to the gradient data information according to the gradient data information;
[0009] determining a category corresponding to the image to be classified according to the waveform feature.
[0010] In an implementation mode, the step of obtaining an image to be classified and determining gradient data information corresponding to the image to be classified comprises:
[0011] obtaining a gray-scale image corresponding to the image to be classified, and performing convolution operation on the gray-scale image to obtain gradient amplitude data and gradient direction data of the gray-scale image;
[0012] determining the target region according to the gradient amplitude data and the gradient direction data, the target region being a region in the frequency domain of the gray-scale image where the gradient amplitude data is greater than a preset amplitude;
[0013] According to the target region, gradient direction data of the target region is acquired, and gradient direction histogram information of the target region is generated, and the gradient direction histogram information is taken as the gradient data information.
[0014] In an implementation manner, the determining of the waveform feature according to the gradient data information comprises:
[0015] The gradient direction histogram information is subjected to Gaussian smoothing processing to obtain Gaussian smoothing processed gradient direction histogram information.
[0016] The wave peak in the Gaussian smoothing processed gradient direction histogram information and the wave trough adjacent to the wave peak are acquired to obtain the waveform feature.
[0017] In an implementation manner, the determining of the category corresponding to the image to be classified according to the waveform feature comprises:
[0018] The first waveform feature, the second waveform feature and the third waveform feature in the waveform feature are acquired, and the first waveform feature and the third waveform feature are located on two sides of the second waveform feature.
[0019] The first difference degree between the second waveform feature and the third waveform feature, the second difference degree between the second waveform feature and the first waveform feature, and the third difference degree between the first waveform feature and the third waveform feature are acquired.
[0020] The category corresponding to the image to be classified is determined according to the first difference degree, the second difference degree and the third difference degree.
[0021] In an implementation manner, the acquiring of the first difference degree between the second waveform feature and the third waveform feature, the second difference degree between the second waveform feature and the first waveform feature, and the third difference degree between the first waveform feature and the third waveform feature comprises:
[0022] The first wave peak amplitude, the first left wave trough amplitude and the first right wave trough amplitude corresponding to the first waveform feature are acquired.
[0023] The second wave peak amplitude, the second left wave trough amplitude and the second right wave trough amplitude corresponding to the second waveform feature are acquired.
[0024] The third wave peak amplitude, the third left wave trough amplitude and the third right wave trough amplitude corresponding to the third waveform feature are acquired.
[0025] According to the first peak amplitude, the first left trough amplitude, the first right trough amplitude, the second peak amplitude, the second left trough amplitude, the second right trough amplitude, the third peak amplitude, the third left trough amplitude, and the third right trough amplitude, a first difference degree between the second waveform feature and the third waveform feature, a second difference degree between the second waveform feature and the first waveform feature, and a third difference degree between the first waveform feature and the third waveform feature are obtained.
[0026] In an implementation manner, the determining the category corresponding to the image to be classified according to the first difference degree, the second difference degree, and the third difference degree comprises:
[0027] The first difference degree and the second difference degree are compared with a first preset value respectively.
[0028] If the first difference degree and the second difference degree are both less than the first preset value, symmetry between a left trough and a right trough corresponding to the second waveform feature is determined according to the second peak amplitude, the second left trough amplitude, and the second right trough amplitude.
[0029] If the symmetry meets a preset condition, the category corresponding to the image to be classified is determined according to the third difference degree.
[0030] In an implementation manner, the determining the category corresponding to the image to be classified according to the third difference degree comprises:
[0031] The third difference degree is compared with a second preset value.
[0032] If the third difference degree is less than the second preset value, the category corresponding to the image to be classified is determined according to the first difference degree and the second difference degree.
[0033] In an implementation manner, the determining the category corresponding to the image to be classified according to the third difference degree comprises:
[0034] The third difference degree is compared with a second preset value.
[0035] If the third difference degree is less than the second preset value, the category corresponding to the image to be classified is determined according to the first peak amplitude and the third peak amplitude.
[0036] In an implementation manner, the determining the category corresponding to the image to be classified according to the first difference degree and the second difference degree comprises:
[0037] The first difference degree and the second difference degree are compared with a third preset value respectively.
[0038] If the first difference degree and the second difference degree are both less than the third preset value, it is determined that the category corresponding to the image to be classified is an urban scene image.
[0039] In an implementation manner, the determining the category corresponding to the image to be classified according to the first wave crest amplitude and the third wave crest amplitude comprises:
[0040] determining an absolute value of a difference between the first wave crest amplitude and the third wave crest amplitude according to the first wave crest amplitude and the third wave crest amplitude, and a maximum value between the first wave crest amplitude and the third wave crest amplitude;
[0041] determining a ratio between the absolute value and the maximum value according to the absolute value and the maximum value;
[0042] If the ratio is less than a fourth preset value, it is determined that the category corresponding to the image to be classified is an urban scene image.
[0043] In a second aspect, an embodiment of the present application further provides an image classification device, and the device comprises:
[0044] a gradient information acquisition module, configured to acquire an image to be classified, and determine gradient data information corresponding to the image to be classified, the gradient data information being used to reflect gradient amplitude information and gradient direction information of a target region in a frequency domain of the image to be classified;
[0045] a wave form feature acquisition module, configured to determine wave form features corresponding to the gradient data information according to the gradient histogram information;
[0046] an image category determination module, configured to determine a category corresponding to the image to be classified according to the wave form features.
[0047] In a third aspect, an embodiment of the present application further provides a terminal device, wherein the terminal device comprises a memory, a processor, and an image classification program stored in the memory and executable on the processor, and the processor executes the image classification program to implement steps of the image classification method in any of the above solutions.
[0048] In a fourth aspect, an embodiment of the present application further provides a computer readable storage medium, and the computer readable storage medium stores an image classification program, and the image classification program is executed by a processor to implement steps of the image classification method in any of the above solutions.
[0049] Beneficial effects: compared with the prior art, the present application provides an image classification method, the present application first acquires a to-be-classified image, and determines gradient data information corresponding to the to-be-classified image. In the present application, the gradient data information is used to reflect gradient amplitude information and gradient direction information of a target region in a frequency domain of the to-be-classified image, so that after the gradient data information is obtained, the present application can determine a waveform feature corresponding to the gradient data information according to the gradient data information. Since the waveform feature can reflect the shape of the wave reflected by the gradient amplitude information and the gradient direction information in the gradient data information, and the shapes of the waves corresponding to images of different categories will be different, i.e., the waveform features will be different. Therefore, the present application can determine the category corresponding to the to-be-classified image according to the waveform feature. As can be seen, the present application only needs to classify images in different scenes according to the waveform feature embodied by the gradient data information, without using the deep learning method in the prior art, and without using a large number of sample images, so that the classification method is simple and efficient. BRIEF DESCRIPTION OF DRAWINGS
[0050] Figure 1 The flowchart of the specific implementation of the image classification method provided by the embodiment of the present application is shown.
[0051] Figure 2 The flowchart of acquiring histogram information in the image classification method provided by the embodiment of the present application is shown.
[0052] Figure 3 The flowchart of determining a waveform feature in the image classification method provided by the embodiment of the present application is shown.
[0053] Figure 4 The flowchart of determining an image category in the image classification method provided by the embodiment of the present application is shown.
[0054] Figure 5 The histogram information of the image classification method provided by the embodiment of the present application applied in the classification of natural scene pictures is shown.
[0055] Figure 6 The histogram information of the image classification method provided by the embodiment of the present application applied in the classification of city scene pictures is shown.
[0056] Figure 7 The principle block diagram of the image classification device provided by the embodiment of the present application is shown.
[0057] Figure 8 The internal structure principle block diagram of the terminal device provided by the embodiment of the present application is shown. DETAILED DESCRIPTION
[0058] For the purposes of the present invention, the technical solutions and effects are more clear and explicit, the following will be further described in detail with reference to the drawings and examples. It should be understood that the specific examples described herein are only used to explain the present invention, and are not used to limit the present invention.
[0059] It is found through research that the existing technology is basically based on deep learning method to realize image classification, but a large number of sample images are needed to achieve significant classification effect, and accurate classification effect cannot be achieved without a large number of samples. And using deep learning method to classify images results in slow running speed, which seriously affects the efficiency of image classification. For example, when it is necessary to distinguish and classify urban scene images and natural scene images, a large number of urban scene images and natural scene images are needed in the prior art using deep learning method, and the urban scene images and natural scene images also need to be labeled to build an image classification model. The whole process is complex and time-consuming, which is not conducive to efficient image classification.
[0060] In order to solve the problems of the prior art, the embodiment of the present application provides an image classification method, which can realize fast and accurate image classification without using the deep learning method of the prior art and a large number of sample images. The classification scheme is simple and efficient. In specific implementation, the embodiment first acquires an image to be classified and determines gradient data information corresponding to the image to be classified. In the embodiment, the gradient data information is used to reflect the gradient amplitude information and the gradient direction information of the target region in the frequency domain of the image to be classified. Therefore, after obtaining the gradient data information, the embodiment can determine the waveform feature corresponding to the gradient data information according to the gradient data information. Since the waveform feature can reflect the shape of the waveform reflected by the gradient amplitude information and the gradient direction information in the gradient data information, and the waveform shape corresponding to images of different categories will be different, i.e. the waveform features will be different. Therefore, the embodiment can determine the category corresponding to the image to be classified according to the waveform feature.
[0061] For example, when an A image needs to be classified, the A image is obtained, which is the image to be classified. Then the gradient data information of the A image is obtained. Then, according to the gradient data information, the shape of the waveform reflected by the gradient amplitude information and the gradient direction information in the gradient data information is obtained, that is, the waveform feature is obtained. In a specific application, if the A image is an urban scene image, the waveform feature corresponding to the gradient data information of the A image will be relatively concentrated and symmetrical, and if the A image is a natural scene image, the waveform feature corresponding to the gradient data information of the A image will be relatively dispersed and irregular. Therefore, in this example, the category corresponding to the A image, that is, whether the A image is an urban scene image or a natural scene image, can be determined according to the waveform feature.
[0062] Exemplary method
[0063] The image classification method in this embodiment can be applied to a terminal device, which can be a computer, a mobile phone, a tablet, or the like. In a specific implementation, as shown in Figure 1 The image classification method includes the following steps:
[0064] Step S100, obtaining an image to be classified, and determining gradient data information corresponding to the image to be classified, the gradient data information being used to reflect gradient amplitude information and gradient direction information of a target region in a frequency domain of the image to be classified.
[0065] In this embodiment, the image to be classified is an image that needs to be classified. After the image to be classified is obtained, the gradient data information corresponding to the image to be classified can be obtained according to the image to be classified, and the gradient data information is used to reflect the gradient amplitude information and the gradient direction information of the target region in the frequency domain of the image to be classified. That is, according to the gradient data information, the gradient amplitude and the gradient direction of the image to be classified can be obtained.
[0066] In one implementation manner, as shown in Figure 2 The step S100 specifically includes the following:
[0067] Step S101, obtaining a grayscale image corresponding to the image to be classified, and performing convolution operation on the grayscale image to obtain gradient amplitude data and gradient direction data of the grayscale image;
[0068] Step S102, determining the target region according to the gradient amplitude data and the gradient direction data, the target region being a region in the frequency domain of the grayscale image where the gradient amplitude data is greater than a preset amplitude;
[0069] In step S103, gradient direction data of the target region is obtained according to the target region, and gradient direction histogram information of the target region is generated, and the gradient direction histogram information is taken as the gradient data information.
[0070] In the embodiment, when the image to be classified needs to be classified, the image to be classified obtained is an RGB image. In order to more accurately analyze, the RGB image is converted into a gray image, and the gray image is denoted as I. Then, the gray image I is convolved by using a sobel operator, and the convolution operation is specifically as follows:
[0071]
[0072]
[0073] wherein G x and G y respectively represent a horizontal gradient and a vertical gradient of the gray image, and * represents convolution.
[0074] Then, gradient amplitude data G and gradient direction data θ of the gray image are calculated, and the calculation is specifically as follows:
[0075]
[0076] After the gradient amplitude data G and the gradient direction data θ of the gray image are obtained, the embodiment determines a region in a frequency domain of the gray image in which the gradient amplitude data is greater than a preset amplitude according to the gradient amplitude data G and the gradient direction data θ, and takes the region in which the gradient amplitude data is greater than the preset amplitude as the target region. Specifically, the embodiment calculates a high-frequency mask of the depth image by using the following formula, and the high-frequency mask is a region in which a gradient amplitude of a picture frequency domain corresponds to a picture space domain in the gray image, that is, the target region in the embodiment, and the specific formula is as follows:
[0077]
[0078] wherein M is the high-frequency mask, (i, j) represents a pixel coordinate, G th is a gradient amplitude threshold. In a specific application process, G th is set to 120, that is, a region in which the gradient amplitude is greater than 120 is a high-frequency region, that is, the embodiment takes the high-frequency region in which the gradient amplitude is greater than 120 as the target region in the embodiment.
[0079] Then, the embodiment obtains gradient direction data of the target region according to the target region, and generates gradient direction histogram information of the target region. In the embodiment, the gradient direction histogram information can be generated to more intuitively analyze the gradient amplitude data and the gradient direction data, so that the waveform feature in the gradient direction histogram information is obtained in the subsequent step. Specifically, the embodiment normalizes gradient direction data θ corresponding to the target region to [0, 180], and performs round rounding processing, specifically as follows:
[0080]
[0081] Then, based on the high-frequency mask M, the gradient direction histogram information of the target region is counted, specifically as follows:
[0082] H(θ, M) = [h(θ1, M), h(θ2, M),... h(θ 180 , M)];
[0083]
[0084] Wherein, H(θ, M) is the gradient direction histogram information, h(θ i , M) is the frequency value of angle i, S(θ i , M) is the total number of pixels with angle i in the target region. The gradient direction histogram information obtained by the embodiment is the gradient data information.
[0085] Step S200, determining the waveform feature corresponding to the gradient data information according to the gradient data information.
[0086] After obtaining the gradient data information, i.e., the gradient direction histogram information, the waveform feature in the gradient direction histogram information can be obtained. Since the gradient direction data reflected in the gradient direction histogram information presents a distribution state in the histogram, the waveform feature is in the form of a waveform shape. Since the waveform features reflected in the gradient direction histogram information of different categories of images are different, the waveform feature obtained by the embodiment is beneficial to determining the category of the image to be classified according to the waveform feature in the subsequent step.
[0087] In one implementation mode, as shown in Figure 3 , the step S200 specifically includes the following steps:
[0088] Step S201, performing Gaussian smoothing processing on the gradient direction histogram information to obtain Gaussian smoothing processed gradient direction histogram information;
[0089] Step S202, obtaining a wave peak in the gradient data information after Gaussian smoothing processing and a wave valley adjacent to the left and right of the wave peak to obtain the waveform feature.
[0090] After obtaining the gradient direction histogram information, in order to improve the data analysis accuracy and obtain more accurate gradient direction histogram information, the embodiment needs to perform noise reduction processing on the gradient direction histogram information. In a specific implementation, in order to reduce statistical noise, the embodiment performs Gaussian smoothing processing on the gradient direction histogram information to obtain gradient direction histogram information after Gaussian smoothing processing. In Gaussian smoothing processing, the size of the Gaussian smoothing kernel is k=15, and the variance is σ=25. The specific formula is as follows:
[0091]
[0092] H (θ, M) = H (θ, M) - H (θ, M) g The gradient direction histogram information after Gaussian smoothing processing is obtained, and compared with the gradient direction histogram information without Gaussian smoothing processing, the embodiment can more accurately determine the waveform feature based on the gradient direction histogram information after Gaussian smoothing processing in the subsequent steps. Since the waveform feature reflects the shape of the waveform in the gradient direction histogram information, including the wave peak and the wave valley. In the embodiment, the waveform feature is defined as a wave peak and a wave valley adjacent to the left and right of the wave peak. The shape of the waveform can be directly reflected from the gradient direction histogram information after Gaussian smoothing processing, so the embodiment can quickly and accurately determine the waveform feature. For example, as shown in Figure 5 and Figure 6 , the gradient direction histogram information of the corresponding scene picture is shown, and the wave peak and the wave valley position can be determined from the gradient direction histogram information, so the waveform feature can be determined. Figure 5 and Figure 6 , the gradient direction histogram information of the corresponding scene picture is shown, and the wave peak and the wave valley position can be determined from the gradient direction histogram information, so the waveform feature can be determined.
[0093] Step S300, determining the category corresponding to the image to be classified according to the waveform feature.
[0094] In the embodiment, when the waveform feature is determined, the embodiment can determine the category corresponding to the image to be classified according to the waveform feature. The category in the embodiment is used to judge the scene category corresponding to the image to be classified, for example, whether the image to be classified belongs to the urban scene category or the natural scene category. Because when distinguishing the image to be classified of the urban scene and the natural scene, since the urban scene has many human traces, the waveform feature reflected by the gradient data information, such as the gradient direction histogram information, is more concentrated and symmetrical, which provides the condition for classifying the image to be classified. For example,Figure 5 and Figure 6 as shown in FIG. A in Figure 5 FIG. A is a natural scene image, Figure 5 FIG. B is gradient direction histogram information corresponding to the natural scene image, Figure 6 FIG. A is an urban scene image, Figure 6 FIG. B is gradient direction histogram information corresponding to the urban scene image. As can be seen, the waveform features embodied by the gradient direction histogram information corresponding to the urban scene image are more concentrated and symmetrical.
[0095] In an implementation manner, as shown in FIG. A in Figure 4 the step S300 specifically comprises the following steps:
[0096] Step S301, acquiring a first waveform feature, a second waveform feature and a third waveform feature in the waveform features, the first waveform feature and the third waveform feature being located on two sides of the second waveform feature;
[0097] Step S302, acquiring a first difference degree between the second waveform feature and the third waveform feature, a second difference degree between the second waveform feature and the first waveform feature, and a third difference degree between the first waveform feature and the third waveform feature;
[0098] Step S303, determining a category corresponding to the image to be classified according to the first difference degree, the second difference degree and the third difference degree.
[0099] In implementation, when distinguishing the to-be-classified image between the urban scene and the natural scene, the gradient direction in the gradient direction histogram information is more concentrated and symmetrical because the urban scene has many human traces. Therefore, the embodiment can analyze the waveform features obtained to determine whether the waveform features in the gradient direction histogram information are symmetrical, so as to determine whether the to-be-classified image belongs to the urban scene image or the natural scene image. Specifically, the embodiment first obtains a first waveform feature, a second waveform feature and a third waveform feature from the obtained waveform features. The first waveform feature and the third waveform feature are located on the left and right sides of the second waveform feature, that is, the first waveform feature, the second waveform feature and the third waveform feature are presented from left to right in the gradient direction histogram. Then, the embodiment obtains the difference degrees between the first waveform feature, the second waveform feature and the third waveform feature, that is, the first difference degree between the second waveform feature and the third waveform feature, the second difference degree between the second waveform feature and the first waveform feature, and the third difference degree between the first waveform feature and the third waveform feature. Then, whether the waveform features are concentrated and similar and whether the two adjacent waveform features are symmetrical can be determined by the first difference degree, the second difference degree and the third difference degree, and if they are symmetrical, it can be determined that the to-be-classified image is an urban scene image.
[0100] In an implementation manner, the embodiment determines, by using the gradient direction histogram information, three continuous waveform features (i.e., the first waveform feature, the second waveform feature and the third waveform feature) in the gradient direction histogram information, corresponding to three wave peaks, denoted as W1, W2 and W3. Then,
[0101] The embodiment obtains the first wave peak amplitude corresponding to the first waveform feature the first left wave trough amplitude and the first right wave trough amplitude obtains the second wave peak amplitude corresponding to the second waveform feature the second left wave trough amplitude and the second right wave trough amplitude and obtains the third wave peak amplitude corresponding to the third waveform feature the third left wave trough amplitude and the third right wave trough amplitude The wave peak amplitudes corresponding to the three waveform features are respectively The left wave trough amplitudes of the three waveform features are respectively The right wave trough amplitudes are respectively Therefore, according to the first peak amplitude, the first left trough amplitude, the first right trough amplitude, the second peak amplitude, the second left trough amplitude, the second right trough amplitude, the third peak amplitude, the third left trough amplitude, and the third right trough amplitude, the first difference degree between the second waveform feature and the third waveform feature, the second difference degree between the second waveform feature and the first waveform feature, and the third difference degree between the first waveform feature and the third waveform feature can be obtained.
[0102] Specifically, the difference degree in the embodiment is the divergence between two waveform features. If the divergence between two waveform features is larger, it means that the difference degree between the two waveform features is larger. For example, if the difference degree KL(W1, W3) between the first waveform feature W1 and the third waveform feature W3 is calculated, the mean μ w1 , variance of the first waveform feature W1, and the mean μ w3 , variance of the third waveform feature W3 are respectively counted. Specific formulas are as follows:
[0103]
[0104] Similarly, based on the above formulas, the second difference degree KL(W1, W2) between the first waveform feature W1 and the second waveform feature W2, and the first difference degree KL(W2, W3) between the second waveform feature W2 and the third waveform feature W3 can be calculated.
[0105] After the first difference degree, the second difference degree and the third difference degree are obtained, the embodiment can determine the category of the image to be classified according to the first difference degree, the second difference degree and the third difference degree. Specifically, the embodiment first obtains the first difference degree KL(W2, W3) between the second waveform feature W2 and the third waveform feature W3, and the second difference degree KL(W1, W2) between the second waveform feature W2 and the first waveform feature W1. Then the first difference degree KL(W2, W3) and the second difference degree KL(W1, W2) are compared with the first preset value respectively, if the first difference degree KL(W2, W3) and the second difference degree KL(W1, W2) are both less than the first preset value, such as KL(W2, W3)<12 and KL(W1, W2)<12, then it means that the difference degree between the first waveform feature, the second waveform feature and the third waveform feature is relatively small, that is, the three are similar. Therefore, at this time, the symmetry between the left wave trough and the right wave trough corresponding to the second waveform feature can be determined according to the second wave peak amplitude, the second left wave trough amplitude and the second right wave trough amplitude. In the judgment of the symmetry between the left wave trough and the right wave trough corresponding to the second waveform feature, if the symmetry meets the preset condition, then it can be judged that the left wave trough and the right wave trough corresponding to the second waveform feature are symmetric. The preset condition of the embodiment is:
[0106]
[0107] That is, if the value of is in the range of 0.6 to 1.4, then it means that the left wave trough and the right wave trough corresponding to the second waveform feature are symmetric. In the gradient direction histogram information, the right wave trough of the first waveform feature is the left wave trough of the second waveform, and the left wave trough of the third waveform is the right wave trough of the second waveform. Therefore, when the left wave trough and the right wave trough corresponding to the second waveform feature are symmetric, it means that the first waveform feature and the third waveform feature are symmetrical to the second waveform feature to a certain extent.
[0108] Then, when the symmetry between the left wave trough and the right wave trough corresponding to the second wave feature in the embodiment meets the preset condition, a third difference KL(W1, W3) between the first wave feature W1 and the third wave feature W3 is obtained. Then, according to the third difference, the category corresponding to the image to be classified is determined. Specifically, the third difference KL(W1, W3) is compared with a second preset value in the embodiment. When the third difference KL(W1, W3) is less than the second preset value, the first difference KL(W2, W3) and the second difference KL(W1, W2) are obtained, and then the first difference KL(W2, W3) and the second difference KL(W1, W2) are compared with a third preset value respectively. When the first difference KL(W2, W3) and the second difference KL(W1, W2) are both less than the third preset value, it is determined that the category corresponding to the image to be classified is an urban scene image. That is, when the third difference KL(W1, W3) is less than the second preset value, the first difference KL(W2, W3) and the second difference KL(W1, W2) can be used to determine the category of the image to be classified in the embodiment. In a specific application, the second preset value and the third preset value in the embodiment can be set in multiple ways. For example, the second preset value can be set to 0.1 or 0.25, and the third preset value can be set to 0.2 or 0.1.
[0109] For example, 1) when the third difference KL(W1, W3) is less than 0.1 (i.e., the second preset value is 0.1), the first difference KL(W2, W3) and the second difference KL(W1, W2) are obtained, and it is determined whether KL(W2, W3) and KL(W1, W2) are both less than 0.2 (i.e., the third preset value is 0.2). When KL(W2, W3) is less than 0.2 and KL(W1, W2) is less than 0.2, it is determined that the three consecutive wave features in the gradient direction histogram of the image to be classified are concentrated and symmetrical, and thus the image to be classified is determined to be an urban scene image.
[0110] 2) when the third difference KL(W1, W3) is less than 0.25 (i.e., the second preset value is 0.25), the first difference KL(W2, W3) and the second difference KL(W1, W2) are obtained, and it is determined whether KL(W2, W3) and KL(W1, W2) are both less than 0.1. When KL(W2, W3) is less than 0.1 and KL(W1, W2) is less than 0.1 (i.e., the third preset value is 0.1), it is determined that the three consecutive wave features in the gradient direction histogram of the image to be classified are concentrated and symmetrical, and thus the image to be classified is determined to be an urban scene image.
[0111] In another implementation, when determining the category corresponding to the image to be classified based on the third difference degree, this embodiment can compare the third difference degree KL(W1, W3) with a preset second preset value. If the third difference degree KL(W1, W3) is less than the second preset value, then the first peak amplitude is obtained. and the amplitude of the third peak Then based on the amplitude of the first peak With the amplitude of the third peak Determine the amplitude of the first peak With the amplitude of the third peak The absolute value of the difference between them, and the amplitude of the first peak. With the amplitude of the third peak The maximum value between the absolute value and the maximum value is determined. Finally, the ratio between the absolute value and the maximum value is determined based on the ratio; if the ratio is less than a fourth preset value, the category corresponding to the image to be classified is determined to be an urban scene image.
[0112] In other words, when the third difference KL(W1, W3) is less than the second preset value, this embodiment can also use the first peak amplitude. and the amplitude of the third peak The conditions for classification are used to determine the category of the image to be classified. In specific applications, both the second and fourth preset values in this embodiment can be set in multiple ways, such as 0.3 or 0.15, and the fourth preset value can be set to 0.1 or 0.15.
[0113] For example, 1) when the third difference KL(W1, W3) < 0.3 (i.e. the second preset value is 0.3), then the amplitude of the first peak is obtained. and the amplitude of the third peak Sure Is it less than 0.1 (the fourth preset value is 0.1 at this time)? If This indicates that the three consecutive waveform features in the gradient direction histogram of the image to be classified are concentrated and symmetrical, thus the image to be classified can be determined to be an urban scene image.
[0114] 2) When the third difference KL(W1, W3) < 0.15 (i.e., the second preset value is 0.15), the amplitude of the first peak is obtained. and the amplitude of the third peak Sure Is it less than 0.15 (the fourth preset value is 0.15 at this time)? If This indicates that the three consecutive waveform features in the gradient direction histogram of the image to be classified are concentrated and symmetrical, thus the image to be classified can be determined to be an urban scene image.
[0115] Therefore, this embodiment can determine whether the image to be classified belongs to an urban scene image or a natural scene image by satisfying any of the above conditions when determining the category corresponding to the image to be classified based on the third difference degree, thereby realizing image classification.
[0116] In summary, this embodiment first acquires the image to be classified and determines the gradient data information corresponding to the image. In this embodiment, the gradient data information reflects the gradient magnitude and gradient direction information of the target region in the frequency domain of the image to be classified. Therefore, after obtaining the gradient data information, this embodiment can determine the waveform features corresponding to the gradient data information. Since the waveform features reflect the shape of the waveform reflected by the gradient magnitude and gradient direction information in the gradient data information, and different categories of images will have different waveform shapes, i.e., different waveform features, this invention can determine the category corresponding to the image to be classified based on the waveform features. Therefore, this embodiment only needs to classify images in different scenes based on the waveform features reflected by the gradient data information, without using the deep learning method in the prior art or a large number of sample images; the classification method is simple and efficient.
[0117] Exemplary device
[0118] like Figure 7 As shown in the illustration, this embodiment also provides an image classification device, which includes: a gradient information acquisition module 10, a waveform feature acquisition module 20, and an image category determination module 30. Specifically, the histogram information acquisition module 10 is used to acquire an image to be classified and determine the gradient data information corresponding to the image to be classified. The gradient data information reflects the gradient magnitude and gradient direction information of the target region in the frequency domain of the image to be classified. The waveform feature acquisition module 20 is used to determine the waveform features corresponding to the gradient data information based on the gradient data information. The image category determination module 30 is used to determine the category corresponding to the image to be classified based on the waveform features.
[0119] In one implementation, the gradient information acquisition module 10 includes:
[0120] The grayscale image acquisition unit is used to acquire the grayscale image corresponding to the image to be classified, and to perform a convolution operation on the grayscale image to obtain the gradient magnitude data and gradient direction data of the grayscale image.
[0121] a data acquisition unit configured to determine the target region according to the gradient amplitude data and the gradient direction data, the target region being a region in the frequency domain of the grayscale image where the gradient amplitude data is greater than a preset amplitude;
[0122] a histogram information generation unit configured to acquire gradient direction data of the target region according to the target region, and generate gradient direction histogram information of the target region, and take the gradient direction histogram information as the gradient data information.
[0123] In an implementation manner, the waveform feature acquisition module 20 comprises:
[0124] a smoothing processing unit configured to perform Gaussian smoothing processing on the gradient direction histogram information to obtain Gaussian smoothing processed gradient direction histogram information;
[0125] a waveform feature determination unit configured to acquire a wave crest and wave troughs adjacent to the wave crest on left and right sides in the Gaussian smoothing processed gradient direction histogram information to obtain the waveform feature.
[0126] In an implementation manner, the image category determination module 30 comprises:
[0127] a waveform feature acquisition unit configured to acquire a first waveform feature, a second waveform feature and a third waveform feature in the waveform feature in sequence, the first waveform feature and the third waveform feature being located on left sides of the second waveform feature;
[0128] a difference degree determination unit configured to acquire a first difference degree between the second waveform feature and the third waveform feature, a second difference degree between the second waveform feature and the first waveform feature, and a third difference degree between the first waveform feature and the third waveform feature;
[0129] a category determination unit configured to determine a category corresponding to the image to be classified according to the first difference degree, the second difference degree and the third difference degree.
[0130] Based on the above embodiments, the application further provides a terminal device, a principle block diagram of which can be as shown in Figure 8The terminal device includes a processor, a memory, a network interface, a display screen, and a temperature sensor connected through a system bus. The processor of the terminal device is configured to provide computing and control capabilities. The memory of the terminal device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The network interface of the terminal device is configured to communicate with an external terminal through a network connection. The computer program is executed by the processor to implement an image classification method. The display screen of the terminal device can be a liquid crystal display screen or an electronic ink display screen. The temperature sensor of the terminal device is pre-installed in the terminal device and is configured to detect the operating temperature of the internal device.
[0131] Those skilled in the art can understand that, Figure 8 The principle block diagram shown in the drawings is only a block diagram of part of the structure related to the present application, and does not constitute a limitation on the terminal device to which the present application is applied. The specific terminal device can include more or fewer components than those shown in the drawings, or combine some components, or have a different component arrangement.
[0132] In one embodiment, a terminal device is provided, which includes a memory, a processor, and an image classification program stored in the memory and executable on the processor. When the processor executes the image classification program, the following operation instructions are implemented:
[0133] An image to be classified is obtained, and gradient data information corresponding to the image to be classified is determined. The gradient data information is used to reflect gradient amplitude information and gradient direction information of a target region in a frequency domain of the image to be classified.
[0134] According to the gradient data information, a waveform feature corresponding to the gradient data information is determined.
[0135] According to the waveform feature, a category corresponding to the image to be classified is determined.
[0136] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiments of the methods can be included. Any reference to memory, storage, database or other medium used in the embodiments provided by the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0137] In summary, the present application discloses an image classification method and device, a terminal device and a storage medium. The method comprises: obtaining an image to be classified, and determining gradient data information corresponding to the image to be classified, wherein the gradient data information is used to reflect gradient amplitude information and gradient direction information of a target region in a frequency domain of the image to be classified; determining waveform features corresponding to the gradient data information according to the gradient histogram information; and determining a category corresponding to the image to be classified according to the waveform features. The present application only needs to classify images in different scenes according to the waveform features embodied in the gradient data information, and the classification method is simple and efficient.
[0138] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement to part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. An image classification method, characterized by, The image classification method comprises: acquiring an image to be classified, and determining gradient data information corresponding to the image to be classified, the gradient data information being used to reflect gradient amplitude information and gradient direction information of a target region in a frequency domain of the image to be classified; determining a waveform feature corresponding to the gradient data information according to the gradient data information; determining a category corresponding to the image to be classified according to the waveform feature; the determining of the category corresponding to the image to be classified according to the waveform feature comprises: acquiring a first waveform feature, a second waveform feature and a third waveform feature in the waveform feature, the first waveform feature and the third waveform feature being located on two sides of the second waveform feature; acquiring a first difference degree between the second waveform feature and the third waveform feature, a second difference degree between the second waveform feature and the first waveform feature, and a third difference degree between the first waveform feature and the third waveform feature; determining the category corresponding to the image to be classified according to the first difference degree, the second difference degree and the third difference degree.
2. The image classification method of claim 1, wherein, the acquiring of the image to be classified and the determining of the gradient data information corresponding to the image to be classified comprises: acquiring a gray-scale image corresponding to the image to be classified, and performing convolution operation on the gray-scale image to obtain gradient amplitude data and gradient direction data of the gray-scale image; determining the target region according to the gradient amplitude data and the gradient direction data, the target region being a region in a frequency domain of the gray-scale image in which the gradient amplitude data is greater than a preset amplitude; acquiring gradient direction data of the target region according to the target region, generating gradient direction histogram information of the target region, and taking the gradient direction histogram information as the gradient data information.
3. The image classification method of claim 2, wherein, the determining of the waveform feature corresponding to the gradient data information according to the gradient data information comprises: performing Gaussian smoothing processing on the gradient direction histogram information to obtain Gaussian smoothing processed gradient direction histogram information; acquiring a wave crest and a wave trough adjacent to the wave crest in the Gaussian smoothing processed gradient direction histogram information to obtain the waveform feature.
4. The image classification method of claim 1, wherein, the acquiring of the first difference degree between the second waveform feature and the third waveform feature, the second difference degree between the second waveform feature and the first waveform feature, and the third difference degree between the first waveform feature and the third waveform feature comprises: acquiring a first wave crest amplitude, a first left wave trough amplitude and a first right wave trough amplitude corresponding to the first waveform feature; acquiring a second wave crest amplitude, a second left wave trough amplitude and a second right wave trough amplitude corresponding to the second waveform feature; acquiring a third wave crest amplitude, a third left wave trough amplitude and a third right wave trough amplitude corresponding to the third waveform feature; According to the first peak amplitude, the first left trough amplitude, the first right trough amplitude, the second peak amplitude, the second left trough amplitude, the second right trough amplitude, the third peak amplitude, the third left trough amplitude and the third right trough amplitude, a first difference between the second waveform feature and the third waveform feature, a second difference between the second waveform feature and the first waveform feature, and a third difference between the first waveform feature and the third waveform feature are obtained.
5. The image classification method of claim 4, wherein, The determining of the category corresponding to the image to be classified according to the first difference, the second difference and the third difference comprises: comparing the first difference and the second difference with a first preset value respectively; if the first difference and the second difference are both less than the first preset value, determining the symmetry between the left trough and the right trough corresponding to the second waveform feature according to the second peak amplitude, the second left trough amplitude and the second right trough amplitude; if the symmetry meets a preset condition, determining the category corresponding to the image to be classified according to the third difference.
6. The image classification method of claim 5, wherein, The determining of the category corresponding to the image to be classified according to the third difference comprises: comparing the third difference with a second preset value; if the third difference is less than the second preset value, determining the category corresponding to the image to be classified according to the first difference and the second difference.
7. The image classification method of claim 5, wherein, The determining of the category corresponding to the image to be classified according to the third difference comprises: comparing the third difference with a second preset value; if the third difference is less than the second preset value, determining the category corresponding to the image to be classified according to the first peak amplitude and the third peak amplitude.
8. The image classification method of claim 6, wherein, The determining of the category corresponding to the image to be classified according to the first difference and the second difference comprises: comparing the first difference and the second difference with a third preset value respectively; if the first difference and the second difference are both less than the third preset value, determining the category corresponding to the image to be classified as a city scene image.
9. The image classification method of claim 7, wherein, The determining of the category corresponding to the image to be classified according to the first peak amplitude and the third peak amplitude comprises: determining an absolute value of a difference between the first peak amplitude and the third peak amplitude and a maximum value between the first peak amplitude and the third peak amplitude according to the first peak amplitude and the third peak amplitude; determining a ratio between the absolute value and the maximum value according to the absolute value and the maximum value; if the ratio is less than a fourth preset value, determining the category corresponding to the image to be classified as a city scene image.
10. An image classification apparatus characterized by comprising: The apparatus comprises: a gradient information acquisition module configured to acquire an image to be classified and determine gradient data information corresponding to the image to be classified, the gradient data information being used to reflect gradient amplitude information and gradient direction information of a target region in a frequency domain of the image to be classified; The waveform feature acquisition module is configured to determine a waveform feature corresponding to the gradient data information according to the gradient histogram information. The image category determination module is configured to determine a category corresponding to the image to be classified according to the waveform feature. The image category determination module comprises: The waveform feature acquisition unit is configured to acquire a first waveform feature, a second waveform feature and a third waveform feature in the waveform feature, the first waveform feature and the third waveform feature being located on two sides of the second waveform feature. The difference degree determination unit is configured to acquire a first difference degree between the second waveform feature and the third waveform feature, a second difference degree between the second waveform feature and the first waveform feature, and a third difference degree between the first waveform feature and the third waveform feature. The category determination unit is configured to determine a category corresponding to the image to be classified according to the first difference degree, the second difference degree and the third difference degree.
11. A terminal device, comprising: The terminal device comprises a memory, a processor and an image classification program stored in the memory and executable on the processor, and the processor implements the steps of the image classification method according to any one of claims 1-9 when executing the image classification program.
12. A computer-readable storage medium, characterized in that, The computer readable storage medium stores an image classification program, and the image classification program implements the steps of the image classification method according to any one of claims 1-9 when executed by a processor.
Citation Information
Patent Citations
Indicator diagram identification method and device
CN106529542A