Tobacco field image preprocessing method
By calculating the minimum circumference circle and pixel proportion of vector surface pattern spots in tobacco field images for clustering, and combining historical image judgment, the accuracy of the count of tobacco plants in tobacco field images is solved, and the number of tobacco plants is improved accuracy.
Patent Information
- Application Number
- CN202411176730.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2025-01-03
AI Technical Summary
Prior Art When obtaining the number of tobacco plants in tobacco field images, there is a problem of accuracy due to uneven vector surface spots being vector surface spots of tobacco plants, especially in the target image, other plants other than tobacco plants are included. hour.
By obtaining the vector surface map of the target tobacco field image, calculate the radius and pixel proportion of the minimum circumference circle of each vector surface map, perform clustering, and judge the central vector surface map and the preset vector surface map based on the clustering results. The similarity of the tobacco plants and suspected non-smoking plants are determined by combining historical tobacco fields to determine whether the vector surface spots in suspected non-smoking plants are non-smoking plants vector surface spots, and delete the vector surface spots of non-smoking plants to improve accuracy.
The accuracy of the number of tobacco plants in tobacco fields is improved. Through the combination of clustering and historical images, the vector surface pattern of tobacco plants and non-smoking plants is effectively distinguished, avoiding misjudgment and improving the accuracy of tobacco plants counting.
Smart Images

Figure CN119251668A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of image processing, and in particular to a preprocessing method for tobacco field images. Background Art
[0002] Tobacco plant counting is an important indicator in tobacco monitoring and evaluation. The prior art discloses a method for obtaining the number of tobacco plants based on photographed tobacco field images. For example, Chinese patent application number CN202311295114.9 discloses a method for processing tobacco field images. The method first obtains a vector surface patch sequence corresponding to the target tobacco field image, then analyzes the number of tobacco plants included in each vector surface patch, and then obtains the number of tobacco plants in the tobacco field image by summing the number of tobacco plants included in all vector surface patches. This method is applicable to the case where each vector surface patch in the target tobacco field image is a tobacco plant vector surface patch. However, when the target tobacco plant image includes plants other than tobacco plants, the above-mentioned vector surface patches are not necessarily all tobacco plant vector surface patches, and there is a problem of inaccurate number of tobacco plants in the above-mentioned tobacco field image. Summary of the invention
[0003] The object of the present invention is to provide a method for preprocessing tobacco field images so as to improve the accuracy of the number of tobacco plants in the tobacco field images obtained above.
[0004] According to the present invention, a method for preprocessing a tobacco field image is provided, the preprocessing method comprising the following steps:
[0005] S100, obtaining a vector surface image corresponding to a target tobacco field image; the vector surface image includes a plurality of vector surface spots.
[0006] S200, clustering the vector surface spots in the vector surface map according to the radius and pixel ratio of the minimum circumscribed circle of each vector surface spot in the vector surface map; the pixel ratio of any vector surface spot is the ratio of the number of pixel points included in the vector surface spot to the number of pixel points included in the minimum circumscribed circle of the vector surface spot.
[0007] S300, judging whether the similarity between the central vector surface spots of the clustered classes and the preset vector surface spots is greater than or equal to the preset similarity threshold in the order of the number of vector surface spots included from most to least, if not, continue to judge the next class; otherwise, stop judging; wherein, the radius of the minimum circumscribed circle of the central vector surface spots of any class is the average radius of the minimum circumscribed circles of the vector surface spots in the class, and the pixel ratio of the central vector surface spots of any class is the average radius pixel ratio of the vector surface spots in the class; the preset vector surface spots are preset tobacco plant vector surface spots that match the growth stage of the tobacco plants corresponding to the target tobacco field image.
[0008] S400: If there is a class whose central vector surface pattern has a similarity with a preset vector surface pattern that is greater than or equal to a preset similarity threshold, the class is determined to be a tobacco plant class, and other classes are determined to be suspected non-tobacco plant classes.
[0009] S500, for the jth vector surface patch p in the i-th suspected non-tobacco plant class i,j , determine the vector surface map corresponding to the historical tobacco field image and p i,j Whether there are vector surface spots in the area with the same position, if so, enter S600; the value range of i is 1 to n, n is the number of suspected non-tobacco plant classes; the value range of j is 1 to m, m is the number of vector surface spots in the i-th suspected non-tobacco plant class; the shooting area of the historical tobacco field image is the same as that of the target tobacco field image, and the shooting time of the historical tobacco field image is earlier than the shooting time of the target tobacco field image.
[0010] S600, obtain the historical tobacco field image with p i,j The radius lr of the minimum circumscribed circle of the vector surface patches in the same area i,j And pixel ratio lc i,j .
[0011] S700, according to lr i,j , lc i,j 、r i,j and c i,j Determine p i,j Whether it is a non-tobacco plant vector surface patch; r i,j For p i,j The radius of the smallest circumscribed circle, c i,j For p i,j Pixel ratio.
[0012] S800, deleting non-tobacco plant vector surface patches in the vector surface map corresponding to the target tobacco field image to obtain an updated vector surface map.
[0013] S900: Obtain the number of tobacco plants in the updated vector surface map.
[0014] Compared with the prior art, the present invention has at least the following beneficial effects:
[0015] On the basis of obtaining the vector surface map corresponding to the target tobacco field image, the present invention also obtains the radius of the minimum circumscribed circle and the pixel ratio of each vector surface spot in the vector surface map. Based on the different radii and pixel ratios of the minimum circumscribed circles of different vector surface spots in the vector surface map, the present invention clusters the vector surface spots in the vector surface map. The radii and pixel ratios of the minimum circumscribed circles of the vector surface spots in the same class are similar, while the radii and / or pixel ratios of the vector surface spots in different classes are quite different. For the classes obtained by clustering, the central vector surface spot and the preset vector surface spot are judged in the order of the number of vector surface spots included from large to small. Similarity, if the similarity is high, the corresponding class is determined to be the tobacco plant class, and the other classes are suspected non-tobacco plant classes; the above-mentioned method of judging in the order of the number of vector surface spots from large to small is conducive to improving the efficiency of obtaining tobacco plant classes, and for suspected non-tobacco plant classes, the present invention further combines historical tobacco field images to judge whether the vector surface spots in each suspected non-tobacco plant class are non-tobacco plant vector surface spots, so as to avoid the situation where tobacco plant vector surface spots exist in suspected non-tobacco plant classes, thereby improving the accuracy of judging whether the vector surface spots in the vector surface image are tobacco plant vector surface spots, thereby improving the accuracy of the number of tobacco plants in the target tobacco field image finally obtained. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0017] Figure 1 The present invention provides a flowchart of a method for preprocessing tobacco field images. DETAILED DESCRIPTION
[0018] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0019] According to this embodiment, Figure 1 As shown, a method for preprocessing a tobacco field image is provided, and the method comprises the following steps:
[0020] S100, obtaining a vector surface image corresponding to a target tobacco field image; the vector surface image includes a plurality of vector surface spots.
[0021] In this embodiment, there is no overlap of tobacco leaves between different tobacco plants in the target tobacco field image, that is, the target tobacco field image is taken at an early stage, such as the root extension stage, so the vector surface patches corresponding to different tobacco plants are relatively independent. The processing method of this embodiment is more suitable for the situation where other plants other than tobacco plants in the tobacco field are relatively far away from the tobacco plants (that is, the leaves do not overlap) and the appearance of other plants and tobacco plants is greatly different, and the appearance difference includes the size difference of the plants, the shape difference of the leaves, and the density difference of the leaves.
[0022] Those skilled in the art know that any method for obtaining a vector surface map corresponding to a target tobacco field image in the prior art falls within the protection scope of the present invention; as a specific implementation, S100 includes:
[0023] S110, obtaining a saturation band map corresponding to the target tobacco field image.
[0024] In this embodiment, the target tobacco field image is a visible light image. Those skilled in the art know that any method of obtaining a saturation band map corresponding to a visible light image in the prior art falls within the protection scope of the present invention.
[0025] S120, updating the saturation of the pixel points in the saturation band map whose saturation is less than a preset saturation threshold to null, to obtain an updated saturation band map.
[0026] In this embodiment, the initial saturation threshold is an empirical value. If the saturation of a pixel in the saturation band map is greater than or equal to the preset saturation threshold, the saturation of the pixel is not updated; otherwise, the saturation of the pixel is updated to nodata.
[0027] S130, performing raster-to-vector surface processing on the updated saturation band map to obtain a vector surface map.
[0028] Those skilled in the art know that any method of converting a raster into a vector plane in the prior art falls within the protection scope of the present invention.
[0029] Based on S110 - S130 , a vector surface map corresponding to the target tobacco field image can be obtained. The vector surface map includes a number of vector surface spots, and any vector surface spot is a tobacco plant vector surface spot or a non-tobacco plant vector surface spot.
[0030] S200, clustering the vector surface spots in the vector surface map according to the radius and pixel ratio of the minimum circumscribed circle of each vector surface spot in the vector surface map; the pixel ratio of any vector surface spot is the ratio of the number of pixel points included in the vector surface spot to the number of pixel points included in the minimum circumscribed circle of the vector surface spot.
[0031] In this embodiment, the radii of the minimum circumscribed circles of the vector surface patches corresponding to plants of different sizes in the target tobacco field image are different, and the radius of the minimum circumscribed circle of the vector surface patches corresponding to larger plants is larger.
[0032] Those skilled in the art know that any method for obtaining the minimum circumscribed circle in the prior art falls within the protection scope of the present invention.
[0033] In this embodiment, the pixel proportions of the vector surface spots corresponding to plants with different leaf shapes and leaf densities in the target tobacco field image are different, and the pixel proportions of the vector surface spots corresponding to plants with wider leaf shapes and denser leaves are larger.
[0034] In this embodiment, the radius and pixel ratio of the minimum circumscribed circle of the vector surface spots of different types of plants in the target tobacco field image are quite different, while the radius and pixel ratio of the minimum circumscribed circle of the vector surface spots of the same type of plants are relatively different; the distance between the vector surface spots in the same class obtained by clustering is relatively small, that is, the difference in the radius and pixel ratio of the minimum circumscribed circle of the vector surface spots in the same class is relatively small; the distance between the vector surface spots in different classes obtained by clustering is relatively large, that is, the difference in the radius of the minimum circumscribed circle of the vector surface spots in different classes is relatively large or / and the difference in pixel ratio is relatively large. As a preferred specific implementation method, the vector surface spots in the vector surface image are clustered using the k-means algorithm, and S200 includes:
[0035] S210, using the k-means algorithm to cluster the vector surface spots in the vector surface map into two categories, namely the first initial category and the second initial category; during the clustering process, the distance between the first vector surface spot and the second vector surface spot is positively correlated with the difference value of the radius of the minimum circumscribed circle of the first vector surface spot and the second vector surface spot, and the distance between the first vector surface spot and the second vector surface spot is positively correlated with the difference value of the pixel proportion of the first vector surface spot and the second vector surface spot; the first vector surface spot is any vector surface spot in the vector surface map, and the second vector surface spot is any vector surface spot in the vector surface except the first vector surface spot.
[0036] In this embodiment, each vector surface spot is taken as an object to be clustered, one vector surface spot is an object, the x coordinate of each vector surface spot is the radius of the minimum circumscribed circle of the corresponding vector surface spot, and the y coordinate of each vector surface spot is the pixel ratio of the corresponding vector surface spot; as a preferred specific implementation method, the distance between the first vector surface spot and the second vector surface spot is dis 1,2= w1 × f(|r1 - r2|) + (1 - w1) × g(|c1 - c2|), where r1 and r2 are the radii of the minimum circumscribed circles of the first vector surface patch and the second vector surface patch respectively, f() is the normalization process corresponding to the radius of the minimum circumscribed circle, c1 and c2 are the pixel occupancy ratios of the first vector surface patch and the second vector surface patch respectively, g() is the normalization process corresponding to the pixel occupancy ratio, and w1 is a preset weight, where 0 < w1 < 1. The method for obtaining the distance between any two vector surface patches is similar to the method for obtaining the distance between the first vector surface patch and the second vector surface patch described above, and will not be elaborated here.
[0037] As a preferred specific embodiment, the process of obtaining w1 includes:
[0038] S211, obtain a sample tobacco field image set; the sample tobacco field image set includes a number of sample tobacco field images, and each sample tobacco field image has the same growth stage as the tobacco plants corresponding to the target tobacco field image.
[0039] In this embodiment, if the growth stage of the tobacco plants corresponding to the target tobacco field image is the 5th day of the root elongation stage, the growth stage of the tobacco plants corresponding to each sample tobacco field image is also the 5th day of the root elongation stage; if the growth stage of the tobacco plants corresponding to the target tobacco field image is the 8th day of the root elongation stage, the growth stage of the tobacco plants corresponding to each sample tobacco field image is also the 8th day of the root elongation stage.
[0040] In this embodiment, the scaling ratio of each sample tobacco field image is the same as that of the target tobacco field image.
[0041] S212, obtain the tobacco plant vector surface patches and non-tobacco plant vector surface patches in the vector surface corresponding to each sample tobacco field image in the sample tobacco field image set.
[0042] In this embodiment, the method for obtaining the vector surface corresponding to each sample tobacco field image is similar to the method for obtaining the vector surface corresponding to the target tobacco field image described above, and will not be elaborated here.
[0043] Optionally, the tobacco plant vector surface patches and non-tobacco plant vector surface patches are distinguished manually.
[0044] S213, obtain the distance between any two tobacco plant vector surface patches in the vector surface corresponding to each sample tobacco field image, and construct a first distance set between tobacco plants; the first distance set includes the distances between any two tobacco plant vector surface patches in the vector surface corresponding to each sample tobacco field image, and the distance between any two tobacco plant vector surface patches is the sum of the first difference value and the second difference value of the corresponding two tobacco plant vector surface patches. The first difference value is the product of the first variable w0 and r', where r' is the normalized difference value of the radius of the minimum circumscribed circle, and the second difference value is the product of (1 - w0) and c', where c' is the normalized difference value of the pixel occupancy ratio.
[0045] In this embodiment, the radius difference value is the absolute value of the radius difference, and the pixel proportion difference value is the absolute value of the pixel proportion difference.
[0046] In this embodiment, for the vector surface map corresponding to each sample tobacco field image, the distance between any two tobacco plant vector surface spots in the vector surface map is obtained and appended to the first empty set, thereby obtaining a first distance set, which includes the distance between any two tobacco plant vector surface spots in the vector surface map corresponding to all sample tobacco field images.
[0047] Those skilled in the art know that any normalization method in the prior art falls within the protection scope of the present invention.
[0048] S214, obtaining the distance between any tobacco plant vector surface patch and any non-tobacco plant vector surface patch in the vector surface map corresponding to each sample tobacco field image, and constructing a second distance set between tobacco plants and non-tobacco plants; the second distance set includes the distance between any tobacco plant vector surface patch and any non-tobacco plant vector surface patch in the vector surface map corresponding to each sample tobacco field image, and the distance between any tobacco plant vector surface patch and any non-tobacco plant vector surface patch is the sum of the first difference value and the second difference value of the corresponding tobacco plant vector surface patch and the non-tobacco plant vector surface patch.
[0049] In this embodiment, for the vector surface map corresponding to each sample tobacco field image, the distance between any tobacco plant vector surface spot and any non-tobacco plant vector surface spot in the vector surface map is obtained, and it is appended to the second empty set. Thus, a second distance set can be obtained, which includes the distance between any tobacco plant vector surface spot and any non-tobacco plant vector surface spot in the vector surface map corresponding to all sample tobacco field images.
[0050] S215, on the premise of satisfying a preset condition, obtaining w0 that maximizes the difference between the distance mean of the second distance set and the distance mean of the first distance set; the preset condition includes: each distance in the first distance set is greater than or equal to 0 and less than or equal to 1, each distance in the second distance set is greater than or equal to 0 and less than or equal to 1, 0 <w0<1。
[0051] Those skilled in the art know that any method for obtaining the optimal solution in the prior art falls within the protection scope of the present invention. Optionally, a value range of w0 that satisfies a preset condition is first obtained, and then w0 that can maximize the difference between the mean distance of the second distance set and the mean distance of the first distance set is obtained within the value range.
[0052] S216: Determine w0, which is obtained so as to maximize the difference between the mean distance value of the second distance set and the mean distance value of the first distance set, as w1.
[0053] The w1 obtained based on S211-S216 can reduce the distance between tobacco plant vector surface patches and enlarge the distance between tobacco plant vector surface patches and non-tobacco plant vector surface patches, which is conducive to classifying tobacco plant vector surface patches into one class and classifying non-tobacco plant vector surface patches and tobacco plant vector surface patches into different classes.
[0054] S220: If the variance of the vector surface spots in the first initial class is greater than a preset variance threshold and the variance of the vector surface spots in the second initial class is less than or equal to the preset variance threshold, proceed to S230.
[0055] In this embodiment, if the variance of the vector surface spots in the first initial class is less than or equal to the preset variance threshold and the variance of the vector surface spots in the second initial class is less than or equal to the preset variance threshold, then the distance between the central vector surface spots of the first initial class and the central vector surface spots of the second initial class is determined. If the distance is greater than or equal to the preset distance threshold, the first initial class and the second initial class are determined as the final result of clustering the vector surface spots in the vector surface map using the k-means algorithm; if the distance is less than the preset distance threshold, then the class composed of all the vector surface spots in the vector surface map is determined as the final result of clustering the vector surface spots in the vector surface map using the k-means algorithm, that is, there is only one class. In the case where the class composed of all the vector surface spots in the vector surface map is determined as the final result of clustering the vector surface spots in the vector surface map using the k-means algorithm, S300-S900 are no longer executed, but the number of tobacco plants in the vector surface map corresponding to the target tobacco field image is obtained.
[0056] In this embodiment, the preset variance threshold is an empirical value. If the variance of the vector surface spots in the first initial class is greater than the preset variance threshold, it is determined that the difference between the radius of the minimum circumscribed circle and the pixel ratio of the vector surface spots in the first initial class is large; if the variance of the vector surface spots in the first initial class is less than or equal to the preset variance threshold, it is determined that the difference between the radius of the minimum circumscribed circle and the pixel ratio of the vector surface spots in the first initial class is small. As a specific implementation, S220 includes:
[0057] S221, obtain the central vector surface patch of the first initial class; the radius of the minimum circumscribed circle of the central vector surface patch of the first initial class is the average radius of the minimum circumscribed circle of the vector surface patches in the first initial class, and the pixel ratio of the central vector surface patch of the first initial class is the average pixel ratio of the vector surface patches in the first initial class.
[0058] S222, obtaining the difference value between each vector surface spot in the first initial class and the central vector surface spot of the first initial class; the difference value between any vector surface spot in the first initial class and the central vector surface spot of the first initial class is positively correlated with the radius difference value between the vector surface spot in the first initial class and the central vector surface spot of the first initial class, and the difference value between any vector surface spot in the first initial class and the central vector surface spot of the first initial class is positively correlated with the pixel ratio difference value between the vector surface spot in the first initial class and the central vector surface spot of the first initial class.
[0059] In this embodiment, the method for obtaining the difference value between each vector surface spot in the first initial class and the central vector surface spot of the first initial class is similar to the above-mentioned method for obtaining the distance between the first vector surface spot and the second vector surface spot, and will not be repeated here.
[0060] S223, obtaining the variance of the vector surface spots in the first initial class according to the difference value between each vector surface spot in the first initial class and the central vector surface spot.
[0061] In this embodiment, the sum of the squares of the difference values between each vector surface spot in the first initial class and the central vector surface spot of the first initial class is first obtained, and then the ratio of the sum of squares to the number of vector surface spots included in the first initial class is determined as the variance of the vector surface spots in the first initial class.
[0062] In this embodiment, the method for obtaining the variance of the vector surface spots in the second initial class is similar to the method for obtaining the variance of the vector surface spots in the first initial class, and will not be described in detail here.
[0063] S230, using a k-means algorithm to cluster the vector surface spots in the first initial class into two classes, namely a first subclass and a second subclass.
[0064] In this embodiment, the method of using the k-means algorithm to cluster the vector surface images in the first initial class into two categories is similar to the method of using the k-means algorithm to cluster the vector surface images in the vector surface image into two categories, which will not be repeated here.
[0065] S240: If the variance of the vector surface spots in the first subclass is less than or equal to the preset variance threshold and the variance of the vector surface spots in the second subclass is less than or equal to the preset variance threshold, proceed to S250.
[0066] In this embodiment, the method for obtaining the variance of the vector surface spots in the first subclass and the method for obtaining the variance of the vector surface spots in the second subclass are similar to the above-mentioned method for obtaining the variance of the vector surface spots in the first initial class, and will not be repeated here.
[0067] S250, if the distance between the central vector surface spots of the second initial class and the first subclass is greater than or equal to the preset distance threshold, and the distance between the central vector surface spots of the second initial class and the second subclass is greater than or equal to the preset distance threshold, then the second initial class, the first subclass and the second subclass are determined as the final result of clustering the vector surface spots in the vector surface map using the k-means algorithm.
[0068] In this embodiment, the preset distance threshold is an empirical value. If the distance between the central vector surface patch between the second initial class and the first subclass is greater than or equal to the preset distance threshold, it means that the radius and pixel percentage of the minimum circumscribed circle of the vector area patch in the second initial class and the first subclass are quite different; if the distance between the central vector surface patch between the second initial class and the first subclass is less than the preset distance threshold, it means that the radius and pixel percentage of the minimum circumscribed circle of the vector area patch in the second initial class and the first subclass are both relatively small, and the vector surface patches in the second initial class and the first subclass correspond to the same type of plants, then the second initial class and the first subclass are merged into one class.
[0069] As a specific implementation, S250 also includes: if the distance between the central vector surface spots between the first subclass and the second initial class is greater than or equal to a preset distance threshold, and the distance between the central vector surface spots between the second subclass and the second initial class is less than the preset distance threshold, then the second subclass and the second initial class are merged into a first merged class, and the first subclass and the first merged class are determined as the final result of clustering the vector surface spots in the vector surface map using the k-means algorithm.
[0070] As a specific implementation, S240 further includes: if the variance of the vector surface spots in the first subclass is greater than a preset variance threshold and the variance of the vector surface spots in the second subclass is less than or equal to the preset variance threshold, then entering S241.
[0071] S241, using the k-means algorithm to cluster the vector surface spots in the first subclass into two classes, namely the first intermediate class and the second intermediate class.
[0072] S242: If the variance of the vector surface spots in the first intermediate class is less than or equal to the preset variance threshold and the variance of the vector surface spots in the second intermediate class is less than or equal to the preset variance threshold, proceed to S243.
[0073] S243, if the distance between the central vector surface patch of any of the second subclass, the first intermediate class and the second intermediate class and the second initial class is greater than or equal to the preset distance threshold, the distance between the central vector surface patch of the first intermediate class and the second subclass is greater than or equal to the preset distance threshold, and the distance between the central vector surface patch of the second intermediate class and the second subclass is greater than or equal to the preset distance threshold, then the second initial class, the second subclass, the first intermediate class and the second intermediate class are determined as the final result of clustering the vector surface patches in the vector surface map using the k-means algorithm.
[0074] As a specific implementation, S240 further includes: if the variance of the vector surface spots in the first subclass is greater than a preset variance threshold and the variance of the vector surface spots in the second subclass is greater than the preset variance threshold, then entering S244.
[0075] S244, using the k-means algorithm to cluster the vector surface spots in the first subclass into two classes, namely the first intermediate class and the second intermediate class.
[0076] S245, using the k-means algorithm, the vector surface patches in the second subclass are clustered into two classes, namely the third intermediate class and the fourth intermediate class.
[0077] S246, if the distance between the central vector surface patch of only the third intermediate class and the second initial class among the first intermediate class, the second intermediate class, the third intermediate class and the fourth intermediate class is less than the preset distance threshold, and the distance between the central vector surface patch of only the fourth intermediate class and the first intermediate class among the third intermediate class and the fourth intermediate class is less than the preset distance threshold, then the third intermediate class and the second initial class are merged into a second merged class, the fourth intermediate class and the first intermediate class are merged into a third merged class, and the second merged class, the second intermediate class and the third merged class are determined as the final result of clustering the vector surface patches in the vector surface map using the k-means algorithm.
[0078] In this embodiment, if the variance of the vector surface spots in a certain class is greater than the preset variance threshold, it is determined that the class includes at least two plants, and the k-means algorithm is used to cluster the vector surface spots in the class into two classes; then it is determined whether the variances of the vector surface spots in the two newly obtained classes are respectively greater than the preset variance threshold. If the variance of the vector surface spots in a certain newly obtained class is greater than the preset variance threshold, the newly obtained class is continued to be divided until the variances of the vector surface spots in the newly obtained class are all less than or equal to the preset variance threshold. If the variances of the vector surface spots in all newly obtained classes are less than or equal to the preset variance threshold, it is determined that the clustering is completed, and then a judgment is made as to whether a merger is needed. When judging whether a merger is needed, only the classes that have not been divided need to be merged, and only the classes that have not been divided that are not obtained in the same k-means algorithm need to be merged. When the distance between the central vector surface spots of two categories is less than a preset distance threshold, it is determined that the two categories need to be merged; the radius of the minimum circumscribed circle of the central vector surface spots of any category is the average radius of the minimum circumscribed circle of the vector surface spots included in the category, and the pixel ratio of the central vector surface spots of any category is the average pixel ratio of the vector surface spots included in the category; the method for obtaining the distance between the central vector surface spots of the two categories is similar to the method for obtaining the first vector surface spots and the second vector surface spots mentioned above, and will not be repeated here.
[0079] S300, judging whether the similarity between the central vector surface spots of the clustered classes and the preset vector surface spots is greater than or equal to the preset similarity threshold in the order of the number of vector surface spots included from most to least, if not, continue to judge the next class; otherwise, stop judging; wherein, the radius of the minimum circumscribed circle of the central vector surface spots of any class is the average radius of the minimum circumscribed circles of the vector surface spots in the class, and the pixel ratio of the central vector surface spots of any class is the average radius pixel ratio of the vector surface spots in the class; the preset vector surface spots are preset tobacco plant vector surface spots that match the growth stage of the tobacco plants corresponding to the target tobacco field image.
[0080] In this embodiment, the similarity between the central vector surface pattern spot of any class and the preset vector surface pattern spot is the difference between 1 and the distance between the central vector surface pattern spot of the class and the preset vector surface pattern spot.
[0081] Optionally, the preset similarity threshold is an empirical value, for example, the preset similarity threshold is greater than or equal to 0.9.
[0082] In this embodiment, the preset vector surface spots are preset tobacco plant vector surface spots that match the growth stage of the tobacco plants corresponding to the target tobacco field image. The growth stages of the tobacco plants corresponding to the target tobacco field image are different, and the corresponding preset vector surface spots are different, which is beneficial to improving the accuracy of judging whether the vector surface spots of the class with the largest number of vector surface spots are tobacco plant vector surface spots.
[0083] In this embodiment, if there is no class whose central vector surface pattern has a similarity with the preset vector surface pattern that is greater than or equal to the preset similarity threshold, S400 to S900 are not executed, but preset information for characterizing the abnormal situation is output.
[0084] S400: If there is a class whose central vector surface pattern has a similarity with a preset vector surface pattern that is greater than or equal to a preset similarity threshold, the class is determined to be a tobacco plant class, and other classes are determined to be suspected non-tobacco plant classes.
[0085] S500, for the jth vector surface patch p in the i-th suspected non-tobacco plant class i,j , determine the vector surface map corresponding to the historical tobacco field image and p i,j Whether there are vector surface spots in the area with the same position, if so, enter S600; the value range of i is 1 to n, n is the number of suspected non-tobacco plant classes; the value range of j is 1 to m, m is the number of vector surface spots in the i-th suspected non-tobacco plant class; the shooting area of the historical tobacco field image is the same as that of the target tobacco field image, and the shooting time of the historical tobacco field image is earlier than the shooting time of the target tobacco field image.
[0086] In this embodiment, the scaling ratio of the historical tobacco field image is the same as that of the target tobacco field image, and the historical tobacco field image and the target tobacco field image correspond to the same tobacco field location area, that is, the actual geographical location corresponding to the same coordinates in the historical tobacco field image and the target tobacco field image is the same.
[0087] In this embodiment, if the historical tobacco field image has the same i,j If there is no vector surface patch in the area with the same position, then p i,j It is a non-tobacco plant vector surface patch.
[0088] Optionally, the shooting time interval between the target tobacco field image and the historical tobacco field image is an empirical value, for example, the shooting time of the historical tobacco field image is 5 days, 8 days or 10 days earlier than the shooting time of the target tobacco field image.
[0089] S600, obtain historical tobacco field images with p i,j The radius lr of the minimum circumscribed circle of the vector surface patches in the same area i,j And pixel ratio lc i,j .
[0090] S700, according to lr i,j , lc i,j 、r i,j and c i,j Determine p i,j Whether it is a non-tobacco plant vector surface patch; r i,j For p i,j The radius of the minimum circumscribed circle, ci,j For p i,j Pixel ratio.
[0091] As a preferred specific implementation, S700 includes:
[0092] S710, obtaining the shooting time interval between the target tobacco field image and the historical tobacco field image.
[0093] In this embodiment, the shooting time interval is an integer, and the unit is day.
[0094] S720, according to r i,j and c i,j Matching is performed in a preset tobacco plant growth library; the preset tobacco plant growth library includes a number of records, each record includes a radius, a pixel ratio and growth days; different records correspond to the radius and pixel ratio of the minimum circumscribed circle of the vector surface patch corresponding to the tobacco plants at different growth days.
[0095] As a specific implementation, the preset tobacco plant growth library includes daily records from the first day after tobacco plants are transplanted to the early stage of maturity; the radius and pixel ratio corresponding to each record are respectively the average radius and average pixel ratio of the minimum circumscribed circle of all tobacco plant vector surface spots in the vector surface image corresponding to the tobacco field image taken on the corresponding days; the scaling ratio of the tobacco field images taken on the above corresponding days is the same as the scaling ratio of the target tobacco field image.
[0096] S730, if the radius and pixel ratio of a record in the preset tobacco plant growth library are the same as r i,j and c i,j If the match is successful, the record is determined as a matching entry, and the radius dr and pixel proportion dc in the specified entry in the preset tobacco plant growth library are obtained; the specified entry is an entry whose growth days are smaller than the growth days in the matching entry by the shooting time interval.
[0097] In this embodiment, if the radius of a record in the preset tobacco plant growth library is i,j The difference value of is less than or equal to the preset radius difference value, and the pixel ratio in the record is the same as c i,j If the difference value of is less than or equal to the preset pixel ratio difference value, it is determined that the radius and pixel ratio in the record are the same as r i,j and c i,j The match is successful; otherwise, it is determined that the radius and pixel ratio of all records in the preset tobacco plant growth library are the same as r i,j and c i,j The match is unsuccessful. If the radius and pixel ratio of all records in the preset tobacco plant growth library are the same as r i,j and c i,j If the match fails, p i,j Determined to be a non-tobacco plant vector surface patch.
[0098] In this embodiment, the preset radius difference value and the preset pixel ratio difference value are both empirical values.
[0099] S740, if lr i,j The difference between dr and dr is less than or equal to the preset radius difference value and lc i,j If the difference between dc and p is less than or equal to the preset pixel ratio difference, i,j It is determined to be a tobacco plant vector surface patch; otherwise, p i,j Determined to be a non-tobacco plant vector surface patch.
[0100] Based on S710-S740, this embodiment also determines whether the vector surface pattern in the suspected non-tobacco plant class is a tobacco plant vector surface pattern based on the growth rate of the tobacco plant in the corresponding stage, which is conducive to further screening out the tobacco plant vector surface pattern from the suspected non-tobacco plant class, improving the accuracy of the judgment of the tobacco plant vector surface pattern, and further improving the accuracy of the final tobacco plant count.
[0101] Based on and judging p i,j The method of determining whether the vector surface patches are non-tobacco plant patches or not can be used to determine whether all the vector surface patches in all the suspected non-tobacco plant classes are non-tobacco plant vector surface patches.
[0102] S800, deleting non-tobacco plant vector surface patches in the vector surface map corresponding to the target tobacco field image to obtain an updated vector surface map.
[0103] S900: Obtain the number of tobacco plants in the updated vector surface map.
[0104] Those skilled in the art know that any method in the prior art for obtaining the number of tobacco plants in a vector surface map falls within the protection scope of the present invention. Optionally, a method for processing tobacco field images based on clustering disclosed in Chinese patent application number CN202311295114.9 is used to obtain the number of tobacco plants in the updated vector surface map.
[0105] Based on the vector surface map corresponding to the target tobacco field image, this embodiment also obtains the radius and pixel ratio of the minimum circumscribed circle of each vector surface spot in the vector surface map. Based on the different radii and pixel ratios of the minimum circumscribed circles of different vector surface spots in the vector surface map, this embodiment clusters the vector surface spots in the vector surface map. The radii and pixel ratios of the minimum circumscribed circles of the vector surface spots in the same class are similar, while the radii and / or pixel ratios of the vector surface spots in different classes are quite different. For the classes obtained by clustering, the central vector surface spot and the preset vector surface spot are determined in the order of the number of vector surface spots included from large to small. Similarity, if the similarity is high, the corresponding class is determined to be the tobacco plant class, and the other classes are suspected non-tobacco plant classes; the above-mentioned method of judging in the order of the number of vector surface spots from large to small is conducive to improving the efficiency of obtaining tobacco plant classes, and for suspected non-tobacco plant classes, this embodiment further combines historical tobacco field images to judge whether the vector surface spots in each suspected non-tobacco plant class are non-tobacco plant vector surface spots, so as to avoid the situation where tobacco plant vector surface spots exist in suspected non-tobacco plant classes, thereby improving the accuracy of judging whether the vector surface spots in the vector surface image are tobacco plant vector surface spots, thereby improving the accuracy of the number of tobacco plants in the target tobacco field image finally obtained.
[0106] Although some specific embodiments of the present invention have been described in detail by way of example, it will be appreciated by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present invention. It will also be appreciated by those skilled in the art that various modifications may be made to the embodiments without departing from the scope and spirit of the present invention. The scope of the present invention is defined by the appended claims.
Claims
1. A method for preprocessing tobacco field images, characterized in that: The pretreatment method comprises the following steps: S100, obtaining a vector surface image corresponding to a target tobacco field image; the vector surface image includes a plurality of vector surface spots; S200, clustering the vector surface spots in the vector surface map according to the radius and pixel ratio of the minimum circumscribed circle of each vector surface spot in the vector surface map; the pixel ratio of any vector surface spot is the ratio of the number of pixel points included in the vector surface spot to the number of pixel points included in the minimum circumscribed circle of the vector surface spot; S300, judging whether the similarity between the central vector surface spots of the clustered classes and the preset vector surface spots is greater than or equal to the preset similarity threshold value in the order of the number of vector surface spots included from large to small, if not, continuing to judge the next class; otherwise, stopping the judgment; wherein the radius of the minimum circumscribed circle of the central vector surface spots of any class is the average radius of the minimum circumscribed circles of the vector surface spots in the class, and the pixel ratio of the central vector surface spots of any class is the average radius pixel ratio of the vector surface spots in the class; the preset vector surface spots are preset tobacco plant vector surface spots that match the growth stage of the tobacco plants corresponding to the target tobacco field image; S400, if there is a class whose central vector surface pattern has a similarity with a preset vector surface pattern that is greater than or equal to a preset similarity threshold, the class is determined to be a tobacco plant class, and other classes are determined to be suspected non-tobacco plant classes; S500, for the jth vector surface patch p in the i-th suspected non-tobacco plant class i,j , determine the vector surface map corresponding to the historical tobacco field image and p i,j Whether there are vector surface spots in the area with the same position, if yes, enter S600; i ranges from 1 to n, n is the number of suspected non-tobacco plant classes; j ranges from 1 to m, m is the number of vector surface spots in the i-th suspected non-tobacco plant class; the shooting area of the historical tobacco field image is the same as that of the target tobacco field image, and the shooting time of the historical tobacco field image is earlier than the shooting time of the target tobacco field image; S600, obtain historical tobacco field images with p i,j The radius lr of the minimum circumscribed circle of the vector surface patches in the same area i,j And pixel ratio lc i,j ; S700, according to lr i,j , lc i,j 、r i,j and c i,j Determine p i,j Whether it is a non-tobacco plant vector surface patch; r i,j For p i,j The radius of the smallest circumscribed circle, c i,j For p i,j Pixel ratio; S800, deleting non-tobacco plant vector surface patches in the vector surface image corresponding to the target tobacco field image to obtain an updated vector surface image; S900: Obtain the number of tobacco plants in the updated vector surface map.
2. The method for preprocessing tobacco field images according to claim 1, characterized in that: S700 includes: S710, obtaining the shooting time interval between the target tobacco field image and the historical tobacco field image; S720, according to r i,j and c i,j Matching is performed in a preset tobacco plant growth library; the preset tobacco plant growth library includes a plurality of records, each record includes a radius, a pixel ratio and a growth day; different records correspond to the radius and pixel ratio of the minimum circumscribed circle of the vector surface pattern corresponding to the tobacco plant at different growth days; S730, if the radius and pixel ratio of a record in the preset tobacco plant growth library are the same as r i,j and c i,j If the match is successful, the record is determined as a matching entry, and the radius dr and pixel proportion dc in the specified entry in the preset tobacco plant growth library are obtained; the specified entry is an entry whose growth days are smaller than the growth days in the matching entry by the shooting time interval; S740, if lr i,j The difference between dr and dr is less than or equal to the preset radius difference value and lc i,j If the difference between dc and p is less than or equal to the preset pixel ratio difference, i,j It is determined to be a tobacco plant vector surface patch; otherwise, p i,j Determined to be a non-tobacco plant vector surface patch.
3. The method for preprocessing tobacco field images according to claim 2, characterized in that: S730 includes: if the radius of a record in the preset tobacco plant growth library is equal to r i,j The difference value of is less than or equal to the preset radius difference value, and the pixel ratio in the record is the same as c i,j If the difference value of is less than or equal to the preset pixel ratio difference value, it is determined that the radius and pixel ratio in the record are the same as r i,j and c i,j The match was successful.
4. The method for preprocessing tobacco field images according to claim 1, characterized in that: Use the k-means algorithm to cluster the vector surface spots in the vector surface map. S200 includes: S210, using a k-means algorithm to cluster the vector surface spots in the vector surface map into two categories, namely a first initial category and a second initial category; during the clustering process, the distance between the first vector surface spot and the second vector surface spot is positively correlated with the difference value of the radius of the minimum circumscribed circle of the first vector surface spot and the second vector surface spot, and the distance between the first vector surface spot and the second vector surface spot is positively correlated with the difference value of the pixel proportion of the first vector surface spot and the second vector surface spot; the first vector surface spot is any vector surface spot in the vector surface map, and the second vector surface spot is any vector surface spot in the vector surface except the first vector surface spot; S220, if the variance of the vector surface spots in the first initial class is greater than a preset variance threshold and the variance of the vector surface spots in the second initial class is less than or equal to the preset variance threshold, proceed to S230; S230, using a k-means algorithm to cluster the vector surface spots in the first initial class into two classes, namely a first subclass and a second subclass; S240, if the variance of the vector surface spots in the first subclass is less than or equal to the preset variance threshold and the variance of the vector surface spots in the second subclass is less than or equal to the preset variance threshold, proceed to S250; S250, if the distance between the central vector surface spots of the second initial class and the first subclass is greater than or equal to the preset distance threshold, and the distance between the central vector surface spots of the second initial class and the second subclass is greater than or equal to the preset distance threshold, then the second initial class, the first subclass and the second subclass are determined as the final result of clustering the vector surface spots in the vector surface map using the k-means algorithm.
5. The method for preprocessing tobacco field images according to claim 4, characterized in that: The distance between the first vector surface spot and the second vector surface spot is dis 1,2 =w1×f(|r1-r2|)+(1-w1)×g(|c1-c2|), r1 and r2 are the radii of the minimum circumscribed circle of the first vector surface pattern and the second vector surface pattern, respectively, f() is the normalization processing corresponding to the radius of the minimum circumscribed circle, c1 and c2 are the pixel proportions of the first vector surface pattern and the second vector surface pattern, respectively, g() is the normalization processing corresponding to the pixel proportion, w1 is the preset weight, 0 <w1<1。 6. The method for preprocessing tobacco field images according to claim 1, characterized in that: S500 also includes: if the historical tobacco field image has the same i,j If there is no vector surface patch in the area with the same position, then p i,j It is a non-tobacco plant vector surface patch.
7. The method for preprocessing tobacco field images according to claim 1, characterized in that: S100 includes: S110, obtaining a saturation band map corresponding to the target tobacco field image; S120, updating the saturation of the pixel points whose saturation is less than a preset saturation threshold in the saturation band map to null, to obtain an updated saturation band map; S130, performing raster-to-vector surface processing on the updated saturation band map to obtain a vector surface map.
