Image recognition method, device, terminal, and storage medium
By obtaining the statistical value of the image on the mobile terminal and judging its distribution form, it solves the problem of difficulty in realizing real-time sky scene recognition on terminals with limited computing power, and achieves efficient and accurate recognition results.
Patent Information
- Application Number
- CN202110172587.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-08
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2041-02-08
AI Technical Summary
The prior art is difficult to realize real-time sky scene recognition on mobile terminals with limited computing power, especially in the context of deep learning, which has a large amount of computing and high power consumption.
By obtaining the statistical value of the image to be recognized in a predetermined color space, the target statistical value belonging to the predetermined statistical range is determined, and based on the distribution shape of the target statistical value, it is judged whether the image contains the target scene. The method includes fitting target line segments, calculating confidence, and determining whether the image contains the target scene.
The amount of calculation is reduced and the recognition speed is improved, making this method suitable for mobile terminals with poor computing power, and at the same time improving the recognition accuracy of the target scene.
Smart Images

Figure CN114943886B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image recognition technology, and in particular to an image recognition method and device, a terminal, and a storage medium. Background Art
[0002] In recent years, in the field of computer vision and pattern recognition, image content recognition is mostly achieved through deep learning, but deep learning requires huge computations to achieve the requirement of real-time recognition of the target scene in the current frame. It is not easy to achieve sky scene recognition through deep learning and apply it to mobile phone products because the computing power of mobile phones is limited and the power consumption is also restricted. Summary of the invention
[0003] The present invention provides an image recognition method and device, a terminal, and a storage medium.
[0004] According to a first aspect of an embodiment of the present disclosure, there is provided an image recognition method, the method comprising:
[0005] Obtaining statistical values of the image to be identified in a predetermined color space;
[0006] Determine, among the statistical values, a target statistical value that is within a predetermined statistical range; wherein the predetermined statistical range represents a value range of the target scene to be identified in the predetermined color space;
[0007] Based on the distribution form of the target statistical value in the predetermined color space, it is determined whether the image to be identified is an image including the target scene.
[0008] In some embodiments, determining whether the image to be identified is an image including the target scene based on the distribution form of the target statistical value in the predetermined color space includes:
[0009] Based on the target statistical value, fit a target line segment; wherein the sum of distances between the target statistical point corresponding to the target statistical value and the target line segment is the smallest;
[0010] Based at least on the target line segment, it is determined whether the image to be recognized is an image including the target scene.
[0011] In some embodiments, the predetermined color space is a three-dimensional space, wherein the first dimension represents the brightness value, the second dimension represents the first color ratio, and the third dimension represents the second color ratio;
[0012] The step of determining whether the image to be recognized is an image including the target scene based at least on the target line segment comprises:
[0013] Determining a first confidence level that the image to be recognized includes the target scene based on a first angle between the target line segment and the brightness axis of the first dimension;
[0014] Determining a second confidence level that the image to be recognized includes the target scene based on a second angle between the target line segment and the color axis of the second dimension or the color axis of the third dimension;
[0015] Determining a third confidence level that the image to be recognized includes the target scene based on an average distance between the target statistical point corresponding to the target statistical value and the target line segment;
[0016] Determining, based on the length of the target line segment, a fourth confidence level that the image to be recognized includes the target scene;
[0017] Determining, according to the number of the target statistical values, a fifth confidence level that the image to be identified includes the target scene;
[0018] Determine whether the image to be identified is an image including the target scene according to any one or any combination of the first confidence level, the second confidence level, the third confidence level, the fourth confidence level, and the fifth confidence level.
[0019] In some embodiments, the method further comprises:
[0020] Determine the starting end and the ending end of the target line segment;
[0021] Determine the first angle according to the angle between the direction of the starting end toward the brightness axis of the first dimension and the direction of the starting end toward the ending end;
[0022] The second angle is determined according to an angle between a direction from the starting end toward the color axis of the second dimension or a direction from the starting end toward the color axis of the third dimension and a direction from the starting end toward the ending end.
[0023] In some embodiments, the target scene includes a sky scene, the first color ratio is a ratio between a blue component and a green component, and the second color ratio is a ratio between a red component and a green component;
[0024] Determining the starting end and the ending end of the target line segment includes:
[0025] If the first color ratios corresponding to the two end points of the target line segment are different, the end with the smaller first color ratio is determined as the starting end, and the end other than the starting end is determined as the ending end;
[0026] or,
[0027] If the first color ratios corresponding to the two end points of the target line segment are the same, the end with the larger second color ratio corresponding to the two end points is determined as the starting end, and the end other than the starting end is determined as the ending end;
[0028] or,
[0029] If the first color ratios corresponding to the two endpoints of the target line segment are the same, and the second color ratios corresponding to the two endpoints are the same, the end with the larger brightness value corresponding to the two endpoints is determined as the starting end, and the end other than the starting end is determined as the ending end.
[0030] In some embodiments, determining whether the image to be identified is an image including the target scene according to any combination of the first confidence level, the second confidence level, the third confidence level, the fourth confidence level, and the fifth confidence level includes:
[0031] Determine a comprehensive confidence level according to a product of any combination of the first confidence level, the second confidence level, the third confidence level, the fourth confidence level, and the fifth confidence level;
[0032] If the comprehensive confidence is greater than a preset confidence threshold, determining that the image to be identified is an image including the target scene;
[0033] If the comprehensive confidence is less than or equal to the preset confidence threshold, it is determined that the image to be identified is an image that does not include the target scene.
[0034] In some embodiments, obtaining the statistical value of the image to be identified in a predetermined color space includes:
[0035] Segmenting the image to be identified into different regional images;
[0036] Obtaining a statistical value of each pixel in the regional image in the predetermined color space;
[0037] The average of the statistical values corresponding to each of the regional images is determined as the statistical value of the image to be identified in the predetermined color space.
[0038] In some embodiments, the method further comprises:
[0039] Obtaining statistical values of a plurality of images including the target scene taken by different devices in the predetermined color space;
[0040] Determine the maximum and minimum values of the statistical value in different dimensions of the predetermined color space;
[0041] The predetermined statistical range is determined based on the maximum value and the minimum value in the different dimensions.
[0042] According to a second aspect of an embodiment of the present disclosure, there is provided an image recognition device, the device comprising:
[0043] A first acquisition module is configured to acquire a statistical value of the image to be identified in a predetermined color space;
[0044] A first determination module is configured to determine, among the statistical values, a target statistical value that falls within a predetermined statistical range; wherein the predetermined statistical range represents a value range of the target scene to be identified in the predetermined color space;
[0045] The second determination module is configured to determine whether the image to be identified is an image including the target scene based on the distribution form of the target statistical value in the predetermined color space.
[0046] In some embodiments, the second determination module is specifically configured to fit a target line segment based on the target statistical value; wherein the sum of distances between the target statistical points corresponding to the target statistical value and the target line segment is the smallest; and based at least on the target line segment, determine whether the image to be identified is an image including the target scene.
[0047] In some embodiments, the predetermined color space is a three-dimensional space, wherein the first dimension represents the brightness value, the second dimension represents the first color ratio, and the third dimension represents the second color ratio;
[0048] The second determination module is specifically configured to determine a first confidence that the image to be identified includes the target scene based on a first angle between the target line segment and the brightness axis of the first dimension; determine a second confidence that the image to be identified includes the target scene based on a second angle between the target line segment and the color axis of the second dimension or the color axis of the third dimension; determine a third confidence that the image to be identified includes the target scene based on an average distance between the target statistical point corresponding to the target statistical value and the target line segment; determine a fourth confidence that the image to be identified includes the target scene based on the length of the target line segment; determine a fifth confidence that the image to be identified includes the target scene according to the number of the target statistical values; and determine whether the image to be identified is an image including the target scene according to any one or any combination of the first confidence, the second confidence, the third confidence, the fourth confidence, and the fifth confidence.
[0049] In some embodiments, the apparatus further comprises:
[0050] A third determination module is configured to determine the starting end and the ending end of the target line segment;
[0051] a fourth determining module, configured to determine the first angle according to an angle between a direction of the starting end toward the brightness axis of the first dimension and a direction of the starting end toward the ending end;
[0052] The fifth determination module is configured to determine the second angle according to the angle between the direction of the starting end toward the color axis of the second dimension or the direction of the starting end toward the color axis of the third dimension and the direction of the starting end toward the end end.
[0053] In some embodiments, the target scene includes a sky scene, the first color ratio is a ratio between a blue component and a green component, and the second color ratio is a ratio between a red component and a green component;
[0054] The third determination module is specifically configured to, if the first color ratios corresponding to the two endpoints of the target segment are different, determine the end with the smaller first color ratio as the starting end, and determine the end other than the starting end as the ending end; or, if the first color ratios corresponding to the two endpoints of the target segment are the same, determine the end with the larger second color ratio corresponding to the two endpoints as the starting end, and determine the end other than the starting end as the ending end; or, if the first color ratios corresponding to the two endpoints of the target segment are the same, and the second color ratios corresponding to the two endpoints are the same, determine the end with the larger brightness value corresponding to the two endpoints as the starting end, and determine the end other than the starting end as the ending end.
[0055] In some embodiments, the second determination module is specifically configured to determine a comprehensive confidence based on the product of any combination of the first confidence, the second confidence, the third confidence, the fourth confidence, and the fifth confidence; if the comprehensive confidence is greater than a preset confidence threshold, determine that the image to be identified is an image including the target scene; if the comprehensive confidence is less than or equal to the preset confidence threshold, determine that the image to be identified is an image that does not include the target scene.
[0056] In some embodiments, the first acquisition module is specifically configured to divide the image to be identified into different regional images; obtain the statistical value of each pixel in the regional image in the predetermined color space; and determine the mean of the statistical values corresponding to each of the regional images as the statistical value of the image to be identified in the predetermined color space.
[0057] In some embodiments, the apparatus further comprises:
[0058] A second acquisition module is configured to acquire statistical values of a plurality of images including the target scene taken by different devices in the predetermined color space;
[0059] A sixth determination module, configured to determine the maximum and minimum values of the statistical value in different dimensions of the predetermined color space;
[0060] The seventh determination module is configured to determine the predetermined statistical range based on the maximum value and the minimum value in the different dimensions.
[0061] According to a third aspect of an embodiment of the present disclosure, a terminal is provided, including:
[0062] processor;
[0063] a memory for storing processor-executable instructions;
[0064] Wherein, the processor is configured to execute the image recognition method as described in the first aspect above.
[0065] According to a fourth aspect of an embodiment of the present disclosure, there is provided a storage medium, including:
[0066] When the instructions in the storage medium are executed by the processor of the terminal, the terminal is enabled to execute the image recognition method as described in the first aspect above.
[0067] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:
[0068] In an embodiment of the present disclosure, after obtaining the statistical value of the image to be identified in a predetermined color space, the target statistical value belonging to the predetermined statistical range is first determined, and then whether the image to be identified is an image including the target scene is determined based on the distribution form of the target statistical value. Since the predetermined statistical range represents the value range of the target scene to be identified in the predetermined color space, the present disclosure obtains the target statistical value based on the predetermined statistical range, which is equivalent to filtering the statistical value in advance. Compared with the method of identifying the target scene by calculating the pixel by pixel of the image to be identified, on the one hand, the number of pixels involved in scene identification is reduced, thereby effectively reducing the amount of calculation and improving the recognition speed, so that the present solution can also be applied to mobile terminals with poor computing power; on the other hand, the target statistical value is already a filtered value belonging to the target scene, and the present disclosure further determines whether the image to be identified is an image including the target scene based on the distribution form of the target statistical value, that is, a secondary confirmation is performed, thereby improving the accuracy of target scene identification.
[0069] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0071] Figure 1 It is a flow chart of an image recognition method shown in an embodiment of the present disclosure.
[0072] Figure 2 An example diagram of a three-dimensional structure formed for a predetermined statistical range.
[0073] Figure 3 This is an example diagram of a sky scene image in an embodiment of the present disclosure.
[0074] Figure 4 It is a distribution diagram of the statistical values of each pixel of the sky scene image in a predetermined color space.
[0075] Figure 5 This is an example diagram of target statistical points and target line segments corresponding to the sky scene image.
[0076] Figure 6 This is an example diagram of a first angle in an embodiment of the present disclosure.
[0077] Figure 7 This is an example diagram of a second angle in an embodiment of the present disclosure.
[0078] Figure 8 The flowchart is a method for determining the starting end and the ending end of a target line segment in an embodiment of the present disclosure.
[0079] Fig. 9 This is an example flowchart of an image recognition method in an embodiment of the present disclosure.
[0080] Fig.10 The figure shows an image recognition device according to an exemplary embodiment.
[0081] Fig.11 It is a block diagram of a terminal device according to an exemplary embodiment. DETAILED DESCRIPTION
[0082] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0083] Figure 1 is a flow chart of an image recognition method shown in an embodiment of the present disclosure, such as Figure 1 As shown, the image recognition method applied in the terminal includes the following steps:
[0084] S11, obtaining statistical values of the image to be identified in a predetermined color space;
[0085] S12, determining a target statistical value in the statistical value that is within a predetermined statistical range; wherein the predetermined statistical range represents a value range of the target scene to be identified in the predetermined color space;
[0086] S13: Determine whether the image to be identified is an image including the target scene based on the distribution form of the target statistical value in the predetermined color space.
[0087] In the embodiments of the present disclosure, the terminal device includes: a mobile device and a fixed device; the mobile device includes: a mobile phone, a tablet computer or a wearable device, etc. The fixed device includes but is not limited to a personal computer (PC).
[0088] The terminal may include an image acquisition module, such as a front camera or a rear camera in a mobile phone, which can perform image acquisition. The terminal can perform image recognition on the acquired images. Of course, the terminal may also not include an image acquisition module, but perform image recognition on the received images.
[0089] In step S11, the terminal may obtain the statistical value of the image to be identified in a predetermined color space. The image to be identified may be a general JPEG image or a bitmap image, or a RAW image that has not been processed. The pixel value of each pixel of the image to be identified is characterized by three color components: red (R), green (G), and blue (B). In the present disclosure, the predetermined color space is a color space other than the RGB color space, for example, the predetermined color space may be a YUV space, a YCbCr space, or a custom color space. For example, the custom color space is YRgBg, which is defined as follows:
[0090] Y=0.299*R+0.587*G+0.114*B
[0091] Rg=1024*R / G (1)
[0092] Bg=1024*B / G
[0093] Among them, Y represents brightness, which is defined in the same way as Y in the YUV space; Rg represents the ratio of the red component (R) to the green component (G) of a pixel; Bg represents the ratio of the blue component (B) to the green component (G) of a pixel, and the value range of R, G and B is between 0 and 255.
[0094] In step S12, after obtaining the statistical values of the image to be identified in the predetermined color space, the target statistical values in the statistical values that fall within the predetermined statistical range can be determined. The predetermined statistical range represents the value range of the target scene to be identified in the predetermined color space.
[0095] For example, if the target scene to be identified is a sky scene, the predetermined statistical range may be a value range in a predetermined color space determined based on sky scene images taken at different times and / or locations. It should be noted that the target scene in the present disclosure is not limited to a sky scene, but may also be a green grass scene, a snow scene, etc.
[0096] In addition, due to the different photosensitive characteristics of different lens photosensitive components, the lens module may also have different ways of converting light signals into electrical signals and electrical signals into digital signals, so the color sensing characteristics of the generated digital images are also different. In this regard, in order to reduce the differences in equipment characteristics, it is also possible to consider collecting a large number of sky scene images for different types of equipment and determine the value range in the predetermined color space.
[0097] In step S13, after determining the target statistical value that belongs to the predetermined statistical range, it can be determined whether the image to be identified is an image including the target scene according to the distribution form of the target statistical value in the predetermined color space.
[0098] It should be noted that the distribution form of the target statistical value in the predetermined color space may be, for example, the number of target statistical points corresponding to the target statistical value, the distribution position and distribution shape of the target statistical points in the predetermined color space, and the like.
[0099] In the related art, when recognizing an image, for example, recognizing a sky scene in an image, the degree of color gradient change between each pixel and the adjacent pixels on the image is usually used to determine whether the sky is included, that is, each pixel on the image must be calculated. It is understandable that the amount of calculation in this way is very large, and therefore it cannot be applied to mobile terminals with limited computing power such as mobile phones. Mobile terminals are also unable to perform targeted image enhancement based on the recognized scene to provide users with a better user experience.
[0100] In contrast, after obtaining the statistical value of the image to be identified in the predetermined color space, the present disclosure first determines the target statistical value belonging to the predetermined statistical range, and then determines whether the image to be identified is an image including the target scene based on the distribution form of the target statistical value. Since the predetermined statistical range represents the value range of the target scene to be identified in the predetermined color space, the present disclosure obtains the target statistical value based on the predetermined statistical range, which is equivalent to filtering the statistical value in advance. Compared with the method of identifying the target scene by calculating the pixel by pixel of the image to be identified, on the one hand, it reduces the number of pixels involved in scene identification, thereby effectively reducing the amount of calculation and improving the recognition speed, so that the present solution can also be applied to mobile terminals with poor computing power; on the other hand, the target statistical value is already a filtered value belonging to the target scene, and the present disclosure further determines whether the image to be identified is an image including the target scene based on the distribution form of the target statistical value, that is, performs a secondary confirmation, thereby improving the accuracy of target scene identification.
[0101] In one embodiment, step S11 includes:
[0102] Segmenting the image to be identified into different regional images;
[0103] Obtaining a statistical value of each pixel in the regional image in the predetermined color space;
[0104] The average of the statistical values corresponding to each of the regional images is determined as the statistical value of the image to be identified in the predetermined color space.
[0105] In this embodiment, the image to be identified can be segmented into different regional images, for example, by performing simple segmentation based on a threshold segmentation method, or by evenly dividing the image into m*n regional images. After segmenting the image, the statistical value of each pixel in the regional image in the predetermined color space is counted, and the mean of the statistical value corresponding to the regional image is used as the statistical value of the image to be identified in the predetermined color space. Alternatively, before converting to the predetermined color space, the mean of each color component corresponding to the regional image is obtained, and then the mean of each color component is converted to the predetermined color space based on the above formula (1) to obtain the statistical value.
[0106] It can be understood that since the pixel values of adjacent pixels in a local area of an image are very likely to be the same, the present invention segments the image in advance to obtain a regional image, and takes the mean of the statistical values of each pixel in the regional image as the statistical value of the regional image. Therefore, the number of statistical values can be reduced as a whole without losing too much image pixel information, and the number of subsequent target statistical values can be further reduced, which has the effect of reducing the amount of calculation and improving the recognition speed.
[0107] In one embodiment, the method further comprises:
[0108] Obtaining statistical values of a plurality of images including the target scene taken by different devices in the predetermined color space;
[0109] Determine the maximum and minimum values of the statistical value in different dimensions of the predetermined color space;
[0110] The predetermined statistical range is determined based on the maximum value and the minimum value in the different dimensions.
[0111] In this embodiment, the terminal determines the statistical values of these images in a predetermined color space based on multiple images including the target scene taken by different devices, and further determines the maximum and minimum values of the statistical values in different dimensions of the predetermined color space. For example, the statistical values corresponding to each pixel point of each image in the YRgBg color space are counted, and the maximum value (Y_high) and minimum value (Y_low) on the Y axis, the maximum value (Rg_high) and minimum value (Rg_low) on the Rg axis, and the maximum value (Bg_high) and minimum value (Bg_low) on the Bg axis are determined from the statistical values of all pixels of all images. Based on the maximum and minimum values in different dimensions, the predetermined statistical range can be determined.
[0112] Figure 2 An example of a three-dimensional structure formed for a predetermined statistical range, such as Figure 2 As shown, the rectangular area determined by the above six parameters Y_high, Y_low, Rg_high, Rg_low, Bg_high and Bg_low is the area formed by the predetermined statistical range, for example, the blue sky statistical area in the sky scene.
[0113] It can be understood that, in this embodiment, the predetermined statistical range is determined based on the maximum and minimum values of multiple images including the target scene taken by different devices in different dimensions of the predetermined color space, so that the predetermined statistical range can cover images including the target scene taken in more situations, thereby improving the accuracy of the present disclosure in determining the target statistical value based on the predetermined statistical range, and determining whether the image to be identified is an image including the target scene based on the target statistical value.
[0114] In one embodiment, determining whether the image to be identified is an image including the target scene based on the distribution form of the target statistical value in the predetermined color space includes:
[0115] Based on the target statistical value, fit a target line segment; wherein the sum of distances between the target statistical point corresponding to the target statistical value and the target line segment is the smallest;
[0116] Based at least on the target line segment, it is determined whether the image to be recognized is an image including the target scene.
[0117] In this embodiment, the distribution form of the target statistical value can be characterized by a fitted target line segment. When fitting the target line segment based on the target statistical value, the main characteristic components (main statistical values) of the target statistical value can be extracted based on principal component analysis (PCA), and the target line segment is fitted based on the extracted main characteristic components, and the target line segment minimizes the sum of the distances between the target statistical points corresponding to the target statistical value and the target line segment.
[0118] The sum of the distances between the target statistical point corresponding to the target statistical value and the target line segment is the smallest, that is, the aggregation degree between the target line segment and the other target statistical points is the highest, so the target line segment can approximately represent the distribution form of all target statistical points to a certain extent. The present disclosure can determine whether the image to be identified is an image including the target scene based at least on the target line segment.
[0119] It can be understood that the present disclosure can further reduce the amount of calculation and improve the recognition speed by fitting the target line segments and recognizing the scene at least based on the target line segments instead of calculating all the target statistical values point by point.
[0120] Figure 3 is an example diagram of a sky scene image in an embodiment of the present disclosure, Figure 4 is the statistical value distribution diagram of each pixel of the sky scene image in the predetermined color space, Figure 5 This is an example diagram of target statistical points and target line segments corresponding to the sky scene image. Figure 4 As shown, Figure 3 In the corresponding sky scene image, the distribution range of each pixel in the predetermined color space is relatively wide, and the elliptical area marked by L corresponds to Figure 4 The distribution of target statistical points in the comparison Figure 4 and Figure 5 It can be seen that Figure 5 The target statistic in is Figure 4 Part of the statistical value, Figure 5 The line segment A in is the target line segment.
[0121] In one embodiment, the predetermined color space is a three-dimensional space, wherein the first dimension represents the brightness value, the second dimension represents the first color ratio, and the third dimension represents the second color ratio;
[0122] The step of determining whether the image to be recognized is an image including the target scene based at least on the target line segment comprises:
[0123] Determining a first confidence level that the image to be recognized includes the target scene based on a first angle between the target line segment and the brightness axis of the first dimension;
[0124] Determining a second confidence level that the image to be recognized includes the target scene based on a second angle between the target line segment and the color axis of the second dimension or the color axis of the third dimension;
[0125] Determining a third confidence level that the image to be recognized includes the target scene based on an average distance between the target statistical point corresponding to the target statistical value and the target line segment;
[0126] Determining, based on the length of the target line segment, a fourth confidence level that the image to be recognized includes the target scene;
[0127] Determining, according to the number of the target statistical values, a fifth confidence level that the image to be identified includes the target scene;
[0128] Determine whether the image to be identified is an image including the target scene according to any one or any combination of the first confidence level, the second confidence level, the third confidence level, the fourth confidence level, and the fifth confidence level.
[0129] In an embodiment of the present disclosure, the first dimension of the predetermined color space is brightness, and the second dimension and the third dimension are both color ratios. For example, the predetermined color space is a YRgBg color space.
[0130] In this embodiment, when determining whether the image to be recognized is an image including a target scene based at least on the target line segment, not only the target line segment but also the number of target pixels is considered.
[0131] The first angle between the target line segment and the brightness axis of the first dimension reflects the contrast of pixels in the local area of the image to be identified that is preliminarily determined to belong to the target scene value range. Contrast is also part of the scene feature, so the present disclosure determines the first confidence level based on the contrast value of the pixel point on the target line segment.
[0132] The second angle between the target line segment and the color axis of the second dimension or the color axis of the third dimension reflects the color relationship of each component of the pixel point on the target line segment. The color relationship is also part of the scene feature, so the present disclosure determines the second confidence level based on the color relationship of each component of the pixel point.
[0133] The average distance between the target statistical point and the target line segment corresponding to the target statistical value reflects the degree of aggregation of all target statistical points. The degree of aggregation of pixel points is also part of the scene feature, so the present disclosure determines the third confidence level according to the average distance between the target statistical point and the target line segment corresponding to the target statistical value.
[0134] The length of the target line segment reflects the span of the target statistical points on the target line segment within the predetermined statistical range. Since the predetermined statistical range may be determined based on multiple images including the target scene taken by different devices, the predetermined statistical range is a wider range covering the target scene obtained based on statistics of a large number of images. Therefore, when identifying a single image, that is, the image to be identified in the present disclosure, the span of the target statistical points on the target line segment within the predetermined statistical range will not be too large, that is, the length of the target line segment will not be too long. If the length of the target line segment is too short, it means that the main features in the local area preliminarily determined to belong to the target scene value range in the image to be identified are not obvious and may not be consistent with the target scene. Therefore, the present disclosure can determine the fourth confidence level based on the length of the target line segment.
[0135] The number of target statistical values reflects the number of pixels in the image to be identified that belong to the predetermined statistical range. If the number of pixels is too small, it means that the image to be identified is less likely to include the target scene. Therefore, the present disclosure can determine the fifth confidence level according to the number of target statistical values.
[0136] Taking the determination of the first confidence level as an example for illustration, the present disclosure may adopt the following method when determining the first confidence level that the image to be identified includes the target scene based on the first angle between the target line segment and the brightness axis of the first dimension:
[0137] Based on a first angle between the target line segment and the brightness axis of the first dimension, searching for a confidence level corresponding to the first angle in a preset first corresponding relationship;
[0138] The confidence level corresponding to the first angle is determined as a first confidence level that the image to be recognized includes the target scene.
[0139] The preset first correspondence relationship may be established based on a large number of sample images, analyzing the angle between the target line segment of the sample image and the brightness axis of the first dimension, and then combining the label of the sample image, wherein the label of the sample image identifies the probability that the sample image includes the target scene.
[0140] It should be noted that in the embodiments of the present disclosure, the second confidence level corresponding to the second angle can also be searched in the preset second correspondence based on the second angle; the third confidence level corresponding to the average distance can be searched in the preset third correspondence based on the average distance between the target statistical point and the target line segment corresponding to the target statistical value; the fourth confidence level corresponding to the distance can be searched in the preset fourth correspondence based on the length of the target line segment; and the fifth confidence level can be searched in the preset fifth correspondence based on the number of target statistical values. The establishment of the preset second correspondence, the preset third correspondence, the preset fourth correspondence, and the preset fifth correspondence can refer to the preset first correspondence, and will not be described in detail in the present disclosure.
[0141] After determining the first confidence level, the second confidence level, the third confidence level, the fourth confidence level, and the fifth confidence level, it can be determined whether the image to be identified is an image including the target scene. The present disclosure can determine whether the image to be identified is an image including the target scene according to any one or more of the above five confidence levels. For example, it is determined whether the image to be identified is an image including the target scene according to the first confidence level (or any other confidence level), or the present disclosure can determine whether the image to be identified is an image including the target scene according to the mean, maximum value, minimum value, etc. of the five confidence levels.
[0142] In one embodiment, determining whether the image to be identified is an image including the target scene according to any combination of the first confidence level, the second confidence level, the third confidence level, the fourth confidence level, and the fifth confidence level includes:
[0143] Determine a comprehensive confidence level according to a product of any combination of the first confidence level, the second confidence level, the third confidence level, the fourth confidence level, and the fifth confidence level;
[0144] If the comprehensive confidence is greater than a preset confidence threshold, determining that the image to be identified is an image including the target scene;
[0145] If the comprehensive confidence is less than or equal to the preset confidence threshold, it is determined that the image to be identified is an image that does not include the target scene.
[0146] In this embodiment, when determining whether the image to be identified is an image including the target scene according to any combination of confidences, a comprehensive confidence can be obtained according to the product of each confidence in the combination, and then the comprehensive confidence is compared with a preset confidence threshold. If the comprehensive confidence is greater than the preset confidence threshold, the image to be identified is determined to be an image including the target scene; and if the comprehensive confidence is less than the preset confidence threshold, the image to be identified is determined to be an image not including the target scene. The arbitrary combination can be a combination of any two confidences, any three confidences, any four confidences, or 5 confidences among the above 5 confidences.
[0147] For example, assuming that the values of the above five confidence levels range from 0 to 100, the calculation of the comprehensive confidence level is shown in the following formula (2):
[0148] Comprehensive confidence = (first confidence * second confidence * third confidence * fourth confidence * fifth confidence) / (100 * 4) (2)
[0149] Among them, the value range of the comprehensive confidence is also 0 to 100, and the larger the value, the greater the possibility of including the target scene.
[0150] In this embodiment, the comprehensive confidence is determined according to the product of each confidence. The comprehensive confidence after the product takes into account the size of each confidence. If one of the confidences has a smaller value, the value of the comprehensive confidence after the product may be smaller. Then, as long as one of the confidences is smaller, the possibility that the image to be identified includes the target scene is also smaller, that is, the size of any confidence may affect the comprehensive confidence. It can be understood that the present disclosure obtains the comprehensive confidence by multiplication, and then determines whether the image to be identified is an image including the target scene according to the size of the comprehensive confidence, which can improve the accuracy of scene recognition.
[0151] In one embodiment, the method further comprises:
[0152] Determine the starting end and the ending end of the target line segment;
[0153] Determine the first angle according to the angle between the direction of the starting end toward the brightness axis of the first dimension and the direction of the starting end toward the ending end;
[0154] The second angle is determined according to an angle between a direction from the starting end toward the color axis of the second dimension or a direction from the starting end toward the color axis of the third dimension and a direction from the starting end toward the ending end.
[0155] In an embodiment of the present disclosure, the present disclosure needs to further determine the starting end and the ending end of the target line segment. Because different definitions of the starting end and the ending end of the target line segment result in different angle definitions between the target line segment and each axis, the present disclosure can determine the starting end and the ending end of the target line segment in advance, and then determine the first angle and the second angle.
[0156] Specifically, the present disclosure determines the angle between the direction of the brightness axis of the starting end toward the first dimension and the direction of the starting end toward the ending end as the first angle; and determines the angle between the direction of the color axis of the starting end toward the second dimension or the direction of the color axis of the starting end toward the third dimension and the direction of the starting end toward the ending end as the second angle. Figure 6 is an example diagram of a first angle in an embodiment of the present disclosure, such as Figure 6 As shown, θy is the first angle. Figure 7 is an example diagram of a second angle in an embodiment of the present disclosure, such as Figure 7 As shown, θbg is the second angle, Figure 7 The second angle shown is the angle between the target line segment and one of the color axes.
[0157] In one embodiment, the target scene includes a sky scene, the first color ratio is a ratio between a blue component and a green component, and the second color ratio is a ratio between a red component and a green component;
[0158] Determining the starting end and the ending end of the target line segment includes:
[0159] If the first color ratios corresponding to the two end points of the target line segment are different, the end with the smaller first color ratio is determined as the starting end, and the end other than the starting end is determined as the ending end;
[0160] or,
[0161] If the first color ratios corresponding to the two end points of the target line segment are the same, the end with the larger second color ratio corresponding to the two end points is determined as the starting end, and the end other than the starting end is determined as the ending end;
[0162] or,
[0163] If the first color ratios corresponding to the two endpoints of the target line segment are the same, and the second color ratios corresponding to the two endpoints are the same, the end with the larger brightness value corresponding to the two endpoints is determined as the starting end, and the end other than the starting end is determined as the ending end.
[0164] In this embodiment, the target scene is a sky scene. Since the sky is more blue in the sky scene, the blue component of the pixel in the image including the sky area will be relatively large, while the value of the red component will be relatively small. Therefore, if the predetermined color space is the YRgBg color space, the value of Bg in the above formula (1) may be greater than the value of Rg.
[0165] Figure 8 FIG. 1 is a flow chart of a method for determining the starting end and the ending end of a target line segment in an embodiment of the present disclosure. Figure 8As shown, in step S101, determine whether the first color ratios (Bg) of the two ends (the first end and the second end) of the target line segment are the same; if they are not the same, execute step S102, if they are the same, execute step S105. In step S102, compare whether the first color ratio of the first end is greater than the first color ratio of the second end, if not, execute step S103, determine the first end as the starting end, and the second end as the end end; if so, execute step S104, determine the second end as the starting end, and the first end as the end end. When the first color ratios of the two ends are the same, in step S105, further compare whether the second color ratios (Rg) of the two ends are the same; if they are not the same, execute step S106, if they are the same, execute step S109. In step S106, compare whether the second color ratio of the first end is less than the second color ratio of the second end. If not, execute step S107 to determine the first end as the starting end and the second end as the ending end; if so, execute step S108 to determine the second end as the starting end and the first end as the ending end. When the second color ratios of the two ends are also the same, in step S109, further compare whether the brightness values of the two ends are the same; if they are the same, execute step 110 to determine the first end as the starting end and the second end as the ending end; if they are different, continue to execute step S111. In S111, compare whether the brightness value of the first end is less than the brightness value of the second end. If not, execute step S112 to determine the first end as the starting end and the second end as the ending end; if so, execute step S113 to determine the second end as the starting end and the first end as the ending end.
[0166] like Figure 6 As shown, in the sky scene, since the contrast of the sky scene is within a certain range, if the first angle θy is close to 0 degrees or 180 degrees, it means that the contrast of the area that may belong to the target scene in the image to be identified is too small or too large, and the probability of the sky scene appearing is very low. Therefore, when the first angle θy is close to 0 degrees or 180 degrees, a smaller first confidence level can be assigned. For example, a smaller first confidence level is determined based on the first angle and the preset first corresponding relationship.
[0167] like Figure 7As shown, θbg represents the angle between the target line segment and the Bg axis, and the value range of θbg is 90 degrees to -90 degrees. In the sky scene, since the B component value of the sky scene is the largest, the R component value is the smallest, and the G component value is between B and R, when θbg is close to 0 degrees, it means that the values of the R component and the G component are close, and the probability of the sky scene appearing at this time is very low. If θbg is close to 90 degrees or -90 degrees, it means that the values of the B component and the G component are very close, and the probability of the sky scene appearing at this time is also very low. Therefore, the present disclosure can assign a smaller second confidence when the second angle θbg is close to 0 degrees, 90 degrees or -90 degrees. For example, a smaller second confidence is determined based on the second angle and the preset second correspondence.
[0168] It can be understood that the method disclosed in the present invention of determining the confidence level according to the first angle, the second angle, the average distance, the length of the line segment and the number of target statistical points has the effect of low computational complexity and simplicity.
[0169] In addition, it should be noted that the present disclosure is not limited to determining the comprehensive confidence by the first to fifth confidences, and the comprehensive confidence may also be determined according to any several of the five confidences.
[0170] Fig. 9 FIG. 1 is an example flow chart of an image recognition method in an embodiment of the present disclosure. Fig. 9 As shown, the image recognition method applied in the terminal includes the following steps:
[0171] S201, dividing the input image into m*n small blocks and calculating the statistical value of each small block.
[0172] In this embodiment, the input image is divided into small blocks, that is, the image to be recognized is divided into different regional images, and the statistical value of each small block is calculated, which can be understood as calculating the mean of the statistical values corresponding to each regional image.
[0173] S202: The statistical value is converted from RGB to a color space of two-dimensional color and one-dimensional brightness.
[0174] In this embodiment, the image to be recognized is converted into a predetermined color space, for example, the predetermined color space YRgBg.
[0175] S203. Determine the blue sky statistical area.
[0176] In this embodiment, the blue sky statistical area is a three-dimensional structure area formed in a predetermined color space after the blue sky scene is determined in advance based on a large number of blue sky images within a predetermined color space value range (ie, the predetermined statistical range of the present disclosure).
[0177] S204, fitting blue sky statistical points to obtain blue sky fitting line segments.
[0178] In this embodiment, the blue sky statistical point and the target statistical point corresponding to the target statistical value are fitted with a blue sky fitting line segment, which is the target line segment.
[0179] S205, specify the starting end and the ending end of the blue sky fitting line segment.
[0180] In this embodiment, specifying the starting end and the ending end of the blue sky fitting line segment determines the starting end and the ending end of the target line segment.
[0181] S206: Calculate the confidence levels of five sky scenes.
[0182] In this embodiment, the five sky scene confidences are a first confidence determined according to the first angle, a second confidence determined according to the second angle, a third confidence determined according to the average distance, a fourth confidence determined according to the length of the target line segment, and a fifth confidence determined according to the number of target statistical values.
[0183] S207: Calculate the final sky scene confidence, and determine whether the input image includes a sky scene according to the final sky scene confidence.
[0184] In this embodiment, the final sky scene confidence is the comprehensive confidence.
[0185] In this embodiment, the m*n statistical value after image segmentation of the input image is obtained, and then the blue sky statistical points (the statistical points corresponding to the target statistical value) are counted in the predetermined color space and the blue sky fitting line segment (the target line segment) is fitted, and the five sky scene confidences are determined according to the target line segment and the target statistical value, and then the final sky scene confidence is calculated to determine whether the input image is an image including the target scene. On the one hand, the number of pixels involved in scene recognition is reduced, thereby effectively reducing the amount of calculation and improving the recognition speed, so that this solution can also be applied to mobile terminals with poor computing power; on the other hand, the target statistical value is already a filtered value belonging to the target scene, and the present disclosure further determines whether the image to be identified is an image including the target scene according to the target line segment and the target statistical value, that is, a secondary confirmation is performed, thereby improving the accuracy of target scene recognition.
[0186] Fig.10 FIG. 1 is a diagram showing an image recognition device according to an exemplary embodiment. Fig.10 , the image recognition device comprises:
[0187] A first acquisition module 301 is configured to acquire a statistical value of an image to be identified in a predetermined color space;
[0188] The first determination module 302 is configured to determine, among the statistical values, a target statistical value that falls within a predetermined statistical range; wherein the predetermined statistical range represents a value range of the target scene to be identified in the predetermined color space;
[0189] The second determination module 303 is configured to determine whether the image to be identified is an image including the target scene based on the distribution form of the target statistical value in the predetermined color space.
[0190] In some embodiments, the second determination module 303 is specifically configured to fit a target line segment based on the target statistical value; wherein the sum of distances between the target statistical points corresponding to the target statistical value and the target line segment is the smallest; and determine whether the image to be identified is an image including the target scene based at least on the target line segment.
[0191] In some embodiments, the predetermined color space is a three-dimensional space, wherein the first dimension represents the brightness value, the second dimension represents the first color ratio, and the third dimension represents the second color ratio;
[0192] The second determination module 303 is specifically configured to determine a first confidence that the image to be identified includes the target scene based on a first angle between the target line segment and the brightness axis of the first dimension; determine a second confidence that the image to be identified includes the target scene based on a second angle between the target line segment and the color axis of the second dimension or the color axis of the third dimension; determine a third confidence that the image to be identified includes the target scene based on an average distance between the target statistical point corresponding to the target statistical value and the target line segment; determine a fourth confidence that the image to be identified includes the target scene based on the length of the target line segment; determine a fifth confidence that the image to be identified includes the target scene according to the number of the target statistical values; and determine whether the image to be identified is an image including the target scene according to any one or any combination of the first confidence, the second confidence, the third confidence, the fourth confidence, and the fifth confidence.
[0193] In some embodiments, the apparatus further comprises:
[0194] A third determination module 304 is configured to determine the starting end and the ending end of the target line segment;
[0195] A fourth determining module 305 is configured to determine the first angle according to an angle between a direction of the starting end toward the brightness axis of the first dimension and a direction of the starting end toward the ending end;
[0196] The fifth determination module 306 is configured to determine the second angle according to the angle between the direction of the starting end toward the color axis of the second dimension or the direction of the starting end toward the color axis of the third dimension and the direction of the starting end toward the end end.
[0197] In some embodiments, the target scene includes a sky scene, the first color ratio is a ratio between a blue component and a green component, and the second color ratio is a ratio between a red component and a green component;
[0198] The third determination module 304 is specifically configured as follows: if the first color ratios corresponding to the two endpoints of the target segment are different, the end with the smaller first color ratio is determined as the starting end, and the end other than the starting end is determined as the ending end; or, if the first color ratios corresponding to the two endpoints of the target segment are the same, the end with the larger second color ratio corresponding to the two endpoints is determined as the starting end, and the end other than the starting end is determined as the ending end; or, if the first color ratios corresponding to the two endpoints of the target segment are the same, and the second color ratios corresponding to the two endpoints are the same, the end with the larger brightness value corresponding to the two endpoints is determined as the starting end, and the end other than the starting end is determined as the ending end.
[0199] In some embodiments, the second determination module 303 is specifically configured to determine a comprehensive confidence based on the product of any combination of the first confidence, the second confidence, the third confidence, the fourth confidence, and the fifth confidence; if the comprehensive confidence is greater than a preset confidence threshold, determine that the image to be identified is an image including the target scene; if the comprehensive confidence is less than or equal to the preset confidence threshold, determine that the image to be identified is an image that does not include the target scene.
[0200] In some embodiments, the first acquisition module 301 is specifically configured to divide the image to be identified into different regional images; obtain the statistical value of each pixel point in the regional image in the predetermined color space; and determine the mean of the statistical values corresponding to each of the regional images as the statistical value of the image to be identified in the predetermined color space.
[0201] In some embodiments, the apparatus further comprises:
[0202] A second acquisition module 307 is configured to acquire statistical values of a plurality of images including the target scene taken by different devices in the predetermined color space;
[0203] A sixth determination module 308, configured to determine the maximum and minimum values of the statistical value in different dimensions of the predetermined color space;
[0204] The seventh determination module 309 is configured to determine the predetermined statistical range based on the maximum value and the minimum value in the different dimensions.
[0205] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0206] Fig.11 8 is a block diagram of a terminal device 800 according to an exemplary embodiment. For example, the device 800 may be a mobile phone, a camera, etc.
[0207] Reference Fig.11 , the device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .
[0208] The processing component 802 generally controls the overall operation of the device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0209] The memory 804 is configured to store various types of data to support operations on the device 800. Examples of such data include instructions for any application or method operating on the device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0210] The power supply component 806 provides power to the various components of the device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 800.
[0211] The multimedia component 808 includes a screen that provides an output interface between the device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0212] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the device 800 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.
[0213] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0214] The sensor assembly 814 includes one or more sensors for providing various aspects of the status assessment of the device 800. For example, the sensor assembly 814 can detect the open / closed state of the device 800, the relative positioning of components, such as the display and keypad of the device 800, and the sensor assembly 814 can also detect the position change of the device 800 or a component of the device 800, the presence or absence of user contact with the device 800, the orientation or acceleration / deceleration of the device 800, and the temperature change of the device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0215] The communication component 816 is configured to facilitate wired or wireless communication between the device 800 and other devices. The device 800 can access a wireless network based on a communication standard, such as Wi-Fi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0216] In an exemplary embodiment, the apparatus 800 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above methods.
[0217] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by the processor 820 of the device 800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0218] A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a processor of a terminal, enables the terminal to perform an image recognition method, the method comprising:
[0219] Obtaining statistical values of the image to be identified in a predetermined color space;
[0220] Determine, among the statistical values, a target statistical value that is within a predetermined statistical range; wherein the predetermined statistical range represents a value range of the target scene to be identified in the predetermined color space;
[0221] Based on the distribution form of the target statistical value in the predetermined color space, it is determined whether the image to be identified is an image including the target scene.
[0222] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0223] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. An image recognition method, characterized in that: The method comprises: Obtaining statistical values of the image to be identified in a predetermined color space; Determine, among the statistical values, a target statistical value that is within a predetermined statistical range; wherein the predetermined statistical range represents a value range of the target scene to be identified in the predetermined color space; Determining whether the image to be identified is an image including the target scene based on the distribution form of the target statistical value in the predetermined color space; Wherein, determining whether the image to be identified is an image including the target scene based on the distribution form of the target statistical value in the predetermined color space includes: Based on the target statistical value, fit a target line segment; wherein the sum of distances between the target statistical point corresponding to the target statistical value and the target line segment is the smallest; Based at least on the target line segment, it is determined whether the image to be recognized is an image including the target scene.
2. The method according to claim 1, characterized in that The predetermined color space is a three-dimensional space, wherein the first dimension represents the brightness value, the second dimension represents the first color ratio, and the third dimension represents the second color ratio; The step of determining whether the image to be recognized is an image including the target scene based at least on the target line segment comprises: Determining a first confidence level that the image to be recognized includes the target scene based on a first angle between the target line segment and the brightness axis of the first dimension; Determining a second confidence level that the image to be recognized includes the target scene based on a second angle between the target line segment and the color axis of the second dimension or the color axis of the third dimension; Determining a third confidence level that the image to be recognized includes the target scene based on an average distance between the target statistical point corresponding to the target statistical value and the target line segment; Determining, based on the length of the target line segment, a fourth confidence level that the image to be recognized includes the target scene; Determining, according to the number of the target statistical values, a fifth confidence level that the image to be identified includes the target scene; Determine whether the image to be identified is an image including the target scene according to any one or any combination of the first confidence level, the second confidence level, the third confidence level, the fourth confidence level, and the fifth confidence level.
3. The method according to claim 2, characterized in that The method further comprises: Determine the starting end and the ending end of the target line segment; Determine the first angle according to the angle between the direction of the starting end toward the brightness axis of the first dimension and the direction of the starting end toward the ending end; The second angle is determined according to an angle between a direction from the starting end toward the color axis of the second dimension or a direction from the starting end toward the color axis of the third dimension and a direction from the starting end toward the ending end.
4. The method according to claim 3, characterized in that The target scene includes a sky scene, the first color ratio is a ratio between a blue component and a green component, and the second color ratio is a ratio between a red component and a green component; Determining the starting end and the ending end of the target line segment includes: If the first color ratios corresponding to the two end points of the target line segment are different, the end with the smaller first color ratio is determined as the starting end, and the end other than the starting end is determined as the ending end; or, If the first color ratios corresponding to the two end points of the target line segment are the same, the end with the larger second color ratio corresponding to the two end points is determined as the starting end, and the end other than the starting end is determined as the ending end; or, If the first color ratios corresponding to the two endpoints of the target line segment are the same, and the second color ratios corresponding to the two endpoints are the same, the end with the larger brightness value corresponding to the two endpoints is determined as the starting end, and the end other than the starting end is determined as the ending end.
5. The method according to claim 2, characterized in that: The determining whether the image to be identified is an image including the target scene according to any combination of the first confidence level, the second confidence level, the third confidence level, the fourth confidence level, and the fifth confidence level comprises: Determine a comprehensive confidence level according to a product of any combination of the first confidence level, the second confidence level, the third confidence level, the fourth confidence level, and the fifth confidence level; If the comprehensive confidence is greater than a preset confidence threshold, determining that the image to be identified is an image including the target scene; If the comprehensive confidence is less than or equal to the preset confidence threshold, it is determined that the image to be identified is an image that does not include the target scene.
6. The method according to claim 1, characterized in that The step of obtaining the statistical value of the image to be identified in a predetermined color space includes: Segmenting the image to be identified into different regional images; Obtaining a statistical value of each pixel in the regional image in the predetermined color space; The average of the statistical values corresponding to each of the regional images is determined as the statistical value of the image to be identified in the predetermined color space.
7. The method according to claim 1, characterized in that The method further comprises: Obtaining statistical values of a plurality of images including the target scene taken by different devices in the predetermined color space; Determine the maximum and minimum values of the statistical value in different dimensions of the predetermined color space; The predetermined statistical range is determined based on the maximum value and the minimum value in the different dimensions.
8. An image recognition device, characterized in that: The device comprises: A first acquisition module is configured to acquire a statistical value of the image to be identified in a predetermined color space; A first determination module is configured to determine, among the statistical values, a target statistical value that falls within a predetermined statistical range; wherein the predetermined statistical range represents a value range of the target scene to be identified in the predetermined color space; The second determination module is configured to fit a target line segment based on the target statistical value; wherein the sum of distances between the target statistical points corresponding to the target statistical value and the target line segment is the smallest; and determine whether the image to be identified is an image including the target scene based at least on the target line segment.
9. The device according to claim 8, characterized in that The predetermined color space is a three-dimensional space, wherein the first dimension represents the brightness value, the second dimension represents the first color ratio, and the third dimension represents the second color ratio; The second determination module is specifically configured to determine a first confidence that the image to be identified includes the target scene based on a first angle between the target line segment and the brightness axis of the first dimension; determine a second confidence that the image to be identified includes the target scene based on a second angle between the target line segment and the color axis of the second dimension or the color axis of the third dimension; determine a third confidence that the image to be identified includes the target scene based on an average distance between the target statistical point corresponding to the target statistical value and the target line segment; determine a fourth confidence that the image to be identified includes the target scene based on the length of the target line segment; determine a fifth confidence that the image to be identified includes the target scene according to the number of the target statistical values; and determine whether the image to be identified is an image including the target scene according to any one or any combination of the first confidence, the second confidence, the third confidence, the fourth confidence, and the fifth confidence.
10. The device according to claim 9, characterized in that The device also includes: A third determination module is configured to determine the starting end and the ending end of the target line segment; a fourth determining module, configured to determine the first angle according to an angle between a direction of the starting end toward the brightness axis of the first dimension and a direction of the starting end toward the ending end; The fifth determination module is configured to determine the second angle according to the angle between the direction of the starting end toward the color axis of the second dimension or the direction of the starting end toward the color axis of the third dimension and the direction of the starting end toward the end end.
11. The device according to claim 10, characterized in that The target scene includes a sky scene, the first color ratio is a ratio between a blue component and a green component, and the second color ratio is a ratio between a red component and a green component; The third determination module is specifically configured to, if the first color ratios corresponding to the two endpoints of the target segment are different, determine the end with the smaller first color ratio as the starting end, and determine the end other than the starting end as the ending end; or, if the first color ratios corresponding to the two endpoints of the target segment are the same, determine the end with the larger second color ratio corresponding to the two endpoints as the starting end, and determine the end other than the starting end as the ending end; or, if the first color ratios corresponding to the two endpoints of the target segment are the same, and the second color ratios corresponding to the two endpoints are the same, determine the end with the larger brightness value corresponding to the two endpoints as the starting end, and determine the end other than the starting end as the ending end.
12. The device according to claim 11, characterized in that The second determination module is specifically configured to determine a comprehensive confidence level according to a product of any combination of the first confidence level, the second confidence level, the third confidence level, the fourth confidence level, and the fifth confidence level; If the comprehensive confidence is greater than a preset confidence threshold, determining that the image to be identified is an image including the target scene; If the comprehensive confidence is less than or equal to the preset confidence threshold, it is determined that the image to be identified is an image that does not include the target scene.
13. The device according to claim 8, characterized in that The first acquisition module is specifically configured to divide the image to be identified into different regional images; obtain the statistical value of each pixel point in the regional image in the predetermined color space; and determine the mean of the statistical values corresponding to each of the regional images as the statistical value of the image to be identified in the predetermined color space.
14. The device according to claim 8, characterized in that The device also includes: A second acquisition module is configured to acquire statistical values of a plurality of images including the target scene taken by different devices in the predetermined color space; A sixth determination module, configured to determine the maximum and minimum values of the statistical value in different dimensions of the predetermined color space; The seventh determination module is configured to determine the predetermined statistical range based on the maximum value and the minimum value in the different dimensions.
15. A terminal, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the image recognition method as claimed in any one of claims 1 to 7.
16. A non-transitory computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of a mobile terminal, the mobile terminal is enabled to execute the image recognition method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Image recognition method and device and computer readable storage medium
CN110287787A
Scene detection method and device, terminal equipment and computer readable storage medium
CN111368587A