Agricultural product image quality enhancement method based on visual macro model

Through the method of enhancing agricultural product image quality based on visual large models, the problem of poor image enhancement effect in the diversified agricultural product categories and complex shooting environments is solved, and the efficient clarity and detail improvement of agricultural product images is achieved, ensuring the accuracy of quality detection.

CN119477720BActive Publication Date: 2025-05-23GUANGXI POLICE ACAD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411588685.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-08
Publication Date
2025-05-23
Estimated Expiration
2044-11-08

AI Technical Summary

Technical Problem

The prior art lacks adaptability in improving the image quality of agricultural products, and it is difficult to ensure image enhancement effect in diverse agricultural product categories and complex shooting environments, especially in the problems of uneven light, color distortion and blurred details.

Method used

The agricultural product image quality enhancement method based on visual large-scale visual model is adopted, and transfer learning and fine-tuning is performed through pre-trained large-scale visual model, combined with super-resolution reconstruction algorithm and multi-task processing capabilities, agricultural product images are enhanced in regions, automatically adjusting contrast and color balance, and optimizing brightness and detail recovery.

Benefits of technology

It significantly improves the clarity and contrast of agricultural product images, enhances the color accuracy and detailed performance of the image, ensures the stable performance of the image in a variety of shooting environments, and improves the accuracy of quality detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119477720B_ABST
    Figure CN119477720B_ABST
Patent Text Reader

Abstract

The invention discloses a method for enhancing the quality of agricultural product images based on a large visual model, comprising the following steps: S1, obtaining an original agricultural product image dataset of agricultural products during picking and transportation; S2, inputting the original agricultural product image dataset of agricultural products into a pre-trained large-scale visual model; S3, fine-tuning the pre-trained large-scale visual model by transfer learning; S4, processing the original agricultural product image dataset of agricultural products using the fine-tuned large-scale visual model; S5, restoring the details of the agricultural product images using a super-resolution reconstruction algorithm; S6, executing a partial region enhancement strategy for agricultural product images of different agricultural product categories based on the multi-task processing capability of the large-scale visual model; and S7, outputting the final enhanced agricultural product images. The invention makes the surface details and texture information of agricultural products clearer, and provides an accurate data basis for quality detection and identification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of agricultural products, and in particular to a method for enhancing the quality of agricultural product images based on a large visual model. Background Art

[0002] With the advancement of computer vision and deep learning technologies, large visual models have gradually been introduced into the field of agricultural product quality inspection. Image quality enhancement, as a key link in agricultural product quality inspection, is directly related to the accuracy and reliability of inspection. However, in practical applications, the acquisition quality of agricultural product images is often limited by the picking environment, transportation conditions and shooting equipment, resulting in low image clarity, color distortion and blurred details. Existing agricultural product image processing technologies usually rely on traditional image processing algorithms, such as filtering denoising, color correction and contrast enhancement. Existing technologies have limitations and cannot guarantee the effect of image enhancement for diverse agricultural product categories and complex shooting environments.

[0003] At present, the technology for improving the quality of agricultural product images faces many challenges. Traditional image enhancement methods lack the ability to adapt to diversified agricultural products. They are usually optimized for specific scenarios and cannot adapt to the complex changes of fruits, vegetables and grains in different collection environments. Due to the large differences in the shapes, colors and textures of different agricultural products, traditional algorithms often cannot achieve a natural balance of colors while maintaining image details. In complex shooting environments, uneven lighting or the presence of noise, traditional methods find it difficult to automatically adapt and optimize images, resulting in insufficient clarity and contrast of the enhanced images, which in turn affects the accuracy of quality detection. In addition, traditional super-resolution algorithms have limited effects on detail recovery and cannot accurately enhance the edge and texture details of agricultural product images, resulting in errors in the detection system when identifying defects and determining grades.

[0004] In the field of agricultural product image quality detection, some studies have begun to introduce visual models for image processing, but most visual models still have defects in practical applications. The existing visual models have limited migration capabilities and adaptability when processing multiple types of agricultural product images, and often require a large amount of specific category data for training. At the same time, it is difficult to perform adaptive enhancement based on defective areas in the image, resulting in inaccurate quality detection results. In addition, it is difficult for existing technologies to perform targeted optimization of local areas of the image, such as contrast adjustment in areas with uneven lighting, correction of areas with uneven colors, and detail enhancement in defective areas, which limit the effectiveness of existing technologies in agricultural product image enhancement. Summary of the invention

[0005] One object of the present invention is to propose a method for enhancing the image quality of agricultural products based on a large visual model. The present invention makes the surface details and texture information of agricultural products clearer, and provides an accurate data basis for quality detection and identification.

[0006] A method for enhancing agricultural product image quality based on a visual macro model according to an embodiment of the present invention comprises the following steps:

[0007] S1, obtain the original agricultural product image dataset during picking and transportation;

[0008] S2, inputting the original agricultural product image dataset of the agricultural products into a pre-trained large-scale visual model, wherein the pre-trained large-scale visual model is trained based on a plurality of general agricultural product original images and has the ability to preliminarily identify and enhance the features of the agricultural product images;

[0009] S3. Perform transfer learning fine-tuning on the pre-trained large-scale visual model. According to the types of agricultural products to be enhanced, the feature images of the corresponding categories are used as training data, and the weights and parameters of the large-scale visual model are optimized based on the characteristics of the training data.

[0010] S4. Use the fine-tuned large-scale visual model to process the original agricultural product image dataset of agricultural products. According to the agricultural product category of the input image, extract the matching enhancement strategy from the enhancement strategy library to perform color correction on the original agricultural product image dataset image to optimize brightness, saturation and color balance.

[0011] S5. Use super-resolution reconstruction algorithm to restore the details of agricultural product images, and use fine-tuned large-scale visual models to automatically detect blurred areas of agricultural product images and enhance edge and texture features of agricultural product images;

[0012] S6. Based on the multi-task processing capability of large-scale visual models, partial area enhancement strategies are implemented for agricultural product images of different agricultural product categories. Agricultural product images are divided into several areas, local contrast is improved for areas with uneven lighting, areas with uneven colors are corrected, and the display effect of defective areas is optimized according to the surface defect characteristics of agricultural products;

[0013] S7. Input the agricultural product image after color correction, denoising, detail restoration and area enhancement processing into the agricultural product quality detection system, further fine-tune the agricultural product image quality according to the output result of the detection system, and output the final enhanced agricultural product image.

[0014] Optionally, the S1 includes the following steps:

[0015] S11. Construct an original agricultural product image dataset of agricultural products, wherein the agricultural products include fruits, vegetables and grains, and a collection of agricultural product images D collected by a collection device during the picking and transportation of agricultural products:

[0016] D={I 1 ,I 2,…,I n};

[0017] Among them, I i represents the i-th agricultural product image;

[0018] S12, each agricultural product image I i Contains the color, morphology and texture feature information of agricultural products. The color, morphology and texture features of each agricultural product image are annotated through the agricultural product image feature extraction method to generate the agricultural product feature set F i :

[0019] F i ={C i ,M i ,T i};

[0020] Among them, C i Represents the color characteristics of agricultural product images, including brightness, saturation and color distribution, M i Represents the morphological features of agricultural product images, including shape, outline and area size, T i Represent the texture features of agricultural product images, including texture direction, texture roughness and texture contrast;

[0021] S13, each agricultural product image I i The agricultural product feature set F i Combined with the agricultural product image collection D to generate a complete original agricultural product image dataset D f :

[0022] D f ={F 1 ,F 2 ,…,F n}.

[0023] Optionally, S2 includes the following steps:

[0024] S21. Build a pre-trained large-scale visual model M, which is based on a general agricultural product image training set T. g Training, set agricultural product image training set T′ g = {I′ 1 ,I′ 2 ,…,I′ m}, where I′ j Denotes the jth general agricultural product image. The initial training objective of the large-scale visual model is to minimize the following composite loss function:

[0025]

[0026] Among them, m is the number of samples in the training set, I′ jrepresents the jth agricultural product image, γ 1 , γ 2 , γ 3 is the weight coefficient of each loss, is the color feature loss, measuring the color deviation, It is the loss of morphological characteristics, which measures the appearance characteristics of agricultural products. It is the texture feature loss, which is used to adjust the detail features;

[0027] S22, the original agricultural product image dataset D f Input to the pre-trained large-scale visual model M, and use the weight parameter matrix W to generate a preliminary feature output set O = {O 1 ,O 2 ,…,O n}, each output vector O i represents the preliminary enhanced features of the i-th image by the large-scale visual model;

[0028] S23, the pre-trained large-scale visual model M uses a multi-head self-attention mechanism to analyze the agricultural product features F i Processing is performed to capture the correlation between different regions, strengthen the characteristics of agricultural products on color, shape and texture, and generate the weighted agricultural product feature vector O i :

[0029]

[0030] Among them, H is the number of long positions, denote the query, key, and value vectors of the h-th head, respectively. is the weight matrix of query, key and value. Softmax function is used to generate attention distribution, d k is the dimension of the key vector, LayerNorm is the layer normalization operation;

[0031] S24. The large-scale visual model introduces multi-scale feature fusion and adaptive enhancement strategy, and finally optimizes the loss function L of the large-scale visual model, taking into account both recognition accuracy and image enhancement effect:

[0032]

[0033] Where n is the number of input samples, O i is the output feature vector of the large-scale visual model for the i-th agricultural product image, y i is the true label of the i-th agricultural product image, and are the enhanced output and ideal enhanced result of the i-th agricultural product image at the s-th scale, α 1 , β 1 is the weight coefficient of identification and enhancement loss, ws is the weight coefficient of the sth scale;

[0034] S25, output the preliminary output feature set O = {O 1 ,O 2 ,…,O n} and the multi-scale enhanced output set E = {E 1 ,E 2 ,…,E n}.

[0035] Optionally, S3 includes the following steps:

[0036] S31. Construct a category feature training data set for the target agricultural product category:

[0037]

[0038] in, represents the i-th agricultural product image of the target agricultural product category c, and k is the number of agricultural product images of the category;

[0039] S32, class feature training data set T c Input into the pre-trained large-scale visual model M, and fine-tune the parameter matrix of the large-scale visual model through transfer learning to optimize the weight matrix W of the large-scale visual model c and the bias vector b c To adapt to the image features of agricultural products of specific agricultural product categories, the optimization goal is to minimize the following transfer learning loss function:

[0040]

[0041] Among them, k is the number of training samples, represents the i-th agricultural product image, λ 1 , 2 , 3 are the weight coefficients of color, morphology and texture loss, Represents the color feature loss, which is used to optimize the color consistency of agricultural product images. Represents the morphological feature loss, which is used to correct the shape features of agricultural product images. Represents texture feature loss;

[0042] S33, adjust the model weight W through the back propagation algorithm c and bias b c , gradually optimize the image features of agricultural products that are suitable for specific agricultural product categories, and the parameters updated after each iteration are:

[0043]

[0044]

[0045] in, and are the model weights and biases after the t+1th iteration, η is the learning rate, which controls the update amplitude, and is the loss function L c Gradients with respect to model parameters;

[0046] S34, the fine-tuned large-scale visual model M c Applied to the target agricultural product category, outputting an enhanced feature set

[0047] Optionally, S4 includes the following steps:

[0048] S41. The fine-tuned large-scale visual model M c Applied to the original agricultural product image dataset D f , identify each agricultural product feature set F i Agricultural product categoriesc i , according to category c i Extract the corresponding enhancement strategy set from the preset enhancement strategy library S

[0049] S42. Category-specific enhancement strategies For the agricultural product feature set F i Color characteristics of C i =(L i ,S i ,H i ) is optimized, where L i Represents brightness characteristics, S i Indicates the saturation characteristic, H i Indicates color balance characteristics.

[0050] The goal of color correction is to minimize the following color deviation loss function:

[0051]

[0052] Among them, α 4 , α 2 , α 3 are the weight coefficients for brightness, saturation and color balance, Respectively represent the brightness, saturation and color balance values ​​of the optimization target;

[0053] S43, for the agricultural product feature set F i Apply the brightness enhancement operation to transform the brightness feature L i Adjust to optimized brightness value For the agricultural product feature set F i Saturation characteristic S i Apply a saturation boost operation to adjust the saturation signature to an optimized saturation value For the agricultural product feature set F i Color balance characteristics of H i Perform balance correction to adjust the color balance value to the optimized balance value

[0054] S44. Output the agricultural product image dataset after color correction, brightness optimization and saturation enhancement:

[0055]

[0056] Optionally, S5 includes the following steps:

[0057] S51, the fine-tuned large-scale visual model M c Application to agricultural product image dataset Detect each agricultural product feature set The fuzzy area in the model generates the fuzzy weight matrix W through the model feature extraction layer 模糊 , score the blur level of agricultural product images:

[0058]

[0059] Among them, S 模糊,i represents the fuzzy score of the i-th agricultural product image, W 模糊,i (p) is the pth pixel weight of the fuzzy weight matrix, is the p-th pixel value of the i-th agricultural product image;

[0060] S52: For the area where the blur score exceeds the threshold, the details of the blur area are restored by using the super-resolution reconstruction algorithm, and the super-resolution of the generative model G is used to reconstruct the reconstructed agricultural product image R. i ;

[0061] S53, agricultural product image R i The texture features are enhanced to obtain the enhanced texture matrix

[0062] S55. Output the agricultural product image dataset after fuzzy area detail restoration, edge enhancement and texture optimization processing:

[0063]

[0064] Optionally, the S6 comprises the following steps:

[0065] S61, dividing the agricultural product image dataset after detail restoration and texture optimization processing into several regions, defining each agricultural product image R i A collection of regions:

[0066]

[0067] in, represents the jth region of the i-th agricultural product image, m is the number of agricultural product image partitions, and the partition boundary is defined as:

[0068]

[0069] Among them, B represents the optimal partition boundary value, is the distance between each partition and the optimal boundary;

[0070] S62. Calculate the illumination distribution of each area based on the multi-task processing capability of the large-scale visual model to obtain the illumination deviation matrix in For Region The illumination deviation is used to calculate the local contrast enhancement value of the area:

[0071]

[0072] in, Indicates area The enhanced local contrast value, is the original contrast value of the region, α is the contrast enhancement coefficient, W j Represents the weight of a region based on its location and lighting requirements in the produce image;

[0073] S63: Perform color correction on the color-uneven areas and calculate the color balance matrix of each area

[0074]

[0075] in, Indicates area Corrected color balance value, is the original color balance value of the region, β is the color correction coefficient, H 目标 represents the target color balance value of the agricultural product image, and σ is the correction coefficient;

[0076] S64, based on the visual model, the surface defect features detected in each area are optimized and enhanced, the detail features in the area are Gaussian enhanced, and the optimized display effect matrix is ​​calculated.

[0077] S65. Output the agricultural product image dataset after local contrast enhancement, color correction and defect optimization processing:

[0078]

[0079] The beneficial effects of the present invention are:

[0080] (1) The present invention adopts the multi-task processing capability of a large-scale visual model. By processing the image in different regions, the contrast and color balance can be automatically adjusted according to the lighting and color distribution conditions of different regions. In areas with uneven lighting, the present invention improves the local contrast through an enhancement strategy so that the agricultural products can maintain clear and delicate image details under various lighting conditions. In areas with uneven colors, adaptive color correction is used to make the overall image color natural and consistent, thereby avoiding the problem that traditional methods are difficult to handle under complex lighting conditions. Experimental results show that the color accuracy of the present invention in the processing of diversified agricultural product images is improved by more than 12%, and the contrast and clarity are significantly improved, ensuring the stable performance of the image under a variety of shooting environments.

[0081] (2) The present invention innovatively introduces a super-resolution reconstruction algorithm and an edge optimization strategy, which significantly improves the blurred area and detail loss problems in agricultural product images. The blurred area is automatically detected by a large-scale visual model and the super-resolution algorithm is applied to the area to perform high-precision restoration of blurred edges and fine textures, ensuring that the details of the agricultural products in the image are fully restored. This method is particularly effective for images of fruits and vegetables with complex surface textures. Compared with traditional image reconstruction methods, the present invention improves edge clarity by more than 15%, making the surface details and texture information of agricultural products clearer, providing an accurate data basis for quality inspection and identification.

[0082] (3) The present invention constructs a category-specific enhancement strategy library to enable large-scale visual models to automatically select appropriate enhancement strategies according to the agricultural product category, and perform customized image enhancement processing for different types of agricultural products. Traditional enhancement methods are prone to inconsistent enhancement effects when processing diversified agricultural products, while the enhancement strategy library of the present invention can be optimized and selected according to the different characteristics of fruit, vegetable and grain categories, thereby ensuring the consistency and applicability of the enhancement effect. Experimental data show that the adaptability of the enhancement strategy library of the present invention in different agricultural product categories has increased by more than 20%, significantly improving the image recognition accuracy and classification accuracy of the detection system. BRIEF DESCRIPTION OF THE DRAWINGS

[0083] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:

[0084] Figure 1 A flowchart of a method for enhancing agricultural product image quality based on a visual macro model proposed by the present invention;

[0085] Figure 2 This is a schematic diagram of a local area enhancement strategy for agricultural product images based on a multi-task visual model in an agricultural product image quality enhancement method based on a large visual model proposed in the present invention. DETAILED DESCRIPTION

[0086] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, which only illustrate the basic structure of the present invention in a schematic manner, and therefore only show the components related to the present invention.

[0087] refer to Figure 1-Figure 2 , a method for enhancing the quality of agricultural product images based on a visual macro model, comprising the following steps:

[0088] S1, obtain the original agricultural product image dataset during picking and transportation;

[0089] S2, inputting the original agricultural product image dataset of agricultural products into a pre-trained large-scale visual model, where the pre-trained large-scale visual model is trained based on multiple general agricultural product original images and has the ability to preliminarily identify and enhance agricultural product image features;

[0090] S3. Perform transfer learning fine-tuning on the pre-trained large-scale visual model. According to the types of agricultural products to be enhanced, the feature images of the corresponding categories are used as training data, and the weights and parameters of the large-scale visual model are optimized based on the characteristics of the training data.

[0091] S4. Use the fine-tuned large-scale visual model to process the original agricultural product image dataset of agricultural products. According to the agricultural product category of the input image, extract the matching enhancement strategy from the enhancement strategy library to perform color correction on the original agricultural product image dataset image to optimize brightness, saturation and color balance.

[0092] S5. Use super-resolution reconstruction algorithm to restore the details of agricultural product images, and use fine-tuned large-scale visual models to automatically detect blurred areas of agricultural product images and enhance edge and texture features of agricultural product images;

[0093] S6. Based on the multi-task processing capability of large-scale visual models, partial area enhancement strategies are implemented for agricultural product images of different agricultural product categories. Agricultural product images are divided into several areas, local contrast is improved for areas with uneven lighting, areas with uneven colors are corrected, and the display effect of defective areas is optimized according to the surface defect characteristics of agricultural products;

[0094] S7. Input the agricultural product image after color correction, denoising, detail restoration and area enhancement processing into the agricultural product quality detection system, further fine-tune the agricultural product image quality according to the output result of the detection system, and output the final enhanced agricultural product image.

[0095] In this implementation, S1 includes the following steps:

[0096] S11. Construct a dataset of original agricultural product images. Agricultural products include fruits, vegetables and grains. The image set D of agricultural products is collected by the collection equipment during the picking and transportation of agricultural products:

[0097] D={I 1 ,I 2 ,…,I n};

[0098] Among them, I i represents the i-th agricultural product image;

[0099] S12, each agricultural product image I i Contains the color, morphology and texture feature information of agricultural products. The color, morphology and texture features of each agricultural product image are annotated through the agricultural product image feature extraction method to generate the agricultural product feature set F i :

[0100] F i ={C i ,M i ,T i};

[0101] Among them, C i Represents the color characteristics of agricultural product images, including brightness, saturation and color distribution, M i Represents the morphological features of agricultural product images, including shape, outline and area size, T i Represent the texture features of agricultural product images, including texture direction, texture roughness and texture contrast;

[0102] S13, each agricultural product image I i The agricultural product feature set F i Combined with the agricultural product image collection D to generate a complete original agricultural product image dataset D f :

[0103] D f ={F 1 ,F 2 ,…,F n}.

[0104] In this implementation, S2 includes the following steps:

[0105] S21. Build a pre-trained large-scale visual model M, which is based on a general agricultural product image training set T. g Training, set agricultural product image training set T g = {I′ 1 ,I′ 2 ,…,I′ m}, where I′ j Denotes the jth general agricultural product image. The initial training objective of the large-scale visual model is to minimize the following composite loss function:

[0106]

[0107] Among them, m is the number of samples in the training set, I′ j represents the jth agricultural product image, γ 1 , γ 2 , γ 3 is the weight coefficient of each loss, is the color feature loss, measuring the color deviation, It is the loss of morphological characteristics, which measures the appearance characteristics of agricultural products. It is the texture feature loss, which is used to adjust the detail features;

[0108] S22, the original agricultural product image dataset D f Input to the pre-trained large-scale visual model M, and use the weight parameter matrix W to generate a preliminary feature output set O = {O 1 ,O 2 ,…,O n}, each output vector O i represents the preliminary enhanced features of the i-th image by the large-scale visual model;

[0109] S23, the pre-trained large-scale visual model M uses a multi-head self-attention mechanism to analyze the agricultural product features F i Processing is performed to capture the correlation between different regions, strengthen the characteristics of agricultural products on color, shape and texture, and generate the weighted agricultural product feature vector O i :

[0110]

[0111] Among them, H is the number of long positions, denote the query, key, and value vectors of the h-th head, respectively. is the weight matrix of query, key and value. Softmax function is used to generate attention distribution, d k is the dimension of the key vector, LayerNorm is the layer normalization operation;

[0112] S24. The large-scale visual model introduces multi-scale feature fusion and adaptive enhancement strategy, and finally optimizes the loss function L of the large-scale visual model, taking into account both recognition accuracy and image enhancement effect:

[0113]

[0114] Where n is the number of input samples, O i is the output feature vector of the large-scale visual model for the i-th agricultural product image, y i is the true label of the i-th agricultural product image, and are the enhanced output and ideal enhanced result of the i-th agricultural product image at the s-th scale, α 1 , β 1 is the weight coefficient of identification and enhancement loss, w s is the weight coefficient of the sth scale;

[0115] S25, output the preliminary output feature set O = {O 1 ,O 2 ,…,O n} and the multi-scale enhanced output set E = {E 1 ,E 2 ,…,E n}.

[0116] In this implementation, S3 includes the following steps:

[0117] S31. Construct a category feature training data set for the target agricultural product category:

[0118]

[0119] in, represents the i-th agricultural product image of the target agricultural product category c, and k is the number of agricultural product images of the category;

[0120] S32, class feature training data set T c Input into the pre-trained large-scale visual model M, and fine-tune the parameter matrix of the large-scale visual model through transfer learning to optimize the weight matrix W of the large-scale visual model c and the bias vector b c To adapt to the image features of agricultural products of specific agricultural product categories, the optimization goal is to minimize the following transfer learning loss function:

[0121]

[0122] Where k is the number of training samples, represents the i-th agricultural product image, λ 1 , 2 ,3 are the weight coefficients of color, morphology and texture loss, Represents the color feature loss, which is used to optimize the color consistency of agricultural product images. Represents the morphological feature loss, which is used to correct the shape features of agricultural product images. Represents texture feature loss;

[0123] S33, adjust the model weight W through the back propagation algorithm c and bias b c , gradually optimize the image features of agricultural products that are suitable for specific agricultural product categories, and the parameters updated after each iteration are:

[0124]

[0125]

[0126] in, and are the model weights and biases after the t+1th iteration, η is the learning rate, which controls the update amplitude, and is the loss function L c Gradients with respect to model parameters;

[0127] S34, the fine-tuned large-scale visual model M c Applied to the target agricultural product category, outputting an enhanced feature set

[0128] In this implementation, S4 includes the following steps:

[0129] S41. The fine-tuned large-scale visual model M c Applied to the original agricultural product image dataset D f , identify each agricultural product feature set F i Agricultural product categoriesc i , according to category c i Extract the corresponding enhancement strategy set from the preset enhancement strategy library S

[0130] S42. Category-specific enhancement strategies For the agricultural product feature set F i Color characteristics of C i =(L i ,S i ,H i ) is optimized, where L i Represents brightness characteristics, S i Indicates the saturation characteristic, H i Indicates color balance characteristics.

[0131] The goal of color correction is to minimize the following color deviation loss function:

[0132]

[0133] Among them, α 4 , α 2 , α 3 are the weight coefficients for brightness, saturation and color balance, Respectively represent the brightness, saturation and color balance values ​​of the optimization target;

[0134] S43, for the agricultural product feature set F i Apply the brightness enhancement operation to transform the brightness feature L i Adjust to optimized brightness value For the agricultural product feature set F i Saturation characteristic S i Apply a saturation boost operation to adjust the saturation signature to an optimized saturation value For the agricultural product feature set F i Color balance characteristics of H i Perform balance correction to adjust the color balance value to the optimized balance value

[0135] S44. Output the agricultural product image dataset after color correction, brightness optimization and saturation enhancement:

[0136]

[0137] In this implementation, S5 includes the following steps:

[0138] S51, the fine-tuned large-scale visual model M c Application to agricultural product image dataset Detect each agricultural product feature set The fuzzy area in the model generates the fuzzy weight matrix W through the model feature extraction layer 模糊 , score the blur level of agricultural product images:

[0139]

[0140] Among them, S 模糊,i represents the fuzzy score of the i-th agricultural product image, W 模糊,i (p) is the pth pixel weight of the fuzzy weight matrix, is the p-th pixel value of the i-th agricultural product image;

[0141] S52: For the area where the blur score exceeds the threshold, the details of the blur area are restored by using the super-resolution reconstruction algorithm, and the super-resolution of the generative model G is used to reconstruct the reconstructed agricultural product image R. i ;

[0142] S53, agricultural product image R i The texture features are enhanced to obtain the enhanced texture matrix

[0143] S55. Output the agricultural product image dataset after fuzzy area detail restoration, edge enhancement and texture optimization processing:

[0144]

[0145] In this implementation, S6 includes the following steps:

[0146] S61, dividing the agricultural product image dataset after detail restoration and texture optimization processing into several regions, defining each agricultural product image R i A collection of regions:

[0147]

[0148] in, represents the jth region of the i-th agricultural product image, m is the number of agricultural product image partitions, and the partition boundary is defined as:

[0149]

[0150] Among them, B represents the optimal partition boundary value, is the distance between each partition and the optimal boundary;

[0151] S62. Calculate the illumination distribution of each area based on the multi-task processing capability of the large-scale visual model to obtain the illumination deviation matrix in For Region The illumination deviation is used to calculate the local contrast enhancement value of the area:

[0152]

[0153] in, Indicates area The enhanced local contrast value, is the original contrast value of the region, α is the contrast enhancement coefficient, W j Represents the weight of a region based on its location and lighting requirements in the produce image;

[0154] S63: Perform color correction on the color-uneven areas and calculate the color balance matrix of each area

[0155]

[0156] in, Indicates area Corrected color balance value, is the original color balance value of the region, β is the color correction coefficient, H 目标 represents the target color balance value of the agricultural product image, and σ is the correction coefficient;

[0157] S64, based on the visual model, the surface defect features detected in each area are optimized and enhanced, the detail features in the area are Gaussian enhanced, and the optimized display effect matrix is ​​calculated.

[0158] S65. Output the agricultural product image dataset after local contrast enhancement, color correction and defect optimization processing:

[0159]

[0160] Embodiment 1:

[0161] This embodiment 1 is based on the demand for improving the image quality of agricultural products in agricultural production and supply chain management. The application scenario is selected as a large agricultural product distribution center in City A, which processes and distributes a large number of fruits, vegetables and grains every day. In order to achieve efficient agricultural product classification and quality inspection, the distribution center is equipped with multiple image acquisition devices for capturing the appearance images of agricultural products in various environments such as unstable light and vibration during transportation. In actual operation, due to the complex acquisition scene and significant changes in ambient light, the quality of the captured agricultural product images is seriously affected, especially the blurred edges, uneven lighting, color distortion and missing details, which makes it difficult for the quality inspection system to obtain accurate image information, thereby affecting the accuracy of agricultural product sorting, classification and quality assessment. To address this problem, the present invention adopts a large-scale visual model and its enhancement strategy library, aiming to automatically repair the blur, noise and uneven lighting problems in the image, thereby improving the image clarity and detail performance, and ensuring the recognition accuracy and work efficiency of the quality inspection system.

[0162] At the agricultural product distribution center in City A, agricultural products including apples, cucumbers and wheat need to be classified by quality through collected images. During the daily morning rush hour, due to the large changes in the lighting of the collection environment, traditional image processing algorithms cannot process stably, resulting in obvious quality inconsistencies in the images under different conditions. To improve this problem, this embodiment applies an agricultural product image quality enhancement method based on a large-scale visual model to carry out actual verification. By configuring a large-scale visual model, the present invention first inputs the collected agricultural product images into a pre-trained large-scale visual model, and performs regional enhancement through multi-tasking processing capabilities, thereby optimizing the performance of different categories of agricultural products under different lighting, colors and textures.

[0163] In the specific process, this embodiment 1 selects three agricultural products, namely apples, cucumbers and wheat, as training samples, and configures 24 high-definition cameras in the agricultural product distribution center. The total number of sample shots reaches 10,000 images, and about 3,300 images are taken for each agricultural product. According to the method in the claim, the training data is input into the large-scale visual model for pre-training, and the color, morphology and texture features are preliminarily extracted, and a category enhancement strategy is formed in the classification strategy library. After the pre-training is completed, the large-scale visual model fine-tunes the specific features of each agricultural product image to adapt to the smooth skin of apples, the strip texture of cucumbers and the granular characteristics of wheat. After the large-scale visual model is fine-tuned, it is run under actual shooting conditions to ensure that the agricultural product images can automatically optimize the contrast, brightness and details under different lighting, color and texture conditions.

[0164] The data was collected in the designated area of ​​the agricultural product distribution center. The cameras were configured on each transport conveyor belt. The collected images included multiple scenes such as full light, low light, and mixed light to simulate the real agricultural product sorting environment. The image resolution was set to 1080p, and the size of each image was 5MB. A total of 10,000 sample images of three categories, apples, cucumbers, and wheat, were collected.

[0165] The collected image dataset is input into the large-scale visual model for pre-training. During this process, the large-scale visual model mainly identifies the color, shape and texture of agricultural products by extracting the basic features of the image. To ensure the stability of data training, the large-scale visual model adopts 10 rounds of cyclic training in the pre-training stage. After each round of data is input into the large-scale visual model, the initial feature extraction results are recorded. Taking apples as an example, the large-scale visual model captures the average brightness value of apples as 180, the saturation as 0.85, and the contrast as 1.2. Through the learning of these feature values, the large-scale visual model preliminarily identifies the smoothness and round edge features of apples.

[0166] After pre-training, the large-scale visual model enters the fine-tuning stage. It will build enhancement strategy libraries for apples, cucumbers, and wheat to adapt to the category characteristics of different agricultural products. The large-scale visual model adjusts the weight matrix through transfer learning, and performs color correction, contrast adjustment, and detail enhancement on each category of images. In the image detail enhancement of apples, by improving the edge sharpness, the large-scale visual model improves the clarity of the defective area of ​​the apple skin by 20%. In the image processing of cucumbers, the contrast of the strip texture is enhanced, so that the large-scale visual model can more accurately identify the maturity of cucumbers. The image optimization of wheat focuses on improving the characteristics of fine particles, making it easier for large-scale visual models to distinguish the integrity of particles.

[0167] On the fine-tuned large-scale visual model, the present invention applies a super-resolution algorithm to reconstruct details of blurred areas. In the sample images of apples, the large-scale visual model detects areas with edge blur scores higher than 0.7, and after applying the super-resolution algorithm, the details of the blurred areas are restored. Taking 20 images of apples as an example, the traditional method can only restore 80% of the details of the original image on average, while the method of the present invention can achieve a detail recovery rate of 96%, and the edge clarity is improved by 15%.

[0168] For the sample images of cucumbers, the large-scale visual model applied color correction and local contrast enhancement in different areas. The large-scale visual model with the striped texture feature as the central area increased its brightness to 1.1 times the original brightness, and adjusted the contrast coefficient to 1.3. In the processing results of the actual captured images, compared with the uniform enhancement of the traditional processing method, the method of the present invention effectively reduced the image distortion in the high-light or low-light areas, and the clarity of the striped texture was significantly improved.

[0169] At the agricultural product distribution center, the collected image samples were processed by the traditional image enhancement method and the method of the present invention, and a detailed experimental data comparison was carried out. The data included image clarity, color accuracy and processing speed:

[0170] index Method of the present invention Traditional methods Image clarity rating 0.92 0.75 Color Accuracy Rating 0.89 0.72 Edge detail recovery rate 96% 80% Single image processing time 1.2 seconds / sheet 2.5 seconds / sheet Agricultural product testing accuracy 98% 85%

[0171] Judging from the experimental results, the image enhancement method of the present invention is significantly superior to traditional methods in terms of image clarity, color accuracy, detail restoration, processing speed and detection accuracy, especially in the restoration of details and edge features. The enhancement strategy library of the present invention can effectively improve the image quality of different agricultural products, ensure the image processing effect in complex environments, and enhance the robustness and accuracy of the quality detection system.

[0172] The present invention adopts the multi-tasking processing capability of a large-scale visual model. By processing the image in different regions, the contrast and color balance can be automatically adjusted according to the lighting and color distribution conditions in different regions. In areas with uneven lighting, the present invention improves the local contrast through an enhancement strategy so that the agricultural products can maintain clear and delicate image details under various lighting conditions. In areas with uneven colors, adaptive color correction is used to make the overall image color natural and consistent, thereby avoiding the problem that traditional methods are difficult to handle complex lighting conditions. Experimental results show that the color accuracy of the present invention in the processing of diversified agricultural products images is improved by more than 12%, and the contrast and clarity are significantly improved, ensuring the stable performance of the image in a variety of shooting environments.

[0173] The present invention innovatively introduces a super-resolution reconstruction algorithm and an edge optimization strategy, which significantly improves the problems of blurred areas and detail loss in agricultural product images. The blurred areas are automatically detected by a large-scale visual model, and the super-resolution algorithm is applied in the area to perform high-precision restoration of blurred edges and fine textures, ensuring that the details of the agricultural products in the image are completely restored. This is especially effective for images of fruits and vegetables with complex skin textures. Compared with traditional image reconstruction methods, the present invention improves edge clarity by more than 15%, making the surface details and texture information of agricultural products clearer, and providing an accurate data basis for quality inspection and identification.

[0174] The present invention constructs a category-specific enhancement strategy library to enable large-scale visual models to automatically select appropriate enhancement strategies according to the category of agricultural products, and perform customized image enhancement processing for different types of agricultural products. Traditional enhancement methods are prone to inconsistent enhancement effects when processing diversified agricultural products, while the enhancement strategy library of the present invention can be optimized and selected according to the different characteristics of fruit, vegetable and grain categories, thereby ensuring the consistency and applicability of the enhancement effect. Experimental data show that the adaptability of the enhancement strategy library of the present invention in different agricultural product categories has increased by more than 20%, significantly improving the image recognition accuracy and classification accuracy of the detection system.

[0175] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.

Claims

1. A method for enhancing agricultural product image quality based on a visual macro model, characterized in that: The steps include: S1, obtain the original agricultural product image dataset during picking and transportation; S2, inputting the original agricultural product image dataset of the agricultural products into a pre-trained large-scale visual model, wherein the pre-trained large-scale visual model is trained based on a plurality of general agricultural product original images and has the ability to preliminarily identify and enhance the features of the agricultural product images; S3. Perform transfer learning fine-tuning on the pre-trained large-scale visual model. According to the types of agricultural products to be enhanced, the feature images of the corresponding categories are used as training data, and the weights and parameters of the large-scale visual model are optimized based on the characteristics of the training data. S4. Use the fine-tuned large-scale visual model to process the original agricultural product image dataset of agricultural products. According to the agricultural product category of the input image, extract the matching enhancement strategy from the enhancement strategy library to perform color correction on the original agricultural product image dataset image to optimize brightness, saturation and color balance. S5. Use super-resolution reconstruction algorithm to restore the details of agricultural product images, and use fine-tuned large-scale visual models to automatically detect blurred areas of agricultural product images and enhance edge and texture features of agricultural product images; S6. Based on the multi-task processing capability of large-scale visual models, partial area enhancement strategies are implemented for agricultural product images of different agricultural product categories. Agricultural product images are divided into several areas, local contrast is improved for areas with uneven lighting, areas with uneven colors are corrected, and the display effect of defective areas is optimized according to the surface defect characteristics of agricultural products; S7. Input the agricultural product image after color correction, denoising, detail restoration and area enhancement processing into the agricultural product quality detection system, further fine-tune the agricultural product image quality according to the output result of the detection system, and output the final enhanced agricultural product image.

2. The method for enhancing agricultural product image quality based on a visual macro model according to claim 1, characterized in that: The S1 comprises the following steps: S11. Construct an original agricultural product image dataset of agricultural products, wherein the agricultural products include fruits, vegetables and grains, and a collection of agricultural product images D collected by a collection device during the picking and transportation of agricultural products: D={I1,I2,…,I n }; Among them, I i represents the i-th agricultural product image; S12, each agricultural product image I i Contains the color, morphology and texture feature information of agricultural products. The color, morphology and texture features of each agricultural product image are annotated through the agricultural product image feature extraction method to generate the agricultural product feature set F i : F i ={C i ,M i ,T i }; Among them, C i Represents the color characteristics of agricultural product images, including brightness, saturation and color distribution, M i Represents the morphological features of agricultural product images, including shape, outline and area size, T i Represent the texture features of agricultural product images, including texture direction, texture roughness and texture contrast; S13, each agricultural product image I i The agricultural product feature set F i Combined with the agricultural product image collection D to generate a complete original agricultural product image dataset D f : D f ={F1,F2,…,F n }。 3. The method for enhancing agricultural product image quality based on a visual macro model according to claim 1, characterized in that: The S2 comprises the following steps: S21. Build a pre-trained large-scale visual model M, which is based on a general agricultural product image training set T. g Training, set agricultural product image training set T g ={I′1,I′2,…,I′ m }, where I′ j Denotes the jth general agricultural product image. The initial training objective of the large-scale visual model is to minimize the following composite loss function: Among them, m is the number of samples in the training set, I′ j represents the jth agricultural product image, γ1, γ2, γ3 are the weight coefficients of each loss, is the color feature loss, measuring the color deviation, It is the loss of morphological characteristics, which measures the appearance characteristics of agricultural products. It is the texture feature loss, which is used to adjust the detail features; S22, the original agricultural product image dataset D f Input to the pre-trained large-scale visual model M, and use the weight parameter matrix W to generate a preliminary feature output set O = {O1, O2, ..., O n }, each output vector O i represents the preliminary enhanced features of the i-th image by the large-scale visual model; S23, the pre-trained large-scale visual model M uses a multi-head self-attention mechanism to analyze the agricultural product features F i Processing is performed to capture the correlation between different regions, strengthen the characteristics of agricultural products on color, shape and texture, and generate the weighted agricultural product feature vector O i : Among them, H is the number of long positions, denote the query, key, and value vectors of the h-th head, respectively. is the weight matrix of query, key and value. Softmax function is used to generate attention distribution, d k is the dimension of the key vector, LayerNorm is the layer normalization operation; S24. The large-scale visual model introduces multi-scale feature fusion and adaptive enhancement strategy, and finally optimizes the loss function L of the large-scale visual model, taking into account both recognition accuracy and image enhancement effect: Where n is the number of input samples, O i is the output feature vector of the large-scale visual model for the i-th agricultural product image, y i is the true label of the i-th agricultural product image, and are the enhanced output and ideal enhanced result of the i-th agricultural product image at the s-th scale, α1 and β1 are the weight coefficients of recognition and enhancement loss, and w s is the weight coefficient of the sth scale; S25, output the preliminary output feature set O = {O1, O2, ..., O n } and the multi-scale enhanced output set E = {E1, E2, …, E n }.

4. The method for enhancing agricultural product image quality based on a visual macro model according to claim 1, characterized in that: The S3 comprises the following steps: S31. Construct a category feature training data set for the target agricultural product category: in, represents the i-th agricultural product image of the target agricultural product category c, and k is the number of agricultural product images of the category; S32, class feature training data set T c Input into the pre-trained large-scale visual model M, and fine-tune the parameter matrix of the large-scale visual model through transfer learning to optimize the weight matrix W of the large-scale visual model c and the bias vector b c To adapt to the image features of agricultural products of specific agricultural product categories, the optimization goal is to minimize the following transfer learning loss function: Where k is the number of training samples, represents the i-th agricultural product image, λ1, λ2, λ3 are the weight coefficients of color, morphology and texture loss, Represents the color feature loss, which is used to optimize the color consistency of agricultural product images. Represents the morphological feature loss, which is used to correct the shape features of agricultural product images. Represents texture feature loss; S33, adjust the model weight W through the back propagation algorithm c and bias b c , gradually optimize the image features of agricultural products that are suitable for specific agricultural product categories, and the parameters updated after each iteration are: in, and are the model weights and biases after the t+1th iteration, η is the learning rate, which controls the update amplitude, and is the loss function L c Gradients with respect to model parameters; S34, the fine-tuned large-scale visual model M c Applied to the target agricultural product category, outputting an enhanced feature set 5. The method for enhancing agricultural product image quality based on a visual macro model according to claim 1, characterized in that: The S4 comprises the following steps: S41. The fine-tuned large-scale visual model M c Applied to the original agricultural product image dataset D f , identify each agricultural product feature set F i Agricultural product categoriesc i , according to category c i Extract the corresponding enhancement strategy set from the preset enhancement strategy library S S42. Category-specific enhancement strategies For the agricultural product feature set F i Color characteristics of C i =(L i ,S i ,H i ) is optimized, where L i Represents brightness characteristics, S i Indicates the saturation characteristic, H i Indicates color balance characteristics; The goal of color correction is to minimize the following color deviation loss function: Among them, α4, α2, and α3 are the weight coefficients of brightness, saturation, and color balance. Respectively represent the brightness, saturation and color balance values ​​of the optimization target; S43, for the agricultural product feature set F i Apply the brightness enhancement operation to transform the brightness feature L i Adjust to optimized brightness value For the agricultural product feature set F i Saturation characteristic S i Apply a saturation boost operation to adjust the saturation signature to an optimized saturation value For the agricultural product feature set F i Color balance characteristics of H i Perform balance correction to adjust the color balance value to the optimized balance value S44. Output the agricultural product image dataset after color correction, brightness optimization and saturation enhancement:

6. The method for enhancing agricultural product image quality based on a visual macro model according to claim 1, characterized in that: The S5 comprises the following steps: S51, the fine-tuned large-scale visual model M c Application to agricultural product image dataset Detect each agricultural product feature set The fuzzy area in the model generates the fuzzy weight matrix W through the model feature extraction layer 模糊 , score the blur level of agricultural product images: Among them, S 模糊,i represents the fuzzy score of the i-th agricultural product image, W 模糊,i (p) is the pth pixel weight of the fuzzy weight matrix, is the p-th pixel value of the i-th agricultural product image; S52: For the area where the blur score exceeds the threshold, the details of the blur area are restored by using the super-resolution reconstruction algorithm, and the super-resolution of the generative model G is used to reconstruct the reconstructed agricultural product image R. i ; S53, agricultural product image R i The texture features are enhanced to obtain the enhanced texture matrix S55. Output the agricultural product image dataset after fuzzy area detail restoration, edge enhancement and texture optimization processing:

7. The method for enhancing agricultural product image quality based on a visual macro model according to claim 1, characterized in that: The S6 comprises the following steps: S61, dividing the agricultural product image dataset after detail restoration and texture optimization processing into several regions, defining each agricultural product image R i A collection of regions: in, represents the jth region of the i-th agricultural product image, m is the number of agricultural product image partitions, and the partition boundary is defined as: Among them, B represents the optimal partition boundary value, is the distance between each partition and the optimal boundary; S62. Calculate the illumination distribution of each area based on the multi-task processing capability of the large-scale visual model to obtain the illumination deviation matrix in For Region The illumination deviation is used to calculate the local contrast enhancement value of the area: in, Indicates area The enhanced local contrast value, is the original contrast value of the region, α is the contrast enhancement coefficient, W j Represents the weight of a region based on its location and lighting requirements in the produce image; S63: Perform color correction on the color-uneven areas and calculate the color balance matrix of each area in, Indicates area Corrected color balance value, is the original color balance value of the region, β is the color correction coefficient, H 目标 represents the target color balance value of the agricultural product image, and σ is the correction coefficient; S64, based on the visual model, the surface defect features detected in each area are optimized and enhanced, the detail features in the area are Gaussian enhanced, and the optimized display effect matrix is ​​calculated. S65. Output the agricultural product image dataset after local contrast enhancement, color correction and defect optimization processing:

Citation Information

Patent Citations

  • Ultra-high voltage converter station protection system panoramic monitoring image super-resolution reconstruction method

    CN114331838A

  • Visual adaptive reconstruction method based on transfer learning

    CN117853363A