Method and device for detecting target object in image, electronic equipment and storage medium

By dividing an image into sub-images and calculating their density values, the automatic detection of target objects solves the problem of low efficiency in manual searching and achieves automated target detection.

CN116823867BActive Publication Date: 2026-01-06TSINGHUA UNIVERSITY +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310652429.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-02
Publication Date
2026-01-06
Estimated Expiration
2043-06-02

AI Technical Summary

Technical Problem

In existing technologies, manually searching for target objects in images is inefficient.

Method used

The image is divided into multiple sub-images, the average gray value of each sub-region is calculated, and the density value of the sub-image is calculated based on the preset gray value range and the average gray value. The density value is used to determine whether the target object is present.

Benefits of technology

It eliminates the need for manual target object searching, improving detection efficiency and achieving automated target object detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116823867B_ABST
    Figure CN116823867B_ABST
Patent Text Reader

Abstract

The application discloses a target object detection method and device in an image, electronic equipment and storage medium, and relates to the technical field of image detection. The method comprises the following steps: dividing an image into a plurality of sub-images; each sub-image comprises a plurality of sub-regions; calculating the average value of the gray values of all pixel points in each sub-region to obtain the average gray value of each sub-region; calculating the density value of each sub-image according to a preset gray value interval comprising a plurality of interval segments and all average gray values; the density value of a sub-image reflects the difference degree between the average gray values of each sub-region in the sub-image; in the case that there is a target sub-image with a density value greater than a preset density threshold value in all sub-images, it is determined that the target sub-image contains a target object different from a background region, so as to realize the detection of the target object in the image, without manual detection, improve the work efficiency, and solve the problem of low work efficiency in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of image detection technology, specifically relating to a method, apparatus, electronic device, and storage medium for detecting target objects in an image. Background Technology

[0002] To detect target objects in an image, a method for detecting target objects in an image is needed.

[0003] In the prior art, staff manually search for target objects in an image to detect them.

[0004] In the process of developing this application, the inventors discovered that the prior art has at least the following problems: because in order to detect target objects in images, staff have to manually search for target objects in the images, resulting in low work efficiency. Summary of the Invention

[0005] This application aims to provide a method, apparatus, electronic device, and storage medium for detecting target objects in an image, which at least solves the problem of low work efficiency caused by the need for workers to manually search for target objects in images in order to detect them in the prior art.

[0006] To solve the above-mentioned technical problems, this application is implemented as follows:

[0007] In a first aspect, embodiments of this application provide a method for detecting a target object in an image, the method comprising:

[0008] The image is divided into multiple sub-images; the image includes a background region and a target object; each sub-image includes multiple sub-regions;

[0009] Calculate the average grayscale value of all pixels in each sub-region to obtain the average grayscale value of each sub-region;

[0010] Based on a preset grayscale value range including multiple interval segments and all the average grayscale values, the density value of each sub-image is calculated; the density value of the sub-image reflects the degree of difference between the average grayscale values ​​of each sub-region in the sub-image.

[0011] If, among all the sub-images, there is a target sub-image with a density value greater than a preset density threshold, it is determined that the target sub-image contains the target object that is distinct from the background region.

[0012] Secondly, embodiments of this application also provide a device for detecting target objects in an image, the device comprising:

[0013] A segmentation module is used to divide an image into multiple sub-images; the image includes a background region and a target object; each sub-image includes multiple sub-regions;

[0014] The first calculation module is used to calculate the average gray value of all pixels in each sub-region to obtain the average gray value of each sub-region.

[0015] The second calculation module is used to calculate the density value of each sub-image based on a preset gray value range including multiple interval segments and all the average gray values; the density value of the sub-image reflects the degree of difference between the average gray values ​​of each sub-region in the sub-image.

[0016] The determination module is used to determine that, if there is a target sub-image with a density value greater than a preset density threshold in all the sub-images, the target sub-image contains the target object that is different from the background region.

[0017] Thirdly, embodiments of this application also provide an electronic device, which includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the method described in the first aspect.

[0018] Fourthly, embodiments of this application also provide a readable storage medium storing a program or instructions that, when executed by a processor, implement the steps of the method described in the first aspect.

[0019] In this embodiment, an image is divided into multiple sub-images; the image includes a background region and a target object; each sub-image includes multiple sub-regions; the average gray value of all pixels in each sub-region is calculated to obtain the average gray value of each sub-region; the density value of each sub-image is calculated based on a preset gray value range including multiple interval segments and all the average gray values; the density value of the sub-image reflects the degree of difference between the average gray values ​​of each sub-region in the sub-image; when there is a target sub-image with a density value greater than a preset density threshold in all sub-images, it is determined that the target sub-image contains a target object that is different from the background region, so as to realize the detection of the target object in the image, and there is no need for manual searching of the target object in the image, which improves work efficiency and solves the problem of low work efficiency caused by manual searching of the target object in the image in order to detect the target object in the image in the prior art. Attached Figure Description

[0020] Figure 1 This is a flowchart illustrating the steps of a method for detecting a target object in an image, as provided in an embodiment of this application.

[0021] Figure 2 This is a flowchart illustrating the specific steps of a method for detecting target objects in an image, as provided in an embodiment of this application.

[0022] Figure 3 This is a schematic diagram of a target object detection system in an image and its output image provided in an embodiment of this application;

[0023] Figure 4 This is a schematic diagram of a target object detection process in an image provided in an embodiment of this application;

[0024] Figure 5 This is an image showing the detection result of a target object detection method provided in an embodiment of this application.

[0025] Figure 6 This is a rendering of the detection results of YOLOv7-tiny provided in an embodiment of this application;

[0026] Figure 7 This is a block diagram of a target object detection device in an image provided in an embodiment of this application;

[0027] Figure 8 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0028] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0029] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0030] The method for detecting target objects in images provided in this application will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.

[0031] Figure 1 This is a flowchart illustrating the steps of a method for detecting a target object in an image, as provided in an embodiment of this application. Figure 1 As shown, the method may include:

[0032] Step 101: Divide the image into multiple sub-images.

[0033] The image includes a background region and a target object; each sub-image includes multiple sub-regions.

[0034] It should be noted that the images in the embodiments of this application are Synthetic Aperture Radar (SAR) images, which are typically used for ship inspection in fields such as coastal defense deployment, maritime search and rescue, oil spill detection, and fisheries management.

[0035] Synthetic Aperture Radar (SAR) utilizes the principle of synthetic aperture to achieve high-resolution microwave imaging, possessing multiple characteristics such as all-weather, all-time capability, high resolution, and wide swath.

[0036] Specifically, in some embodiments, the image is a SAR image of a sea surface scene, with the sea surface as the background area and a ship as the target object.

[0037] In the embodiments of this application, dividing the image into multiple sub-images facilitates the separate analysis of each sub-image, thereby determining the sub-image where the target object is located.

[0038] Step 102: Calculate the average gray value of all pixels in each sub-region to obtain the average gray value of each sub-region.

[0039] It should be noted that the grayscale value of a pixel is a normalized grayscale value, that is, the grayscale value of a pixel is the original grayscale value of the pixel divided by 255. For example, if the original grayscale value of a pixel is 199, then the normalized grayscale value of the pixel is 199 / 255, which is 0.78 (rounded to two decimal places).

[0040] In this embodiment of the application, the average gray value of each sub-region is obtained by calculating the average gray value of all pixels in each sub-region, and then the degree of difference between the average gray values ​​of each sub-region can be analyzed.

[0041] For example, if a sub-region contains 100 pixels, namely p1 (grayscale value h1), p2 (grayscale value h2), p3 (grayscale value h3), ..., p100 (grayscale value h100), then the average grayscale value of the sub-region is (h1+h2+h3+...+h100) / 100.

[0042] Step 103: Calculate the density value of each sub-image based on the preset gray value range including multiple interval segments and all the average gray values.

[0043] The density value of the sub-image reflects the degree of difference between the average gray values ​​of each sub-region in the sub-image.

[0044] It should be noted that the higher the density value of a sub-image, the greater the difference in average gray values ​​between the various sub-regions within the sub-image.

[0045] In this embodiment of the application, the density value of each sub-image is calculated based on a preset gray value range including multiple interval segments and all average gray values, so that it can be determined whether each sub-image contains a target object based on the density value of each sub-image.

[0046] Specifically, in some embodiments, the number of intervals (K) can be preset, which is the number of interval segments contained in the grayscale value interval. Then, the grayscale value interval is set according to the number of intervals. The grayscale value interval is grayscale value 0 to grayscale value 1. For example, if the number of intervals is 5, the grayscale value interval includes 5 interval segments, namely grayscale value 0 to grayscale value 0.2, grayscale value 0.2 to grayscale value 0.4, grayscale value 0.4 to grayscale value 0.6, grayscale value 0.6 to grayscale value 0.8, and grayscale value 0.8 to grayscale value 1.0.

[0047] Step 104: If there is a target sub-image with a density value greater than a preset density threshold in all the sub-images, determine that the target sub-image contains the target object that is different from the background region.

[0048] In this embodiment of the application, when there is a target sub-image with a density value greater than a preset density threshold in all sub-images, it is determined that the target sub-image contains a target object that is different from the background area, so as to achieve the purpose of detecting the target object in the image.

[0049] Specifically, in some embodiments, the density threshold can be preset to 0.

[0050] In summary, in this embodiment, an image is divided into multiple sub-images; the image includes a background region and a target object; each sub-image includes multiple sub-regions; the average gray value of all pixels in each sub-region is calculated to obtain the average gray value of each sub-region; the density value of each sub-image is calculated based on a preset gray value range including multiple interval segments and all the average gray values; the density value of the sub-image reflects the degree of difference between the average gray values ​​of each sub-region in the sub-image; when there is a target sub-image with a density value greater than a preset density threshold in all sub-images, it is determined that the target sub-image contains a target object that is different from the background region, so as to realize the detection of the target object in the image, and there is no need for manual searching of the target object in the image, which improves work efficiency and solves the problem of low work efficiency caused by manual searching of the target object in the image in order to detect the target object in the image in the prior art.

[0051] Figure 2 This is a flowchart illustrating the specific steps of a method for detecting target objects in an image, as provided in an embodiment of this application. Figure 2 As shown, the method may include:

[0052] Step 201: Divide the image into multiple sub-images.

[0053] The image includes a background region and a target object; each sub-image includes multiple sub-regions.

[0054] The implementation method of this step is similar to that of step 101 above, and will not be repeated here.

[0055] Optionally, in some embodiments, all the sub-images have the same area; all the sub-regions have the same area.

[0056] In this embodiment, all sub-images have the same area, and all sub-regions have the same area. This facilitates the sorting and numbering of the positions of the sub-images and sub-regions, thereby enabling the determination of the positions of the sub-images and sub-regions.

[0057] Optionally, in some embodiments, step 201 may include the following sub-steps (sub-step 2011, sub-step 2012):

[0058] Sub-step 2011: If the image cannot be divided equally by the sub-image, merge the image with the black image to obtain a merged image.

[0059] The merged image can be divided equally by the sub-images; the black image is an image in which all pixels have a grayscale value of 0.

[0060] In this embodiment of the application, when an image cannot be equally divided into sub-images, the image is merged with a black image to obtain a merged image. This allows the merged image to be equally divided into sub-images, which is beneficial for further processing of the merged image.

[0061] Sub-step 2012: Divide the merged image into multiple sub-images.

[0062] In this embodiment of the application, the merged image is divided into multiple sub-images, and then all sub-images are further analyzed.

[0063] This can be achieved by executing sub-steps 2011 to 2012. By dividing the image into multiple sub-images, it is beneficial to analyze each sub-image separately, thereby determining the sub-image where the target object is located.

[0064] Optionally, in some embodiments, the method further includes:

[0065] Step 205: Multiply the side length of the sub-image by the preset overlap value to obtain the overlap value of the side length of the sub-image.

[0066] Wherein, the overlap degree is the ratio of the area of ​​the overlapping portion of the sub-image with the adjacent sub-image to the area of ​​the sub-image.

[0067] In this embodiment of the application, the overlap value of the sub-image's side length is obtained by multiplying the value of the sub-image's side length by a preset overlap degree, and then the non-overlap value of the sub-image's side length can be calculated based on the overlap value.

[0068] It should be noted that the overlap S is usually set in the range of (0,1), for example, S is preset to 0.5; in other embodiments, the overlap S is 0, that is, there is no overlap between adjacent sub-images.

[0069] Specifically, in some embodiments, the length is represented by the number of rows and the width by the number of columns. The area (size) information of the image is represented as M×N, where M represents the number of rows of the image and N represents the number of columns of the image. The area (size) information of the sub-image is represented as M1×N1, where M1 represents the number of rows of the sub-image and N1 represents the number of columns of the sub-image. The area information of the sub-image is preset, for example, the area information of the sub-image is set to 300×300. The area (size) information of the sub-region is represented as M2×N2, where M2 represents the number of rows of the sub-region and N2 represents the number of columns of the sub-region. The area information of the sub-region is preset, for example, the area information of the sub-region is set to 10×10. The setting conditions that the area information of the sub-image, the area information of the sub-region, and the overlap must meet are: M1×S is an integer, N1×S is an integer, M1×(1-S) / M2 is an integer, and N1×(1-S) / N2 is an integer.

[0070] The side length of a sub-image includes the length and width of the sub-image. The overlap value of the length of the sub-image is M1×S, and the overlap value of the width of the sub-image is N1×S.

[0071] Step 206: Subtract the overlap value from the side length of the sub-image to obtain the non-overlapping side length of the sub-image.

[0072] In this embodiment of the application, the non-overlapping value of the side length of the sub-image is obtained by subtracting the overlap value from the side length of the sub-image, so as to determine whether the image can be divided equally by the sub-images based on the non-overlapping value.

[0073] Specifically, in some embodiments, the non-overlapping value of the length of the sub-image is M1-M1×S, and the non-overlapping value of the width of the sub-image is N1-N1×S. The explanation of the letters is as described above and will not be repeated here.

[0074] Step 207: If the side length of the image cannot be divided evenly by the non-overlapping value, it is determined that the image cannot be equally divided by the sub-image.

[0075] In this embodiment of the application, if the side length of the image cannot be divided evenly by the non-overlapping value, it is determined that the image cannot be divided equally by the sub-images. Therefore, the image can be further processed so that the processed image can be divided equally by the sub-images.

[0076] Specifically, in some embodiments, if the length of the image cannot be divided by a non-overlapping value or the width of the image cannot be divided by a non-overlapping value, it is determined that the image cannot be divided into sub-images. That is, if M / (M1×(1-S)) is not an integer or N / (N1×(1-S)) is not an integer, it is determined that the image cannot be divided into sub-images. The explanation of the letters is as described above and will not be repeated here.

[0077] Step 208: If the side length of the merged image is divisible by the non-overlapping value, determine that the merged image can be equally divided by the sub-images.

[0078] In this embodiment of the application, if the side length of the merged image is divisible by the non-overlapping value, it is determined that the merged image can be equally divided into sub-images, and then the merged image is further processed to detect the target object in the image.

[0079] Specifically, in some embodiments, the length is represented by the number of rows and the width by the number of columns. The side length of the merged image includes the length and width of the merged image. The area (size) information of the merged image is represented as J×L, where J represents the number of rows of the image and L represents the number of columns of the image. If the value of the length of the merged image is divisible by the non-overlapping value and the value of the width of the merged image is divisible by the non-overlapping value, it is determined that the merged image can be divided into sub-images equally. That is, if J / (M1×(1-S)) is an integer and L / (N1×(1-S)) is an integer, it is determined that the merged image can be divided into sub-images equally. The explanation of the letters is as described above and will not be repeated here.

[0080] By executing steps 205 to 208, it can be determined that the image cannot be equally divided by the sub-images, and that the merged image can be equally divided by the sub-images, thereby further processing the merged image to detect the target object in the image.

[0081] Step 202: Calculate the average grayscale value of all pixels in each sub-region to obtain the average grayscale value of each sub-region.

[0082] The implementation method of this step is similar to that of step 102 above, and will not be repeated here.

[0083] Step 203: Calculate the density value of each sub-image based on the preset gray value range including multiple interval segments and all the average gray values.

[0084] The density value of the sub-image reflects the degree of difference between the average gray values ​​of each sub-region in the sub-image.

[0085] The implementation method of this step is similar to that of step 103 above, and will not be repeated here.

[0086] Optionally, in some embodiments, step 203 may include the following sub-steps (sub-step 2031, sub-step 2032):

[0087] Sub-step 2031: Calculate the difference value of each sub-region based on all the interval segments and all the average gray values.

[0088] The difference value of the sub-region reflects the degree of difference between the average gray value of the sub-region and the average gray value of other sub-regions in the sub-image to which the sub-region belongs.

[0089] It should be noted that the larger the difference value of a sub-region, the greater the difference between the average gray value of the sub-region and the average gray value of other sub-regions in the sub-image to which the sub-region belongs.

[0090] In this embodiment of the application, the difference value of each sub-region is calculated based on all interval segments and all average gray values, and then the density value of each sub-image is calculated based on the difference value of each sub-region.

[0091] Optionally, in some embodiments, sub-step 2031 may include the following sub-steps (sub-step 2031a, sub-step 2031b):

[0092] Step 2031a: Based on all the interval segments and all the average gray values, determine the interval average value vector and interval quantity vector corresponding to each sub-image.

[0093] Wherein, the elements of the matrix of the interval average value vector are the average gray values ​​of the sub-image falling into the interval segments, and the elements of the matrix of the interval quantity vector are the number of average gray values ​​of the sub-image falling into the interval segments.

[0094] It should be noted that when the number of average gray values ​​of the segments falling into the interval of the sub-image is 0, the average value of the average gray values ​​of the segments falling into the interval of the sub-image is recorded as a constant, such as 0.

[0095] In this embodiment of the application, by determining the interval average value vector and interval quantity vector corresponding to each sub-image based on all interval segments and all average gray values, the difference value of each sub-region can be determined based on the interval average value vector and interval quantity vector corresponding to each sub-image.

[0096] Specifically, in some embodiments, the average gray values ​​of all sub-regions of a sub-image constitute a sub-image mean array (denoted as T). m,n ), T m,n The element is the average gray value of a sub-region of the sub-image, T. m,n The l-th element is represented as T m,n (l), the interval average vector corresponding to the sub-image is represented as: For a 1×K vector, the number of intervals corresponding to the sub-image is represented as: Let T be a 1×K vector, where m is the x-coordinate index of the sub-image in the image, n is the y-coordinate index of the sub-image in the image, and l represents T. m,n The element index is K, where K is the interval number.

[0097] For example, the T corresponding to the sub-image m,n It includes 4 elements, namely T m,n (1) (value is 0.06), T m,n (2) (value is 0.1), T m,n (3) (value is 0.3), T m,n(4) (value is 0.5), the number of intervals K is 5, that is, the gray value interval includes 5 interval segments, namely Q1 (gray value 0 to gray value 0.2), Q2 (gray value 0.2 to gray value 0.4), Q3 (gray value 0.4 to gray value 0.6), Q4 (gray value 0.6 to gray value 0.8), Q5 (gray value 0.8 to gray value 1.0), then T m,n The element falling into Q1 is T. m,n (1) (value is 0.06), T m,n (2) (value is 0.1), T m,n The average number of gray values ​​falling into Q1 is 2, T m,n The average gray value falling into Q1 is 0.08 (i.e., obtained from (0.06+0.1) / 2); T m,n The element falling into Q2 is T. m,n (3) (value is 0.3), T m,n The average number of gray values ​​falling into Q1 is 1, T m,n The average gray value falling into Q2 is 0.3 (i.e., obtained from 0.3 / 1); T m,n The element falling into Q3 is T. m,n (4) (value is 0.5), T m,n The average number of gray values ​​falling into Q3 is 1, T m,n The average gray value falling into Q3 is 0.5 (i.e., obtained from 0.5 / 1); T m,n The number of elements falling into Q4 is 0, that is, T m,n The number of average gray values ​​falling into Q4 is 0, T m,n The average grayscale value falling into Q4 is 0; T m,n The number of elements falling into Q5 is 0, that is, T m,n The number of average grayscale values ​​falling into Q5 is 0, T m,n The average grayscale value of the element falling into Q5 is 0.

[0098] From the above, the matrix representation of the interval average vector corresponding to the sub-image can be obtained as follows:

[0099]

[0100] The matrix representation of the interval quantity vector corresponding to the sub-image is as follows:

[0101]

[0102] Step 2031b: Calculate the difference value of each sub-region based on the interval average value vector, interval quantity vector, and all the average gray values ​​corresponding to each sub-image.

[0103] In this embodiment of the application, the difference value of each sub-region is calculated based on the interval average value vector, interval quantity vector and all average gray values ​​corresponding to each sub-image, and then the density value of each sub-image is determined based on the difference value of each sub-region.

[0104] This can be achieved by performing steps 2031a to 2031b, which determine the difference value of each sub-region, that is, the degree of difference between the average gray value of the sub-region and the average gray value of other sub-regions in the sub-image to which the sub-region belongs.

[0105] Optionally, in some embodiments, step 2031b may include the following molecular steps (molecular step 2031b-1, molecular step 2031b-2, molecular step 2031b-3):

[0106] Molecular step 2031b-1: Calculate the distance vector of each sub-region based on the average gray value of each sub-region and the interval average value vector of the sub-image to which the sub-region belongs.

[0107] Wherein, the elements of the distance vector matrix are the differences between the average gray value of the sub-region and the values ​​of the elements of the interval average vector corresponding to the sub-image to which the sub-region belongs.

[0108] In this embodiment of the application, the distance vector of each sub-region is calculated based on the average gray value of each sub-region and the interval average value vector of the sub-image to which the sub-region belongs. Thus, the intermediate vector corresponding to the distance vector of each sub-region is obtained through the distance vector of each sub-region.

[0109] Specifically, in some embodiments, the distance vector of the sub-region is represented as Let T be a 1×K vector. The elements of the distance vector matrix are non-negative, representing the absolute difference between the average gray value of the sub-region and the average value of the corresponding sub-image's interval vector. Here, m is the x-coordinate index of the sub-image, n is the y-coordinate index of the sub-image, and l represents T. m,n The element index is K, where K is the interval number.

[0110] For example, the matrix representation of the interval average vector corresponding to the sub-image is:

[0111]

[0112] T m,n The value of the l-th element is 0.5, i.e., T m,n If the average gray value of the sub-region corresponding to the l-th element is 0.5, then the average gray value of the sub-region is compared with... Taking the difference and absolute value, we get 0.42 (from 0.5-0.08), 0.2 (from 0.5-0.3), 0 (from 0.5-0.5), 0.5 (from 0.5-0), and 0.5 (from 0.5-0). Then T... m,n The distance vector of the sub-region corresponding to the l-th element is:

[0113]

[0114] Molecular step 2031b-2: Based on each distance vector, obtain the intermediate vector corresponding to each distance vector.

[0115] In this embodiment of the application, the intermediate vector corresponding to each distance vector is obtained based on each distance vector, thereby serving as the basis for obtaining the difference value of each sub-region.

[0116] Specifically, in some embodiments, the intermediate vector corresponding to the distance vector can be represented as: Where m is the x-coordinate index of the sub-image, n is the y-coordinate index of the sub-image, and l represents T. m,n The element index.

[0117] Optionally, in some embodiments, molecular step 2031b-2 may include the following sub-steps (sub-step 2031b-2a, sub-step 2031b-2b):

[0118] Sub-step 2031b-2a: If the value of an element of the distance vector is greater than a preset difference threshold, the value of an element of the intermediate vector corresponding to the element of the distance vector is determined as the first value.

[0119] In this embodiment, if the value of an element of the distance vector is greater than a preset difference threshold, it is determined that the element of the distance vector is a valid factor for the difference value of the sub-region. The value of the element of the intermediate vector corresponding to the element of the distance vector is determined as the first value, and then the difference value of the sub-region is calculated.

[0120] Specifically, in some embodiments, the difference threshold can be preset to 0.2.

[0121] Sub-step 2031b-2b: If the value of an element of the distance vector is less than or equal to the difference threshold, the value of an element of the intermediate vector corresponding to the element of the distance vector is determined as the second value.

[0122] In this embodiment, if the value of an element of the distance vector is less than or equal to the difference threshold, it indicates that the element of the distance vector is not a valid factor for the difference value of the sub-region. The value of the element of the intermediate vector corresponding to the element of the distance vector is determined as the second value, and then the difference value of the sub-region is calculated.

[0123] Optionally, in some embodiments, the first value is 1 and the second value is 0.

[0124] In this embodiment of the application, the difference value of the sub-region is calculated by setting the first value to 1 and the second value to 0.

[0125] This can be achieved by performing sub-steps 2031b-2a to 2031b-2b, which transform each distance vector into the intermediate vector corresponding to each distance vector, and then calculate the difference value of the sub-region.

[0126] Calculate the distance between sub-steps 2031b-2a and 2031b-2b, for example:

[0127] T m,n The distance vector of the sub-region corresponding to the l-th element is:

[0128]

[0129] The difference threshold is 0.2, because The first element, 0.42, is greater than 0.2. The second element, 0.2, equals 0.2. The third element, 0, is less than 0.2. The fourth element, 0.5, is greater than 0.2. If the fifth element, 0.5, is greater than 0.2, then T m,n The intermediate vector corresponding to the distance vector of the sub-region corresponding to the l-th element is:

[0130]

[0131] Molecular step 2031b-3: Calculate the difference value of each sub-region based on the quantity vector of each interval and each intermediate vector.

[0132] In this embodiment of the application, the difference value of each sub-region is calculated based on the quantity vector of each interval and each intermediate vector, thereby the density value of each sub-image can be calculated based on the difference value of each sub-region.

[0133] Specifically, in some embodiments, T m,n The difference value of the subregion corresponding to the l-th element is represented by ρ. m,n(l), where m is the x-coordinate index of the sub-image, n is the y-coordinate index of the sub-image, and l represents T. m,n The element index. ρ m,n The calculation expression for (l) is:

[0134]

[0135] in, The indicated will The vector obtained after transposing. This is the vector of interval counts corresponding to the sub-images. For T m,n The intermediate vector corresponding to the distance vector of the sub-region corresponding to the l-th element.

[0136] For example, T m,n The intermediate vector corresponding to the distance vector of the sub-region corresponding to the l-th element is:

[0137]

[0138] but for:

[0139]

[0140] T m,n The interval quantity vector corresponding to the sub-image is:

[0141]

[0142] Then T m,n The difference value of the subregion corresponding to the l-th element is:

[0143]

[0144] This can be achieved by performing molecular steps 2031b-1 to 2031b-3, calculating the difference value of each sub-region, and then determining the density value of each sub-image based on the difference values ​​of all sub-regions.

[0145] Sub-step 2032: Calculate the density value of each sub-image based on the difference values ​​of all the sub-regions, the preset weights, and the preset deviation values.

[0146] In this embodiment of the application, the density value of each sub-image is calculated based on the difference value of all sub-regions, a preset weight, and a preset deviation value. Then, based on the density value of each sub-image, it is determined whether the sub-image contains a target object.

[0147] It should be noted that all sub-regions have the same weights, and all sub-images have the same deviation values. The weights and deviation values ​​can be pre-determined through training to determine the optimal weights and deviation values, for example, by using the orthogonal matching pursuit algorithm to solve the weighted sparse optimization problem.

[0148] Specifically, in some embodiments, the difference values ​​of all sub-regions of each sub-image are sorted in order (e.g., in ascending order of l) to form the density vector of each sub-image, T. m,n The density vector of the sub-image is represented as The elements of the matrix are ρ m,n (l), where m is the x-coordinate index of the sub-image, n is the y-coordinate index of the sub-image, and l represents T. m,n The element index. Then, the weights (ω) corresponding to all sub-regions of each sub-image are sorted in order (e.g., in ascending order of l) to form the weight vector of each sub-image, T. m,n The density vector of the sub-image is represented as The elements of the matrix are ω, T m,n Let b be the deviation value of the sub-image to which it belongs, then T m,n The expression for calculating the density value of the sub-image is:

[0149]

[0150] Among them, y m,n For T m,n The density value of the sub-image to which it belongs. for The transpose of .

[0151] For example, T m,n The sub-image comprises four sub-regions, and the difference values ​​of these four sub-regions are ρ. m,n (1) ρ m,n (2), ρ m,n (3) ρ m,n (4), T m,n If the deviation value of the sub-image is b, and the weight of the sub-region is ω, then:

[0152]

[0153] T m,n The density vector of the sub-image is:

[0154]

[0155] but:

[0156]

[0157] and then:

[0158]

[0159] By executing sub-steps 2031 to 2032, the density value of each sub-image can be calculated, and then it can be determined whether each sub-image contains a target object based on the density value of each sub-image.

[0160] Step 204: If there is a target sub-image with a density value greater than a preset density threshold in all the sub-images, determine that the target sub-image contains the target object that is different from the background region.

[0161] The implementation method of this step is similar to that of step 104 above, and will not be repeated here.

[0162] Optionally, in some embodiments, after step 204, the method further includes:

[0163] Step 209: Based on the target sub-image, use a single-stage target detector to obtain the first coordinate parameter of the target object in the target sub-image.

[0164] In this embodiment of the application, by using a single-stage target detector to obtain the first coordinate parameter of the target object in the target sub-image based on the target sub-image, the second coordinate parameter of the target object in the image can be determined based on the first coordinate parameter.

[0165] It should be noted that the single-stage object detection method is used to detect the original target sub-image corresponding to the target sub-image. In this method, the gray values ​​of all pixels in the original target sub-image are not normalized. The target sub-image is the image obtained by normalizing the gray values ​​of all pixels in the original target sub-image. For example, if the gray value of pixel 1 in the original target sub-image is 199, then the gray value of pixel 1 in the target sub-image is 199 / 255, which is 0.78 (rounded to two decimal places). The single-stage object detection method is a method that can achieve object detection by extracting features only once, such as YOLOv7-tiny (a single-stage object detector).

[0166] Specifically, in some embodiments, the number of target sub-images can be multiple, and the number of target objects can be multiple. The first coordinate parameters of the multiple target sub-images can then form a first coordinate parameter set {[x...} m,n (k), y m,n (k), w m,n (k), h m,n (k)]}, where k is the kth first coordinate parameter in the first coordinate parameter set, x m,n(k) represents the x-coordinate of the target object in the target sub-image, y m,n (k) is the ordinate of the target object in the target sub-image, w m,n (k) represents the width of the target object, h m,n (k) represents the height of the target object.

[0167] Step 210: Based on the first coordinate parameter and the position parameter of the target sub-image in the image, obtain the second coordinate parameter of the target object in the image.

[0168] In this embodiment of the application, the second coordinate parameter of the target object in the image is obtained by using the first coordinate parameter and the position parameter of the target sub-image in the image, so as to realize the detection of the target object in the image.

[0169] It should be noted that the position parameter of the target sub-image in the image can include m and n, where m is the horizontal coordinate index of the target sub-image in the image and n is the vertical coordinate index of the target sub-image in the image.

[0170] Specifically, in some embodiments, the number of target sub-images can be multiple, and the number of target objects can be multiple. First, a maximum suppression algorithm is used to filter the first set of coordinate parameters, eliminating detection results where adjacent sub-images overlap (i.e., when a target object is simultaneously in two target sub-images, one target sub-image is eliminated, and the other is retained). That is, based on the first set of coordinate parameters {[x... m,n (k), y m,n (k), w m,n (k), h m,n (k)]}, using the maximum suppression algorithm to obtain the first set of coordinate parameters after filtering:

[0171] {[x m,n (k), y m,n (k), w m,n (k), h m,n (k)] *}

[0172] Then, based on the filtered first set of coordinate parameters, a second set of coordinate parameters consisting of the second coordinate parameters of multiple target sub-images is obtained:

[0173] {[x′ m,n (k), y′ m,n (k), w′ m,n (k), h′ m,n (k)] *}

[0174] Where k is the k-th second coordinate parameter in the set of second coordinate parameters, x′m,n (k) is the x-coordinate of the target object in the image, y′ m,n (k) is the ordinate of the target object in the image, w′ m,n (k) represents the width of the target object, h′ m,n (k) represents the height of the target object.

[0175] And it satisfies: x′ m,n (k)=(1-S)×m×M1+x m,n (k), y′ m,n (k)=(1-S)×n×N1+y m,n (k), w′ m,n (k)=w m,n (k), h′ m,n (k)=h m,n (k), where the explanation of the letters is as described above and will not be repeated here.

[0176] Finally, based on each second coordinate parameter in the second coordinate parameter set, the location of each target object is marked in the image.

[0177] By executing steps 209 to 210, the second coordinate parameter of the target object in the image can be obtained, and the position of the target object in the image can be obtained based on the second coordinate parameter.

[0178] Optionally, refer to Figure 3 In some embodiments, the image target object detection system corresponding to the aforementioned image target object detection method includes: (1) a pre-screening module for determining that the target sub-image contains a target object that is different from the background area; (2) a target detector module for obtaining the first coordinate parameter of the target object in the target sub-image; and (3) a post-processing module for obtaining the second coordinate parameter of the target object in the image. Figure 3 In the input image, there are two target objects (i.e., elliptical objects). The pre-screening module outputs two target sub-images containing the target objects (i.e., two elliptical images in the diagram). The target detector module outputs two target sub-images containing the first coordinate parameter. The post-processing module outputs an image containing the second coordinate parameter (the positions of the two target objects in the image can be marked according to the second coordinate parameter).

[0179] Optionally, refer to Figure 4In some embodiments, the target object detection process corresponding to the aforementioned image target object detection method includes: X1, inputting an image and preset parameters, including overlap S, area information M1×N1 of sub-images, area information M2×N2 of sub-regions, number of intervals K, difference threshold, density threshold, weight ω, deviation value b, etc.; X2, filling the image and dividing the filled image into multiple sub-images, where filling the image means merging the image with a black image when the image cannot be equally divided into sub-images to obtain a merged image, and the filled image is the merged image; X3, determining the interval average value vector and region value corresponding to each sub-image based on all interval segments and all average gray values. X4. Calculate the difference value of each sub-region based on the interval average vector, interval quantity vector, and all average gray values ​​corresponding to each sub-image; X5. Calculate the density value of each sub-image based on the difference values ​​of all sub-regions, the preset weight, and the preset deviation value; X6. Determine whether the density value of each sub-image is greater than the preset density threshold; X7. If the density value of the sub-image is not greater than the preset density threshold, discard the sub-image, i.e., do not perform further processing on the sub-image; X8. If the density value of the sub-image is greater than the preset density threshold, determine the sub-image as the target sub-image, and put the first coordinate parameter of the sub-image into the first coordinate parameter set.

[0180] Optionally, in some embodiments, the target object detection method in the image of this application is used to detect ships (including ships 61, 62, 63, and 64) in the image 50 of the sea scene (image resolution 11615x11781). The time to obtain the detection result (i.e., the coordinate parameters of the ships in the image of the sea scene) is 60.1 seconds. The image in which the positions of the ships are marked in the image of the sea scene based on the detection result is shown below. Figure 5 As shown, region 51 of image 50 depicting the sea surface is magnified to obtain magnified image 60. The positions of ships 61, 62, 63, and 64 are marked in magnified image 60. YOLOv7-tiny is used to detect the ships (including ships 61, 62, 63, and 64) in image 50 (image resolution 11615x11781). The time to obtain the detection results (i.e., the coordinate parameters of the ships in the image of the sea surface) is 551.1 seconds. The image showing the ship positions marked in the image of the sea surface based on the detection results is shown below. Figure 6As shown, region 51 of image 50 of the sea scene is magnified to obtain magnified image 60. The positions of ships 61, 62, 63, and 64 are marked in magnified image 60. It can be seen that the detection effect of the target object detection method in the image of this application embodiment is consistent with the detection effect of YOLOv7-tiny. Compared with YOLOv7-tiny, the detection time of the target object detection method in the image of this application embodiment is shorter.

[0181] In summary, in this embodiment, an image is divided into multiple sub-images; the image includes a background region and a target object; each sub-image includes multiple sub-regions; the average gray value of all pixels in each sub-region is calculated to obtain the average gray value of each sub-region; the density value of each sub-image is calculated based on a preset gray value range including multiple interval segments and all the average gray values; the density value of the sub-image reflects the degree of difference between the average gray values ​​of each sub-region in the sub-image; when there is a target sub-image with a density value greater than a preset density threshold in all sub-images, it is determined that the target sub-image contains a target object that is different from the background region, so as to realize the detection of the target object in the image, and there is no need for manual searching of the target object in the image, which improves work efficiency and solves the problem of low work efficiency caused by manual searching of the target object in the image in order to detect the target object in the image in the prior art.

[0182] Figure 7 This is a block diagram of a target object detection device in an image provided in an embodiment of this application, such as... Figure 7 As shown, the device 300 includes:

[0183] The segmentation module 301 is used to divide an image into multiple sub-images; the image includes a background region and a target object; each sub-image includes multiple sub-regions;

[0184] The first calculation module 302 is used to calculate the average gray value of all pixels in each sub-region to obtain the average gray value of each sub-region.

[0185] The second calculation module 303 is used to calculate the density value of each sub-image based on a preset gray value range including multiple interval segments and all the average gray values; the density value of the sub-image reflects the degree of difference between the average gray values ​​of each sub-region in the sub-image.

[0186] The determining module 304 is used to determine that, when there is a target sub-image with a density value greater than a preset density threshold in all the sub-images, the target sub-image contains the target object that is different from the background region.

[0187] Optionally, the second computing module 303 specifically includes:

[0188] The first calculation submodule is used to calculate the difference value of each sub-region based on all the interval segments and all the average gray values; the difference value of the sub-region reflects the degree of difference between the average gray value of the sub-region and the average gray value of other sub-regions in the sub-image to which the sub-region belongs;

[0189] The second calculation submodule is used to calculate the density value of each sub-image based on the difference values ​​of all the sub-regions, the preset weights, and the preset deviation values.

[0190] Optionally, the first calculation submodule specifically includes:

[0191] The module is defined to determine the interval average value vector and interval quantity vector corresponding to each sub-image based on all the interval segments and all the average gray values; the elements of the interval average value vector matrix are the average gray values ​​of the sub-image falling into the interval segments, and the elements of the interval quantity vector matrix are the number of average gray values ​​of the sub-image falling into the interval segments.

[0192] The calculation module is used to calculate the difference value of each sub-region based on the interval average value vector, interval quantity vector and all the average gray values ​​corresponding to each sub-image.

[0193] Optionally, the calculation is divided into modules, specifically including:

[0194] The first calculation module is used to calculate a distance vector for each sub-region based on the average gray value of each sub-region and the interval average value vector corresponding to the sub-image to which the sub-region belongs; the elements of the distance vector matrix are the differences between the average gray value of the sub-region and the values ​​of the elements of the interval average value vector corresponding to the sub-image to which the sub-region belongs;

[0195] An intermediate vector molecule module is used to obtain an intermediate vector corresponding to each distance vector based on each distance vector.

[0196] The second calculation module is used to calculate the difference value of each sub-region based on each interval quantity vector and each intermediate vector.

[0197] Optionally, the intermediate vector molecule module specifically includes:

[0198] The first determining module is used to determine the value of the element of the intermediate vector corresponding to the element of the distance vector as a first value when the value of the element of the distance vector is greater than a preset difference threshold.

[0199] The second determining module is used to determine the value of the element of the intermediate vector corresponding to the element of the distance vector as a second value when the value of the element of the distance vector is less than or equal to the difference threshold.

[0200] Optionally, the first value is 1 and the second value is 0.

[0201] Optionally, all the sub-images have the same area; all the sub-regions have the same area.

[0202] Optionally, module 301 is divided into:

[0203] The merging submodule is used to merge the image with a black image when the image cannot be equally divided by the sub-images to obtain a merged image; the merged image can be equally divided by the sub-images; the black image is an image in which all pixels have a grayscale value of 0;

[0204] The segmentation submodule is used to divide the merged image into multiple sub-images.

[0205] Optionally, the device 300 further includes:

[0206] The overlap value module is used to multiply the side length of the sub-image by a preset overlap degree to obtain the overlap value of the side length of the sub-image; the overlap degree is the ratio of the area of ​​the overlapping part of the sub-image with the adjacent sub-image to the area of ​​the sub-image.

[0207] The non-overlap value module is used to subtract the overlap value from the side length of the sub-image to obtain the non-overlap value of the side length of the sub-image;

[0208] The first judgment module is used to determine that the image cannot be equally divided by the sub-images if the side length of the image cannot be divided evenly by the non-overlapping value.

[0209] The second judgment module is used to determine that the merged image can be equally divided by the sub-images if the side length of the merged image can be divided by the non-overlapping value.

[0210] Optionally, the device 300 further includes:

[0211] The first acquisition module is used to acquire the first coordinate parameter of the target object in the target sub-image using a single-stage target detector based on the target sub-image;

[0212] The second acquisition module is used to acquire the second coordinate parameter of the target object in the image based on the first coordinate parameter and the position parameter of the target sub-image in the image.

[0213] The device for detecting target objects in images in the embodiments of this application can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. For example, mobile electronic devices can be mobile phones, tablets, laptops, PDAs, in-vehicle electronic devices, wearable devices, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs), etc., while non-mobile electronic devices can be servers, network attached storage (NAS), personal computers (PCs), televisions (TVs), ATMs, or self-service machines, etc. The embodiments of this application do not impose specific limitations.

[0214] The target object detection device in the image in this embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this embodiment does not specifically limit it.

[0215] The image target object detection device provided in this application embodiment can achieve... Figure 1 The various processes implemented by the target object detection device in the image in the method embodiment will not be described again here to avoid repetition.

[0216] The embodiments of this application enable the detection of target objects in images without the need for manual searching of these objects, thus improving work efficiency and solving the problem of low work efficiency caused by the need for manual searching of target objects in images in prior art.

[0217] Optionally, embodiments of this application also provide an electronic device, including a processor, a memory, and a program or instructions stored in the memory and executable on the processor. When the program or instructions are executed by the processor, they implement the various processes of the above-described method embodiments for detecting target objects in images and achieve the same technical effects. To avoid repetition, they will not be described again here.

[0218] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.

[0219] Figure 8 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of this application.

[0220] The electronic device 400 includes, but is not limited to, components such as: radio frequency unit 401, network module 402, audio output unit 403, input unit 404, sensor 405, display unit 406, user input unit 407, interface unit 408, memory 409, and processor 410.

[0221] Those skilled in the art will understand that the electronic device 400 may also include a power supply (such as a battery) for supplying power to various components. The power supply may be logically connected to the processor 410 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system. Figure 8 The electronic device structure shown does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements, which will not be elaborated here.

[0222] The processor 410 is configured to divide an image into multiple sub-images; the image includes a background region and a target object; each sub-image includes multiple sub-regions.

[0223] Calculate the average grayscale value of all pixels in each sub-region to obtain the average grayscale value of each sub-region;

[0224] Based on a preset grayscale value range including multiple interval segments and all the average grayscale values, the density value of each sub-image is calculated; the density value of the sub-image reflects the degree of difference between the average grayscale values ​​of each sub-region in the sub-image.

[0225] If, among all the sub-images, there is a target sub-image with a density value greater than a preset density threshold, it is determined that the target sub-image contains the target object that is distinct from the background region.

[0226] In this embodiment, an image is divided into multiple sub-images; the image includes a background region and a target object; each sub-image includes multiple sub-regions; the average gray value of all pixels in each sub-region is calculated to obtain the average gray value of each sub-region; the density value of each sub-image is calculated based on a preset gray value range including multiple interval segments and all the average gray values; the density value of the sub-image reflects the degree of difference between the average gray values ​​of each sub-region in the sub-image; when there is a target sub-image with a density value greater than a preset density threshold in all sub-images, it is determined that the target sub-image contains a target object that is different from the background region, so as to realize the detection of the target object in the image, and there is no need for manual searching of the target object in the image, which improves work efficiency and solves the problem of low work efficiency caused by manual searching of the target object in the image in order to detect the target object in the image in the prior art.

[0227] Optionally, the processor 410 is further configured to calculate a difference value for each of the sub-regions based on all the interval segments and all the average gray values; the difference value of the sub-region reflects the degree of difference between the average gray value of the sub-region and the average gray value of other sub-regions in the sub-image to which the sub-region belongs; and calculate a density value for each sub-image based on the difference values ​​of all the sub-regions, a preset weight, and a preset deviation value.

[0228] Optionally, the processor 410 is further configured to determine an interval average vector and an interval quantity vector corresponding to each sub-image based on all the interval segments and all the average gray values; the elements of the matrix of the interval average vector are the average of the average gray values ​​of the sub-image falling into the interval segments, and the elements of the matrix of the interval quantity vector are the number of average gray values ​​of the sub-image falling into the interval segments; and to calculate the difference value of each sub-region based on the interval average vector, the interval quantity vector, and all the average gray values ​​corresponding to each sub-image.

[0229] Optionally, the processor 410 is further configured to calculate a distance vector for each sub-region based on the average gray value of each sub-region and the interval average vector corresponding to the sub-image to which the sub-region belongs; the elements of the distance vector matrix are the differences between the average gray value of the sub-region and the values ​​of the elements of the interval average vector corresponding to the sub-image to which the sub-region belongs; obtain an intermediate vector corresponding to each distance vector based on each distance vector; and calculate a difference value for each sub-region based on each interval number vector and each intermediate vector.

[0230] Optionally, the processor 410 is further configured to, when the value of an element of the distance vector is greater than a preset difference threshold, determine the value of an element of the intermediate vector corresponding to the element of the distance vector as a first value; and when the value of an element of the distance vector is less than or equal to the difference threshold, determine the value of an element of the intermediate vector corresponding to the element of the distance vector as a second value.

[0231] Optionally, the first value is 1 and the second value is 0.

[0232] Optionally, all the sub-images have the same area; all the sub-regions have the same area.

[0233] Optionally, the processor 410 is further configured to, when the image cannot be equally divided by the sub-images, merge the image with a black image to obtain a merged image; the merged image can be equally divided by the sub-images; the black image is an image in which all pixels have a grayscale value of 0; and divide the merged image into multiple sub-images.

[0234] Optionally, the processor 410 is further configured to multiply the side length value of the sub-image by a preset overlap degree to obtain an overlap value of the side length of the sub-image; the overlap degree is the ratio of the area of ​​the overlapping portion of the sub-image with the adjacent sub-image to the area of ​​the sub-image; subtract the overlap value from the side length value of the sub-image to obtain a non-overlap value of the side length of the sub-image; if the side length value of the image cannot be divided evenly by the non-overlap value, determine that the image cannot be equally divided by the sub-image; if the side length value of the merged image can be divided evenly by the non-overlap value, determine that the merged image can be equally divided by the sub-image.

[0235] Optionally, the processor 410 is further configured to obtain a first coordinate parameter of the target object in the target sub-image using a single-stage target detector based on the target sub-image; and to obtain a second coordinate parameter of the target object in the image based on the first coordinate parameter and the position parameter of the target sub-image in the image.

[0236] In this embodiment, an image is divided into multiple sub-images; the image includes a background region and a target object; each sub-image includes multiple sub-regions; the average gray value of all pixels in each sub-region is calculated to obtain the average gray value of each sub-region; the density value of each sub-image is calculated based on a preset gray value range including multiple interval segments and all the average gray values; the density value of the sub-image reflects the degree of difference between the average gray values ​​of each sub-region in the sub-image; when there is a target sub-image with a density value greater than a preset density threshold in all sub-images, it is determined that the target sub-image contains a target object that is different from the background region, so as to realize the detection of the target object in the image, and there is no need for manual searching of the target object in the image, which improves work efficiency and solves the problem of low work efficiency caused by manual searching of the target object in the image in order to detect the target object in the image in the prior art.

[0237] It should be understood that, in this embodiment, the input unit 404 may include a graphics processing unit (GPU) 4041 and a microphone 4042. The GPU 4041 processes image data of still images or videos obtained by an image capture device (such as a camera) in video capture mode or image capture mode. The display unit 406 may include a display panel 4061, which may be configured in the form of a liquid crystal display, an organic light-emitting diode, or the like. The user input unit 407 includes at least one of a touch panel 4071 and other input devices 4072. The touch panel 4071 is also called a touch screen. The touch panel 4071 may include a touch detection device and a touch controller. Other input devices 4072 may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, power buttons, etc.), trackballs, mice, and joysticks, which will not be described in detail here.

[0238] The memory 409 can be used to store software programs and various data. The memory 409 may primarily include a first storage area for storing programs or instructions and a second storage area for storing data. The first storage area may store the operating system, application programs or instructions required for at least one function (such as sound playback, image playback, etc.). Furthermore, the memory 409 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus RAM (DRRAM). The memory 409 in the embodiments of this application includes, but is not limited to, these and any other suitable types of memory.

[0239] Processor 410 may include one or more processing units; optionally, processor 410 integrates an application processor and a modem processor, wherein the application processor mainly handles operations involving the operating system, user interface, and applications, and the modem processor mainly handles wireless communication signals, such as a baseband processor. It is understood that the aforementioned modem processor may also not be integrated into processor 410.

[0240] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above-described method for detecting target objects in images and achieve the same technical effect. To avoid repetition, these will not be described again here.

[0241] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.

[0242] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above-described image target object detection method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0243] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.

[0244] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0245] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0246] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. A method of detecting a target object in an image, characterized by, The method comprises: dividing an image into a plurality of sub-images; the image comprises a background region and a target object; each of the sub-images comprises a plurality of sub-regions; calculating an average value of gray scale values of all pixel points of each of the sub-regions to obtain an average gray scale value of each of the sub-regions; calculating a density value of each of the sub-images according to a preset gray scale value interval comprising a plurality of interval segments and all of the average gray scale values; the density value of the sub-image reflects a difference degree between the average gray scale values of the respective sub-regions in the sub-image; in a case where there is a target sub-image with a density value greater than a preset density threshold value among all of the sub-images, determining that the target sub-image contains the target object distinguished from the background region.

2. The method of claim 1, wherein, The calculating of the density value of each of the sub-images according to the preset gray scale value interval comprising a plurality of interval segments and all of the average gray scale values comprises: calculating a difference value of each of the sub-regions according to all of the interval segments and all of the average gray scale values; the difference value of the sub-region reflects a difference degree between the average gray scale value of the sub-region and the average gray scale values of other sub-regions in the sub-image to which the sub-region belongs; calculating the density value of each of the sub-images according to the difference value of all of the sub-regions, a preset weight and a preset deviation value.

3. The method of claim 2, wherein, The calculating of the difference value of each of the sub-regions according to all of the interval segments and all of the average gray scale values comprises: determining an interval average value vector and an interval quantity vector corresponding to each of the sub-images according to all of the interval segments and all of the average gray scale values; an element of a matrix of the interval average value vector is an average value of the average gray scale values of the sub-image falling into the interval segment, and an element of a matrix of the interval quantity vector is a quantity of the average gray scale values of the sub-image falling into the interval segment; calculating the difference value of each of the sub-regions according to the interval average value vector and the interval quantity vector corresponding to each of the sub-images and all of the average gray scale values.

4. The method of claim 3, wherein, The calculating of the difference value of each of the sub-regions according to the interval average value vector and the interval quantity vector corresponding to each of the sub-images and all of the average gray scale values comprises: calculating a distance vector of each of the sub-regions according to the average gray scale value of each of the sub-regions and the interval average value vector corresponding to the sub-image to which the sub-region belongs; an element of a matrix of the distance vector is a difference value of the average gray scale value of the sub-region and a value of an element of the interval average value vector corresponding to the sub-image to which the sub-region belongs; obtaining an intermediate vector corresponding to each of the distance vectors according to each of the distance vectors; calculating the difference value of each of the sub-regions according to each of the interval quantity vectors and each of the intermediate vectors.

5. The method of claim 4, wherein, The obtaining of the intermediate vector corresponding to each of the distance vectors according to each of the distance vectors comprises: in a case where a value of the element of the distance vector is greater than a preset difference value threshold value, determining a value of an element of the intermediate vector corresponding to the element of the distance vector as a first numerical value; In a case where the value of the element of the distance vector is less than or equal to the difference threshold value, the value of the element of the intermediate vector corresponding to the element of the distance vector is determined as a second numerical value.

6. The method of claim 5, wherein, The first numerical value is 1, and the second numerical value is 0.

7. The method of claim 1, wherein, The areas of all the sub-images are the same, and the areas of all the sub-regions are the same.

8. An apparatus for detecting a target object in an image, characterized by comprising: The apparatus comprises: a division module configured to divide an image into a plurality of sub-images; the image comprises a background region and a target object; each of the sub-images comprises a plurality of sub-regions; a first calculation module configured to calculate an average value of the gray values of all the pixel points of each of the sub-regions to obtain an average gray value of each of the sub-regions; a second calculation module configured to calculate a density value of each of the sub-images according to a preset gray value interval comprising a plurality of interval segments and all the average gray values; the density value of the sub-image reflects a difference degree between the average gray values of the respective sub-regions in the sub-image; a determination module configured to, in a case where there is a target sub-image with a density value greater than a preset density threshold value among all the sub-images, determine that the target sub-image contains the target object that is different from the background region.

9. An electronic device, comprising: The apparatus comprises a processor, a memory, and a program or instructions stored on the memory and executable on the processor; when the program or instructions are executed by the processor, the steps of the method for detecting a target object in an image according to any one of claims 1 to 7 are implemented.

10. A readable storage medium, characterized by, The program or instructions are stored on the readable storage medium; when the program or instructions are executed by the processor, the steps of the method for detecting a target object in an image according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Aerial target automatic detection method based on background fitting of multiple sub-regions

    CN107316318A

  • Object detection method and device, storage medium and electronic device

    CN111310727A