Positioning detection method, device and equipment
By preconfiguring the color categories and index values and processing image pixel points based on the color categories, the problem of difficult to classify objects with similar shapes and features in the image to be detected is solved, and accurate object positioning and detection is achieved.
Patent Information
- Application Number
- CN202411022852.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-26
- Publication Date
- 2024-11-22
AI Technical Summary
When the shapes and features of different objects in the image to be detected are similar, it is difficult for neural network models to accurately determine the category of each object area, resulting in the inability to output accurate and reliable category results.
By preconfiguring multiple color categories, each category corresponds to the color range and index value, traverses the image pixel points in turn, determines the target connection domain and external area based on the color category, generates a color category marking image, and then determines positioning detection in the image to be detected area.
It can accurately divide the area of object of different colors, determine the category of each object area, correctly handle target objects of similar colors but different types, and achieve accurate and reliable category detection.
Smart Images

Figure CN119006812A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of machine vision technology, and in particular to a positioning detection method, device and equipment. Background Art
[0002] When there are multiple categories of objects in the image to be detected, such as oranges and lemons, it is necessary to be able to locate each object and detect the category of each object. For example, first segment out several object regions (this process is called positioning, such as when there are 3 oranges and 2 lemons in the image to be detected, 5 object regions need to be segmented), and then determine the category of each object region (this process is called detection, such as determining that object region 1 is an orange category, object region 2 is a lemon category, and so on).
[0003] In order to locate and detect the image to be detected, the image to be detected can be input into the neural network model, and the neural network model performs artificial intelligence processing on the image to be detected. During the artificial intelligence processing, the image to be detected can be segmented into several object areas and the category of each object area can be determined.
[0004] However, when the shapes of different objects in the image to be detected are similar and the features of different objects in the image to be detected are similar, it is difficult for the neural network model to determine the category of each object area. In other words, the neural network model cannot output accurate and reliable categories, and cannot accurately obtain the category of each object area. Summary of the invention
[0005] The present application provides a positioning detection method, which pre-configures multiple color categories. For each color category, the color category corresponds to a color range and an index value. The method includes:
[0006] Traverse each pixel of the image to be detected in sequence; for the currently traversed pixel, determine the target color category corresponding to the pixel based on the color range to which the color of the pixel belongs;
[0007] Generate a color category labeled image, wherein for each pixel point of the color category labeled image, the pixel value of the pixel point is the index value of the target color category corresponding to the pixel point;
[0008] Determine a target connected domain based on the color category labeled image, and determine a circumscribed area of the target connected domain, wherein the target connected domain is composed of pixels having the same pixel value and being interconnected;
[0009] A positioning detection area corresponding to the circumscribed area is determined in the image to be detected, and a color category of the positioning detection area corresponds to an index value of the target connected domain.
[0010] The present application provides a positioning detection device, which pre-configures multiple color categories. For each color category, the color category corresponds to a color range and an index value. The device includes:
[0011] A determination module is used to sequentially traverse each pixel of the image to be detected; for the currently traversed pixel, determine the target color category corresponding to the pixel based on the color range to which the color of the pixel belongs;
[0012] A generating module, used for generating a color category labeled image, wherein for each pixel point of the color category labeled image, the pixel value of the pixel point is the index value of the target color category corresponding to the pixel point;
[0013] A processing module, configured to determine a target connected domain based on the color category labeled image, and determine a circumscribed area of the target connected domain, wherein the target connected domain is composed of interconnected pixel points having the same pixel value;
[0014] The detection module is used to determine a positioning detection area corresponding to the circumscribed area in the image to be detected, wherein the color category of the positioning detection area corresponds to the index value of the target connected domain.
[0015] The present application provides an electronic device, comprising: a processor and a machine-readable storage medium, wherein the machine-readable storage medium stores machine-executable instructions that can be executed by the processor; the processor is used to execute the machine-executable instructions to implement the positioning detection method disclosed in the above example.
[0016] The present application provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the positioning detection method disclosed in the above example is implemented.
[0017] The present application provides a machine-readable storage medium, which stores machine-executable instructions that can be executed by a processor; wherein the processor is used to execute the machine-executable instructions to implement the positioning detection method disclosed in the above example.
[0018] As can be seen from the above technical scheme, in the embodiment of the present application, multiple color categories are pre-configured, each color category corresponds to a color range and an index value, thereby realizing the location and detection of the image to be detected based on the color category. Can segment several object regions (i.e., the location process) based on the color range and the index value corresponding to the color category, can determine the category (i.e., the detection process) of each object region based on the color range and the index value corresponding to the color category. In this way, even if the shapes of the different objects in the image to be detected are similar, and the features of the different objects in the image to be detected are similar, the category of each object region can be accurately determined, and accurate and reliable category detection results can be obtained. According to the multiple color categories set, target objects of different colors can be segmented in the image, and then location detection is performed, with color as a feature, image segmentation and location detection are carried out for the target objects of different categories, and the target objects of similar colors but different types can be correctly processed. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 It is a flowchart of a positioning detection method in one embodiment of the present application;
[0020] Figure 2 It is a flowchart of a positioning detection method in one embodiment of the present application;
[0021] Figure 3 is a schematic diagram of a sample image in one embodiment of the present application;
[0022] Figure 4 is a schematic diagram of a color category labeled image in one embodiment of the present application;
[0023] Figure 5 is a schematic diagram of converting an initial connected domain into a candidate connected domain in one implementation of the present application;
[0024] Figure 6 is a schematic diagram of a positioning detection result in one embodiment of the present application;
[0025] Figure 7 is a structural schematic diagram of a positioning detection device in one embodiment of the present application;
[0026] Figure 8 It is a hardware structure diagram of an electronic device in one embodiment of the present application. DETAILED DESCRIPTION
[0027] In an embodiment of the present application, a positioning detection method is proposed, which can be applied to an electronic device, and a plurality of color categories are pre-configured. For each color category, the color category can correspond to a color range and an index value.
[0028] See also Figure 1FIG. 4 is a flow chart of the method, which may include:
[0029] Step 101, traverse each pixel of the image to be detected in turn; for the currently traversed pixel, determine the target color category corresponding to the pixel based on the color range to which the color of the pixel belongs.
[0030] Step 102: Generate a color category labeled image. For each pixel of the color category labeled image, the pixel value of the pixel is the index value of the target color category corresponding to the pixel.
[0031] Step 103: determine a target connected domain based on the color category labeled image, and determine a circumscribed area of the target connected domain, wherein the target connected domain is composed of pixels having the same pixel value and being connected to each other.
[0032] Step 104: determining a positioning detection area corresponding to the circumscribed area in the image to be detected, wherein the color category of the positioning detection area corresponds to the index value of the target connected domain.
[0033] Exemplarily, determining the target color category corresponding to the pixel based on the color range to which the color of the pixel belongs may include, but is not limited to: based on the color range corresponding to each color category, if the color of the pixel belongs to only one candidate color range, the color category corresponding to the candidate color range may be determined as the target color category. Alternatively, based on the color range corresponding to each color category, if the color of the pixel belongs to at least two candidate color ranges at the same time, for each candidate color range, the number of pixels corresponding to the candidate color range may be determined; wherein, based on the colors of all neighboring pixels of the pixel, the number of pixels is the total number of neighboring pixels whose colors belong only to the candidate color range. On this basis, based on the number of pixels corresponding to each candidate color range, the color category corresponding to the candidate color range with the largest number of pixels may be determined as the target color category.
[0034] Exemplarily, the multiple color categories may include a background color category and at least two foreground color categories. Determining the target connected domain based on the color category labeled image may include, but is not limited to: determining multiple initial connected domains from the color category labeled image. Determining multiple candidate connected domains based on the multiple initial connected domains; wherein, if the multiple initial connected domains include a first initial connected domain and a second initial connected domain, the second initial connected domain is located inside the first initial connected domain, the index value of the first initial connected domain corresponds to the foreground color category, and the index value of the second initial connected domain corresponds to the background color category, then the pixel value of each pixel point in the second initial connected domain is modified to the index value of the first initial connected domain to obtain a candidate connected domain. The candidate connected domain whose index value corresponds to the foreground color category is determined as the target connected domain.
[0035] Exemplarily, determining multiple candidate connected domains based on multiple initial connected domains may also include, but is not limited to: if the multiple initial connected domains include a third initial connected domain, the area of the third initial connected domain may be smaller than a threshold value, and when the third initial connected domain is adjacent to the initial connected domain of the foreground color category, the pixel value of each pixel in the third initial connected domain may be modified to the index value of the initial connected domain to obtain a candidate connected domain; when the third initial connected domain is not adjacent to the initial connected domain of the foreground color category, the pixel value of each pixel in the third initial connected domain may be modified to the index value of the background color category to obtain a candidate connected domain. For the remaining initial connected domains except the first initial connected domain, the second initial connected domain and the third initial connected domain, the remaining initial connected domains are determined as candidate connected domains.
[0036] Exemplarily, the multiple color categories may include a background color category and at least two foreground color categories, based on which, for each foreground color category, the configured color range and the configured index value corresponding to the foreground color category may be obtained; wherein the color ranges corresponding to different foreground color categories do not have overlapping areas or have overlapping areas, and the index values corresponding to different foreground color categories are different. Also, the color range and the configured index value corresponding to the background color category may be obtained; wherein the union range may be taken for the color ranges corresponding to all foreground color categories, so that the union range may be excluded from the configured complete color range to obtain the color range corresponding to the background color category; wherein the index value corresponding to the background color category is different from the index value corresponding to each foreground color category.
[0037] Exemplarily, for each color category, the color category also corresponds to an object name, and the object name represents a unique identifier of the object. Based on this, after determining the positioning detection area corresponding to the circumscribed area in the image to be detected, the object name corresponding to the color category of the positioning detection area can also be marked in the positioning detection area of the image to be detected, thereby marking the object name in the image to be detected.
[0038] As can be seen from the above technical scheme, in the embodiment of the present application, multiple color categories are pre-configured, each color category corresponds to a color range and an index value, thereby realizing the location and detection of the image to be detected based on the color category. Can segment several object regions (i.e., the location process) based on the color range and the index value corresponding to the color category, can determine the category (i.e., the detection process) of each object region based on the color range and the index value corresponding to the color category. In this way, even if the shapes of the different objects in the image to be detected are similar, and the features of the different objects in the image to be detected are similar, the category of each object region can be accurately determined, and accurate and reliable category detection results can be obtained. According to the multiple color categories set, target objects of different colors can be segmented in the image, and then location detection is performed, with color as a feature, image segmentation and location detection are carried out for the target objects of different categories, and the target objects of similar colors but different types can be correctly processed.
[0039] The technical solution of the embodiment of the present application is described below in conjunction with specific application scenarios.
[0040] Image segmentation and positioning detection are basic tasks of machine vision and are widely used in the field of industrial automation. In order to locate and detect the image to be detected, the image to be detected can be input into a neural network model, and the neural network model performs artificial intelligence processing on the image to be detected. During the artificial intelligence processing, the image to be detected can be segmented into several object regions and the category of each object region can be determined.
[0041] However, when the shapes of different objects in the image to be detected are similar and the features of different objects in the image to be detected are similar, it is difficult for the neural network model to determine the category of each object area. In other words, the neural network model cannot output accurate and reliable categories, and cannot accurately obtain the category of each object area.
[0042] In response to the above findings, a positioning detection method is proposed in an embodiment of the present application, which is an image segmentation and positioning detection method based on multiple color categories. It uses color as a feature to perform image segmentation and positioning detection on target objects of different categories, and can correctly process target objects of similar colors but different types.
[0043] See also Figure 2 FIG. 1 is a flow chart of a positioning detection method, which may include:
[0044] Step 201: Obtain at least two pre-configured foreground color categories, and for each foreground color category, obtain a configured color range and a configured index value corresponding to the foreground color category.
[0045] Exemplarily, the user can set foreground color categories for target objects of different colors respectively (e.g., the user can set one or more foreground color categories according to the color type of the target object that needs to be processed, and in the subsequent process, setting at least two foreground color categories is used as an example for explanation), so that the pre-configured foreground color category can be obtained. Assuming that there are target objects of at least two colors, at least two pre-configured foreground color categories can be obtained. Among them, the foreground color category is the color category for the target object, that is, the foreground color category is used to represent the category of the color of the target object.
[0046] For example, for the positioning detection task, assuming that there are target objects of two colors, two foreground color categories can be set, respectively called foreground color category a1 and foreground color category a2.
[0047] Assuming that there are target objects of three colors, three foreground color categories can be set, which are respectively called foreground color category a1, foreground color category a2 and foreground color category a3, and so on.
[0048] For example, for each foreground color category, a color range corresponding to the foreground color category can be obtained, and the color ranges corresponding to different foreground color categories may not have overlapping areas, and the color ranges corresponding to different foreground color categories may also have overlapping areas. For example, the color range corresponding to foreground color category a1 has an overlapping area with the color range corresponding to foreground color category a2, and the color range corresponding to foreground color category a1 has no overlapping area with the color range corresponding to foreground color category a3.
[0049] The color range corresponding to the foreground color category may be set by the user based on experience. For example, if the user already knows the color range corresponding to the foreground color category, the user may directly set the color range corresponding to the foreground color category.
[0050] Alternatively, the color range corresponding to the foreground color category can also be set with the help of a program. For example, a sample image is selected, and the sample image can include target objects of each color. The user can select the target object in the sample image, and the program outputs the color range within the selection range (i.e., the minimum color value within the selection range to the maximum color value within the selection range), and this color range is used as the color range corresponding to the foreground color category of the target object. Obviously, after selecting each target object, the color range corresponding to each foreground color category can be obtained.
[0051] Of course, the above is only an example of obtaining the color range corresponding to the foreground color category, and there is no limitation to this.
[0052] For the color range corresponding to the foreground color category, the color range is a color interval, such as color value b1 to color value b2, or the color range is the union of multiple color intervals, such as color value b1 to color value b2, color value b3 to color value b4, and color value b2 to color value b3 do not belong to the color range.
[0053] For two color ranges corresponding to different foreground color categories, the two color ranges may not have overlapping areas, that is, the two color ranges do not have intersecting color values, or the two color ranges may have overlapping areas, that is, the two color ranges have intersecting color values.
[0054] For the color range corresponding to the foreground color category, the color range can be a color range of any color space (such as RGB, HSI, and HSV, etc.). For example, the color range can be a color range of an RGB color space, that is, the color range is a value range for RGB color values. The color range can be a color range of an HSI color space, that is, the color range is a value range for HSI color values. The color range can be a color range of an HSV color space, that is, the color range is a value range for HSV color values. Of course, the above are just a few examples of color spaces, and there is no limitation on this color space.
[0055] See also Figure 3 As shown, it is a schematic diagram of a sample image, which includes target objects such as lemons and oranges. Therefore, two foreground color categories are set, namely foreground color category a1 and foreground color category a2. Foreground color category a1 is a category for lemons, and foreground color category a2 is a category for oranges.
[0056] When setting the color range corresponding to the foreground color category, you can use the program to set it, allowing the user to select in the sample image. Assuming that two lemons are selected in the sample image, the foreground color category a1 corresponds to two selection ranges. Taking the color range of the HSV color space as an example, the color range of the first selection range is (h, s, v)|36≤h≤54, 0≤s≤241, 66≤v≤255, and the color range of the second selection range is (h, s, v)|26≤h≤42, 216≤s≤255, 56≤v≤171. Then the color range corresponding to the foreground color category a1 is the union of the two color ranges, that is, {(h, s, v)|36≤h≤54, 0≤s≤241, 66≤v≤255}∪{(h, s, v)|26≤h≤42, 216≤s≤255, 56≤v≤171}. Assume that two oranges are selected in the sample image, and the foreground color category a2 corresponds to two selection ranges. The color range of the first selection range is (h, s, v)|15≤h≤33, 110≤s≤255, 17≤v≤255, and the color range of the second selection range is (h, s, v)|33≤h≤45, 0≤s≤252, 246≤v≤255. The color range corresponding to the foreground color category a2 is the union of the two color ranges, that is, {(h, s, v)|15≤h≤33, 110≤s≤255, 17≤v≤255}∪{(h, s, v)|33≤h≤45, 0≤s≤252, 246≤v≤255}. Obviously, the color range corresponding to the foreground color category a1 and the color range corresponding to the color category a2 have an intersection.
[0057] Exemplarily, for each foreground color category, an index value corresponding to the foreground color category can be obtained, and different foreground color categories have different index values, and the index value is a unique identifier of the foreground color category. For example, the index value corresponding to foreground color category a1 is different from the index value corresponding to foreground color category a2, the index value corresponding to foreground color category a1 is different from the index value corresponding to foreground color category a3, and the index value corresponding to foreground color category a2 is different from the index value corresponding to foreground color category a3.
[0058] The index value corresponding to the foreground color category can be set by the user based on experience, such as the user sets the index value corresponding to each foreground color category, and the index values corresponding to different foreground color categories are different. Or, the index value corresponding to the foreground color category can also be set with the help of a program. For example, the program automatically generates the index value corresponding to each foreground color category, and the index values corresponding to different foreground color categories are different. Of course, the above is only an example of obtaining the index value corresponding to the foreground color category, and there is no limitation to this.
[0059] Regarding the index value corresponding to the foreground color category, the index value may be located in a specified numerical range (eg, 0-255), that is, a numerical value is selected from the specified numerical range as the index value corresponding to the foreground color category.
[0060] Regarding two index values corresponding to different foreground color categories, the interval between the two index values may be greater than a threshold value (such as 50). For example, when the index value corresponding to one foreground color category is 50, the index value corresponding to the other foreground color category may be greater than 100. In this way, by making the interval between the two index values greater than the threshold value, when the index values are used as pixel values, the pixel values of different pixels can be clearly distinguished.
[0061] against Figure 3 In the example of the sample image shown, the foreground color category a1 is a category for lemons, and the foreground color category a2 is a category for oranges. For the index value, the index value for the foreground color category a1 can be set to 100, and the index value for the foreground color category a2 can be set to 200.
[0062] Exemplarily, for each foreground color category, the foreground color category may also correspond to an object name of the target object, and the object name may represent a unique identifier of the target object.
[0063] For example, the object name corresponding to the foreground color category a1 is lemon, which means that the foreground color category a1 is the foreground color category for the target object lemon. The object name corresponding to the foreground color category a2 is orange, which means that the foreground color category a2 is the foreground color category for the target object orange.
[0064] Step 202: Obtain the color range corresponding to the background color category and the configured index value.
[0065] Exemplarily, a background color category (a background color category) may also be set. The background color category is a color category for non-target objects, that is, the background color category is used to represent a category of background color.
[0066] For example, for the background color category, the color range corresponding to the background color category can be obtained. For example, the union range of the color ranges corresponding to all foreground color categories can be taken, so that the union range is excluded from the configured complete color range to obtain the color range corresponding to the background color category.
[0067] For example, if n foreground color categories are set in advance, the color range of each foreground color category is C i , i ranges from 1 to n, C 1 Indicates the color range of the first foreground color category, and so on, C nrepresents the color range of the nth foreground color category. Based on this, the union range of the color ranges corresponding to all foreground color categories can be recorded as On this basis, after excluding the union range from the configured complete color range (i.e., the value range including all color values), the color range corresponding to the background color category can be recorded as Obviously, the union of the color range corresponding to the background color category and the color range of all foreground color categories constitutes the full set of the color space, that is, the complete color range.
[0068] For the color range corresponding to the background color category, the color range is a color interval, such as color value b1 to color value b2, or the color range is the union of multiple color intervals, such as color value b1 to color value b2, color value b3 to color value b4, and color value b2 to color value b3 do not belong to the color range.
[0069] Regarding the color range corresponding to the background color category, based on the definition of the color range corresponding to the background color category, it can be known that this color range is obtained by excluding the union of the color ranges corresponding to all foreground color categories. Therefore, there is no overlapping area between this color range and the color range of each foreground color category.
[0070] Based on this, any color will belong to the color range of at least one color category (such as the background color category or the foreground color category). For example, if a color belongs to the color range of the background color category, then the color does not belong to the color range of the foreground color category. Conversely, if a color belongs to the color range of the foreground color category, then the color does not belong to the color range of the background color category.
[0071] For the color range corresponding to the background color category, the color range is a color range of any color space (such as RGB, HSI, and HSV, etc.), and the color space is the same as the color space of the foreground color category.
[0072] For example, for the background color category, an index value corresponding to the background color category can be obtained, and the index value corresponding to the background color category is different from the index value corresponding to each foreground color category. For example, the index value corresponding to the background color category can be a unique identifier of the background color category.
[0073] The index value corresponding to the background color category can be set by the user based on experience, or can be set with the help of a program, as long as the index value corresponding to the background color category is different from the index value corresponding to each foreground color category. Regarding the index value corresponding to the background color category, the index value can be in a specified numerical range (such as 0-255), that is, a value is selected from the specified numerical range as the index value corresponding to the background color category. For example, the index value corresponding to the background color category is fixed to 0.
[0074] At this point, multiple color categories can be obtained, and the multiple color categories can include a background color category and at least two foreground color categories. The background color category corresponds to a color range and an index value. For each foreground color category, the foreground color category corresponds to a color range, an index value and an object name of the target object.
[0075] Step 203: Acquire an image to be detected, which may also be referred to as an image to be processed.
[0076] For example, in the process of positioning detection, multiple images to be detected can be obtained, and positioning detection needs to be performed on these images to be detected. For the convenience of description, the processing process of one image to be detected is taken as an example.
[0077] Step 204, traverse each pixel of the image to be detected in sequence; for the currently traversed pixel, determine the target color category corresponding to the pixel based on the color range to which the color of the pixel belongs.
[0078] In a possible implementation, based on the color range corresponding to each color category (such as the background color category and the foreground color category), if the color of the pixel point belongs to only one candidate color range, the color category corresponding to the candidate color range can be determined as the target color category corresponding to the pixel point.
[0079] For example, if the color of the pixel point only belongs to the color range corresponding to the background color category (this color range is called the candidate color range), the background color category corresponding to the candidate color range is determined as the target color category corresponding to the pixel point, that is, the target color category is the background color category.
[0080] For example, if the color of the pixel point only belongs to the color range corresponding to the foreground color category a1 (this color range is called the candidate color range), then the foreground color category a1 corresponding to the candidate color range is determined as the target color category corresponding to the pixel point, that is, the target color category is the foreground color category a1.
[0081] In a possible implementation, based on the color range corresponding to each color category (such as the background color category and the foreground color category), if the color of the pixel point belongs to at least two candidate color ranges at the same time, the following steps can be used to determine the target color category corresponding to the pixel point:
[0082] Step S11: for each candidate color range, determine the number of pixels corresponding to the candidate color range.
[0083] For example, since the color ranges corresponding to different foreground color categories may have overlapping areas, if the color of the pixel is located in the overlapping area, the color of the pixel may belong to the color ranges corresponding to at least two foreground color categories at the same time. The color ranges corresponding to the at least two foreground color categories are called candidate color ranges, that is, the color of the pixel belongs to at least two candidate color ranges at the same time.
[0084] For example, if the color of the pixel point belongs to both the color range corresponding to the foreground color category a1 and the color range corresponding to the foreground color category a2, these two color ranges are referred to as candidate color ranges.
[0085] For example, the neighboring pixels of the pixel can be determined from the image to be detected. For example, a circular area with a radius of r is constructed with the pixel as the center, and all the pixels in the circular area are regarded as the neighboring pixels of the pixel. The value of r can be configured based on experience, such as 10, 15, 20, etc. For another example, a rectangular area with a length of m and a width of n is constructed with the pixel as the center, and all the pixels in the rectangular area are regarded as the neighboring pixels of the pixel. The values of m and n can be configured based on experience, and m and n can be the same or different. Of course, the above are just examples of determining neighboring pixels.
[0086] Exemplarily, for each candidate color range, the number of pixels corresponding to the candidate color range may be determined. Specifically, based on the colors of all neighboring pixels of the pixel, the number of pixels may be the total number of neighboring pixels whose colors only belong to the candidate color range.
[0087] For example, for the candidate color range corresponding to the foreground color category a1, based on the color of each adjacent pixel, if the color only belongs to the candidate color range, the number of pixels corresponding to the candidate color range is increased by 1. If the color does not belong to the candidate color range, the number of pixels corresponding to the candidate color range remains unchanged. If the color belongs to the candidate color range, and the color also belongs to the color range corresponding to other foreground color categories, the number of pixels corresponding to the candidate color range remains unchanged. Obviously, after performing the above processing on all adjacent pixels, the number of pixels corresponding to the candidate color range can be obtained, and this number of pixels is the total number of adjacent pixels whose colors only belong to the candidate color range.
[0088] Similarly, the number of pixels corresponding to the candidate color range corresponding to the foreground color category a2 can be obtained.
[0089] Step S12: Based on the number of pixels corresponding to each candidate color range, the color category corresponding to the candidate color range with the largest number of pixels is determined as the target color category corresponding to the pixel. For example, if the number of pixels corresponding to the candidate color range corresponding to the foreground color category a1 is greater than the number of pixels corresponding to the candidate color range corresponding to the foreground color category a2, the target color category is the foreground color category a1. If the number of pixels corresponding to the candidate color range corresponding to the foreground color category a2 is greater than the number of pixels corresponding to the candidate color range corresponding to the foreground color category a1, the target color category is the foreground color category a2.
[0090] In summary, the target color category corresponding to each pixel of the image to be detected can be determined.
[0091] In a possible implementation, each pixel of the image to be detected can be traversed, and for the currently traversed pixel, if the color of the pixel belongs to a specific color space (such as RGB, HSI, and HSV, etc.), the color of the pixel is not converted. Alternatively, if the color of the pixel does not belong to a specific color space, the color of the pixel can be converted to the color of the specific color space, and there is no restriction on this conversion process. The specific color space is a color space of the color range corresponding to each color category.
[0092] Based on the color range corresponding to each color category (such as the background color category and the foreground color category), it can be determined which color category's color range the pixel's color belongs to. Obviously, based on the definition of the color range, the pixel's color will belong to at least one color category's color range.
[0093] If the color of the pixel belongs to the color range of only one color category, then the pixel belongs to that color category, that is, the color category is used as the target color category corresponding to the pixel. If the color of the pixel belongs to the color range of at least two color categories, the color category to which the pixel belongs is determined by calculating the degree of membership, that is, the target color category corresponding to the pixel is determined by the degree of membership.
[0094] For example, the degree of membership is the degree to which a pixel belongs to a certain color category. The degree of membership of the pixel with respect to each color category can be calculated, and then the color category with the largest degree of membership is taken as the color category to which the pixel belongs, that is, the color category with the largest degree of membership is taken as the target color category of the pixel.
[0095] Assuming that the degree of membership of the pixel with respect to color category i is Di, then Di=Ri×Bi. Among them, Ri is the ratio of the number of pixels whose colors only belong to the color range of color category i among the neighboring pixels of the pixel to the total number of surrounding pixels, and the total number of surrounding pixels is the total number of all neighboring pixels. For Bi, if the color of the pixel belongs to the color range of color category i, then Bi=1, if the color of the pixel does not belong to the color range of color category i, then Bi=0. Obviously, based on the above method, the degree of membership of the pixel with respect to color category i can be determined, and then the degree of membership of the pixel with respect to each color category can be obtained.
[0096] Step 205: Generate a color category labeled image. For each pixel of the color category labeled image, the pixel value of the pixel is the index value of the target color category corresponding to the pixel.
[0097] Exemplarily, for each pixel of the image to be detected, the target color category corresponding to the pixel can be obtained. Since each color category corresponds to an index value, each pixel of the image to be detected corresponds to an index value, that is, the index value of the target color category corresponding to the pixel.
[0098] For example, suppose that foreground color category a1 is a category for lemons, and foreground color category a1 corresponds to index value 100, foreground color category a2 is a category for oranges, and foreground color category a2 corresponds to index value 200, and background color category corresponds to index value 0. Based on this, for each pixel of the image to be detected, if the target color category corresponding to the pixel is foreground color category a1, then the pixel corresponds to index value 100, if the target color category corresponding to the pixel is foreground color category a2, then the pixel corresponds to index value 200, and if the target color category corresponding to the pixel is the background color category, then the pixel corresponds to index value.
[0099] For example, based on the index value corresponding to each pixel of the image to be detected, a color category labeled image can be generated. Figure 4 As shown, it is a schematic diagram of the color category labeled image. For each pixel of the color category labeled image, the pixel value of the pixel is the index value of the target color category corresponding to the pixel, that is, the index value is used as the pixel value of the color category labeled image. For example, for all pixels corresponding to the foreground color category a1, the pixel values of these pixels are the index value 100 corresponding to the foreground color category a1, that is, the pixel values of these pixels are 100, for all pixels corresponding to the foreground color category a2, the pixel values of these pixels are the index value 200 corresponding to the foreground color category a2, that is, the pixel values of these pixels are 200, for all pixels corresponding to the background color category, the pixel values of these pixels are the index value 0 corresponding to the background color category, that is, the pixel values of these pixels are 0.
[0100] Step 206: Determine a plurality of initial connected domains from the color category labeled image.
[0101] For example, the initial connected domain is composed of pixels with the same pixel value and connected to each other. A connected domain labeling algorithm can be used to label each initial connected domain in the color category labeled image. Figure 4 As shown in the figure, all pixels with the same pixel value and connected to each other constitute the initial connected domain. Figure 4 In FIG. 5 , multiple initial connected domains are shown, each of which represents a suspected target object.
[0102] Obviously, all pixels in the initial connected domain have the same color category index value (that is, the pixel value is the index value), that is, all pixels with the same color category index value belong to the same initial connected domain, and the initial connected domain represents a suspected target object. In the subsequent process, the initial connected domain can be optimized, and each optimized target connected domain represents a real target object.
[0103] Step 207: Determine multiple candidate connected domains based on the multiple initial connected domains.
[0104] In a possible implementation, for each initial connected domain, the initial connected domain may be used as a candidate connected domain, that is, multiple initial connected domains may be used as multiple candidate connected domains, and this process will not be described in detail.
[0105] In a possible implementation, a hole filling operation may be performed on multiple initial connected domains, and the connected domains after the hole filling operation are used as candidate connected domains. The hole filling operation refers to treating the background connected domain contained in the foreground connected domain as a hole, and assigning the pixel points of the background connected domain to the pixel values of the foreground connected domain. Alternatively, an area filtering operation may be performed on multiple initial connected domains, and the connected domains after the area filtering operation are used as candidate connected domains. The area filtering operation refers to assigning the pixel points of the foreground connected domain with a smaller area to the pixel values of the background connected domain, or to the pixel values of other foreground connected domains. Alternatively, a hole filling operation and an area filtering operation may be performed on multiple initial connected domains, and the connected domains after the hole filling operation and the area filtering operation are used as candidate connected domains.
[0106] For example, performing a hole filling operation on multiple initial connected domains and using the connected domains after the hole filling operation as candidate connected domains may include: if the multiple initial connected domains include a first initial connected domain and a second initial connected domain, the second initial connected domain is located inside the first initial connected domain, and the index value of the first initial connected domain corresponds to a foreground color category, and the index value of the second initial connected domain corresponds to a background color category, then the pixel value of each pixel point in the second initial connected domain may be modified to the index value of the first initial connected domain to obtain a candidate connected domain. In addition, for the remaining initial connected domains except the first initial connected domain and the second initial connected domain, the remaining initial connected domains may be directly determined as candidate connected domains.
[0107] See also Figure 4 As shown in the figure, the initial connected domain in the upper left corner is used as the first initial connected domain (the index value corresponds to the foreground color category), and the initial connected domain inside the first initial connected domain is used as the second initial connected domain (the index value corresponds to the background color category). Based on this, the pixel value of each pixel point in the second initial connected domain is modified to the index value of the first initial connected domain. In this way, the pixel value of each pixel point in the first initial connected domain and the second initial connected domain is the same, both of which are the index values of the foreground color category, thereby obtaining a candidate connected domain. Figure 5 , which is a schematic diagram of converting an initial connected domain into a candidate connected domain. Obviously, the first initial connected domain and the second initial connected domain become the candidate connected domain in the upper left corner.
[0108] The initial connected domain in the upper right corner is used as the first initial connected domain, and the initial connected domain inside the first initial connected domain is used as the second initial connected domain. The pixel value of each pixel in the second initial connected domain is modified to the index value of the first initial connected domain. In this way, the first initial connected domain and the second initial connected domain form a candidate connected domain. Figure 5 As shown, the candidate connected domain in the upper right corner can be formed.
[0109] The initial connected domain in the lower left corner is used as the first initial connected domain, and the initial connected domain inside the first initial connected domain is used as the second initial connected domain. The pixel value of each pixel in the second initial connected domain is modified to the index value of the first initial connected domain. In this way, the first initial connected domain and the second initial connected domain form a candidate connected domain. Figure 5 As shown, the candidate connected domain in the lower left corner can be formed.
[0110] For example, performing an area filtering operation on multiple initial connected domains and using the connected domains after the area filtering operation as candidate connected domains may include: if the multiple initial connected domains include a third initial connected domain, and the area of the third initial connected domain (such as the total number of all pixels in the third initial connected domain) is less than a threshold (configured based on experience), then: when the third initial connected domain is adjacent to the initial connected domain of the foreground color category, the pixel value of each pixel in the third initial connected domain may be modified to the index value of the initial connected domain to obtain a candidate connected domain. Alternatively, when the third initial connected domain is not adjacent to the initial connected domain of the foreground color category, the pixel value of each pixel in the third initial connected domain may be modified to the index value of the background color category to obtain a candidate connected domain. In addition, for the remaining initial connected domains except the third initial connected domain, the remaining initial connected domains may be directly determined as candidate connected domains.
[0111] See also Figure 4 As shown in the figure, there is a third initial connected domain with a smaller area (the index value corresponds to the foreground color category) at the edge of the initial connected domain s1 in the middle of the upper side, and the third initial connected domain is adjacent to the initial connected domain s1. Therefore, the pixel value of each pixel in the third initial connected domain is modified to the index value of the initial connected domain s1. In this way, the pixel value of each pixel of the third initial connected domain and the initial connected domain s1 is the same, both of which are the index values of the foreground color category, thereby obtaining a candidate connected domain. See Figure 5 As shown, the third initial connected domain and the initial connected domain s1 become the candidate connected domains in the middle of the upper side.
[0112] There is a third initial connected domain at the edge of the initial connected domain s2 in the middle of the lower side, and the third initial connected domain is adjacent to the initial connected domain s2. Therefore, the pixel value of each pixel in the third initial connected domain is modified to the index value of the initial connected domain s2, thereby obtaining a candidate connected domain. Figure 5 As shown, the third initial connected domain and the initial connected domain s2 become candidate connected domains in the middle of the lower side.
[0113] There is a third initial connected domain at the edge of the initial connected domain s3 in the lower left corner, and the third initial connected domain is adjacent to the initial connected domain s3. Therefore, the pixel value of each pixel in the third initial connected domain is modified to the index value of the initial connected domain s3, thereby obtaining a candidate connected domain. Figure 5 As shown, this third initial connected domain and the initial connected domain s3 become the candidate connected domains in the lower left corner.
[0114] For example, performing hole filling and area filtering operations on multiple initial connected domains, and using the connected domains after the hole filling and area filtering operations as candidate connected domains, may include: if the multiple initial connected domains include a first initial connected domain and a second initial connected domain, and the second initial connected domain is located inside the first initial connected domain, then the pixel value of each pixel in the second initial connected domain may be modified to the index value of the first initial connected domain to obtain a candidate connected domain. If the multiple initial connected domains include a third initial connected domain, when the third initial connected domain is adjacent to an initial connected domain of a foreground color category, then the pixel value of each pixel in the third initial connected domain may be modified to the index value of the initial connected domain to obtain a candidate connected domain; when the third initial connected domain is not adjacent to an initial connected domain of a foreground color category, then the pixel value of each pixel in the third initial connected domain may be modified to the index value of the background color category to obtain a candidate connected domain. In addition, for the remaining initial connected domains other than the first initial connected domain, the second initial connected domain, and the third initial connected domain, the remaining initial connected domains may be directly determined as candidate connected domains.
[0115] See also Figure 5 As shown, it is a schematic diagram of multiple candidate connected domains obtained after hole filling operations and area filtering operations are performed on multiple initial connected domains. Among these candidate connected domains, there are 6 candidate connected domains of foreground color categories and 1 candidate connected domain of background color category (black connected domain).
[0116] Step 208: determine the candidate connected domain whose index value corresponds to the foreground color category as the target connected domain, wherein the target connected domain may be composed of pixels with the same pixel value and connected to each other.
[0117] For example, for each candidate connected domain, the pixel value of the candidate connected domain represents an index value, and the index value may correspond to a foreground color category or a background color category. Based on this, the candidate connected domain of the foreground color category (i.e., the index value of the candidate connected domain corresponds to the foreground color category) and the candidate connected domain of the background color category may be obtained, and then the candidate connected domain of the foreground color category may be determined as the target connected domain. Figure 5 As shown, the candidate connected domains of the six foreground color categories can be used as the six target connected domains.
[0118] Exemplarily, the target connected domain is composed of pixels with the same pixel value and connected to each other. Figure 5 Multiple target connected domains are shown, each of which represents a real target object. All pixels in the target connected domain have the same color category index value (i.e., the pixel value is the index value), that is, all pixels with the same color category index value belong to the same target connected domain, and all pixels with the same color category index value and interconnected form a target connected domain, and the target connected domain represents a real target object.
[0119] For example, images are labeled in color categories (see Figure 5 As shown in the figure, pixels with the same index value represent the target object or background of the same color category, while pixels with different index values represent the target object or background of different color categories, thereby completing the image segmentation task. In the image segmentation result, each foreground connected domain (i.e., target connected domain) is an independent target object. For example, all pixels with a pixel value of 100 represent the foreground color category a1 (lemon category), all pixels with a pixel value of 200 represent the foreground color category a2 (orange category), and all pixels with a pixel value of 0 represent the background color category.
[0120] For example, the image segmentation result can be obtained through operations such as connected domain labeling, hole filling and area filtering. Figure 4 The color category labeled image shown in the figure is subjected to operations such as connected domain labeling, hole filling and area filtering to obtain Figure 5 After obtaining the image segmentation result (i.e. segmenting the target objects of various colors according to the color category labeled image), the position, size and other information of various target objects can also be obtained through geometric feature calculation, that is, positioning detection is achieved, which is explained below.
[0121] Step 209: For each target connected domain, determine the circumscribed area of the target connected domain.
[0122] Exemplarily, the circumscribed area of the target connected domain may be the minimum circumscribed rectangular area, or the circumscribed area of the target connected domain may be the area after the minimum circumscribed rectangular area is expanded by a certain proportion, or the circumscribed area of the target connected domain may be the minimum circumscribed circle area, or the circumscribed area of the target connected domain may be the area after the minimum circumscribed circle area is expanded by a certain proportion, or the circumscribed area of the target connected domain may be the convex hull area. Of course, the above are just a few examples, and there is no limitation on the circumscribed area. Which specific geometric shape is used to characterize the circumscribed area of the target connected domain depends on the needs of the actual application.
[0123] Taking the minimum bounding rectangle area as an example, since each target connected domain represents a target object, the minimum bounding rectangle area of the target connected domain can represent information such as the position and size of the target object. For example, the position of the target object is the position of the minimum bounding rectangle area, such as the center point position, length and width, or the four corner point positions, or the one corner point position, length and width. The size of the target object is the length and width of the minimum bounding rectangle area.
[0124] Step 210: Determine a location detection area corresponding to the circumscribed area in the image to be detected, wherein the color category of the location detection area corresponds to the index value of the target connected domain, and mark the name of the object corresponding to the color category of the location detection area in the image to be detected.
[0125] Exemplarily, for each target connected domain, after obtaining the circumscribed area of the target connected domain, the positioning detection area corresponding to the circumscribed area can be determined from the image to be detected, that is, the positioning detection area is the circumscribed area in the image to be detected. Since the pixel value of the target connected domain represents the index value, and the index value corresponds to a certain foreground color category, the color category corresponding to the index value of the target connected domain can be determined, and this color category is the color category of the positioning detection area.
[0126] For example, if the index value of the target connected domain is 100, and the pixel value 100 corresponds to the foreground color category a1 (lemon category), the color category of the positioning detection area is the foreground color category a1. Alternatively, if the index value of the target connected domain is 200, and the pixel value 200 corresponds to the foreground color category a2 (orange category), the color category of the positioning detection area is the foreground color category a2.
[0127] Exemplarily, since each color category can also correspond to an object name, the object name corresponding to the color category of the positioning detection area can also be marked in the positioning detection area. For example, if the color category of the positioning detection area is the foreground color category a1, then the object name corresponding to the foreground color category a1 is marked in the positioning detection area, that is, lemon. If the color category of the positioning detection area is the foreground color category a2, then the object name corresponding to the foreground color category a2 is marked in the positioning detection area, that is, orange.
[0128] See also Figure 6 As shown in FIG. 1 , a schematic diagram of the positioning detection result is shown. Six positioning detection areas are determined in the image to be detected. These six positioning detection areas are connected to six target domains (see Figure 5 For each positioning detection area, the color category of the positioning detection area corresponds to the index value of the target connected domain, and the object name corresponding to the color category of the positioning detection area is marked.
[0129] As can be seen from the above technical solutions, in the embodiment of the present application, multiple color categories are pre-configured, each color category corresponds to a color range and an index value, and the positioning and detection of the image to be detected are realized based on the color category. Several object areas can be segmented based on the color range and index value corresponding to the color category, and the category of each object area can be determined based on the color range and index value corresponding to the color category. The category of each object area can be accurately determined to obtain accurate and reliable category detection results. According to the set multiple color categories, target objects of different colors can be segmented in the image, and then positioning detection can be performed. With color as a feature, image segmentation and positioning detection are performed for target objects of different categories, and target objects of similar colors but different types can be correctly processed. There can be an intersection of color ranges between color categories, and pixels belonging to the intersection part can be correctly processed, thereby distinguishing objects of similar colors but different types. No neural network is used, no training is required, and the deployment is simple, and the color category can be flexibly adjusted to adapt to different applications.
[0130] Based on the same application concept as the above method, the embodiment of the present application proposes a positioning detection device, which pre-configures multiple color categories. For each color category, the color category corresponds to a color range and an index value, see Figure 7 FIG. 1 is a schematic diagram of the structure of the device, wherein the device comprises:
[0131] The determination module 71 is used to sequentially traverse each pixel of the image to be detected; for the currently traversed pixel, determine the target color category corresponding to the pixel based on the color range to which the color of the pixel belongs;
[0132] A generating module 72 is used to generate a color category labeled image, wherein for each pixel point of the color category labeled image, the pixel value of the pixel point is the index value of the target color category corresponding to the pixel point;
[0133] A processing module 73 is used to determine a target connected domain based on the color category labeled image, and determine a circumscribed area of the target connected domain, wherein the target connected domain is composed of pixels having the same pixel value and being interconnected;
[0134] The detection module 74 is used to determine a positioning detection area corresponding to the circumscribed area in the image to be detected, and the color category of the positioning detection area corresponds to the index value of the target connected domain.
[0135] Exemplarily, when the determination module 71 determines the target color category corresponding to the pixel point based on the color range to which the color of the pixel point belongs, it is specifically used to: based on the color range corresponding to each color category, if the color of the pixel point belongs to only one candidate color range, then the color category corresponding to the candidate color range can be determined as the target color category; or, based on the color range corresponding to each color category, if the color of the pixel point belongs to at least two candidate color ranges at the same time, then: for each candidate color range, the number of pixels corresponding to the candidate color range can be determined; wherein, based on the colors of all adjacent pixels of the pixel point, the number of pixels is the total number of adjacent pixels whose colors belong only to the candidate color range; and, based on the number of pixels corresponding to each candidate color range, the color category corresponding to the candidate color range with the maximum number of pixels is determined as the target color category.
[0136] Exemplarily, the multiple color categories include a background color category and at least two foreground color categories; when the processing module 73 determines the target connected domain based on the color category labeled image, it is specifically used to: determine multiple initial connected domains from the color category labeled image; determine multiple candidate connected domains based on the multiple initial connected domains; wherein, if the multiple initial connected domains include a first initial connected domain and a second initial connected domain, the second initial connected domain is located inside the first initial connected domain, the index value of the first initial connected domain corresponds to the foreground color category, and the index value of the second initial connected domain corresponds to the background color category, then the pixel value of each pixel point in the second initial connected domain is modified to the index value of the first initial connected domain to obtain a candidate connected domain; and the candidate connected domain whose index value corresponds to the foreground color category is determined as the target connected domain.
[0137] Exemplarily, when determining multiple candidate connected domains based on the multiple initial connected domains, the processing module 73 is specifically used to: if the multiple initial connected domains include a third initial connected domain, and the area of the third initial connected domain is less than a threshold, when the third initial connected domain is adjacent to the initial connected domain of the foreground color category, modify the pixel value of each pixel in the third initial connected domain to the index value of the initial connected domain to obtain a candidate connected domain; when the third initial connected domain is not adjacent to the initial connected domain of the foreground color category, modify the pixel value of each pixel in the third initial connected domain to the index value of the background color category to obtain a candidate connected domain; for the remaining initial connected domains except the first initial connected domain, the second initial connected domain and the third initial connected domain, determine the remaining initial connected domains as candidate connected domains.
[0138] Exemplarily, the multiple color categories include a background color category and at least two foreground color categories, and the processing module 73 is further used to obtain, for each foreground color category, a configured color range and a configured index value corresponding to the foreground color category; wherein the color ranges corresponding to different foreground color categories do not have overlapping areas or have overlapping areas, and the index values corresponding to different foreground color categories are different; and, obtain the color range and the configured index value corresponding to the background color category; wherein a union range is taken for the color ranges corresponding to all foreground color categories, and the union range is excluded from the configured complete color range to obtain the color range corresponding to the background color category; wherein the index value corresponding to the background color category is different from the index value corresponding to each foreground color category.
[0139] Exemplarily, for each color category, the color category also corresponds to an object name, and the object name represents a unique identifier of the object; the detection module 74 is also used to mark the object name corresponding to the color category of the positioning detection area in the positioning detection area after determining the positioning detection area in the image to be detected.
[0140] Based on the same application concept as the above method, an electronic device is proposed in the embodiment of the present application, see Figure 8 As shown, the electronic device includes: a processor 81 and a machine-readable storage medium 82, the machine-readable storage medium 82 stores machine-executable instructions that can be executed by the processor 81; the processor 81 is used to execute the machine-executable instructions to implement the positioning detection method of the above example of the present application.
[0141] Based on the same application concept as the above method, an embodiment of the present application further provides a machine-readable storage medium, on which a number of computer instructions are stored. When the computer instructions are executed by a processor, the positioning detection method disclosed in the above example of the present application can be implemented.
[0142] The above-mentioned machine-readable storage medium may be any electronic, magnetic, optical or other physical storage device, which may contain or store information, such as executable instructions, data, etc. For example, the machine-readable storage medium may be: RAM (Radom Access Memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state drive, any type of storage disk (such as CD, DVD, etc.), or similar storage medium, or a combination thereof.
[0143] Based on the same application concept as the above method, an embodiment of the present application also provides a computer program product, which may include a computer program; wherein, when the computer program is executed by a processor, it can implement the positioning detection method disclosed in the above example of the present application.
[0144] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the embodiments of the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0145] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A positioning detection method, characterized in that: Preconfigure a plurality of color categories, and for each color category, the color category corresponds to a color range and an index value. The method includes: Traverse each pixel of the image to be detected in sequence; for the currently traversed pixel, determine the target color category corresponding to the pixel based on the color range to which the color of the pixel belongs; Generate a color category labeled image, wherein for each pixel point of the color category labeled image, the pixel value of the pixel point is the index value of the target color category corresponding to the pixel point; Determine a target connected domain based on the color category labeled image, and determine a circumscribed area of the target connected domain, wherein the target connected domain is composed of pixels having the same pixel value and being interconnected; A positioning detection area corresponding to the circumscribed area is determined in the image to be detected, and a color category of the positioning detection area corresponds to an index value of the target connected domain.
2. The method according to claim 1, characterized in that The determining of the target color category corresponding to the pixel point based on the color range to which the color of the pixel point belongs includes: Based on the color range corresponding to each color category, if the color of the pixel point belongs to only one candidate color range, the color category corresponding to the candidate color range is determined as the target color category; Alternatively, based on the color range corresponding to each color category, if the color of the pixel belongs to at least two candidate color ranges at the same time, for each candidate color range, the number of pixels corresponding to the candidate color range is determined; wherein, based on the colors of all neighboring pixels of the pixel, the number of pixels is the total number of neighboring pixels whose colors belong only to the candidate color range; Based on the number of pixels corresponding to each candidate color range, the color category corresponding to the candidate color range with the maximum number of pixels is determined as the target color category.
3. The method according to claim 1, characterized in that The plurality of color categories include a background color category and at least two foreground color categories; The determining of the target connected domain based on the color category labeled image comprises: Determining a plurality of initial connected domains from the color category labeled image; Determine a plurality of candidate connected domains based on the plurality of initial connected domains; wherein, if the plurality of initial connected domains include a first initial connected domain and a second initial connected domain, the second initial connected domain is located inside the first initial connected domain, the index value of the first initial connected domain corresponds to a foreground color category, and the index value of the second initial connected domain corresponds to a background color category, then modify the pixel value of each pixel point in the second initial connected domain to the index value of the first initial connected domain, and obtain the candidate connected domain; The candidate connected domain whose index value corresponds to the foreground color category is determined as the target connected domain.
4. The method according to claim 3, characterized in that The determining of a plurality of candidate connected domains based on the plurality of initial connected domains further comprises: If the multiple initial connected domains include a third initial connected domain, and the area of the third initial connected domain is smaller than a threshold, when the third initial connected domain is adjacent to the initial connected domain of the foreground color category, the pixel value of each pixel in the third initial connected domain is modified to the index value of the initial connected domain to obtain a candidate connected domain; when the third initial connected domain is not adjacent to the initial connected domain of the foreground color category, the pixel value of each pixel in the third initial connected domain is modified to the index value of the background color category to obtain a candidate connected domain; For the remaining initial connected domains except the first initial connected domain, the second initial connected domain, and the third initial connected domain, the remaining initial connected domains are determined as candidate connected domains.
5. The method according to claim 1, characterized in that: The plurality of color categories include a background color category and at least two foreground color categories, the method further comprising: For each foreground color category, obtain a configured color range and a configured index value corresponding to the foreground color category; wherein the color ranges corresponding to different foreground color categories have no overlapping area or have overlapping areas, and the index values corresponding to different foreground color categories are different; Obtain the color range and configured index value corresponding to the background color category; wherein, take the union range of the color ranges corresponding to all foreground color categories, exclude the union range from the configured complete color range, and obtain the color range corresponding to the background color category; wherein the index value corresponding to the background color category is different from the index value corresponding to each foreground color category.
6. The method according to any one of claims 1 to 5, characterized in that: For each color category, the color category also corresponds to an object name, and the object name represents a unique identifier of the object; after determining the positioning detection area corresponding to the circumscribed area in the image to be detected, the method further includes: The positioning detection area is marked with an object name corresponding to the color category of the positioning detection area.
7. A positioning detection device, characterized in that: A plurality of color categories are preconfigured, and for each color category, the color category corresponds to a color range and an index value, and the device comprises: A determination module is used to sequentially traverse each pixel of the image to be detected; for the currently traversed pixel, determine the target color category corresponding to the pixel based on the color range to which the color of the pixel belongs; A generating module, used for generating a color category labeled image, wherein for each pixel point of the color category labeled image, the pixel value of the pixel point is the index value of the target color category corresponding to the pixel point; A processing module, configured to determine a target connected domain based on the color category labeled image, and determine a circumscribed area of the target connected domain, wherein the target connected domain is composed of interconnected pixel points having the same pixel value; The detection module is used to determine a positioning detection area corresponding to the circumscribed area in the image to be detected, wherein the color category of the positioning detection area corresponds to the index value of the target connected domain.
8. The device according to claim 7, characterized in that in, The determination module is specifically used to determine the target color category corresponding to the pixel point based on the color range to which the color of the pixel point belongs: based on the color range corresponding to each color category, if the color of the pixel point belongs to only one candidate color range, then the color category corresponding to the candidate color range is determined as the target color category; or, based on the color range corresponding to each color category, if the color of the pixel point belongs to at least two candidate color ranges at the same time, for each candidate color range, the number of pixels corresponding to the candidate color range is determined; wherein, based on the colors of all neighboring pixels of the pixel point, the number of pixels is the total number of neighboring pixels whose colors belong only to the candidate color range; based on the number of pixels corresponding to each candidate color range, the color category corresponding to the candidate color range with the largest number of pixels is determined as the target color category; Wherein, the multiple color categories include a background color category and at least two foreground color categories; when the processing module determines the target connected domain based on the color category labeled image, it is specifically used to: determine multiple initial connected domains from the color category labeled image; determine multiple candidate connected domains based on the multiple initial connected domains; wherein, if the multiple initial connected domains include a first initial connected domain and a second initial connected domain, the second initial connected domain is located inside the first initial connected domain, the index value of the first initial connected domain corresponds to the foreground color category, and the index value of the second initial connected domain corresponds to the background color category, then the pixel value of each pixel point in the second initial connected domain is modified to the index value of the first initial connected domain to obtain the candidate connected domain; the candidate connected domain whose index value corresponds to the foreground color category is determined as the target connected domain; Wherein, when the processing module determines a plurality of candidate connected domains based on the plurality of initial connected domains, it is specifically used to: if the plurality of initial connected domains include a third initial connected domain, and the area of the third initial connected domain is less than a threshold, when the third initial connected domain is adjacent to the initial connected domain of the foreground color category, modify the pixel value of each pixel in the third initial connected domain to the index value of the initial connected domain, and obtain the candidate connected domain; when the third initial connected domain is not adjacent to the initial connected domain of the foreground color category, modify the pixel value of each pixel in the third initial connected domain to the index value of the background color category, and obtain the candidate connected domain; for the remaining initial connected domains except the first initial connected domain, the second initial connected domain and the third initial connected domain, determine the remaining initial connected domains as candidate connected domains; Wherein, the multiple color categories include a background color category and at least two foreground color categories, and the processing module is further used to obtain, for each foreground color category, a configured color range and a configured index value corresponding to the foreground color category; wherein the color ranges corresponding to different foreground color categories do not have overlapping areas or have overlapping areas, and the index values corresponding to different foreground color categories are different; and, obtain the color range and the configured index value corresponding to the background color category; wherein a union range is taken for the color ranges corresponding to all foreground color categories, and the union range is excluded from the configured complete color range to obtain the color range corresponding to the background color category; wherein the index value corresponding to the background color category is different from the index value corresponding to each foreground color category; Among them, for each color category, the color category also corresponds to an object name, and the object name represents the unique identification of the object; the detection module is also used to mark the object name corresponding to the color category of the positioning detection area in the positioning detection area after determining the positioning detection area in the image to be detected.
9. An electronic device, characterized in that: include: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor; The processor is used to execute machine executable instructions to implement the method described in any one of claims 1-6.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
SAR (synthetic aperture radar) segmentation method based on polychotomy weighting segmentation
CN103020977A
License plate detection method based on multi-information neighborhood voting
CN103279736A
Vehicle body color identification method
CN105005766A
Image segmentation method based on voting strategy
CN105701807A
Image segmentation method and image segmentation device
CN106340023A
