A method for automatic segmentation and extraction of pest and disease areas in fruit tree leaves

By analyzing the grayscale histogram and block processing of fruit tree leaf images, the problem of low efficiency and mis-segmentation of traditional fruit tree diseases and insect pests detection is solved, and higher detection precision and accuracy are achieved.

CN118470050BActive Publication Date: 2024-09-06YIFENG AGRICULTURAL DEVELOPMENT (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410924056.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-11
Publication Date
2024-09-06
Estimated Expiration
2044-07-11

AI Technical Summary

Technical Problem

Traditional fruit tree pest control relies on manual observation, which is inefficient and costly. Computer vision technology is greatly affected by lighting and photography factors during the detection process, making it difficult to quickly and accurately detect pests and diseases.

Method used

The automatic segmentation and extraction method of fruit leaf diseases and insect pests areas is used to obtain the grayscale histogram of each channel image, analyze the peak width and peak concentration, perform block processing and linear function processing, and enhance the fruit leaf image to reduce the impact of light and improve detection. Accuracy.

Benefits of technology

It effectively reduces the brightness of the leaf stem area, improves the accuracy of detection of fruit tree leaf diseases and insect pests, clearly extracts the diseased leaf area, reduces false segmentation, and improves the accuracy of the detection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118470050B
    Figure CN118470050B
Patent Text Reader

Abstract

The present invention relates to the field of image processing technology, and in particular to a method for automatically segmenting and extracting pest and disease areas of fruit tree leaves, comprising: obtaining a grayscale histogram of each channel image of a fruit tree leaf image, obtaining a first grayscale level according to the grayscale histogram, obtaining a peak width according to the first grayscale level, obtaining an optimal channel image according to the number of pixels and the peak width corresponding to the first grayscale level, performing block processing on the optimal channel image, obtaining an optimal target range according to the peak concentration of the block images, obtaining a linear function according to the optimal target range, obtaining an enhanced fruit tree leaf image according to the linear function, and obtaining the degree of disease influence according to the enhanced fruit tree leaf image. The present invention improves the detection accuracy of fruit tree leaf pests and diseases by performing block brightness enhancement or reduction processing on the image, thereby increasing the brightness of the pest and disease area and reducing the brightness of the leaf stem area.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of image processing, and in particular to a method for automatically segmenting and extracting disease and insect pest areas of fruit tree leaves. Background Art

[0002] The fruit industry plays an important role in my country's economic development. It is also a basic industry for increasing farmers' economic income. It plays an important role in optimizing the economic structure and adjusting the economic balance. Fruit trees are often affected by various diseases and pests in their daily growth, which reduces the yield and quality of fruit trees and affects market sales. Diseases and pests pose a certain threat to the normal growth of fruits and seriously affect the economic benefits of orchards. Therefore, disease and pest control is an important part of the planting industry.

[0003] Traditional fruit tree pest control relies on manual observation and planting experience. Manual observation of pests and diseases in large-scale planting bases is time-consuming, inefficient and has a high learning cost. At the same time, the quality of practitioners is uneven, and home planting enthusiasts lack access to pest and disease consultation, and are unable to quickly master the knowledge of fruit tree pest and disease control. With the rise of precision agriculture, it is of great significance to use computer vision-related technologies to detect fruit tree pests and diseases. However, in actual applications, in the process of computer detection of pests and diseases, factors such as lighting and camera exposure will affect the detection results. Summary of the invention

[0004] In order to solve the above problems, the present invention provides a method for automatically segmenting and extracting disease and insect pest areas on fruit tree leaves.

[0005] The method for automatically segmenting and extracting pest and disease areas of fruit tree leaves of the present invention adopts the following technical scheme:

[0006] An embodiment of the present invention provides a method for automatically segmenting and extracting pest and disease areas of fruit tree leaves, the method comprising the following steps:

[0007] Collecting fruit tree leaf images, obtaining each channel image of the fruit tree leaf image, and a grayscale histogram of each channel image;

[0008] Obtaining a first grayscale and the number of pixels corresponding to the first grayscale according to a grayscale histogram of the channel image, obtaining a peak width according to the first grayscale, obtaining a peak concentration degree according to the number of pixels corresponding to the first grayscale and the peak width, and obtaining an optimal channel image according to the peak concentration degree;

[0009] According to the optimal channel image, a plurality of block images and the order of the block images are obtained; according to the grayscale histogram of the block images, a target grayscale level and a target range of the block images are obtained; according to the target grayscale level and the grayscale histogram of the block images, a peak concentration of the block images is obtained; according to the target range of the block images and the peak concentration of the block images, a difference between the target ranges of any two block images is obtained; according to the difference between the target ranges, an optimal target range is obtained; according to the optimal target range, a linear function of the pixels in the block images is obtained; and according to the linear function and the order of the block images, an enhanced fruit leaf image is obtained;

[0010] The diseased leaf area is obtained based on the enhanced fruit tree leaf image.

[0011] Furthermore, the step of obtaining the first grayscale level and the number of pixels corresponding to the first grayscale level according to the grayscale histogram of the channel image includes the following specific steps:

[0012] For any channel image, the difference in the number of pixels corresponding to the i-th grayscale level and the i-1-th grayscale level in the grayscale histogram of the channel image is obtained along the direction of increasing grayscale levels. If the difference is greater than 0, the difference in the number of pixels corresponding to the i+1-th grayscale level and the i-th grayscale level is obtained, and so on, until the difference in the number of pixels corresponding to the j+1-th grayscale level and the j-th grayscale level is less than 0, the j-th grayscale level is recorded as the first grayscale level, and the number of pixels corresponding to the first grayscale level is obtained.

[0013] Furthermore, the step of obtaining the peak width according to the first gray level includes the following specific steps:

[0014] In the grayscale histogram of the channel image, along the left side of the first grayscale level, obtain the number of pixels corresponding to the grayscale level and The gray level with the smallest absolute value of the difference is recorded as the second gray level; in the gray histogram of the channel image, along the right side of the first gray level, obtain the number of pixels corresponding to the gray level and The gray level with the smallest absolute value of the difference is recorded as the third gray level, the difference between the third gray level and the second gray level is recorded as the peak width, and A is the number of pixels corresponding to the first gray level.

[0015] Furthermore, the step of obtaining the peak concentration degree according to the number of pixels and the peak width corresponding to the first gray level and obtaining the optimal channel image according to the peak concentration degree includes the following specific steps:

[0016] For any channel image, the ratio of the number of pixels corresponding to the first gray level to the peak width is taken as the peak concentration degree, the peak concentration degrees corresponding to all channel images are obtained, and the channel image corresponding to the maximum peak concentration degree is taken as the optimal channel image.

[0017] Furthermore, the method of obtaining a plurality of block images and the order of the block images according to the optimal channel image, and obtaining a target grayscale level and a target range of the block images according to the grayscale histogram of the block images includes the following specific steps:

[0018] The optimal channel image is denoted as , the image length is , the image width is , the optimal channel image is obtained by equal division The size is The block image, is the preset first block ratio, The second block ratio is preset, and the order of obtaining a plurality of block images by dividing the optimal channel image in the order from left to right and from top to bottom;

[0019] For any block image, obtain the grayscale histogram of the block image, obtain all the maximum points in the grayscale histogram of the block image, record the grayscale level corresponding to the rightmost maximum point in the grayscale histogram of the block image as the target grayscale level, and record the grayscale levels of the nearest trough positions on both sides of the target grayscale level as and ,in ,Will as the target range of the i-th block image.

[0020] Furthermore, the step of obtaining the peak concentration of the block image according to the target grayscale and the grayscale histogram of the block image includes the following specific steps:

[0021]

[0022] In the formula, is the target grayscale level of the i-th block image, The specific method of obtaining is as follows: The number of pixels corresponding to the target gray level is recorded as , in the grayscale histogram of the i-th block image, along the left side of the target grayscale level, obtain the number of pixels corresponding to the grayscale level and The gray level with the smallest absolute value of the difference is recorded as the fourth gray level, and the difference between the target gray level and the fourth gray level is recorded as ; The specific method of obtaining is as follows: in the grayscale histogram of the i-th block image, along the right side of the target grayscale, obtain the number of pixels corresponding to the grayscale and The gray level with the smallest absolute value of the difference is recorded as the fifth gray level, and the difference between the fifth gray level and the target gray level is recorded as ; is the number of pixels corresponding to gray level k in the gray histogram of the i-th block image, is the peak concentration of the i-th block image.

[0023] Furthermore, the method of obtaining the difference between the target ranges of any two segmented images according to the target ranges of the segmented images and the peak concentration of the segmented images, and obtaining the optimal target range according to the difference between the target ranges, comprises the following specific steps:

[0024]

[0025] In the formula, is the gray level of the nearest trough position on the left side of the target gray level in the gray level histogram of the i-th block image, recorded as the left value of the target range of the i-th block image, is the gray level of the nearest trough position on the right side of the target gray level in the gray level histogram of the i-th block image, recorded as the right value of the target range of the i-th block image, is the gray level of the nearest trough position on the left side of the target gray level in the gray level histogram of the j-th block image, recorded as the left value of the target range of the j-th block image, is the gray level of the nearest trough position on the right side of the target gray level in the gray level histogram of the j-th block image, recorded as the right value of the target range of the j-th block image, is the peak concentration of the i-th block image, is the peak concentration of the jth block image, is to take the absolute value, max() is to take the maximum value, is the difference between the target range of the i-th block image and the j-th block image;

[0026] Get the differences between all target ranges, and record the minimum value of the differences between all target ranges as , represents the difference between the target ranges of the p-th block image and the q-th block image, then the optimal target range is , Take the value on the left side of the target range for the p-th block image, Take the value on the right side of the target range for the p-th block image, Take the value on the left side of the target range of the qth block image, The right side of the target range of the qth block image is taken.

[0027] Furthermore, the step of obtaining the linear function of the pixels in the block image according to the optimal target range includes the following specific steps:

[0028] The linear function is:

[0029]

[0030] In the formula, is the gray value of any pixel in the kth block image after the optimal channel image is divided into blocks, is the gray value of any pixel in the kth block image after linear processing after the optimal channel image is divided into blocks. is the left side value of the optimal target range, Take the value on the right side of the optimal target range.

[0031] Furthermore, the step of obtaining the enhanced fruit leaf image according to the linear function and the sequence of the block images includes the following specific steps:

[0032] The optimal channel image is linearly processed through the pixels on all the block images after block division using a linear function to obtain the block images after linear processing. All the block images after linear processing are merged in the order of the block images to obtain a merged image, which is recorded as the enhanced fruit tree leaf image.

[0033] Furthermore, the step of obtaining the diseased leaf area according to the enhanced fruit tree leaf image includes the following specific steps:

[0034] The enhanced fruit tree leaf image is subjected to Otsu threshold segmentation to obtain the optimal segmentation threshold. The grayscale values ​​of pixels in the enhanced fruit tree leaf image that are greater than the optimal segmentation threshold are set to 255, and the grayscale values ​​of pixels that are less than or equal to the optimal segmentation threshold are set to 0 to obtain a leaf disease image. The area composed of pixels with a grayscale value of 255 in the leaf disease image is the diseased leaf area.

[0035] The beneficial effect of the technical solution of the present invention is that when using computer vision technology to detect pest-infected leaves of fruit trees, due to the influence of light, the grayscale values ​​of the leaf stem part and the pest-infected area of ​​the pest-infected leaves are relatively close. During the threshold segmentation, the leaf stem part will be divided into the pest-infected area, thereby affecting the detection result. The present invention analyzes the grayscale histogram of each channel image of the fruit tree leaf image, obtains the first grayscale level and the number of pixels corresponding to the first grayscale level according to the grayscale histogram of the channel image, obtains the peak width according to the first grayscale level, obtains the peak concentration degree according to the number of pixels corresponding to the first grayscale level and the peak width, and obtains the optimal channel image according to the peak concentration degree. The distribution of the diseased leaf area in the optimal channel image is more obvious, which is conducive to the detection of the diseased leaf area. Since the image is affected by light in a local area, a number of block images are obtained according to the optimal channel image, and then the target grayscale is obtained according to the grayscale histogram of the block image. The peak concentration of the block images is obtained according to the target grayscale level and the grayscale histogram of the block images. The difference between the target ranges of any two block images is obtained according to the target range of the block images and the peak concentration of the block images. The optimal target range is obtained according to the difference between the target ranges. The optimal target range mainly includes the diseased leaf area. Then, the linear function of the pixels in the block images is obtained according to the optimal target range. The enhanced fruit tree leaf image is obtained according to the linear function. The diseased leaf area in the enhanced fruit tree leaf image is more obvious, and the brightness of the leaf stem area is reduced, thereby improving the detection accuracy of fruit tree leaf diseases and insect pests. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. 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 paying creative work.

[0037] Figure 1 A flowchart of the steps of a method for automatically segmenting and extracting pest and disease areas of fruit tree leaves provided by an embodiment of the present invention;

[0038] Figure 2 An R channel image of a method for automatically segmenting and extracting pest and disease areas of fruit tree leaves provided by an embodiment of the present invention;

[0039] Figure 3 A G channel image of a method for automatically segmenting and extracting pest and disease areas of fruit tree leaves provided by an embodiment of the present invention;

[0040] Figure 4A B channel image of a method for automatically segmenting and extracting pest and disease areas of fruit tree leaves provided by an embodiment of the present invention;

[0041] Figure 5 A block diagram of a method for automatically segmenting and extracting pest and disease areas on fruit tree leaves provided by an embodiment of the present invention;

[0042] Figure 6 An enhanced fruit tree leaf image of a method for automatically segmenting and extracting pest and disease areas in fruit tree leaves provided by an embodiment of the present invention;

[0043] Figure 7 A leaf disease image of a method for automatically segmenting and extracting disease and insect pest areas of fruit tree leaves provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0044] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of the specific implementation method, structure, characteristics and effects of a method for automatic segmentation and extraction of pest and disease areas of fruit tree leaves proposed by the present invention in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.

[0045] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.

[0046] The specific scheme of the method for automatically segmenting and extracting pest and disease areas in fruit tree leaves provided by the present invention is described in detail below with reference to the accompanying drawings.

[0047] See also Figure 1 , which shows a flowchart of a method for automatically segmenting and extracting pest and disease areas of fruit tree leaves provided by an embodiment of the present invention, the method comprising the following steps:

[0048] Step S001, collecting fruit tree leaf images, obtaining each channel image of the fruit tree leaf image, and the grayscale histogram of each channel image.

[0049] It should be noted that the main purpose of this embodiment is to use computer vision technology to quickly detect leaf pest and disease areas in fruit tree breeding, and to judge the severity of the impact of pests and diseases on fruit trees based on the characteristics of the pest and disease areas. First, it is necessary to collect corresponding images and perform certain preprocessing.

[0050] Specifically, a high-precision camera is installed near the growing fruit trees to collect the fruit tree leaf images. The fruit tree leaf images are RGB images. Since the fruit tree leaves are usually green and have obvious color characteristics, it is necessary to obtain the RGB three-channel images of the fruit tree leaf images for analysis and processing. To obtain the R channel image, G channel image, and B channel image of the fruit tree leaf image, please refer to Figure 2 , Figure 3 , Figure 4 , Figure 2 , Figure 3 , Figure 4 They are respectively the R channel image, G channel image, and B channel image of the present embodiment. It should be noted that each channel image is a grayscale image. In order to analyze the grayscale value distribution of pixels on the three channels of R, G, and B, the grayscale histograms of the three channel images are statistically analyzed respectively to obtain the grayscale histogram of the R channel image, the grayscale histogram of the G channel image, and the grayscale histogram of the B channel image.

[0051] At this point, the images of each channel of the fruit tree leaf image and the grayscale histogram of each channel image are obtained.

[0052] Step S002: obtain a first grayscale level and the number of pixels corresponding to the first grayscale level according to the grayscale histogram of the channel image, obtain a peak width according to the first grayscale level, obtain a peak concentration degree according to the number of pixels corresponding to the first grayscale level and the peak width, and obtain an optimal channel image according to the peak concentration degree.

[0053] It should be noted that due to reasons such as lighting and camera exposure, the grayscale value characteristics of the leaf stem part of the fruit tree image in the grayscale image are similar to the grayscale value characteristics of the disease and insect pest area. In the subsequent segmentation and recognition, they will be confused with the fruit tree disease and insect pest area, affecting the segmentation results. The grayscale value distribution of each channel in the three channels of R, G, and B of the image is different, so it is necessary to select the channel where the disease and insect pest area is more obviously distributed for single-channel enhancement processing.

[0054] It should be noted that the channel image includes three types of background area, normal leaf area, and diseased leaf area. The background area and normal leaf area are represented by pixels with relatively low grayscale values ​​in the grayscale image and account for a large proportion of the number of pixels in the image, while the diseased leaf area is represented by pixels with relatively high grayscale values ​​and accounts for a small proportion of the number of pixels in the image. The more concentrated the peaks on the left side of the histogram are, the greater the grayscale difference between the diseased leaf area and the background and normal leaf area, and the easier it is to segment the corresponding diseased leaf area.

[0055] Specifically, for any channel image, the difference in the number of pixels corresponding to the i-th grayscale level and the i-1-th grayscale level in the grayscale histogram is obtained along the direction of increasing grayscale levels (i is greater than 1). If the difference is greater than 0, the difference in the number of pixels corresponding to the i+1-th grayscale level and the i-th grayscale level is obtained, and so on, until the difference in the number of pixels corresponding to the j+1-th grayscale level and the j-th grayscale level is less than 0. At this time, the j-th grayscale level is recorded as the first grayscale level, and the number of pixels corresponding to the first grayscale level is recorded as A, where (j>i+1). It should be noted that the range of grayscale levels in the grayscale histogram of the channel image is , that is, 256 gray levels.

[0056] Furthermore, in the grayscale histogram of the channel image, along the left side of the first grayscale level, the number of pixels corresponding to the grayscale level and The gray level with the smallest absolute value of the difference is recorded as the second gray level; in the gray histogram of the channel image, along the right side of the first gray level, obtain the number of pixels corresponding to the gray level and The gray level with the smallest absolute value of the difference is recorded as the third gray level, and the difference between the third gray level and the second gray level is recorded as the peak width.

[0057] Furthermore, the peak concentration degree is obtained according to the number of pixels and the peak width corresponding to the first gray level, as follows:

[0058]

[0059] In the formula, is the number of pixels corresponding to the first gray level, is the peak width, is the concentration of peaks. The larger L is, the sharper the peaks corresponding to the background area and the normal leaf area in the grayscale histogram of the channel image are, the higher the concentration is, and the easier it is to segment the diseased leaf area. Conversely, the flatter the peaks corresponding to the background area and the normal leaf area in the grayscale histogram of the channel image are, the lower the concentration is, and the more difficult it is to segment the diseased leaf area.

[0060] Furthermore, the above is the peak concentration degree obtained by analyzing any channel image, and all peak concentration degrees are obtained, and the channel image corresponding to the maximum peak concentration degree is taken as the optimal channel image.

[0061] At this point, the optimal channel image is obtained.

[0062] Step S003, divide the optimal channel image into blocks and obtain the order of the block images, obtain the target grayscale level and the target range of the block images according to the grayscale histogram of the block images, obtain the peak concentration of the block images according to the target grayscale level and the grayscale histogram of the block images, obtain the difference between the target ranges of any two block images according to the target range of the block images and the peak concentration of the block images, obtain the optimal target range according to the difference between the target ranges, obtain the linear function of the pixels in the block images according to the optimal target range, and obtain the enhanced fruit tree leaf image according to the linear function and the order of the block images.

[0063] It should be noted that through the analysis of the optimal channel image, since the image is affected by exposure or light, the grayscale value difference between the leaf stem part and the diseased leaf area is small, and it is difficult to detect the diseased leaf area by threshold segmentation, among which the leaf stem part is in the normal leaf area. Therefore, it is necessary to perform grayscale linear transformation enhancement on the optimal channel image to reduce the bright grayscale value of the leaf stem part caused by exposure or other reasons as much as possible.

[0064] It should be further explained that since exposure usually occurs in the leaf stem part, that is, in a local position, the image is first processed in blocks. After blocking, the leaf stem part is usually present in a small block, and the histogram in each small block shows a double-peak characteristic, so the target range of the grayscale value of the suspected lesion area is determined by calculating the difference between the peaks of the target area in the grayscale histogram of each block. Then, according to the optimal target range, the grayscale value of the pixels within the target range in each block is pulled up, and the grayscale value of the pixels outside the target range in each block is compressed. Thereby reducing the highlight grayscale value of the leaf stem part caused by exposure, and enhancing the grayscale value of the pixels in the suspected lesion area.

[0065] Specifically, the optimal channel image is recorded as , is the size of the image. In this embodiment, the image size is To explain, the image length , image width , the optimal channel image is obtained by equal division The size is At the same time, the optimal channel image is obtained in the order from left to right and from top to bottom. For the order of obtaining several block images through block division, please refer to Figure 5 , Figure 5 is a block diagram of this embodiment, is the preset first block ratio, is the preset second block ratio. In this embodiment, the first block ratio is , the second block ratio It is described that other values ​​can be set in the specific implementation. When the blocking ratio cannot make the optimal channel image blocked, that is, when the elements in the optimal channel image are blocked, it may exceed the boundary of the optimal channel image. At this time, this embodiment uses the quadratic linear interpolation method to interpolate and fill the data of the part of the optimal channel image that exceeds the boundary.

[0066] It should be noted that, by analyzing the grayscale histogram of each block image, it is found that the grayscale histogram of each block image presents a bimodal or multi-modal state. According to the characteristics of the block image itself, it can be known that the leftmost peak is the area where the background pixels are located, and the rightmost peak is the area where the pixels in the diseased leaf area are located. Therefore, the grayscale target range of the suspected lesion area can be determined based on the difference in the distribution of the rightmost peak in the histogram of the block image.

[0067] Specifically, for any block image, obtain the grayscale histogram of the block image, obtain all the maximum points in the grayscale histogram of the block image, record the grayscale level corresponding to the rightmost maximum point in the grayscale histogram of the block image as the target grayscale level, and record the grayscale levels of the nearest trough positions on both sides of the target grayscale level as and ,in ,Will As the target range of the i-th block image, it should be noted that for any block image, the range of gray levels in the grayscale histogram of the block image is , that is, 256 gray levels.

[0068] Furthermore, the above analysis is performed on any block image, and the target ranges of all block images are obtained, which are recorded as , ,… ,… ,in, As the target range of the i-th block image, n is the total number of block images obtained by block division of the optimal channel image. It should be noted that For the sake of simplicity, n is used here instead.

[0069] Specifically, for any block image, the peak concentration of the block image is obtained according to the target grayscale and the grayscale histogram of the block image, as follows:

[0070]

[0071] In the formula, is the target grayscale level of the i-th block image, The specific method of obtaining is as follows: The number of pixels corresponding to the target gray level is recorded as , in the grayscale histogram of the i-th block image, along the left side of the target grayscale level, obtain the number of pixels corresponding to the grayscale level and The gray level with the smallest absolute value of the difference is recorded as the fourth gray level, and the difference between the target gray level and the fourth gray level is recorded as ; The specific method of obtaining is as follows: in the grayscale histogram of the i-th block image, along the right side of the target grayscale, obtain the number of pixels corresponding to the grayscale and The gray level with the smallest absolute value of the difference is recorded as the fifth gray level, and the difference between the fifth gray level and the target gray level is recorded as ; is the number of pixels corresponding to gray level k in the gray histogram of the i-th block image, is the peak concentration of the i-th block image.

[0072] It should be noted that the above analysis is performed by taking any one block image as an example, and the peak concentration of other block images can be obtained similarly.

[0073] Furthermore, the difference between the target ranges of any two block images is obtained according to the target ranges of the block images and the peak concentration of the block images, as follows:

[0074]

[0075] In the formula, is the gray level of the nearest trough position on the left side of the target gray level in the gray level histogram of the i-th block image, recorded as the left value of the target range of the i-th block image, is the gray level of the nearest trough position on the right side of the target gray level in the gray level histogram of the i-th block image, recorded as the right value of the target range of the i-th block image, is the gray level of the nearest trough position on the left side of the target gray level in the gray level histogram of the j-th block image, recorded as the left value of the target range of the j-th block image, is the gray level of the nearest trough position on the right side of the target gray level in the gray level histogram of the j-th block image, recorded as the right value of the target range of the j-th block image, is the peak concentration of the i-th block image, is the peak concentration of the jth block image, is to take the absolute value, max() is to take the maximum value, is the difference between the target range of the i-th block image and the j-th block image.

[0076] It should be noted that in the above formula , Represents the Euclidean distance between the target range of the i-th block image and the j-th block image; It represents the difference in the concentration of peak values ​​in the target range between the i-th block image and the j-th block image. The smaller the value of is, the closer the concentration of peaks in the target range of the two block images is; The smaller the value of , the higher the similarity between the target ranges of the i-th block image and the j-th block image.

[0077] Furthermore, the differences between all target ranges are obtained, and the minimum value of the differences between all target ranges is recorded as , Indicates that the difference between the target ranges of the p-th block image and the q-th block image is the lowest, then the optimal target range is , Take the value on the left side of the target range for the p-th block image, Take the value on the right side of the target range for the p-th block image, Take the value on the left side of the target range of the qth block image, The right side of the target range of the qth block image is taken.

[0078] It should be noted that, the optimal target range is obtained above, and linear processing can be performed on different block images according to the optimal target range.

[0079] Specifically, for any block image, the linear function of the pixels in the block image is obtained according to the optimal target range, as follows:

[0080] Take the value on the left side of the optimal target range , recorded as AT1, the right side of the optimal target range is taken , recorded as AT2;

[0081] The linear function is:

[0082]

[0083] In the formula, is the gray value of any pixel in the kth block image after the optimal channel image is divided into blocks, is the gray value of any pixel in the kth block image after linear processing after the optimal channel image is divided into blocks. is the left side value of the optimal target range, Take the value on the right side of the optimal target range.

[0084] It should be noted that when the gray value of any pixel in any block image is When the gray value of the pixel is raised to Between, that is, the gray value of the pixels in the diseased leaf area is enhanced, making the diseased area on the leaf more obvious; when When , the grayscale value of the pixel is halved, that is, the grayscale value of the pixel in the background area is weakened, thereby increasing the contrast with the diseased leaf area; when When the pixel gray value is compressed to Since the corresponding pixels within the target range are mainly pixels in the diseased leaf area, the pixels that are not within the optimal target range are also weakened to reduce interference with the diseased leaf area. Similarly, the diseased leaf area can be displayed more clearly. By weakening the grayscale value outside the optimal target range, the highlight grayscale value of the leaf stem part caused by exposure is reduced.

[0085] Furthermore, the optimal channel image is linearly processed by using a linear function through the pixels on all the block images after the block, and the block images after the linear processing are obtained. All the block images after the linear processing are merged in the order of the block images to obtain the merged image, which is recorded as the enhanced fruit leaf image. Please participate Figure 6 , Figure 6 This is the merged image of this embodiment, that is, the enhanced fruit tree leaf image.

[0086] At this point, the enhanced fruit tree leaf image is obtained.

[0087] Step S004: obtaining the diseased leaf area according to the enhanced fruit tree leaf image, and obtaining the degree of disease influence according to the diseased leaf area.

[0088] It should be noted that step S003 obtains an enhanced fruit tree leaf image, which is also a grayscale image, and the diseased leaf area in the enhanced fruit tree leaf image is more obvious. The diseased leaf area can be segmented out through appropriate threshold segmentation, and the disease assessment can be further performed based on the characteristics of the diseased leaf area.

[0089] Specifically, the enhanced fruit tree leaf image is subjected to Otsu threshold segmentation to obtain the optimal segmentation threshold, the grayscale values ​​of pixels in the enhanced fruit tree leaf image that are greater than the optimal segmentation threshold are set to 255, and the grayscale values ​​of pixels that are less than or equal to the optimal segmentation threshold are set to 0, to obtain a leaf disease image, and the area composed of pixels with a grayscale value of 255 in the leaf disease image is the diseased leaf area.

[0090] It should be noted that the diseased leaf area obtained is a number of closed connected domains. Figure 7 , Figure 7 This is the leaf disease image of this embodiment.

[0091] Furthermore, the number of all pixels in the diseased leaf area is taken as the area of ​​the diseased leaf area, recorded as TA, the number of all pixels in the leaf disease image is taken as the area of ​​the leaf disease image, recorded as TB, and the ratio of TA to TB is taken as the degree of disease impact. The greater the degree of disease impact, the greater the impact of the fruit tree leaves by the disease and insect pests, and more attention should be paid to the disease of the fruit tree in the future.

[0092] This concludes the present embodiment.

[0093] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for automatically segmenting and extracting pest and disease areas of fruit tree leaves, characterized in that: The method comprises the following steps: Collecting fruit tree leaf images, obtaining each channel image of the fruit tree leaf image, and a grayscale histogram of each channel image; Obtaining a first grayscale and the number of pixels corresponding to the first grayscale according to a grayscale histogram of the channel image, obtaining a peak width according to the first grayscale, obtaining a peak concentration degree according to the number of pixels corresponding to the first grayscale and the peak width, and obtaining an optimal channel image according to the peak concentration degree; According to the optimal channel image, a plurality of block images and the order of the block images are obtained; according to the grayscale histogram of the block images, a target grayscale level and a target range of the block images are obtained; according to the target grayscale level and the grayscale histogram of the block images, a peak concentration of the block images is obtained; according to the target range of the block images and the peak concentration of the block images, a difference between the target ranges of any two block images is obtained; according to the difference between the target ranges, an optimal target range is obtained; according to the optimal target range, a linear function of the pixels in the block images is obtained; and according to the linear function and the order of the block images, an enhanced fruit leaf image is obtained; Obtain the diseased leaf area according to the enhanced fruit tree leaf image; The method of obtaining the difference between the target ranges of any two segmented images according to the target ranges of the segmented images and the peak concentration of the segmented images, and obtaining the optimal target range according to the difference between the target ranges, includes the following specific steps: In the formula, is the gray level of the nearest trough position on the left side of the target gray level in the gray level histogram of the i-th block image, recorded as the left value of the target range of the i-th block image, is the gray level of the nearest trough position on the right side of the target gray level in the gray level histogram of the i-th block image, recorded as the right value of the target range of the i-th block image, is the gray level of the nearest trough position on the left side of the target gray level in the gray level histogram of the j-th block image, recorded as the left value of the target range of the j-th block image, is the gray level of the nearest trough position on the right side of the target gray level in the gray level histogram of the j-th block image, recorded as the right value of the target range of the j-th block image, is the peak concentration of the i-th block image, is the peak concentration of the jth block image, is to take the absolute value, max() is to take the maximum value, is the difference between the target range of the i-th block image and the j-th block image; Get the differences between all target ranges, and record the minimum value of the differences between all target ranges as , represents the difference between the target ranges of the p-th block image and the q-th block image, then the optimal target range is , Take the value on the left side of the target range for the p-th block image, Take the value on the right side of the target range for the p-th block image, Take the value on the left side of the target range of the qth block image, Take the value on the right side of the target range of the qth block image; The specific steps of obtaining the linear function of the pixels in the block image according to the optimal target range are as follows: The linear function is: In the formula, is the gray value of any pixel in the kth block image after the optimal channel image is divided into blocks, is the gray value of any pixel in the kth block image after linear processing after the optimal channel image is divided into blocks. is the left side value of the optimal target range, Take the value on the right side of the optimal target range.

2. According to claim 1, a method for automatically segmenting and extracting pest and disease areas of fruit tree leaves is characterized by: The step of obtaining the first grayscale level and the number of pixels corresponding to the first grayscale level according to the grayscale histogram of the channel image includes the following specific steps: For any channel image, the difference in the number of pixels corresponding to the i-th grayscale level and the i-1-th grayscale level in the grayscale histogram of the channel image is obtained along the direction of increasing grayscale levels. If the difference is greater than 0, the difference in the number of pixels corresponding to the i+1-th grayscale level and the i-th grayscale level is obtained, and so on, until the difference in the number of pixels corresponding to the j+1-th grayscale level and the j-th grayscale level is less than 0, the j-th grayscale level is recorded as the first grayscale level, and the number of pixels corresponding to the first grayscale level is obtained.

3. The method for automatically segmenting and extracting pest and disease areas of fruit tree leaves according to claim 1, characterized in that: The step of obtaining the peak width according to the first gray level includes the following specific steps: In the grayscale histogram of the channel image, along the left side of the first grayscale level, obtain the number of pixels corresponding to the grayscale level and The gray level with the smallest absolute value of the difference is recorded as the second gray level; in the gray histogram of the channel image, along the right side of the first gray level, obtain the number of pixels corresponding to the gray level and The gray level with the smallest absolute value of the difference is recorded as the third gray level, the difference between the third gray level and the second gray level is recorded as the peak width, and A is the number of pixels corresponding to the first gray level.

4. The method for automatically segmenting and extracting pest and disease areas of fruit tree leaves according to claim 1, characterized in that: The step of obtaining the peak concentration degree according to the number of pixels and the peak width corresponding to the first gray level and obtaining the optimal channel image according to the peak concentration degree includes the following specific steps: For any channel image, the ratio of the number of pixels corresponding to the first gray level to the peak width is taken as the peak concentration degree, the peak concentration degrees corresponding to all channel images are obtained, and the channel image corresponding to the maximum peak concentration degree is taken as the optimal channel image.

5. The method for automatically segmenting and extracting pest and disease areas of fruit tree leaves according to claim 1, characterized in that: The method of obtaining a plurality of block images and the order of the block images according to the optimal channel image, and obtaining a target grayscale level and a target range of the block images according to the grayscale histogram of the block images, comprises the following specific steps: The optimal channel image is denoted as , the image length is , the image width is , the optimal channel image is obtained by equal division The size is The block image, is the preset first block ratio, The second block ratio is preset, and the order of obtaining a plurality of block images by dividing the optimal channel image in the order from left to right and from top to bottom; For any block image, obtain the grayscale histogram of the block image, obtain all the maximum points in the grayscale histogram of the block image, record the grayscale level corresponding to the rightmost maximum point in the grayscale histogram of the block image as the target grayscale level, and record the grayscale levels of the nearest trough positions on both sides of the target grayscale level as and ,in ,Will as the target range of the i-th block image.

6. The method for automatically segmenting and extracting pest and disease areas of fruit tree leaves according to claim 1, characterized in that: The step of obtaining the peak concentration of the block image according to the target grayscale and the grayscale histogram of the block image includes the following specific steps: In the formula, is the target grayscale level of the i-th block image, The specific method of obtaining is as follows: The number of pixels corresponding to the target gray level is recorded as , in the grayscale histogram of the i-th block image, along the left side of the target grayscale level, obtain the number of pixels corresponding to the grayscale level and The gray level with the smallest absolute value of the difference is recorded as the fourth gray level, and the difference between the target gray level and the fourth gray level is recorded as ; The specific method of obtaining is as follows: in the grayscale histogram of the i-th block image, along the right side of the target grayscale, obtain the number of pixels corresponding to the grayscale and The gray level with the smallest absolute value of the difference is recorded as the fifth gray level, and the difference between the fifth gray level and the target gray level is recorded as ; is the number of pixels corresponding to gray level k in the gray histogram of the i-th block image, is the peak concentration of the i-th block image.

7. The method for automatically segmenting and extracting pest and disease areas of fruit tree leaves according to claim 1, characterized in that: The method of obtaining an enhanced fruit leaf image according to the sequence of the linear function and the block images includes the following specific steps: The optimal channel image is linearly processed through the pixels on all the block images after block division using a linear function to obtain the block images after linear processing. All the block images after linear processing are merged in the order of the block images to obtain a merged image, which is recorded as the enhanced fruit tree leaf image.

8. The method for automatically segmenting and extracting pest and disease areas of fruit tree leaves according to claim 1, characterized in that: The specific steps of obtaining the diseased leaf area according to the enhanced fruit tree leaf image are as follows: The enhanced fruit tree leaf image is subjected to Otsu threshold segmentation to obtain the optimal segmentation threshold. The grayscale values ​​of pixels in the enhanced fruit tree leaf image that are greater than the optimal segmentation threshold are set to 255, and the grayscale values ​​of pixels that are less than or equal to the optimal segmentation threshold are set to 0 to obtain a leaf disease image. The area composed of pixels with a grayscale value of 255 in the leaf disease image is the diseased leaf area.