Visual detection device and method for diseases and pests of red heart pomelo
Patent Information
- Application Number
- CN202610833712.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-10
- Publication Date
- 2026-10-13
AI Technical Summary
[0002]红心柚作为重要的经济果树,其病虫害的早期、精准检测对果园的产量与品质保障至关重要,在实际果园环境中,自然光照条件极为复杂,受天气、时段及枝叶遮挡等因素影响,采集到的红心柚植株图像常出现局部过曝或欠曝的光照不均现象,导致病斑的纹理细节和区域形态等关键判别特征被严重干扰
本申请提供的红心柚病虫害视觉检测装置及方法中,首先,获取待检测红心柚的原始图像,并以所述原始图像中各像素亮度值相对于图像平均亮度的偏差,作为亮度偏差值,该步骤可实现对各像素亮度偏离图像整体平均水平的方向和程度的客观量化,从而提高了后续光照异常区域划分的准确性和抗纹理干扰能力,避免将病斑或叶脉等正常纹理误判为光照异常;其次,依据所有的亮度偏差值从所述原始图像中划分出光照异常区域,进而确定光照补偿图像,该步骤可仅对真实过曝或过暗区域进行定向增益补偿和保边平滑,从而提高了光照补偿的针对性,使补偿后图像在消除光照不均的同时完整保留病斑边缘和细节纹理等关键判别信息;随后,以小尺度卷积核提取所述光照补偿图像的特征作为第一特征图,以大尺度卷积核从所述光照补偿图像中提取大尺度区域形态特征,并经上采样和特征对齐映射,得到与所述第一特征图语义对齐的第二特征图,该步骤可对光照补偿图像并行提取局部细节特征和大尺度区域形态特征,并通过上采样和特征对齐映射使两组特征空间可逐像素比较,从而提高了多尺度特征融合的语义可比性;进而,确定所述第一特征图与所述第二特征图逐像素响应之差的绝对值,并将绝对值超过预设的自适应阈值的像素标记为尺度敏感区域,该步骤可对局部特征与大尺度特征的响应差异进行全图量化,并通过基于统计分布的自适应阈值自动定位尺度敏感区域,从而提高了对病虫害特征发生剧烈尺度变化的区域的发现能力;然后,在所述尺度敏感区域内,根据像素响应之差的方向和大小对所述第一特征图和所述第二特征图加权融合,得到多尺度融合特征图,该步骤可根据响应差异的方向和幅度自适应生成归一化融合权重,在细节强时强化细节、在区域形态强时强化大尺度特征,从而提高了融合特征对混合型病虫害的多尺度适应能力;最后,基于所述多尺度融合特征图进行病虫害识别,输出待检测红心柚的病虫害类别和病斑位置,该步骤可对多尺度自适应融合后的特征同步进行分类和密集位置预测并输出类别和病斑位置,从而提高了实际果园中多类型病虫害并发场景下精准识别与定位的一体化检测能力;综上所述,本申请的方案可在自适应光照补偿的基础上,根据图像内容自身特性自动调节多尺度特征融合策略,以输出病虫害类别。
Smart Images

Figure CN122906540A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of visual inspection technology, and in particular to a visual inspection device and method for diseases and pests of red pomelo. Background Technology
[0002] As an important economic fruit tree, the early and accurate detection of diseases and pests of red pomelo is crucial to ensuring the yield and quality of the orchard. In the actual orchard environment, the natural lighting conditions are extremely complex. Affected by factors such as weather, time of day, and shading by branches and leaves, the collected images of red pomelo plants often show uneven lighting phenomena such as local overexposure or underexposure, which seriously interferes with the key discriminative features such as the texture details and regional morphology of lesions.
[0003] Existing illumination compensation methods typically focus only on adjusting the overall brightness of the image, lacking the ability to adaptively identify and directionally compensate for areas with abnormal lighting. This can easily damage the edge details of the original image during the compensation process, thus reducing subsequent detection accuracy. Furthermore, the visual representation of diseases and pests in pomelo exhibits significant multi-scale characteristics: pests usually manifest as small holes and feeding marks, while diseases like canker and anthracnose are characterized by large-scale features such as the regional spread and spatial distribution of lesions. Existing multi-scale feature fusion methods often use fixed weights or generate fusion coefficients through general attention mechanisms, failing to automatically determine whether to enhance local details or large-scale morphological features based on the actual scale characteristics of each spatial location in the image. This makes it difficult to balance the recognition accuracy of different types of diseases and pests in mixed-type disease and pest detection. Therefore, how to automatically adjust the multi-scale feature fusion strategy based on the characteristics of the image content itself, on the basis of adaptive illumination compensation, to output the disease and pest category has become a challenge for the industry. Summary of the Invention
[0004] Based on this, this application provides a visual detection device and method for red grapefruit pests and diseases that automatically adjusts a multi-scale feature fusion strategy according to the characteristics of the image content itself to output the pest and disease category.
[0005] Firstly, this application provides a visual detection method for diseases and pests of red pomelo, comprising the following steps: Obtain the original image of the red pomelo to be detected, and use the deviation of the brightness value of each pixel in the original image relative to the average brightness of the image as the brightness deviation value; Based on all brightness deviation values, areas of abnormal lighting are identified from the original image, and then a lighting compensation image is determined. The features of the illumination-compensated image are extracted using small-scale convolution kernels as the first feature map. Large-scale region morphological features are extracted from the illumination-compensated image using large-scale convolution kernels. After upsampling and feature alignment mapping, a second feature map that is semantically aligned with the first feature map is obtained. Determine the absolute value of the difference between the pixel-by-pixel responses of the first feature map and the second feature map, and mark pixels whose absolute values exceed a preset adaptive threshold as scale-sensitive regions; Within the scale-sensitive region, the first feature map and the second feature map are weighted and fused according to the direction and magnitude of the difference in pixel responses to obtain a multi-scale fused feature map; Based on the multi-scale fusion feature map, pest and disease identification is performed, and the pest and disease categories and lesion locations of the red grapefruit to be detected are output.
[0006] In some embodiments, dividing the illumination-abnormal region from the original image based on all brightness deviation values specifically includes: Obtain the preset allowable range of brightness deviation; Pixels in the original image whose corresponding brightness deviation value exceeds the allowable range are identified as pixels with abnormal lighting. All spatially connected pixels with consistent brightness deviation directions among all pixels with lighting abnormalities are grouped into several lighting abnormality regions.
[0007] In some embodiments, determining the illumination-compensated image specifically includes: For each region with abnormal lighting, a pixel-level adaptive gain coefficient is generated for the corresponding pixel based on the brightness deviation value of each pixel within the region. Gain compensation is performed on each pixel in the abnormal lighting area based on the adaptive gain coefficient at each pixel level, and the brightness value of each pixel is adjusted to obtain the compensated brightness value of each pixel in each abnormal lighting area. The brightness values of each pixel after gain compensation are range-clamped to ensure that the compensated brightness values are within the preset effective brightness range. After range clamping, the boundaries between each abnormal and normal illumination region are smoothed to obtain an illumination-compensated image.
[0008] In some embodiments, extracting features from the illumination compensation image using small-scale convolutional kernels as a first feature map specifically includes: Construct local feature extraction branches using small-scale convolutional kernel stacking; The illumination-compensated image is input into the local feature extraction branch to extract the first feature map.
[0009] In some embodiments, extracting large-scale region morphological features from the illumination-compensated image using large-scale convolutional kernels, and then upsampling and feature alignment mapping to obtain a second feature map semantically aligned with the first feature map specifically includes: A large receptive field feature extraction branch is constructed, and the illumination-compensated image is input into the large receptive field feature extraction branch to extract large-scale regional morphological feature maps. Upsample the large-scale region morphological feature map to make its spatial resolution the same as the first feature map. Figure 1 To; The upsampled large-scale region morphological feature map is subjected to feature alignment mapping so that the channel semantics of the mapped large-scale region morphological feature map are aligned with the first feature map, thus obtaining the second feature map.
[0010] In some embodiments, determining the absolute value of the difference between the pixel-by-pixel responses of the first feature map and the second feature map specifically includes: At each identical spatial location between the first feature map and the second feature map, the difference in response is calculated channel by channel; Take the absolute value of the difference between each response to obtain the absolute value of the difference between the responses at each spatial location.
[0011] In some embodiments, within the scale-sensitive region, the first feature map and the second feature map are weighted and fused according to the direction and magnitude of the difference in pixel responses to obtain a multi-scale fused feature map, specifically including: Within the scale-sensitive region, fusion weights are generated based on the direction and magnitude of the difference in pixel responses; The first feature map and the second feature map are weighted and fused according to the fusion weight to obtain a multi-scale fused feature map.
[0012] Secondly, this application provides a visual detection device for diseases and pests of red pomelo, comprising: The acquisition module is used to acquire the original image of the red pomelo to be detected, and to use the deviation of the brightness value of each pixel in the original image relative to the average brightness of the image as the brightness deviation value. The processing module is used to divide the abnormal lighting areas from the original image based on all the brightness deviation values, and then determine the lighting compensation image; The processing module is further configured to extract features of the illumination compensation image using a small-scale convolution kernel as a first feature map, extract large-scale regional morphological features from the illumination compensation image using a large-scale convolution kernel, and obtain a second feature map that is semantically aligned with the first feature map after upsampling and feature alignment mapping. The processing module is further configured to determine the absolute value of the difference between the pixel-by-pixel responses of the first feature map and the second feature map, and to mark pixels whose absolute values exceed a preset adaptive threshold as scale-sensitive regions. The processing module is further configured to perform weighted fusion of the first feature map and the second feature map within the scale-sensitive region according to the direction and magnitude of the difference in pixel responses, to obtain a multi-scale fused feature map; The execution module is used to identify pests and diseases based on the multi-scale fused feature map and output the pest and disease categories and lesion locations of the red pomelo to be detected.
[0013] Thirdly, this application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described visual detection method for diseases and pests of red pomelo.
[0014] Fourthly, this application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the above-described visual detection method for diseases and pests of red pomelo.
[0015] The technical solutions provided by the embodiments disclosed in this application have the following beneficial effects: The visual detection device and method for diseases and pests of red pomelo provided in this application firstly acquires the original image of the red pomelo to be detected, and uses the deviation of the brightness value of each pixel in the original image relative to the average brightness of the image as the brightness deviation value. This step can objectively quantify the direction and degree of the deviation of the brightness of each pixel from the overall average level of the image, thereby improving the accuracy of subsequent division of abnormal lighting areas and the ability to resist texture interference, and avoiding misjudging normal textures such as lesions or leaf veins as abnormal lighting. Secondly, based on all the brightness deviation values, the abnormal lighting areas are divided from the original image, and then the lighting compensation image is determined. This step can perform directional gain compensation and edge-preserving flatness only on the truly overexposed or underexposed areas. This process improves the targeting of illumination compensation, ensuring that the compensated image retains key discriminative information such as lesion edges and detailed textures while eliminating uneven illumination. Subsequently, features from the illumination-compensated image are extracted using small-scale convolutional kernels as the first feature map. Large-scale morphological features are then extracted from the illumination-compensated image using large-scale convolutional kernels. After upsampling and feature alignment mapping, a second feature map semantically aligned with the first feature map is obtained. This step allows for parallel extraction of local detail features and large-scale morphological features from the illumination-compensated image. Upsampling and feature alignment mapping enable pixel-by-pixel comparison between the two feature spaces, thereby improving the semantic comparability of multi-scale feature fusion. Furthermore, The absolute value of the pixel-by-pixel response difference between the first feature map and the second feature map is determined, and pixels whose absolute value exceeds a preset adaptive threshold are marked as scale-sensitive regions. This step can perform full-image quantization of the response difference between local and large-scale features, and automatically locate scale-sensitive regions through an adaptive threshold based on statistical distribution, thereby improving the ability to detect areas where pest and disease features undergo drastic scale changes. Then, within the scale-sensitive region, the first feature map and the second feature map are weighted and fused according to the direction and magnitude of the pixel response difference to obtain a multi-scale fused feature map. This step can adaptively generate normalized fusion weights based on the direction and magnitude of the response difference. When details are strong, details are enhanced; when regional morphology is strong, large-scale features are enhanced, thereby improving the multi-scale adaptability of the fused features to mixed pests and diseases. Finally, based on the multi-scale fused feature map, pest and disease identification is performed, and the pest and disease category and lesion location of the red pomelo to be detected are output. This step can simultaneously classify and predict the dense location of the features after multi-scale adaptive fusion and output the category and lesion location, thereby improving the integrated detection capability of accurate identification and localization in the scenario of multiple types of pests and diseases occurring simultaneously in actual orchards. In summary, the solution of this application can automatically adjust the multi-scale feature fusion strategy according to the characteristics of the image content itself on the basis of adaptive illumination compensation to output the pest and disease category. Attached Figure Description
[0016] Figure 1This is an exemplary flowchart of a visual detection method for diseases and pests of red pomelo according to some embodiments of this application; Figure 2 These are schematic diagrams illustrating application scenarios of a visual inspection data processing system according to some embodiments of this application; Figure 3 This is a schematic diagram of the process for generating fusion weights according to some embodiments of this application; Figure 4 This is a schematic diagram of the structure of a visual detection device for diseases and pests of red pomelo according to some embodiments of this application; Figure 5 This is a schematic diagram of the structure of a computer device for implementing a visual detection method for diseases and pests of red grapefruit, according to some embodiments of this application. Detailed Implementation
[0017] To better understand the above technical solutions, the following will provide a detailed explanation of the technical solutions in conjunction with the accompanying drawings and specific implementation methods.
[0018] refer to Figure 1 The figure is an exemplary flowchart of a visual detection method for diseases and pests of red pomelo according to some embodiments of this application. The visual detection method for diseases and pests of red pomelo mainly includes the following steps: In step 101, the original image of the red grapefruit to be detected is obtained, and the deviation of the brightness value of each pixel in the original image from the average brightness of the image is used as the brightness deviation value.
[0019] In specific implementation, the original image of the red pomelo to be detected can be obtained in the following way: An image acquisition device deployed in the orchard is used to photograph the red pomelo plants in the area to be detected, capturing visible light images of the plant parts, including the fruit, leaves, and branches. During photography, the optical axis of the image acquisition device is directed towards the canopy or fruit-bearing part of the red pomelo plant. Based on the lighting environment of the orchard, exposure parameters are adjusted or a supplementary lighting device is activated to ensure that the main area of the red pomelo plant in the captured image has a reasonable brightness distribution range and that there are no large areas of overexposure or underexposure. After acquisition, the obtained visible light image is used as the original image of the red pomelo to be detected and transmitted to an image processing unit communicatively connected to the image acquisition device for subsequent steps to calculate the brightness deviation value of the original image. The image acquisition device can be a color camera or a camera device equipped with a visible light lens, and the image processing unit can be an embedded processor, an edge computing device, or a remote server. Other methods can also be used in other embodiments, and are not limited here.
[0020] In specific implementation, the brightness deviation value, which is the deviation of each pixel's brightness value from the average brightness of the image, can be achieved as follows: First, the original image is converted from its original color space to a brightness-chroma separated color space, and the brightness channel in this color space is extracted to obtain a brightness image with the same spatial resolution as the original image. Then, all pixels in the brightness image are traversed, and the brightness value of each pixel is accumulated and divided by the total number of pixels to obtain the average brightness of the original image. Next, for each pixel in the brightness image, the brightness value of that pixel is subtracted from the average brightness of the image, and the difference is the brightness deviation value of that pixel. The brightness deviation value is a signed numerical value. A positive value indicates that the pixel brightness is higher than the average brightness of the image, and a negative value indicates that the pixel brightness is lower than the average brightness of the image. The absolute value reflects the degree to which the pixel deviates from the average level of the image. Thus, a corresponding brightness deviation value is generated for each pixel in the original image, and a brightness deviation map corresponding to the original image space is generated, so that subsequent steps can divide the lighting abnormality area from the original image based on all the brightness deviation values. In other embodiments, if the original image itself is a single-channel brightness image, the deviation of the pixel brightness value from the average brightness of the image is directly calculated on the brightness image as the brightness deviation value, which is not limited here.
[0021] It should be noted that the brightness deviation value in this application represents the direction and degree of deviation of the brightness of a single pixel in the original image from the overall average brightness of the image, and serves as the basis for dividing areas of abnormal illumination and determining the direction of gain compensation.
[0022] In addition, it should be noted that the above steps can objectively quantify the direction and degree of deviation of the brightness of each pixel from the overall average level of the image, thereby improving the accuracy of subsequent division of abnormal lighting areas and the ability to resist texture interference, and avoiding misjudging normal textures such as lesions or leaf veins as abnormal lighting.
[0023] In some embodiments, reference Figure 2 As shown in the figure, this figure is a schematic diagram of the application scenario of the visual inspection data processing system shown in some embodiments of this application. The figure includes three main components: acquisition device, server and data storage device. The acquisition device is responsible for collecting the original image of the red grapefruit to be inspected and sending the acquired original image to the server through the communication network. The visual inspection data processing system runs in the server. The server stores the processing results in the data storage device and visualizes them.
[0024] In step 102, the illumination abnormality area is divided from the original image based on all the brightness deviation values, and then the illumination compensation image is determined.
[0025] In some embodiments, the identification of areas of abnormal illumination from the original image based on all brightness deviation values can be achieved by the following steps: Obtain the preset allowable range of brightness deviation; Pixels in the original image whose corresponding brightness deviation value exceeds the allowable range are identified as pixels with abnormal lighting. All spatially connected pixels with consistent brightness deviation directions among all pixels with lighting abnormalities are grouped into several lighting abnormality regions.
[0026] It should be noted that the permissible range of brightness deviation in this application is a numerical range that defines the normal fluctuation range of brightness in an image, and is the criterion for distinguishing between pixels with normal lighting and pixels with abnormal lighting.
[0027] In specific implementation, the brightness deviation tolerance range can be preset in the following way: based on the statistical distribution characteristics of the brightness deviation values of all pixels in the brightness deviation map, a symmetrical numerical range centered at zero is selected as the brightness deviation tolerance range; specifically, the standard deviation of all brightness deviation values can be calculated, or the deviation value amplitude corresponding to a certain quantile after sorting the absolute values of all brightness deviation values can be taken, and the negative and positive values of the amplitude can be used as the lower and upper bounds of the range, respectively; this range covers normal pixels in the image whose brightness is close to the average level of the image. The original scene corresponding to the pixels within the range is considered to have normal lighting, and the area outside the range is considered to have abnormal lighting. Other methods can also be used in other embodiments, which are not limited here.
[0028] In specific implementation, the following method can be used to determine the pixels in the original image whose brightness deviation value exceeds the allowable range as pixels with abnormal lighting: traverse each pixel in the brightness deviation map corresponding to the original image, and compare the brightness deviation value of the pixel with the lower and upper bounds of the allowable range of brightness deviation; if the brightness deviation value is less than the lower bound or greater than the upper bound, the pixel is determined to be a pixel with abnormal lighting; if the brightness deviation value is between the lower and upper bounds, it is determined to be a pixel with normal lighting; thus, a pixel with abnormal lighting and normal lighting is obtained. Each pixel in the pixel map is marked as either pixel with abnormal lighting or pixel with normal lighting. Other methods can also be used in other embodiments, which are not limited here.
[0029] In specific implementation, aggregating spatially connected pixels with consistent brightness deviation directions among all pixels with lighting abnormalities into several lighting abnormality regions can be achieved in the following way: performing connected component analysis on the pixels marked as lighting abnormalities in the lighting abnormality marking map, and adding brightness deviation direction constraints during the connected component analysis process, only dividing spatially adjacent pixels with the same positive or negative sign of brightness deviation values into the same connected component; the connected component formed by pixels with positive brightness deviation values is regarded as an overexposed area, and the connected component formed by pixels with negative brightness deviation values is regarded as an underexposed area, and finally each connected component corresponds to a lighting abnormality region; in other embodiments, the lighting abnormality region can also be extracted by combining morphological dilation and connected component labeling, which is not limited in this application.
[0030] In some embodiments, determining the illumination-compensated image can be achieved by the following steps: For each region with abnormal lighting, a pixel-level adaptive gain coefficient is generated for the corresponding pixel based on the brightness deviation value of each pixel within the region. Gain compensation is performed on each pixel in the abnormal lighting area based on the adaptive gain coefficient at each pixel level, and the brightness value of each pixel is adjusted to obtain the compensated brightness value of each pixel in each abnormal lighting area. The brightness values of each pixel after gain compensation are range-clamped to ensure that the compensated brightness values are within the preset effective brightness range. After range clamping, the boundaries between each abnormal and normal illumination region are smoothed to obtain an illumination-compensated image.
[0031] It should be noted that the adaptive gain coefficient in this application is a combination parameter indicating the adjustment direction and adjustment strength for compensating the brightness of each pixel in the abnormal lighting area, so that the brightness of the compensated area approaches the average brightness of the image.
[0032] In specific implementation, for each illumination anomaly region, the pixel-level adaptive gain coefficient generated for the corresponding pixel based on the brightness deviation value of each pixel within the illumination anomaly region can be achieved in the following way: For each determined illumination anomaly region, firstly, according to the region type determined when the illumination anomaly region was divided, obtain the unified gain direction for gain compensation within the region. If the region type is an overexposed area, the gain direction is to darken; if the region type is an underexposed area, the gain direction is to brighten. Then, traverse each pixel within the illumination anomaly region, obtain the brightness deviation value corresponding to that pixel, and use the absolute value of the brightness deviation value as the deviation amplitude of that pixel. Next, convert the deviation amplitude into the corresponding gain intensity value according to a pre-set monotonic mapping relationship, so that pixels with larger deviation amplitudes obtain larger gain intensity values, while pixels with deviation amplitudes closer to the boundary of the brightness deviation tolerance range obtain gain intensity values close to zero. This monotonic mapping relationship can be implemented through linear mapping or lookup table. Finally, combine the gain direction and the gain intensity value as the pixel-level adaptive gain coefficient for that pixel. Other methods can also be used in other embodiments, which are not limited here.
[0033] In specific implementation, gain compensation is performed on each pixel corresponding to the illumination anomaly region based on the pixel-level adaptive gain coefficient to adjust the brightness value of each pixel, thereby obtaining the compensated brightness value of each pixel in each illumination anomaly region. This can be achieved in the following way: traverse each illumination anomaly region, and for each pixel in the illumination anomaly region, obtain the gain direction and gain intensity value contained in the pixel-level adaptive gain coefficient corresponding to that pixel; if the gain direction is to darken, subtract the gain intensity value from the original brightness value of the pixel in the original image to obtain the compensated brightness value of the pixel; if the gain direction is to brighten, add the gain intensity value to the original brightness value of the pixel in the original image to obtain the compensated brightness value of the pixel; after performing the above gain compensation operation on each pixel in each illumination anomaly region, the brightness values of all pixels in each illumination anomaly region are corrected, while the brightness values of pixels in all normal regions remain unchanged, thus obtaining the compensated pixel brightness value of each illumination anomaly region. Other methods can also be used in other embodiments, which are not limited here.
[0034] In specific implementation, the brightness values of each pixel after gain compensation are subjected to range clamping processing to ensure that the compensated brightness values are within a preset effective brightness range. This can be achieved in the following way: Obtain the preset effective brightness range, which corresponds to a reasonable value range of the image brightness channel, for example, 0 to 255 when the brightness value is represented by an eight-bit unsigned integer; Traverse the brightness value of each pixel in each abnormal illumination region obtained after gain compensation, and compare the brightness value with the lower and upper bounds of the effective brightness range. If the brightness value is lower than the lower bound, set the brightness value as the lower bound value; if the brightness value is higher than the upper bound, set the brightness value as the upper bound value; if the brightness value is between the lower and upper bounds, keep the original value unchanged; After completing the above comparison and adjustment for the brightness values of all pixel values after gain compensation, the brightness values of each pixel after range clamping processing are obtained. This processing ensures that the compensated brightness values will not contain invalid data that exceeds the limit. Other methods can also be used in other embodiments, which are not limited here.
[0035] In specific implementation, the boundary smoothing process between each abnormal lighting region and the normal region after range clamping is performed to obtain the lighting compensation image. This can be achieved in the following way: First, based on the region mask of each abnormal lighting region, the boundary transition zone between each abnormal lighting region and the normal region is determined. This boundary transition zone can be obtained by morphologically dilating the mask of the abnormal lighting region and taking the difference with the original mask. Then, for each pixel within the boundary transition zone, an edge-preserving smoothing filter is applied. This smoothing filter adjusts the smoothing intensity based on the brightness similarity and gradient information of pixels in the local neighborhood. While reducing the brightness difference on both sides of the boundary and eliminating false edges caused by brightness abrupt changes due to differences in region gain compensation, it can preserve the original details such as the edge of lesions and leaf vein texture at the boundary. For example, bilateral filtering or guided filtering can be used. After the above edge-preserving smoothing process is completed for each boundary transition zone, a lighting compensation image with uniform overall brightness and complete preservation of details is obtained. Other methods can also be used in other embodiments, which are not limited here.
[0036] It should be noted that the above steps can be used to perform targeted gain compensation and edge-preserving smoothing only on the actual overexposed or underexposed areas, thereby improving the targeting of illumination compensation. This allows the compensated image to completely preserve key discrimination information such as the edges of lesions and detailed textures while eliminating uneven illumination.
[0037] In step 103, features of the illumination-compensated image are extracted using small-scale convolution kernels as a first feature map, and large-scale region morphological features are extracted from the illumination-compensated image using large-scale convolution kernels. After upsampling and feature alignment mapping, a second feature map that is semantically aligned with the first feature map is obtained.
[0038] In some embodiments, extracting features from the illumination-compensated image using small-scale convolutional kernels as a first feature map can be achieved through the following steps: Construct local feature extraction branches using small-scale convolutional kernel stacking; The illumination-compensated image is input into the local feature extraction branch to extract the first feature map.
[0039] It should be noted that the local feature extraction branch in this application is a convolutional subnetwork that extracts the first feature map from the illumination-compensated image that responds to local detailed structures such as the edge of lesions, insect bite marks, and leaf vein texture.
[0040] In specific implementation, the local feature extraction branch that constructs a stack of small-scale convolutional kernels can be implemented in the following way: a convolutional sub-network composed of multiple small-sized convolutional kernels connected in series is built as a local feature extraction branch. This local feature extraction branch only uses small-sized convolutional kernels and aims to maintain spatial resolution. It extracts features within the local receptive field of the input image by sliding windows layer by layer. This ensures that each spatial location of the output feature map of this local feature extraction branch only integrates the original image information within the coverage neighborhood, thereby focusing on responding to local detailed structures such as lesion edges, insect bite marks, and leaf vein textures. Other methods can also be used in other embodiments, which are not limited here.
[0041] In specific implementation, the illumination-compensated image is input into the local feature extraction branch, and the first feature map is extracted in the following way: the obtained illumination-compensated image is directly used as the input of the local feature extraction branch. The illumination-compensated image flows through the small-scale convolution kernels of each level in the local feature extraction branch in sequence. Each level of small-scale convolution kernel further extracts deeper local detail features based on the output of the previous level. Finally, the final output of the local feature extraction branch is used as the first feature map extracted in this step. The first feature map retains the response to local texture and edge information in the illumination-compensated image. Other methods can also be used in other embodiments, which are not limited here.
[0042] In some embodiments, extracting large-scale region morphological features from the illumination-compensated image using large-scale convolutional kernels, and obtaining a second feature map semantically aligned with the first feature map through upsampling and feature alignment mapping, can be achieved through the following steps: A large receptive field feature extraction branch is constructed, and the illumination-compensated image is input into the large receptive field feature extraction branch to extract large-scale regional morphological feature maps. Upsample the large-scale region morphological feature map to make its spatial resolution the same as the first feature map. Figure 1 To; The upsampled large-scale region morphological feature map is subjected to feature alignment mapping so that the channel semantics of the mapped large-scale region morphological feature map are aligned with the first feature map, thus obtaining the second feature map.
[0043] It should be noted that the large receptive field feature extraction branch in this application is a convolutional subnetwork that extracts feature maps from the illumination-compensated image that respond to the morphology of a large area such as lesion area, leaf vein distribution, and fruit outline.
[0044] In specific implementation, a large receptive field feature extraction branch is constructed. The illumination-compensated image is input into this branch to extract large-scale regional morphological feature maps. This can be achieved by: constructing a convolutional subnetwork capable of obtaining a large receptive field as the large receptive field feature extraction branch. This branch expands the effective receptive field step by step by stacking convolutional layers and performing downsampling operations in between, or by introducing dilated convolutions to expand the receptive field without reducing resolution. After the illumination-compensated image is input into this branch, as the network layers advance, the receptive field range of the original image corresponding to each spatial location gradually expands, enabling each spatial location of the output feature map to perceive and cover a large area of morphology, such as lesion areas, leaf vein distribution, and fruit outlines. Finally, the output of this large receptive field feature extraction branch is used as the large-scale regional morphological feature map. Other methods can also be used in other embodiments, which are not limited here.
[0045] In specific implementation, the large-scale region morphological feature map is upsampled to make its spatial resolution comparable to the first feature map. Figure 1 This can be achieved by: obtaining the spatial resolution of the first feature map as the target resolution; using the large-scale region morphological feature map as input; and adjusting the width and height of the large-scale region morphological feature map to match the first feature map through interpolation upsampling operations. Figure 1 Thus, the upsampled feature map is completely aligned with the first feature map in spatial dimension, and the pixels at each spatial location form a one-to-one correspondence between the two. Other methods can also be used in other embodiments, which are not limited here.
[0046] In specific implementation, feature alignment mapping is performed on the upsampled large-scale region morphological feature map to align the channel semantics of the mapped large-scale region morphological feature map with the first feature map, resulting in a second feature map. This can be achieved by inputting the upsampled large-scale region morphological feature map into a feature alignment mapping module, which consists of a convolutional layer and a normalization layer. The convolutional layer adjusts the number of channels in the upsampled large-scale region morphological feature map to match the number of channels in the first feature map, and the normalization layer adjusts the feature value distribution of the adjusted feature map to be within a comparable range to the feature value distribution of the first feature map. After the above channel adjustment and distribution alignment, a second feature map with semantics aligned with the first feature map is obtained. At this point, the second feature map and the first feature map, under the conditions of consistent spatial resolution, consistent number of channels, and comparable feature semantics, can be used for subsequent pixel-by-pixel response difference calculation. Other methods can also be used in other embodiments, which are not limited here.
[0047] It should be noted that the above steps can extract local detail features and large-scale regional morphological features in parallel from the illumination-compensated image, and the two feature spaces can be compared pixel by pixel through upsampling and feature alignment mapping, thereby improving the semantic comparability of multi-scale feature fusion.
[0048] In step 104, the absolute value of the difference between the pixel-by-pixel responses of the first feature map and the second feature map is determined, and pixels whose absolute values exceed a preset adaptive threshold are marked as scale-sensitive regions.
[0049] In some embodiments, determining the absolute value of the difference between the pixel-by-pixel responses of the first feature map and the second feature map can be achieved by the following steps: At each identical spatial location between the first feature map and the second feature map, the difference in response is calculated channel by channel; Take the absolute value of the difference between each response to obtain the absolute value of the difference between the responses at each spatial location.
[0050] It should be noted that the pixel-wise response difference in this application is a signed numerical value that measures the difference between the local detail response and the large-scale regional morphological response of the first feature map and the second feature map at the same spatial location and channel. It is the basis for judging scale-sensitive locations and driving dynamic fusion weights.
[0051] In specific implementation, calculating the response difference channel by channel at each identical spatial location of the first feature map and the second feature map can be achieved in the following way: Since the second feature map has undergone upsampling and feature alignment mapping, it has the same spatial resolution and number of channels as the first feature map, and the channel semantics of the two are aligned. Therefore, for each identical spatial location of the first feature map and the second feature map, the response value of the corresponding channel in the second feature map is subtracted from the channel response value of the first feature map in all channels corresponding to that spatial location to obtain the response difference in each channel. The response difference is a signed numerical value. A positive value indicates that the local detail response of the first feature map is stronger than the large-scale region morphological response of the second feature map in that channel, and a negative value indicates that the large-scale region morphological response of the second feature map is stronger than the local detail response of the first feature map. After the traversal is completed, all channels of all spatial locations obtain the corresponding response difference. Other methods can also be used in other embodiments, which are not limited here.
[0052] In specific implementation, marking pixels whose absolute values exceed a preset adaptive threshold as scale-sensitive regions can be achieved in the following way: First, obtain the absolute values of the response differences corresponding to all spatial locations, statistically analyze the distribution of these absolute values, and take the value of the absolute values of all response differences that is located at a preset quantile after sorting by numerical value as the adaptive threshold. As an example, the preset quantile is the 90th quantile. Then, traverse each spatial location and compare the absolute value of the response difference at that spatial location with the adaptive threshold: if the absolute value of the response difference is greater than the adaptive threshold, mark the corresponding pixel as a scale-sensitive pixel; if the absolute value of the response difference is not greater than the adaptive threshold, mark the corresponding pixel as a non-scale-sensitive pixel. After traversal, aggregate all pixels marked as scale-sensitive pixels that are spatially connected to obtain the scale-sensitive region. In other embodiments, the adaptive threshold can also be the mean of all absolute values of response differences plus a preset multiple of the standard deviation as the threshold, which is not limited here.
[0053] It should be noted that the above steps can quantify the response differences between local features and large-scale features across the entire map, and automatically locate scale-sensitive regions through adaptive thresholds based on statistical distribution, thereby improving the ability to detect regions where pest and disease features undergo drastic scale changes.
[0054] In step 105, within the scale-sensitive region, the first feature map and the second feature map are weighted and fused according to the direction and magnitude of the difference in pixel responses to obtain a multi-scale fused feature map.
[0055] In some embodiments, within the scale-sensitive region, the first feature map and the second feature map are weighted and fused according to the direction and magnitude of the difference in pixel responses to obtain a multi-scale fused feature map. This can be achieved by the following steps: Within the scale-sensitive region, fusion weights are generated based on the direction and magnitude of the difference in pixel responses; The first feature map and the second feature map are weighted and fused according to the fusion weight to obtain a multi-scale fused feature map.
[0056] In some embodiments, reference Figure 3 As shown in the figure, this is a schematic diagram of the process for generating fusion weights in some embodiments of this application. In this embodiment, generating fusion weights based on the direction and magnitude of the difference in pixel responses within the scale-sensitive region can be achieved using the following steps: In step 1051, for each pixel within the scale-sensitive region, the weight allocation direction is determined based on the sign of the difference in responses corresponding to the pixel. In step 1052, weight coefficients for the first feature map and the second feature map are generated based on the magnitude of the difference in responses corresponding to pixels. In step 1053, the weight coefficients of the first feature map and the second feature map are normalized to obtain the fusion weight.
[0057] In specific implementation, for each pixel within the scale-sensitive region, determining the weight allocation direction based on the sign of the response difference can be achieved as follows: For each pixel within the scale-sensitive region, obtain the response difference corresponding to the pixel and check the sign of the response difference; if the response difference is positive, it indicates that the local detail response of the first feature map at that pixel is stronger than the large-scale region morphological response of the second feature map, and the weight allocation direction is determined to favor the first feature map; if the response difference is negative, it indicates that the large-scale region morphological response of the second feature map is stronger than the local detail response of the first feature map, and the weight allocation direction is determined to favor the second feature map. Other methods can also be used in other embodiments, which are not limited here.
[0058] In specific implementation, generating the weight coefficients of the first feature map and the second feature map based on the magnitude of the response difference corresponding to the pixel can be achieved in the following way: taking the absolute value of the response difference corresponding to the pixel as the response magnitude, mapping the response magnitude to a preset weight coefficient value range, and using a monotonically increasing correspondence so that the larger the response magnitude, the larger the dominant weight coefficient after mapping; then, generating the weight coefficients of the first feature map and the second feature map according to the determined weight allocation direction of the pixel: if the weight allocation direction is inclined towards the first feature map, then the dominant weight coefficient is used as the weight coefficient of the first feature map, and the preset baseline weight coefficient is used as the weight coefficient of the second feature map; if the weight allocation direction is inclined towards the second feature map, then the dominant weight coefficient is used as the weight coefficient of the second feature map, and the baseline weight coefficient is used as the weight coefficient of the first feature map; as an example, the baseline weight coefficient is 0.1; thus, each pixel in the scale-sensitive region obtains the weight coefficients of the first feature map and the second feature map respectively. Other methods can also be used in other embodiments, which are not limited here.
[0059] In specific implementation, the weight coefficients of the first feature map and the second feature map are normalized to obtain the fusion weight. This can be achieved in the following way: For pixels in each scale-sensitive region, the weight coefficients of the generated first feature map and the weight coefficients of the second feature map are summed. The weight coefficients of the first feature map are divided by the sum to obtain the normalized fusion weight of the first feature map. The weight coefficients of the second feature map are then divided by the sum to obtain the normalized fusion weight of the second feature map. After normalization, the sum of the fusion weights of the first and second feature maps is 1, and their respective values are both between 0 and 1, ensuring that the feature map response amplitude remains within a reasonable range during subsequent weighted fusion. The obtained normalized fusion weights of the first and second feature maps are the fusion weights corresponding to the pixel. Other methods can also be used in other embodiments, which are not limited here.
[0060] In specific implementation, the first feature map and the second feature map are weighted and fused according to the fusion weights to obtain a multi-scale fused feature map. This can be achieved in the following way: traverse each pixel within the scale-sensitive region, obtain the normalized first feature map fusion weight and the normalized second feature map fusion weight corresponding to the pixel; at the spatial location of the pixel, multiply the response value of each channel in the first feature map at that location by the normalized first feature map fusion weight, multiply the response value of each channel in the second feature map at that location by the normalized second feature map fusion weight, and then add the two weighted response values channel by channel. The obtained result is used as the multi-scale feature value after spatial location fusion. For non-scale-sensitive pixels outside the scale-sensitive region, the first feature map and the second feature map are weighted and fused using a preset fixed weight, or the response values of the first feature map and the second feature map at that location are directly averaged as the fused feature value. After traversal, the multi-scale fused feature values of all spatial locations are used to form a multi-scale fused feature map. This multi-scale fused feature map adaptively fuses local detail features and large-scale regional morphological features at scale-sensitive locations. Other methods can also be used in other embodiments, which are not limited here.
[0061] It should be noted that the multi-scale fusion feature map in this application is a feature map used to fuse local detail features and large-scale regional morphological features, and adaptively adjusts the fusion ratio of the two features according to the scale sensitivity at different spatial locations.
[0062] In addition, it should be noted that the above steps can adaptively generate normalized fusion weights based on the direction and magnitude of the response differences, strengthening details when details are strong and strengthening large-scale features when regional morphology is strong, thereby improving the multi-scale adaptability of fusion features to mixed pests and diseases.
[0063] In step 106, pest and disease identification is performed based on the multi-scale fusion feature map, and the pest and disease categories and lesion locations of the red pomelo to be detected are output.
[0064] In some embodiments, the identification of pests and diseases based on the multi-scale fused feature map, and the output of the pest and disease category and lesion location of the red pomelo to be detected, can be achieved by the following steps: The multi-scale fused feature map is classified to identify the pest and disease categories of the red pomelo to be detected; The location of the lesions in the multi-scale fused feature map is obtained by performing location prediction processing on the map. The pest / disease type and the location of the lesion are output as the detection results.
[0065] In specific implementation, the classification processing of the multi-scale fused feature map to identify the pest and disease category of the red pomelo to be detected can be achieved in the following way: The multi-scale fused feature map is input into the classification processing branch. The classification processing branch first performs a global pooling operation on the multi-scale fused feature map to compress the multi-scale fused feature map in the spatial dimension, resulting in a feature vector of fixed length. Then, the feature vector is passed through at least one fully connected layer in sequence, and finally mapped to the output nodes with the same number of preset pest and disease categories. Each output node corresponds to one pest and disease category, and the response value on the output node represents the confidence that the multi-scale fused feature map belongs to the corresponding pest and disease category. Next, the pest and disease category corresponding to the output node with the highest confidence is selected as the pest and disease category of the red pomelo to be detected. If the confidence of all output nodes is lower than the preset confidence judgment threshold, it is determined that the red pomelo to be detected is not infected with pests and diseases, and a health label is output as the pest and disease category. Other methods can also be used in other embodiments, which are not limited here.
[0066] It should be noted that the classification processing branch in this application can be pre-constructed in the following manner: A classification sub-network with the multi-scale fused feature map as input is built as the classification processing branch. This branch sequentially includes a global pooling layer, at least one fully connected layer, and an output layer. The global pooling layer is used to compress the input multi-scale fused feature map in the spatial dimension to obtain a fixed-length feature vector. The fully connected layer is used to perform a non-linear transformation on the feature vector to extract classification discriminant features. The number of nodes in the output layer is set to be consistent with the preset number of pest and disease categories, with each node corresponding to one pest and disease category. Confidence transformation processing can be added after the output layer so that the response value of each output node represents the confidence level of the input image belonging to the corresponding pest and disease category. The number of layers and nodes in each layer of the classification processing branch are determined according to the actual deployment. Scenario setting: The confidence threshold can be preset in the following way: After constructing the classification processing branch, the classification processing branch is tested using a labeled verification sample set. This verification sample set includes images of known healthy samples and images of samples known to be infected with various pests and diseases. The highest confidence value output by the classification processing branch for each verification sample is obtained. The distribution of the highest confidence values corresponding to all healthy samples is statistically analyzed. Based on this distribution, a confidence threshold value that can distinguish healthy samples from pest and disease samples with a preset allowable misjudgment ratio is selected, and this confidence threshold value is used as the confidence threshold. If a verification sample set cannot be obtained in actual deployment, an empirical fixed value can be directly set as the confidence threshold, for example, 0.5. Other methods can also be used in other embodiments, which are not limited here.
[0067] In specific implementation, the location prediction processing of the multi-scale fused feature map to obtain the location of the lesion of the red grapefruit to be detected can be achieved in the following way: The multi-scale fused feature map is input into the location prediction processing branch, which performs a pixel-by-pixel dense prediction operation on the multi-scale fused feature map and outputs a location response map with the same spatial resolution as the multi-scale fused feature map; the response value of each spatial location in the location response map represents the probability that the location belongs to the lesion region; the location response map is subjected to threshold segmentation processing, and spatial locations with response values exceeding a preset location determination threshold are marked as lesion candidate pixels, and spatially connected lesion candidate pixels are aggregated into a lesion candidate region; then, the minimum bounding rectangle or irregular contour of each lesion candidate region is extracted to obtain the bounding box coordinates or contour vertex coordinate sequence of the lesion candidate region, which is used as the lesion location corresponding to the lesion candidate region; finally, all detected lesion locations are summarized to obtain the lesion location of the red grapefruit to be detected; if no lesion candidate region is detected, an empty location is output as the lesion location. Other methods can also be used in other embodiments, which are not limited here.
[0068] It should be noted that the prediction processing branch in this application can be pre-constructed in the following manner: A dense prediction sub-network with the multi-scale fused feature map as input is built as the location prediction processing branch. This location prediction processing branch consists of at least one convolutional layer, has one output channel, and the spatial resolution of the output feature map is consistent with the input multi-scale fused feature map. An activation process can be added after the last layer of this location prediction processing branch, so that the response value of each spatial location in the output feature map is within a preset numerical range, representing the probability that the spatial location belongs to a lesion region. The number of convolutional layers and the kernel size of the location prediction processing branch are set according to the actual lesion size distribution. The location determination threshold can be preset in the following manner: [The text abruptly ends here, likely due to an incomplete sentence or missing information.] After the location prediction processing branch, a validation sample set with lesion location annotations is used to test the location prediction processing branch, and the location response map output by the location prediction processing branch for each validation sample is obtained. For the spatial locations in the location response map that are marked as real lesion areas, the lower quantile of their response value distribution is counted. For the spatial locations marked as non-lesion background areas, the upper quantile of their response value distribution is counted. The separation value that can maximize the distinction between lesion areas and background areas is selected as the location determination threshold. If a validation sample set with location annotations cannot be obtained in actual deployment, an empirical fixed value can be directly set as the location determination threshold, such as 0.5. Other methods can also be used in other embodiments, which are not limited here.
[0069] In specific implementation, the output of the pest and disease category and the lesion location as the detection result can be achieved in the following way: the pest and disease category output by the classification processing branch and the lesion location output by the location prediction processing branch are paired and encapsulated to generate a structured detection result; if the pest and disease category is a health identifier, the detection result only contains the health identifier and empty location information; if the pest and disease category is a specific pest and disease category, the detection result contains the name of the pest and disease category and the coordinates of one or more corresponding lesion locations; finally, the detection result is returned as the complete output of the visual detection method for the red pomelo pests and diseases for the current original image to be detected. Other methods can also be used in other embodiments, which are not limited here.
[0070] It should be noted that the above steps can simultaneously classify and predict the dense location of the features after multi-scale adaptive fusion and output the category and lesion location, thereby improving the integrated detection capability for accurate identification and localization in actual orchard scenarios with multiple types of pests and diseases occurring simultaneously.
[0071] In another aspect, in some embodiments, this application provides a visual detection device for diseases and pests of red pomelo, with reference to... Figure 4 The figure is a schematic diagram of the structure of a visual detection device for diseases and pests of red pomelo according to some embodiments of this application. The visual detection device for diseases and pests of red pomelo includes: an acquisition module 401, a processing module 402, and an execution module 403, which are described below. The acquisition module 401 in this application is mainly used to acquire the original image of the red pomelo to be detected, and to use the deviation of the brightness value of each pixel in the original image relative to the average brightness of the image as the brightness deviation value. Processing module 402, in this application, is mainly used to divide the abnormal lighting area from the original image based on all the brightness deviation values, and then determine the lighting compensation image; The processing module 402 described in this application is further configured to extract features of the illumination compensation image using a small-scale convolution kernel as a first feature map, extract large-scale regional morphological features from the illumination compensation image using a large-scale convolution kernel, and obtain a second feature map that is semantically aligned with the first feature map after upsampling and feature alignment mapping. The processing module 402 described in this application is further configured to determine the absolute value of the difference between the pixel-by-pixel responses of the first feature map and the second feature map, and to mark pixels whose absolute value exceeds a preset adaptive threshold as scale-sensitive regions; The processing module 402 described in this application is further configured to perform weighted fusion of the first feature map and the second feature map within the scale-sensitive region according to the direction and magnitude of the difference in pixel responses, to obtain a multi-scale fused feature map; The execution module 403 in this application is mainly used to identify pests and diseases based on the multi-scale fusion feature map, and output the pest and disease categories and lesion locations of the red pomelo to be detected.
[0072] Each module in the aforementioned visual detection device for diseases and pests of red pomelo can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.
[0073] In another embodiment, this application provides a computer device, which may be a server, and its internal structure diagram may be as follows. Figure 5 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computational and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database stores visual detection data of diseases and pests in red grapefruit. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it implements a visual detection method for diseases and pests in red grapefruit.
[0074] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0075] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above embodiment of the visual detection method for diseases and pests of red pomelo.
[0076] In one embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps described in the above embodiment of the visual detection method for diseases and pests of red grapefruit.
[0077] In one embodiment, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the steps described in the above embodiment of the visual detection method for diseases and pests of red grapefruit.
[0078] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0079] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0080] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A visual detection method for diseases and pests of red pomelo, characterized in that, Includes the following steps: Obtain the original image of the red pomelo to be detected, and use the deviation of the brightness value of each pixel in the original image relative to the average brightness of the image as the brightness deviation value; Based on all brightness deviation values, areas of abnormal lighting are identified from the original image, and then a lighting compensation image is determined. The features of the illumination-compensated image are extracted using small-scale convolution kernels as the first feature map. Large-scale region morphological features are extracted from the illumination-compensated image using large-scale convolution kernels. After upsampling and feature alignment mapping, a second feature map that is semantically aligned with the first feature map is obtained. Determine the absolute value of the difference between the pixel-by-pixel responses of the first feature map and the second feature map, and mark pixels whose absolute values exceed a preset adaptive threshold as scale-sensitive regions; Within the scale-sensitive region, the first feature map and the second feature map are weighted and fused according to the direction and magnitude of the difference in pixel responses to obtain a multi-scale fused feature map; Based on the multi-scale fusion feature map, pest and disease identification is performed, and the pest and disease categories and lesion locations of the red grapefruit to be detected are output.
2. The method as described in claim 1, characterized in that, The process of identifying areas of abnormal illumination from the original image based on all brightness deviation values specifically includes: Obtain the preset allowable range of brightness deviation; Pixels in the original image whose corresponding brightness deviation value exceeds the allowable range are identified as pixels with abnormal lighting. All spatially connected pixels with consistent brightness deviation directions among all pixels with lighting abnormalities are grouped into several lighting abnormality regions.
3. The method as described in claim 1, characterized in that, Determining the illumination-compensated image specifically includes: For each region with abnormal lighting, a pixel-level adaptive gain coefficient is generated for the corresponding pixel based on the brightness deviation value of each pixel within the region. Gain compensation is performed on each pixel in the illumination anomaly area based on the adaptive gain coefficient at each pixel level, and the brightness value of each pixel is adjusted to obtain the compensated brightness value of each pixel in each illumination anomaly area. The brightness values of each pixel after gain compensation are range-clamped to ensure that the compensated brightness values are within the preset effective brightness range. After range clamping, the boundaries between each abnormal and normal illumination region are smoothed to obtain an illumination-compensated image.
4. The method as described in claim 1, characterized in that, Extracting features from the illumination-compensated image using small-scale convolutional kernels as the first feature map specifically includes: Construct local feature extraction branches using small-scale convolutional kernel stacking; The illumination-compensated image is input into the local feature extraction branch to extract the first feature map.
5. The method as described in claim 1, characterized in that, Extracting large-scale region morphological features from the illumination-compensated image using large-scale convolutional kernels, and then upsampling and feature alignment mapping to obtain a second feature map semantically aligned with the first feature map, specifically includes: A large receptive field feature extraction branch is constructed, and the illumination-compensated image is input into the large receptive field feature extraction branch to extract large-scale regional morphological feature maps. The large-scale region morphological feature map is upsampled to make its spatial resolution consistent with the first feature map; The upsampled large-scale region morphological feature map is subjected to feature alignment mapping so that the channel semantics of the mapped large-scale region morphological feature map are aligned with the first feature map, thus obtaining the second feature map.
6. The method as described in claim 1, characterized in that, Determining the absolute value of the difference between the pixel-by-pixel responses of the first feature map and the second feature map specifically includes: At each identical spatial location between the first feature map and the second feature map, the difference in response is calculated channel by channel; Take the absolute value of the difference between each response to obtain the absolute value of the difference between the responses at each spatial location.
7. The method as described in claim 1, characterized in that, Within the scale-sensitive region, the first feature map and the second feature map are weighted and fused according to the direction and magnitude of the difference in pixel responses to obtain a multi-scale fused feature map, specifically including: Within the scale-sensitive region, fusion weights are generated based on the direction and magnitude of the difference in pixel responses; The first feature map and the second feature map are weighted and fused according to the fusion weight to obtain a multi-scale fused feature map.
8. A visual detection device for diseases and pests of red pomelo, characterized in that, include: The acquisition module is used to acquire the original image of the red pomelo to be detected, and to use the deviation of the brightness value of each pixel in the original image relative to the average brightness of the image as the brightness deviation value. The processing module is used to divide the abnormal lighting areas from the original image based on all the brightness deviation values, and then determine the lighting compensation image; The processing module is further configured to extract features of the illumination compensation image using a small-scale convolution kernel as a first feature map, extract large-scale regional morphological features from the illumination compensation image using a large-scale convolution kernel, and obtain a second feature map that is semantically aligned with the first feature map after upsampling and feature alignment mapping. The processing module is further configured to determine the absolute value of the difference between the pixel-by-pixel responses of the first feature map and the second feature map, and to mark pixels whose absolute values exceed a preset adaptive threshold as scale-sensitive regions. The processing module is further configured to perform weighted fusion of the first feature map and the second feature map within the scale-sensitive region according to the direction and magnitude of the difference in pixel responses, to obtain a multi-scale fused feature map; The execution module is used to identify pests and diseases based on the multi-scale fused feature map and output the pest and disease categories and lesion locations of the red pomelo to be detected.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the visual detection method for diseases and pests of red pomelo as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the visual detection method for diseases and pests of red grapefruit as described in any one of claims 1 to 7.