A natural image processing analysis method for plant recognition
By employing adaptive median filtering, multi-scale Retinex algorithm, and color card correction technology, the problems of noise and color bias in plant identification under low light conditions were solved, achieving efficient plant feature extraction and identification.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-04
- Publication Date
- 2026-03-20
AI Technical Summary
In complex lighting scenarios, low light causes blurring noise and light source color bias, which reduces the accuracy and robustness of plant recognition models. Traditional methods struggle to balance brightness and color accuracy, resulting in incomplete feature extraction.
Noise removal is achieved through adaptive median filtering and morphological operations, while illumination compensation and texture detail enhancement are performed using the multi-scale Retinex algorithm. Color shift is corrected through color card correction and nonlocal color transfer techniques, and the main plant region is extracted using a semantic segmentation model.
It significantly improves the accuracy and robustness of plant identification under complex lighting conditions, providing high-contrast, low-noise, and color-accurate image data to ensure the integrity and accuracy of plant features.
Smart Images

Figure CN121074671B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of plant recognition, and in particular to a natural image processing analysis method for plant recognition. BACKGROUND
[0002] The natural image processing analysis method for plant recognition is a key technology of the deep integration of computer vision technology and ecology, agronomy and other fields, and is widely used in scenes such as shade plants, ecological diversity monitoring such as counting rare species, and garden plant maintenance such as distinguishing weeds from medicinal plants. The core is to provide key data support for species classification, behavior recognition, and growth cycle tracking by collecting plant images in natural environments such as field crops, and processing and analyzing them through noise reduction, enhancement, feature extraction, etc. However, in complex lighting scenes such as low-light environments in night forests, artificial light source environments in greenhouses, and natural environments in twilight backlight, natural images often have both blur noise caused by low light and color distortion caused by light source color cast. Although traditional low-light enhancement methods can improve image visibility by increasing brightness, they can easily amplify color cast such as yellow shift caused by sodium lamps. Conventional color correction techniques are also difficult to accurately restore true colors such as misjudging the green color of plant leaves in backlight as dark brown due to dark area noise interference. When both are processed independently, the balance between brightness and color accuracy cannot be considered, ultimately leading to incomplete plant feature extraction such as ignoring the color difference of flower colors, significantly reducing the accuracy and robustness of the recognition model. SUMMARY
[0003] The present application provides a natural image processing analysis method for plant recognition, which solves the problem of detail blur in low light, overcomes the color cast problem caused by artificial light sources, alleviates the problem of subject and background confusion in dense scenes, and balances the technical contradiction between noise suppression and edge preservation.
[0004] To achieve the above-mentioned purpose, the embodiments of the present application disclose the following technical solutions:
[0005] In a first aspect, the present application discloses a natural image processing analysis method for plant recognition, comprising the following steps: step S1: obtaining an original natural image; an original natural image containing plants is collected by an image collection device, the original natural image contains plant subjects and backgrounds, and there are problems of low-light noise and color distortion;
[0006] Step S2: preprocessing the original natural image; the resolution of the original natural image is uniformly scaled to a preset size, and adaptive median filtering is used to remove high-frequency noise, the window size of the adaptive median filtering is dynamically adjusted according to the noise intensity of the local area, balancing the high-frequency noise suppression effect and the preservation of the plant subject edge details, at the same time, the small area interference area in the image is eliminated through morphological opening operation, obtaining a preprocessed image ;
[0007] Step S3: Process the preprocessed image Perform low-light enhancement; S3.1, Calculation The grayscale histogram is used to calculate the percentage of pixels in dark areas. If the percentage of pixels in dark areas reaches a preset proportion, adaptive illumination compensation is triggered. Based on the multi-scale Retinex algorithm, three Gaussian kernels of different scales are used to decompose the image into three color channels: R, G, and B. The illumination component at the Gaussian scale is calculated for each channel. The illumination contribution at each scale is balanced by learnable weight parameters to generate the illumination-compensated image. The weighting parameters are dynamically adjusted in conjunction with the main characteristics of the plant to ensure the accuracy of light compensation in the plant area; S3.2, for Texture detail enhancement: Non-local mean filtering is used to extract high-frequency details, and edge features of the plant subject are enhanced by edge-preserving convolution kernels to obtain an image enhanced in low light. .
[0008] Step S4: Enhance the low-light image Perform color correction; S4.1, Detect standard color card areas in the image: Extract candidate areas with uniform color and saturation higher than a preset threshold through morphological segmentation, perform shape analysis on the candidate areas, and screen out potential color card areas; finally determine the position of the standard color card through color consistency test; S4.2, Calculate color offset: Using the standard RGB value of the color card as a reference, calculate the average value of the actual RGB pixel values of each channel in the color card area; calculate the difference between the standard value and the actual average value of each channel; using the maximum absolute value of the offset of each channel as a benchmark, divide the offset of each channel by the maximum absolute value to obtain the ratio, set the diagonal element to 1 and add the ratio to form a color correction matrix to ensure that the pixel values after color mapping remain within the effective range; S4.3, Non-local color transfer: Divided into For each local block, a color distribution histogram is calculated. Blocks with similar color distributions are found in the neighborhood blocks. The true color distribution of the neighborhood blocks is transferred to the current block to correct the color shift, resulting in a color-corrected image. .
[0009] Step S5: Color-corrected image Feature preservation and post-processing are performed; S5.1, Identifying the Region of Interest (ROI) of the main plant: A pre-trained semantic segmentation model is used to perform preliminary image segmentation to generate a main subject mask; morphological closing operations are performed on the mask to connect the broken areas of the main subject; the complete boundary of the main subject is extracted using the minimum bounding rectangle algorithm to generate the final ROI region. S5.2, suppressing background interference: Gaussian blur is performed on the non-ROI region to reduce the interference of background texture on the subject feature; S5.3, outputting the final processed image , the brightness distribution of the image is uniform, color distortion is corrected, and the plant subject feature is completely retained.
[0010] In a second aspect, the present scheme discloses a natural image processing and analysis system for plant recognition, comprising:
[0011] An image acquisition module is configured to perform step S1 in the first aspect to acquire an original natural image;
[0012] A preprocessing module is configured to perform step S2 in the first aspect to perform resolution scaling, noise suppression and interference elimination on the original natural image, and output a preprocessed image ;
[0013] A low-light enhancement module is configured to perform step S3 in the first aspect to perform adaptive light compensation and texture detail enhancement on , and output a low-light enhanced image ;
[0014] A color correction module is configured to perform step S4 in the first aspect to perform reference color card correction and non-local color migration on , and output a color corrected image ;
[0015] A feature retention module is configured to perform step S5 in the first aspect to perform subject ROI extraction, background suppression and post-processing on , and output a final processed image .
[0016] The natural image processing and analysis method for plant recognition of the present application realizes accurate compensation of dark area light through the synergistic effect of multi-scale Retinex algorithm and learnable weight parameters, effectively suppresses noise interference while retaining plant subject texture details; combined with the step-by-step processing mechanism of non-local mean filtering and directional convolution kernel, both high-frequency details and edge contours are extracted and strengthened, solving the technical contradiction between noise suppression and detail retention in low-light conditions of traditional methods; based on the correction system of color card matching and color distribution migration, through HSV space segmentation and histogram similarity measurement, the color deviation problem caused by artificial light source is overcome, so that the color features of the plant subject present a natural state; the combination of semantic segmentation model and morphological post-processing accurately extracts the subject ROI and suppresses the background interference, providing high-contrast, low-noise and color-realistic image data for subsequent recognition, significantly improving the accuracy and robustness of plant recognition in complex scenes. BRIEF DESCRIPTION OF DRAWINGS
[0017] Figure 1 A flowchart of the method of embodiment one of the present application; Figure 2 A flowchart of the low-light enhancement of the pre-processed image in embodiment one of the present application; A flowchart of the low-light enhancement of the pre-processed image in embodiment one of the present application; Figure 3 A flowchart of the color correction of the low-light enhanced image in embodiment one of the present application; A flowchart of the color correction of the low-light enhanced image in embodiment one of the present application;
[0018] Figure 4 A flowchart of the feature preservation and post-processing of the color corrected image in embodiment one of the present application; A flowchart of the feature preservation and post-processing of the color corrected image in embodiment one of the present application;
[0019] Figure 5 A system block diagram of embodiment two of the present application;
[0020] Figure 6 An internal system block diagram of the low-light enhancement module of embodiment two of the present application;
[0021] Figure 7 A module interaction diagram of embodiment two of the present application. DETAILED DESCRIPTION
[0022] Reference will now be made in detail to the present application. While the application will be described in conjunction with these specific embodiments, it will be understood that they are not intended to limit the application to these embodiments. On the contrary, the application is intended to cover alternatives, modifications, and equivalents, which can be included within the spirit and scope of the application as defined by the appended claims. In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application. The present application can be practiced without some or all of these specific details. In other instances, well known process operations have not been described in detail in order not to unnecessarily obscure the present application.
[0023] The singular forms "a," "an," and "the" include plural referents unless the context clearly dictates otherwise. Unless otherwise defined, 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 application belongs.
[0024] Summary of the application: In the prior art, plant recognition natural image processing faces technical bottlenecks under complex lighting conditions. Low light environment is easy to cause insufficient image brightness and noise interference, making the main body details of the plant blurred; artificial light source or backlight scene causes color distortion, resulting in color feature distortion. These problems will reduce the accuracy of subsequent feature extraction, causing the recognition model to have poor discrimination ability for small features, especially in outdoor or dense scenes, the high similarity between the main body and the background will exacerbate feature confusion, and traditional methods are difficult to achieve effective separation. In view of the above problems, the present application proposes a multi-stage cooperative optimization image processing framework. First, through adaptive median filtering and morphological operation, noise is suppressed and the main body edge profile is retained in the preprocessing stage; then an adaptive illumination compensation model is constructed based on a multi-scale Retinex algorithm, and the learning weight parameters are used to dynamically balance the brightness enhancement effect under different lighting conditions, avoiding overexposure or underexposure caused by fixed parameters in traditional methods. To solve the contradiction between low-light enhancement and detail preservation, a step-by-step processing mechanism is adopted. The color correction link combines color card assisted correction and non-local color transfer technology, solves the color distortion problem caused by artificial light source through HSV space segmentation and histogram similarity measurement, and makes the plant main body color return to the natural state. Finally, through the combination of semantic segmentation model and morphological post-processing, the main body region of interest is accurately extracted and the background interference is suppressed, providing input data with uniform brightness, true color and complete features for subsequent recognition.
[0025] Embodiment one
[0026] A natural image processing analysis method for plant recognition, as claimed in claim 1, comprising the following steps: step S1: obtaining an original natural image; an original natural image containing a plant is collected by an image collection device, the original natural image contains a plant main body and a background, and there are problems of low-light noise and color distortion;
[0027] In this embodiment, in the field night or dense forest low-light scene: a high-definition camera with infrared fill light function is used, the fill light intensity is set to 10-15 lux to avoid strong light direct radiation causing plant leaf reflection;
[0028] Greenhouse crop monitoring scene: an industrial-grade CCD camera is used, the resolution is set to 2048x1536 pixels, the frame rate is 25fps, and it is suitable for the stable artificial light source environment in the greenhouse;
[0029] Collection operation requirements: when shooting, the plant main body should be completely included, such as herbaceous plants which should cover the leaves, stems and soil within 5cm around the roots, woody plants which should include a single branch and complete leaves, and at the same time, the light conditions such as light intensity, weather type and light source type during collection are recorded by the camera built-in sensor and stored as image metadata, providing environmental reference basis for subsequent preprocessing and enhancement steps;
[0030] Step S2: preprocessing the original natural image;
[0031] The resolution of the original natural image is uniformly scaled to a preset size, and adaptive median filtering is used to remove high-frequency noise. The window size of the adaptive median filtering is dynamically adjusted according to the noise intensity of the local area, balancing the high-frequency noise suppression effect and the preservation of the details of the plant main body edge. At the same time, the morphological opening operation is used to eliminate small area interference regions in the image, obtaining the preprocessed image ;
[0032] wherein the adaptive median filtering traverses the image with a basic size sliding window, and the noise intensity is judged by calculating the dispersion degree of the pixel gray value in the window. Specifically, the noise intensity N is defined by the standard deviation σ of the pixel gray value in the local area: N = σ. The adjustment of the dynamic window size W is realized by the following formula: ;
[0033] wherein: is the minimum window size, i.e. a preset value, ensuring the preservation of details in low noise areas; is the basic window size, i.e. a preset value, suitable for medium noise areas; is the maximum window size, i.e. a preset value, strengthening the suppression in high noise areas; and are noise intensity thresholds, set based on experimental data, used to divide noise levels. This mechanism dynamically balances noise suppression and edge detail preservation, avoiding blurring of the main texture. When a high noise area is detected, the window size is increased to strengthen the noise suppression effect; in a medium noise area, the basic window size is maintained; in a low noise area, the window size is reduced to reduce the impact on details. During the filtering process, the basic window size is forced to be used for the plant main body edge area identified by the gradient operator, avoiding blurring of the edge features due to excessive filtering.
[0034] In this embodiment, the resolution scaling: the preset size is determined according to the input specifications of the subsequent plant recognition model, and a medium resolution suitable for mainstream models is commonly selected. The scaling algorithm selects an interpolation method that balances efficiency and texture preservation effect, ensuring that key texture features such as plant leaves are not distorted during scaling;
[0035] Adaptive median filtering: traverse the image with a basic size sliding window, and judge the noise intensity by calculating the dispersion degree of the pixel gray value in the window. When a high noise area is detected, the window size is increased to strengthen the noise suppression effect; in a medium noise area, the basic window size is maintained; in a low noise area, the window size is reduced to reduce the impact on details. During the filtering process, the basic window size is forced to be used for the plant main body edge area identified by the gradient operator, avoiding blurring of the edge features due to excessive filtering;
[0036] Morphological opening operation: a structure element suitable for removing small area interference is adopted, first, the small interference areas in the image are eliminated through the erosion operation, then the edge profile of the plant body is restored through the dilation operation, and finally the preprocessed image with both signal-to-noise ratio and edge gradient retention rate meeting the requirements of subsequent processing is output .
[0037] Step S3: low-light enhancement is performed on the preprocessed image , such as Figure 2 ; S3.1, the gray histogram of is calculated, the proportion of dark pixels is counted, and if the proportion of dark pixels reaches a preset proportion, adaptive light compensation is triggered: based on the multi-scale Retinex algorithm, the image is decomposed into R, G, and B color channels by using three different scale Gaussian kernels, and the light component under the Gaussian scale is calculated for each channel; the light contribution of each scale is balanced by a learnable weight parameter to generate a light compensated image , and the weight parameter is dynamically adjusted in combination with the plant body features to ensure the accuracy of light compensation of the plant region;
[0038] S3.2, texture detail enhancement is performed on : high-frequency details are extracted by non-local mean filtering, and the edge features of the plant body are enhanced by edge-preserving convolution kernel to obtain a low-light enhanced image .
[0039] Step S4: color correction is performed on the low-light enhanced image , such as Figure 3 ; S4.1, detecting the standard color card region in the image: the candidate region with uniform color and saturation higher than a preset threshold is extracted by morphological segmentation, and the potential color card region is selected by shape analysis; the standard color card position is finally determined by color consistency test; S4.2, calculating the color offset: taking the standard RGB value of the color card as the reference, the average value of the actual RGB pixel value of each channel in the color card region is counted; the difference between the standard value and the actual average value of each channel is calculated; taking the maximum absolute value of each channel offset as the reference, the offset of each channel is divided by the maximum absolute value to obtain the ratio, and the diagonal elements are set to 1 plus the ratio, thereby forming a color correction matrix, ensuring that the pixel value after color mapping remains within the effective range; S4.3, non-local color transfer: dividing into local blocks, calculating the color distribution histogram of each block, finding the block with similar color distribution in the neighborhood block, and migrating the real color distribution of the neighborhood block to the current block to correct the color offset, thereby obtaining a color corrected image .
[0040] Step S5: color correction is performed on the color corrected image characteristic reservation and post-processing are performed, such as Figure 4 ; S5.1, identifying a region of interest ROI of the plant body: a pre-trained semantic segmentation model is used to preliminarily segment the image to generate a body mask; morphological closing operation is performed on the mask to connect the broken areas of the body; the minimum circumscribed rectangle algorithm is used to extract the complete boundary of the body to generate the final ROI region ; S5.2, suppressing background interference: Gaussian blur is performed on the non-ROI region to reduce the interference of background texture on the body features; S5.3, outputting the final processed image , the brightness distribution of which is uniform, the color distortion is corrected, and the plant body features are completely reserved.
[0041] In the embodiment, step S1: original natural image acquisition, according to the scene, a suitable image acquisition device is selected, a high-definition camera with infrared fill light can be used for night shooting in the wild; an industrial-grade CCD camera is used for monitoring crops in the greenhouse to adapt to the stable light source environment. When collecting, the complete plant body needs to be included, for example, when shooting crops, the leaves, stems and surrounding soil need to be included, and the lighting conditions of the image are recorded, such as low light, backlight, artificial fill light, etc., to provide a reference for subsequent processing.
[0042] In the special processing of backlight and shadow scenes, the scheme strengthens the recognizability of dark area texture features through gradient perception optimized illumination compensation mechanism, the system automatically increases the weight proportion of small scale Gaussian kernel when identifying high dynamic range distribution, effectively solving the underexposure problem of plant body in strong light environment; the intelligent shadow positioning technology based on HSV color space accurately distinguishes real shadow and plant color area through collaborative detection of brightness and saturation changes, avoiding misjudgment of chlorophyll loss area as shadow; a brightness compensation factor is introduced in the color transfer stage to correct the cold tone shift, and the automatic correction function of the similarity weight model eliminates local color temperature distortion; finally, the illumination compensation and color transfer form a closed loop processing cascade, which significantly improves the dark area detail reservation and color restoration degree while keeping the original algorithm architecture unchanged, so that the plant body and the background form a natural and coordinated light and shadow relationship.
[0043] Step S2: preprocessing, the preset size is set according to the identification requirement, the adaptive median filter traverses the image through a sliding window, calculates the median and standard deviation of the pixels in the window, if the standard deviation is large, it means that the noise is strong, then the window size is increased; otherwise, the window size is reduced. The morphological opening operation uses a rectangular structural element, which erodes and then dilates the image to eliminate small interference areas such as leaf shadows, and finally obtains a preprocessed image that retains the edge of the main body .
[0044] Step S3: low light enhancement, S3.1: calculating the gray histogram of the image, and if the proportion of dark pixels is high, adaptive light compensation is started. The multi-scale Retinex algorithm selects multiple Gaussian scales, which respectively correspond to local, medium, and global light components; the image is decomposed into R, G, and B color channels, and the light components under different Gaussian scales are calculated for each channel; the light contributions of each scale are balanced through learnable weight parameters to generate a light-compensated image .
[0045] S3.2: The high-frequency details such as leaf veins are extracted by non-local mean filtering; and the edge features of the plant body such as leaf edges are strengthened through an edge-preserving convolution kernel to obtain a low-light enhanced image . .
[0046] Step S4: Color correction, S4.1: A standard color card placement area is preset in the image, and the color card is placed at a suitable position beside the plant during shooting. The color card position is located by extracting a region with uniform color through morphological segmentation and matching the color range. S4.2: The actual average values of the R, G, and B channels are calculated by traversing the pixels in the color card area, and the offset is obtained by comparing the actual average values with the standard RGB values of the color card to generate a color correction matrix.
[0047] S4.3: The color-corrected image is obtained by applying the color correction matrix to the low-light enhanced image . .
[0048] Step S5: Feature preservation and post-processing, S5.1: A pre-trained semantic segmentation model is used to mark the body boundary to generate a binary mask; morphological closing operation is performed on the mask to connect the broken areas such as leaf overlaps, and the minimum bounding rectangle is extracted as the ROI region .
[0049] S5.2: Gaussian blur is performed on the non-ROI regions such as the sky and soil in the background to reduce the interference of background texture on the main features.
[0050] S5.3: The output image is obtained by applying the color correction matrix to the ROI region .
[0051] Through multi-stage collaborative processing, the problems of low-light detail blur, inaccurate color correction, and confusion between the main body and the background in traditional methods are solved, and the recognition accuracy is significantly improved.
[0052] The application further proposes that the window size of the adaptive median filtering is dynamically adjusted according to the noise intensity of the local area, balancing the high-frequency noise suppression effect and the reservation of the edge details of the plant main body; meanwhile, the morphological opening operation is used to eliminate small-area interference areas in the image, obtaining the preprocessed image .
[0053] In the embodiment, the dynamic window adjustment of the adaptive median filtering: the filtering window is initially small in size, and whether to adjust is determined by calculating the noise intensity of the pixels in the window. When the noise intensity is high, such as more salt and pepper noise under low light, the window is increased; when the noise intensity is low, the window is reduced. The core of the adjustment is to balance the noise suppression and the edge reservation. For the edge of the plant main body, such as the wing veins of butterfly wings and the outline of tree trunks, the window is kept small in size to avoid the edge being blurred; for the uniform area of the background, such as the sky and the water surface, the window can be appropriately increased to enhance the noise reduction effect.
[0054] The interference elimination of the morphological opening operation uses a square structural element to perform the erosion and expansion operations. The erosion step removes the details smaller than the structural element in the image, such as the spots on the leaves; the expansion step restores the edge outline of the main body to avoid the deformation of the main body caused by excessive erosion. After the operation, small-area interference areas, such as lens reflection points and dust in the air, are completely eliminated, while the main body area, such as the flower, is completely reserved due to the large area.
[0055] In actual application, the preprocessing procedure can effectively improve the signal-to-noise ratio of the image, and better reserve the gradient value of the edge of the main body, providing a reliable foundation for subsequent enhancement and correction.
[0056] The application further proposes that in the adaptive light compensation process based on the multi-scale Retinex algorithm in step S3.1, the learnable weight parameter α is dynamically calculated based on the LBP feature similarity of the plant main body and the pre-stored template, and the dynamic adjustment is realized through the following mathematical model:
[0057] ;
[0058] wherein, is the learnable weight parameter;
[0059] is a cosine similarity function, defined as: ;
[0060] is the LBP feature vector of the plant main body, is the pre-stored leaf LBP template vector; represents the L2 norm of the vector .
[0061] In embodiments, the LBP feature vector is extracted, and the local binary pattern (LBP) feature is calculated for the plant subject area, such as the plant leaves. A suitable neighborhood sampling mode is used to compare the gray value of each pixel with the neighborhood pixels, generate the LBP value of the pixel, and then count the LBP value distribution of the entire subject area to form a feature vector. .
[0062] The template vector is pre-stored, and the pre-stored LBP features from typical plant samples, and the leaf template contains LBP distributions of various plant leaves. All templates are subjected to standardization processing.
[0063] Cosine similarity calculation, the similarity is calculated through a specific formula with The value reflects the degree of similarity between the two. When the subject and the template are highly similar, the similarity value is higher; when the difference is larger, the similarity value is lower.
[0064] Weight parameter adjustment, the value of a is adjusted according to the similarity value, and the value of a is in a certain interval. When the similarity value is high, indicating that the subject feature is clear, a larger value of a is taken to enhance the contribution of large-scale illumination components to improve the overall brightness; when the similarity value is low, indicating that the subject feature is fuzzy, a smaller value of a is taken to enhance the contribution of small-scale illumination components to highlight local details.
[0065] This mechanism makes the low-light enhancement more targeted. For example, for plants with blurred leaf veins, local details are preferentially enhanced, and compared with the Retinex algorithm with fixed parameters, the details can be better preserved.
[0066] It should be particularly noted that when the plant subject is severely occluded or defocused, the LBP feature extraction may be abnormal. In embodiments, in a certain greenhouse cucumber leaf recognition experiment, because more than 60% of the leaf surface is covered with dew, the LBP feature vector of is incomplete, and the value approaches the lower limit of 0.5 in theory, causing insufficient illumination compensation. The system switches to a conservative compensation mode based on the gray histogram distribution through a pre-set abnormal processing mechanism, and finally restores the signal-to-noise ratio, which is weaker than the ideal state but significantly better than the traditional Retinex algorithm. The above case verifies the robustness boundary of the weight adjustment mechanism in extreme scenarios.
[0067] The application further proposes that the construction method of the color correction matrix in step S4.2 is: based on the standard RGB values of each channel in the standard color card, the average of the actual RGB pixel values in each channel in the standard color card area is counted; the difference between the standard value and the actual average value of each channel is calculated; the offset of each channel is divided by the maximum absolute value of the offset to obtain a ratio, and the diagonal element is set to 1 plus the ratio, thereby forming the color correction matrix, and ensuring that the pixel value after color mapping is kept within the effective range.
[0068] In the embodiment, the standard color card data is obtained by using an international standard color card, and the standard RGB values of each color block of the color card are pre-stored as reference data, which come from the factory calibration report of the color card.
[0069] Actual deviation calculation: after locating the color card area in the image, all pixels in the area are traversed, and the average values of R, G and B channels are calculated respectively, and the offset of each channel is obtained by comparing the average values with the standard values.
[0070] Correction matrix generation: taking the maximum absolute value of the offset; taking the maximum absolute value of the offset; constructing a diagonal matrix, the diagonal element is 1 plus the corresponding ratio, and the non-diagonal element is 0 to avoid channel cross interference.
[0071] The matrix multiplies the RGB value of each pixel in the image with the matrix, that is, the offset is corrected, so that the color is closer to the standard value. Since the matrix elements have certain limitations, it can be ensured that the pixel value after correction is within the effective range, avoiding oversaturation.
[0072] Compared with the traditional Gamma correction, the color deviation can be corrected more accurately, and it is especially suitable for crop color correction under greenhouse artificial light source, such as correcting the yellow offset caused by sodium lamp.
[0073] The application further proposes that the similarity measurement of the non-local color migration in step S4.3 is calculated by the following mathematical model:
[0074] The size of the local block The color distribution histogram of the local block And the neighborhood block Is And The similarity weight Is defined as:
[0075] Wherein, Is a smoothing parameter, and the denominator Is used to control the weight decay rate; the numerator is the sum of squares of the histogram difference, reflecting the difference degree of color distribution.
[0076] In embodiments, non-local color transfer achieves accurate correction of color distribution by similar block matching, wherein,
[0077] Local block division, the image is divided into non-overlapping local blocks of a certain size, each block containing a certain number of pixels and recording its coordinates in the image.
[0078] Histogram calculation, for each block, the gray level histogram of R, G, and B channels is counted respectively, and the histogram reflects the color distribution characteristics of the block, such as the high proportion of high gray level of the G channel of the green leaf block.
[0079] Similarity weight calculation, for each block, the weight of the neighborhood block is calculated by a specific formula, which reflects the similarity of the color distribution of the two blocks. The numerator is the sum of the squares of the histogram difference, and the smaller the value, the more similar the color distribution of the two blocks; the smoothing parameter is set according to the noise level of the image, which controls the decay rate of the weight; the weight value is within a certain range, the higher the similarity, the closer the weight is to the maximum value.
[0080] Color transfer, for each block, select the several neighborhood blocks with the highest weight, and transfer the color distribution to the current block according to the weight, to correct the color deviation in the block, such as correcting the yellowish leaf block to natural green.
[0081] Solves the local color deviation problem caused by traditional global color correction, for example, in a backlight scene, the color of the back light of the plant can be made consistent with the light receiving surface, improving the local color consistency.
[0082] The application further proposes that the construction method of the edge-preserving convolution kernel in step S3.2 is: the gradient direction distribution of the edge region of the plant body is counted; a multi-directional convolution kernel is constructed based on the gradient direction distribution, and the weight value of each directional convolution kernel is proportional to the average value of the gradient intensity in the direction; the multi-directional convolution kernel is normalized to ensure that the sum of the convolution kernel weights is 1, thereby enhancing the edge while suppressing noise interference.
[0083] In embodiments, gradient direction distribution statistics, the low-light enhanced image uses Sobel operator to calculate the gradient of the main body region to obtain horizontal and vertical gradients, and the gradient direction of each pixel is obtained by calculation; the distribution frequency of the gradient direction is counted to determine the main direction of the main body edge, such as the leaf edge being mainly at a certain angle.
[0084] Multi-directional convolution kernel design, according to the main direction counted, the convolution kernel in the corresponding direction is designed, and each convolution kernel has a suitable size. The weight value of the convolution kernel is proportional to the average value of the gradient intensity in the corresponding direction, for example, if the average value of the gradient intensity in a certain direction is large, the center weight of the convolution kernel in that direction can be adjusted appropriately to enhance the response.
[0085] The normalization processing, summing all elements of each convolution kernel, dividing each element by the sum, ensures that the sum of the convolution kernel weights is 1, avoiding overflow of the pixel value after convolution.
[0086] The edge enhancement operation, respectively convolving the multi-directional convolution kernel with the image, taking the maximum value of each result as the final edge enhancement image, not only strengthens the main body edge, such as the leaf stalk edge of the plant, but also suppresses the noise amplification due to the weight normalization.
[0087] Compared with the traditional Sobel operator, the convolution kernel can better enhance the edge and improve the signal-to-noise ratio, and is especially suitable for repairing blurred edges under low light.
[0088] The application further proposes that the detection method of the standard color card region in the step S4.1 comprises: segmenting the image based on the HSV color space, extracting a candidate region with uniform brightness and saturation higher than a preset threshold; performing shape analysis on the candidate region, and screening a rectangular region with an aspect ratio close to 1:1 and an area within a preset range as a potential color card region; and finally determining the position of the standard color card through color consistency test.
[0089] In the embodiment, the detection of the standard color card region is a method based on the color correction, the HSV color space segmentation converts the image from RGB to HSV space, H represents hue, S represents saturation, and V represents brightness, a suitable saturation threshold is set to exclude low-saturation gray and white interference regions, a suitable brightness threshold is set to exclude dark or bright regions, and a candidate region meeting the conditions is extracted, and the colors of these regions are uniform and the brightness is moderate.
[0090] The shape analysis performs contour extraction on the candidate region, calculates the aspect ratio of the minimum circumscribed rectangle thereof, and screens a region with an aspect ratio close to 1:1 and an area within a suitable range as a potential color card region, and these features meet the rectangular feature of the standard color card.
[0091] The color consistency test calculates the standard deviation of the H, S and V values of all pixels in the potential region, and if the standard deviation is small, it indicates that the colors in the region are highly consistent, and the region is confirmed as a standard color card region; otherwise, if the colors are mixed in the background region, it is excluded.
[0092] In actual application, the method has high accuracy in detecting the color card in a complex background such as grass and branches, and can effectively identify the color card even if the color card is partially blocked.
[0093] The application further proposes that the extraction method of the region of interest ROI in the step S5.1 is: a pre-trained semantic segmentation model is used to preliminarily segment the image to generate a main body mask; a morphological closing operation is performed on the mask to connect the main body broken area; and a minimum enclosing rectangle algorithm is used to extract the complete boundary of the main body to generate a final ROI region. .
[0094] The extraction of the region of interest ROI is used in the step of separating the plant main body from the background, the semantic segmentation model preliminarily segments, a pre-trained semantic segmentation model is used for pixel-level classification on the color-corrected image I3, the pixels belonging to the plant main body are marked, and a binary main body mask is generated.
[0095] The morphological closing operation connects the broken area, the main body mask may be broken due to main body occlusion, such as leaf occlusion, a suitable structural element is used to perform the closing operation, first inflation and then corrosion, small holes in the mask are filled, and the broken main body area is connected, such as reconnecting the plants divided by branches.
[0096] The minimum enclosing rectangle extracts the complete boundary, the contour of the processed mask is extracted, the contour points are fitted through a suitable algorithm, the minimum enclosing rectangle surrounding the main body is obtained, and the region in the rectangle is the ROI. If the main body is not rectangular, such as flowers and snakes, the rectangle needs to be appropriately enlarged to ensure complete inclusion of the main body.
[0097] Embodiment two
[0098] A natural image processing and analysis system for plant recognition, such as Figure 5 、 7 , comprising:
[0099] An image acquisition module for performing step S1 of the natural image processing and analysis method for plant recognition of embodiment one to acquire an original natural image;
[0100] A preprocessing module for performing step S2 of the natural image processing and analysis method for plant recognition of embodiment one to perform resolution scaling, noise suppression and interference elimination on the original natural image, and output a preprocessed image ;
[0101] A low-light enhancement module for performing step S3 of the natural image processing and analysis method for plant recognition of embodiment one to perform adaptive light compensation and texture detail enhancement on , and output a low-light enhanced image ;
[0102] A color correction module for performing step S4 of the natural image processing and analysis method for plant recognition of embodiment one to perform color correction on Reference color card correction and non-local color migration are performed, and a color-corrected image is output ;
[0103] The feature reservation module is configured to perform step S5 of the natural image processing analysis method for plant recognition of embodiment one, and The main body ROI extraction, background suppression and post-processing are performed, and a final processed image is output .
[0104] In the embodiment, the image acquisition module hardware adopts a high-pixel industrial camera, is equipped with an adjustable focal length lens to adapt to different shooting distances, supports automatic exposure, and can prolong the exposure time to avoid image blur in low light; the software realizes real-time image acquisition and storage, and records metadata such as acquisition time and light intensity.
[0105] The preprocessing module is based on GPU to realize parallel processing, and performs resolution scaling, adaptive median filtering, morphological opening operation and other operations through related libraries to quickly output a preprocessed image .
[0106] The low-light enhancement module, such as Figure 6 , includes a light compensation subunit and a detail enhancement subunit, and performs multi-thread parallel processing. The light compensation unit realizes multi-scale Retinex decomposition, and the detail enhancement unit accelerates non-local mean filtering, thereby improving the brightness of low-light images as a whole.
[0107] The color correction module integrates color card detection algorithms and color migration logic, efficiently performs correction matrix calculation through a matrix operation library, and quickly completes color correction of the image.
[0108] The feature reservation module calls a related framework to load a semantic segmentation model, and performs ROI extraction on the GPU; the non-ROI region is subjected to blur processing, and the finally output image can be displayed or stored in real time through a related interface.
[0109] The modules realize data transmission through shared memory, form a complete processing pipeline, have low processing delay, and meet the real-time monitoring requirements, such as real-time plant recognition of a garden robot.
[0110] The application further provides that the low-light enhancement module comprises:
[0111] The light compensation unit is configured to perform multi-scale Retinex decomposition, weight parameter adjustment and light component balancing of step S3.1;
[0112] The detail enhancement unit is configured to perform texture detail enhancement of step S3.2.
[0113] In this embodiment, the two sub-units of the low-light enhancement module work together to achieve a balance between brightness enhancement and detail preservation.
[0114] The illumination compensation unit includes multi-scale Retinex decomposition: for preprocessed images It is decomposed into reflection component and illumination component according to different scales;
[0115] Weight parameter adjustment: Triggered when the proportion of dark area pixels is high. Dynamically adjust, calculating weights independently for each color channel.
[0116] The detail enhancement unit includes nonlocal mean filtering: setting appropriate search and similarity windows for... Filtering is performed to remove noise by weighted averaging of similar pixels, while preserving texture details.
[0117] Edge-preserving convolution kernel enhancement: A multi-directional convolution kernel is loaded to perform a convolution operation on the filtered image, enhancing subject edges, such as the serrated edges of leaves, and outputting a low-light enhanced image. .
[0118] The two units are connected through a data buffer. The output of the illumination compensation unit is directly used as the input of the detail enhancement unit. During the processing, the brightness distribution is monitored through histogram equalization to ensure that the enhancement effect is appropriate. Compared with a single enhancement algorithm, it can better preserve details and suppress noise.
[0119] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them; although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications can still be made to the specific implementation methods of the present invention or equivalent substitutions can be made to some technical features without departing from the spirit of the technical solutions of the present invention, and all such modifications should be covered within the scope of the technical solutions claimed in the present invention.
Claims
1. A natural image processing and analysis method for plant identification, characterized in that, Includes the following steps: Step S1: Acquire raw natural images; acquire raw natural images containing plants using an image acquisition device. The raw natural images contain the plant subject and background, and have problems with low light noise and color distortion. Step S2: Preprocess the original natural image; scale the resolution of the original natural image to a preset size, and use adaptive median filtering to remove high-frequency noise. The window size of the adaptive median filter is dynamically adjusted according to the noise intensity of the local area to balance the high-frequency noise suppression effect with the preservation of the edge details of the plant subject. At the same time, morphological opening operations are used to eliminate small-area interference areas in the image, resulting in the preprocessed image. ; Step S3: Process the preprocessed image Perform low-light enhancement; S3.1, Calculation The grayscale histogram is used to calculate the percentage of pixels in dark areas. If the percentage of pixels in dark areas reaches a preset proportion, adaptive illumination compensation is triggered. Based on the multi-scale Retinex algorithm, three Gaussian kernels of different scales are used to decompose the image into three color channels: R, G, and B. The illumination component at the Gaussian scale is calculated for each channel. The illumination contribution at each scale is balanced by learnable weight parameters to generate the illumination-compensated image. The weight parameters are dynamically adjusted in conjunction with the main features of the plant to ensure the accuracy of light compensation in the plant area. In the adaptive light compensation process based on the multi-scale Retinex algorithm, the learnable weight parameter α is dynamically calculated based on the LBP feature similarity between the main plant and the pre-stored template, and is dynamically adjusted through the following mathematical model: ; in, The weight parameters are learnable; weight parameters The similarity value is adjusted by adjusting α within a certain range. When the similarity value is high, indicating that the main features are clear, α is taken as a larger value to enhance the contribution of the large-scale illumination component and improve the overall brightness. When the similarity value is low, indicating that the main features are blurry, α is taken as a smaller value to enhance the contribution of the small-scale illumination component and highlight local details. The cosine similarity function is defined as follows: ; This represents the LBP feature vector of the plant body. This is a pre-stored blade LBP template vector; Representing vectors The L2 norm; S3.2, To Texture detail enhancement: Non-local mean filtering is used to extract high-frequency details, and edge features of the plant subject are enhanced by edge-preserving convolution kernels to obtain an image enhanced in low light. ; Step S4: Enhance the low-light image Perform color correction; S4.1, Detect standard color card areas in the image: Extract candidate areas with uniform color and saturation higher than a preset threshold through morphological segmentation, perform shape analysis on the candidate areas, and screen out potential color card areas; finally determine the position of the standard color card through color consistency test; S4.2, Calculate color offset: Using the standard RGB value of the color card as a reference, calculate the average value of the actual RGB pixel values of each channel in the color card area; calculate the difference between the standard value and the actual average value of each channel; using the maximum absolute value of the offset of each channel as a benchmark, divide the offset of each channel by the maximum absolute value to obtain the ratio, set the diagonal element to 1 and add the ratio to form a color correction matrix to ensure that the pixel values after color mapping remain within the effective range; S4.3, Non-local color transfer: Divided into For each local block, a color distribution histogram is calculated. Blocks with similar color distributions are found in the neighborhood blocks. The true color distribution of the neighborhood blocks is transferred to the current block to correct the color shift, resulting in a color-corrected image. ; Step S5: Color-corrected image Feature preservation and post-processing are performed; S5.1, Identifying the Region of Interest (ROI) of the main plant: A pre-trained semantic segmentation model is used to perform preliminary image segmentation to generate a main subject mask; morphological closing operations are performed on the mask to connect the broken areas of the main subject; the complete boundary of the main subject is extracted using the minimum bounding rectangle algorithm to generate the final ROI region. S5.2 Suppress background interference: Apply Gaussian blur to non-ROI regions to reduce the interference of background textures on the main features; S5.3 Output the final processed image The image The brightness distribution is uniform, the color distortion is corrected, and the main features of the plant are completely preserved.
2. The natural image processing and analysis method for plant identification according to claim 1, characterized in that, The adaptive median filter dynamically adjusts the window size based on the noise intensity of local regions, balancing high-frequency noise suppression with the preservation of details at the plant's edges. Simultaneously, morphological opening operations are used to eliminate small interference areas in the image, resulting in a preprocessed image. .
3. The natural image processing and analysis method for plant identification according to claim 1, characterized in that, The method for constructing the color correction matrix in step S4.2 is as follows: based on the standard RGB values of each channel in the standard color chart, calculate the average value of the actual RGB pixel values of each channel within the standard color chart area; Calculate the difference between the standard value and the actual average value for each channel; Based on the maximum absolute value of the offset of each channel, the offset of each channel is divided by the maximum absolute value to obtain a ratio. The diagonal elements are then set to 1 and added to the ratio to form a color correction matrix, ensuring that the pixel values after color mapping remain within the effective range.
4. The natural image processing and analysis method for plant identification according to claim 1, characterized in that, The similarity measure of nonlocal color migration described in step S4.3 is calculated using the following mathematical model: For size local blocks With neighboring blocks Their color distribution histograms are as follows: and Similarity weight Defined as: in, For smoothing parameters, the denominator Used to control the rate of weight decay; the numerator is the sum of squares of the histogram differences, reflecting the degree of difference in color distribution.
5. The natural image processing and analysis method for plant identification according to claim 1, characterized in that, The method for constructing the edge-preserving convolution kernel in step S3.2 is as follows: statistically analyze the gradient direction distribution of the edge region of the plant body; construct multi-directional convolution kernels based on the gradient direction distribution, wherein the weight value of each direction convolution kernel is proportional to the mean value of the gradient intensity in that direction; normalize the multi-directional convolution kernels to ensure that the sum of the convolution kernel weights is 1, thereby enhancing the edge while suppressing noise interference.
6. The natural image processing and analysis method for plant identification according to claim 1, characterized in that, The method for detecting the standard color card area in step S4.1 includes: segmenting the image based on the HSV color space, extracting candidate areas with uniform brightness and saturation higher than a preset threshold; performing shape analysis on the candidate areas, and selecting rectangular areas with an aspect ratio close to 1:1 and an area within a preset range as potential color card areas; and finally determining the position of the standard color card through color consistency testing.
7. The natural image processing and analysis method for plant identification according to claim 1, characterized in that, The method for extracting the Region of Interest (ROI) in step S5.1 is as follows: A pre-trained semantic segmentation model is used to perform preliminary segmentation of the image to generate a subject mask; morphological closing operations are performed on the mask to connect the broken areas of the subject; the minimum bounding rectangle algorithm is used to extract the complete boundary of the subject, generating the final ROI region. .
8. A natural image processing and analysis system for plant identification, characterized in that, include: The image acquisition module is used to perform step S1 as described in claim 1 to acquire the original natural image; The preprocessing module is used to perform step S2 as described in claim 1, performing resolution scaling, noise suppression, and interference removal on the original natural image, and outputting the preprocessed image. ; The low-light enhancement module is used to perform step S3 as described in claim 1, for... Perform adaptive lighting compensation and texture detail enhancement to output an image enhanced in low light conditions. ; The color correction module is used to perform step S4 as described in claim 1, for... Perform reference color chart correction and non-local color transfer, and output the color-corrected image. ; The feature retention module is used to perform step S5 as described in claim 1, for... Perform main ROI extraction, background suppression, and post-processing to output the final processed image. .
9. The natural image processing and analysis system for plant identification according to claim 8, characterized in that, The low-light enhancement module includes: The illumination compensation unit is used to perform the multi-scale Retinex decomposition, weight parameter adjustment and illumination component balancing in step S3.
1. The detail enhancement unit is used to perform the texture detail enhancement in step S3.2.
Citation Information
Patent Citations
Cotton image segmentation method and system based on morphological reconstruction and adaptive threshold
CN112862841A
Ancient character image recognition and semantic analysis method
CN120472471A