[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN117197062B - A method and system for measuring leaf nitrogen content based on RGB images - Google Patents

A method and system for measuring leaf nitrogen content based on RGB images Download PDF

Info

Publication number
CN117197062B
CN117197062B CN202311108046.0A CN202311108046A CN117197062B CN 117197062 B CN117197062 B CN 117197062B CN 202311108046 A CN202311108046 A CN 202311108046A CN 117197062 B CN117197062 B CN 117197062B
Authority
CN
China
Prior art keywords
neural network
data set
nitrogen content
leaf nitrogen
white balance
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202311108046.0A
Other languages
Chinese (zh)
Other versions
CN117197062A (en
Inventor
史良胜
李金敏
查元源
胡小龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan University WHU
Original Assignee
Wuhan University WHU
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan University WHU filed Critical Wuhan University WHU
Priority to CN202311108046.0A priority Critical patent/CN117197062B/en
Publication of CN117197062A publication Critical patent/CN117197062A/en
Application granted granted Critical
Publication of CN117197062B publication Critical patent/CN117197062B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Color Television Image Signal Generators (AREA)

Abstract

本发明提供一种基于RGB图像的叶片氮含量测量方法及系统,属于图像处理技术领域,包括:采用相机拍摄作物的冠层照片;基于拍摄的照片制作白平衡校正和曝光校正的图像数据集;构建图像白平衡和曝光校正的卷积神经网络,并对相机拍摄的照片进行校正测试;基于校正后的作物冠层图像,训练叶片氮含量估测的神经网络模型,并在不同拍摄角度、不同拍摄设备和不同品种的作物中进行应用。与传统方法相比,本发明实现成本低,操作简单,对用户和设备没有特别的要求,在各种天气条件下都可以完成测量任务,具有很强的普适性。

The present invention provides a leaf nitrogen content measurement method and system based on RGB images, which belongs to the field of image processing technology, including: taking crop canopy photos with a camera; producing image data sets for white balance correction and exposure correction based on the taken photos; constructing a convolutional neural network for image white balance and exposure correction, and performing correction tests on the photos taken by the camera; training a neural network model for leaf nitrogen content estimation based on the corrected crop canopy images, and applying it to crops of different shooting angles, different shooting equipment and different varieties. Compared with traditional methods, the present invention has low implementation cost, simple operation, no special requirements for users and equipment, can complete measurement tasks under various weather conditions, and has strong universality.

Description

一种基于RGB图像的叶片氮含量测量方法及系统A method and system for measuring leaf nitrogen content based on RGB images

技术领域Technical Field

本发明涉及图像处理技术领域,尤其涉及一种基于RGB图像的叶片氮含量测量方法及系统。The present invention relates to the technical field of image processing, and in particular to a method and system for measuring the nitrogen content of leaves based on RGB images.

背景技术Background Art

氮是作物生长发育过程中不可或缺的营养元素之一,对细胞生长、分裂和新细胞形成有着很重要的影响。通过施加氮肥可以有效提高作物的产量,但是过量的氮肥施用也会造成严重的环境污染甚至减产等问题。因此,作物氮素状态的准确估计对精准农业的氮素管理是非常必要的。Nitrogen is one of the indispensable nutrients in the growth and development of crops, and has a very important influence on cell growth, division and new cell formation. The application of nitrogen fertilizer can effectively increase crop yields, but excessive nitrogen fertilizer application can also cause serious environmental pollution and even reduce production. Therefore, accurate estimation of crop nitrogen status is very necessary for nitrogen management in precision agriculture.

传统的破坏性采样方法通过在田间采集植物叶片,然后在实验室进行化学分析,费时费力。在非破坏性的方法中,单光子雪崩二极管(Single photon avalanche diodes,SPAD)测量范围太小,在实际应用中效率很低;高光谱/多光谱仪等设备通常非常昂贵,这也限制了其在农业生产中的应用。智能手机的普及使得田间作物的图像获取变得简单。已有的研究表明,计算机视觉的方法可以用于对作物氮素状态进行估计。然而,目前利用智能手机等相机设备监测作物氮素的研究仍不充分,大多数都忽略了拍摄过程中自然光线或者拍照设置错误对作物氮素估计结果的影响。尽管作物的特征没有变化,不同的数码相机(或不同设置的同一相机)在获取图像时都会产生不一致的颜色;使用同一相机在不同时间拍摄的图像颜色可能也会有所不同。Traditional destructive sampling methods collect plant leaves in the field and then perform chemical analysis in the laboratory, which is time-consuming and laborious. Among non-destructive methods, single photon avalanche diodes (SPADs) have a very small measurement range and are inefficient in practical applications; equipment such as hyperspectral/multispectral instruments are usually very expensive, which also limits their application in agricultural production. The popularity of smartphones has made it easy to obtain images of field crops. Existing studies have shown that computer vision methods can be used to estimate the nitrogen status of crops. However, current research on monitoring crop nitrogen using camera devices such as smartphones is still insufficient, and most of them ignore the impact of natural light or incorrect camera settings during shooting on crop nitrogen estimation results. Although the characteristics of the crop have not changed, different digital cameras (or the same camera with different settings) will produce inconsistent colors when acquiring images; the colors of images taken at different times using the same camera may also be different.

因此,如果单一地使用一种计算机视觉技术,难以适应野外复杂环境中的氮素估计任务。Therefore, if a single computer vision technology is used, it will be difficult to adapt to the nitrogen estimation task in complex field environments.

发明内容Summary of the invention

本发明提供一种基于RGB图像的叶片氮含量测量方法及系统,用以解决现有技术中采用单一视觉测量技术无法准确地测量叶片氮含量的缺陷。The present invention provides a leaf nitrogen content measurement method and system based on RGB images, which are used to solve the defect that the single visual measurement technology used in the prior art cannot accurately measure the leaf nitrogen content.

第一方面,本发明提供一种基于RGB图像的叶片氮含量测量方法,包括:In a first aspect, the present invention provides a method for measuring leaf nitrogen content based on RGB images, comprising:

采集作物冠层样本照片;Collect photos of crop canopy samples;

调整所述作物冠层样本照片的白平衡模式,得到白平衡校正数据集,由所述白平衡校正数据集构建图像白平衡校正神经网络;Adjusting the white balance mode of the crop canopy sample photo to obtain a white balance correction data set, and constructing an image white balance correction neural network based on the white balance correction data set;

调整所述作物冠层样本照片的曝光模式,得到曝光校正数据集,由所述校正数据集构建图像曝光校正神经网络;Adjusting the exposure mode of the crop canopy sample photo to obtain an exposure correction data set, and constructing an image exposure correction neural network based on the correction data set;

综合所述图像白平衡校正神经网络和所述图像曝光校正神经网络对所述作物冠层样本照片进行校正,得到校正后数据集;Correcting the crop canopy sample photo by integrating the image white balance correction neural network and the image exposure correction neural network to obtain a corrected data set;

构建叶片氮含量测量神经网络初始模型,获取叶片氮标签,基于所述校正后数据集和所述叶片氮标签对所述叶片氮含量测量神经网络初始模型进行训练,得到叶片氮含量测量模型;Constructing an initial neural network model for measuring leaf nitrogen content, obtaining leaf nitrogen labels, and training the initial neural network model for measuring leaf nitrogen content based on the corrected data set and the leaf nitrogen labels to obtain a leaf nitrogen content measurement model;

将待测量作物冠层照片输入所述叶片氮含量测量模型,得到叶片氮含量测量结果。The canopy photo of the crop to be measured is input into the leaf nitrogen content measurement model to obtain the leaf nitrogen content measurement result.

根据本发明提供的一种基于RGB图像的叶片氮含量测量方法,采集作物冠层样本照片,包括:According to a leaf nitrogen content measurement method based on RGB images provided by the present invention, a crop canopy sample photo is collected, comprising:

采用智能手机相机在任一白天时刻拍摄作物冠层,采集任意三个不同预设角度照片,以预设文件格式保存拍摄照片;Use a smartphone camera to photograph crop canopies at any time during the day, collect photos from any three different preset angles, and save the photos in a preset file format;

利用图像处理软件调整所述拍摄照片的白平衡设置和曝光设置,得到真值图像。The white balance setting and exposure setting of the photographed photo are adjusted using image processing software to obtain a true value image.

根据本发明提供的一种基于RGB图像的叶片氮含量测量方法,调整所述作物冠层样本照片的白平衡模式,得到白平衡校正数据集,由所述白平衡校正数据集构建图像白平衡校正神经网络,包括:According to a leaf nitrogen content measurement method based on RGB images provided by the present invention, the white balance mode of the crop canopy sample photo is adjusted to obtain a white balance correction data set, and an image white balance correction neural network is constructed from the white balance correction data set, including:

调整真值图像的白平衡模式,得到包含不同色温的多个色温偏差图像,将所述多个色温偏差图像与所述真值图像构成所述白平衡校正数据集;Adjusting the white balance mode of the true value image to obtain a plurality of color temperature deviation images including different color temperatures, and combining the plurality of color temperature deviation images and the true value image to form the white balance correction data set;

基于所述白平衡校正数据集,构建白平衡校正全卷积神经网络,采用L1损失函数,以及Adam优化器对所述白平衡校正全卷积神经网络进行训练收敛,得到所述图像白平衡校正神经网络。Based on the white balance correction data set, a white balance correction full convolutional neural network is constructed, and the L1 loss function and the Adam optimizer are used to train and converge the white balance correction full convolutional neural network to obtain the image white balance correction neural network.

根据本发明提供的一种基于RGB图像的叶片氮含量测量方法,调整所述作物冠层样本照片的曝光模式,得到曝光校正数据集,由所述校正数据集构建图像曝光校正神经网络,包括:According to a leaf nitrogen content measurement method based on RGB images provided by the present invention, the exposure mode of the crop canopy sample photo is adjusted to obtain an exposure correction data set, and an image exposure correction neural network is constructed based on the correction data set, including:

调整真值图像的曝光模式,得到包含不同曝光值的多个曝光偏差图像,将所述多个曝光偏差图像与所述真值图像构成所述曝光校正数据集;Adjusting the exposure mode of the true value image to obtain a plurality of exposure deviation images including different exposure values, and forming the exposure correction data set with the plurality of exposure deviation images and the true value image;

基于所述曝光校正数据集,构建曝光校正全卷积神经网络,采用L1损失函数,以及Adam优化器对所述曝光校正全卷积神经网络进行训练收敛,得到所述图像曝光校正神经网络。Based on the exposure correction data set, an exposure correction full convolutional neural network is constructed, and the exposure correction full convolutional neural network is trained and converged using an L1 loss function and an Adam optimizer to obtain the image exposure correction neural network.

根据本发明提供的一种基于RGB图像的叶片氮含量测量方法,综合所述图像白平衡校正神经网络和所述图像曝光校正神经网络对所述作物冠层样本照片进行校正,得到校正后数据集,包括:According to a leaf nitrogen content measurement method based on RGB images provided by the present invention, the image white balance correction neural network and the image exposure correction neural network are integrated to correct the crop canopy sample photo to obtain a corrected data set, including:

将所述作物冠层样本照片输入所述图像白平衡校正神经网络,得到白平衡校正后数据集;Inputting the crop canopy sample photo into the image white balance correction neural network to obtain a white balance corrected data set;

将所述作物冠层样本照片输入所述图像曝光校正神经网络,得到曝光校正后数据集。The crop canopy sample photos are input into the image exposure correction neural network to obtain an exposure-corrected data set.

根据本发明提供的一种基于RGB图像的叶片氮含量测量方法,构建叶片氮含量测量神经网络初始模型,获取叶片氮标签,基于所述校正后数据集和所述叶片氮标签对所述叶片氮含量测量神经网络初始模型进行训练,得到叶片氮含量测量模型之前,还包括:According to a leaf nitrogen content measurement method based on RGB images provided by the present invention, an initial model of a leaf nitrogen content measurement neural network is constructed, leaf nitrogen labels are obtained, and the initial model of the leaf nitrogen content measurement neural network is trained based on the corrected data set and the leaf nitrogen labels. Before obtaining the leaf nitrogen content measurement model, the method further includes:

将所述校正后数据集中的色卡部分进行裁剪,得到仅包括作物冠层信息图像的裁剪后数据集;Cropping the color card part in the corrected data set to obtain a cropped data set that only includes crop canopy information images;

对所述裁剪后数据集进行数据增强,得到增强数据集。Data enhancement is performed on the cropped data set to obtain an enhanced data set.

根据本发明提供的一种基于RGB图像的叶片氮含量测量方法,构建叶片氮含量测量神经网络初始模型,获取叶片氮标签,基于所述校正后数据集和所述叶片氮标签对所述叶片氮含量测量神经网络初始模型进行训练,得到叶片氮含量测量模型,包括:According to a leaf nitrogen content measurement method based on RGB images provided by the present invention, an initial model of a leaf nitrogen content measurement neural network is constructed, a leaf nitrogen label is obtained, and the initial model of the leaf nitrogen content measurement neural network is trained based on the corrected data set and the leaf nitrogen label to obtain a leaf nitrogen content measurement model, including:

采用预设卷积神经网络构建所述叶片氮含量测量神经网络初始模型;A preset convolutional neural network is used to construct an initial neural network model for measuring leaf nitrogen content;

通过实验测量所述作物冠层样本照片得到所述叶片氮标签;Obtaining the leaf nitrogen label by experimentally measuring the crop canopy sample photo;

采用均方误差MSE损失函数和Adam优化器对所述叶片氮含量测量神经网络初始模型进行训练收敛,得到所述叶片氮含量测量模型。The mean square error (MSE) loss function and the Adam optimizer are used to train and converge the initial model of the leaf nitrogen content measurement neural network to obtain the leaf nitrogen content measurement model.

根据本发明提供的一种基于RGB图像的叶片氮含量测量方法,还包括:A leaf nitrogen content measurement method based on RGB images provided by the present invention also includes:

将不同拍摄角度、不同拍摄设备和不同作物品种的作物冠层图像输入至所述叶片氮含量测量模型,得到不同叶片氮含量测量结果;Inputting crop canopy images of different shooting angles, different shooting equipment and different crop varieties into the leaf nitrogen content measurement model to obtain measurement results of different leaf nitrogen contents;

利用不同预设精度评价指标对所述不同叶片氮含量测量结果进行评价对比。The nitrogen content measurement results of the different leaves are evaluated and compared using different preset accuracy evaluation indicators.

第二方面,本发明还提供一种基于RGB图像的叶片氮含量测量系统,包括:In a second aspect, the present invention further provides a leaf nitrogen content measurement system based on RGB images, comprising:

采集模块,用于采集作物冠层样本照片;A collection module for collecting sample photos of crop canopies;

白平衡数据处理模块,用于调整所述作物冠层样本照片的白平衡模式,得到白平衡校正数据集,由所述白平衡校正数据集构建图像白平衡校正神经网络;A white balance data processing module, used for adjusting the white balance mode of the crop canopy sample photo to obtain a white balance correction data set, and constructing an image white balance correction neural network based on the white balance correction data set;

曝光数据处理模块,用于调整所述作物冠层样本照片的曝光模式,得到曝光校正数据集,由所述校正数据集构建图像曝光校正神经网络;An exposure data processing module, used for adjusting the exposure mode of the crop canopy sample photo to obtain an exposure correction data set, and constructing an image exposure correction neural network based on the correction data set;

校正模块,用于综合所述图像白平衡校正神经网络和所述图像曝光校正神经网络对所述作物冠层样本照片进行校正,得到校正后数据集;A correction module, used to correct the crop canopy sample photo by integrating the image white balance correction neural network and the image exposure correction neural network to obtain a corrected data set;

训练模块,用于构建叶片氮含量测量神经网络初始模型,获取叶片氮标签,基于所述校正后数据集和所述叶片氮标签对所述叶片氮含量测量神经网络初始模型进行训练,得到叶片氮含量测量模型;A training module is used to construct an initial model of a neural network for measuring leaf nitrogen content, obtain leaf nitrogen labels, and train the initial model of the neural network for measuring leaf nitrogen content based on the corrected data set and the leaf nitrogen labels to obtain a leaf nitrogen content measurement model;

测量模块,用于将待测量作物冠层照片输入所述叶片氮含量测量模型,得到叶片氮含量测量结果。The measurement module is used to input the canopy photo of the crop to be measured into the leaf nitrogen content measurement model to obtain the leaf nitrogen content measurement result.

第三方面,本发明还提供一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述程序时实现如上述任一种所述基于RGB图像的叶片氮含量测量方法。In a third aspect, the present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a leaf nitrogen content measurement method based on RGB images as described above is implemented.

第四方面,本发明还提供一种非暂态计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现如上述任一种所述基于RGB图像的叶片氮含量测量方法。In a fourth aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-described methods for measuring leaf nitrogen content based on RGB images.

本发明提供的基于RGB图像的叶片氮含量测量方法及系统,通过采用具有注意力机制的全卷积神经网络,能够很好地完成相机照片的白平衡和曝光校正,有效降低了复杂光线变化带来的影响。基于白平衡和曝光校正之后的图像,训练出用于作物叶片氮含量估测的卷积神经网络,可以提高作物氮素估计的精度。基于该架构的一系列计算机视觉算法,解决了野外复杂环境下光线变化和用户拍摄设置错误等带来的各种图像质量问题,成功地完成了作物叶片氮含量的估计任务。The leaf nitrogen content measurement method and system based on RGB images provided by the present invention can well complete the white balance and exposure correction of camera photos by adopting a fully convolutional neural network with an attention mechanism, effectively reducing the impact of complex light changes. Based on the images after white balance and exposure correction, a convolutional neural network for estimating the nitrogen content of crop leaves is trained to improve the accuracy of crop nitrogen estimation. A series of computer vision algorithms based on this architecture solve various image quality problems caused by light changes in complex outdoor environments and user shooting setting errors, and successfully complete the task of estimating the nitrogen content of crop leaves.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

为了更清楚地说明本发明或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

图1是本发明提供的基于RGB图像的叶片氮含量测量方法的流程示意图之一;FIG1 is a schematic diagram of a flow chart of a method for measuring nitrogen content in leaves based on RGB images provided by the present invention;

图2是本发明提供的基于RGB图像的叶片氮含量测量方法的流程示意图之二;FIG2 is a second flow chart of the method for measuring nitrogen content in leaves based on RGB images provided by the present invention;

图3是本发明提供的白平衡校正的数据集示例图;FIG3 is an example diagram of a data set for white balance correction provided by the present invention;

图4是本发明提供的曝光校正的数据集示例图;FIG4 is an example diagram of a data set for exposure correction provided by the present invention;

图5是本发明提供的白平衡校正神经网络对不同色温设定图片的校正效果图;FIG5 is a diagram showing the correction effect of the white balance correction neural network provided by the present invention on pictures with different color temperature settings;

图6是本发明提供的曝光校正神经网络对不同EV值设定图片的校正效果图;FIG6 is a diagram showing the correction effect of the exposure correction neural network provided by the present invention on pictures with different EV value settings;

图7是本发明提供的不同卷积神经网络利用RGB图像估计叶片氮含量的精度对比图;FIG7 is a comparison chart of the accuracy of different convolutional neural networks provided by the present invention in estimating leaf nitrogen content using RGB images;

图8是本发明提供的基于RGB图像的叶片氮含量测量系统的结构示意图;FIG8 is a schematic diagram of the structure of a leaf nitrogen content measurement system based on RGB images provided by the present invention;

图9是本发明提供的电子设备的结构示意图。FIG. 9 is a schematic diagram of the structure of an electronic device provided by the present invention.

具体实施方式DETAILED DESCRIPTION

为使本发明的目的、技术方案和优点更加清楚,下面将结合本发明中的附图,对本发明中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

图1是本发明实施例提供的基于RGB图像的叶片氮含量测量方法的流程示意图之一,如图1所示,包括:FIG. 1 is a flow chart of a method for measuring nitrogen content in leaves based on RGB images provided by an embodiment of the present invention. As shown in FIG. 1 , the method comprises:

步骤100:采集作物冠层样本照片;Step 100: Collecting crop canopy sample photos;

步骤200:调整所述作物冠层样本照片的白平衡模式,得到白平衡校正数据集,由所述白平衡校正数据集构建图像白平衡校正神经网络;Step 200: adjusting the white balance mode of the crop canopy sample photo to obtain a white balance correction data set, and constructing an image white balance correction neural network based on the white balance correction data set;

步骤300:调整所述作物冠层样本照片的曝光模式,得到曝光校正数据集,由所述校正数据集构建图像曝光校正神经网络;Step 300: adjusting the exposure mode of the crop canopy sample photo to obtain an exposure correction data set, and constructing an image exposure correction neural network based on the correction data set;

步骤400:综合所述图像白平衡校正神经网络和所述图像曝光校正神经网络对所述作物冠层样本照片进行校正,得到校正后数据集;Step 400: Correcting the crop canopy sample photo by integrating the image white balance correction neural network and the image exposure correction neural network to obtain a corrected data set;

步骤500:构建叶片氮含量测量神经网络初始模型,获取叶片氮标签,基于所述校正后数据集和所述叶片氮标签对所述叶片氮含量测量神经网络初始模型进行训练,得到叶片氮含量测量模型;Step 500: constructing an initial neural network model for measuring leaf nitrogen content, obtaining leaf nitrogen labels, and training the initial neural network model for measuring leaf nitrogen content based on the corrected data set and the leaf nitrogen labels to obtain a leaf nitrogen content measurement model;

步骤600:将待测量作物冠层照片输入所述叶片氮含量测量模型,得到叶片氮含量测量结果。Step 600: Input the crop canopy photo to be measured into the leaf nitrogen content measurement model to obtain the leaf nitrogen content measurement result.

本发明实施例首先采用相机拍摄作物的冠层照片,通过对获取的冠层照片进行渲染,得到不同白平衡模式的图像,构建图像白平衡校正神经网络,还通过对获取的冠层照片进行渲染,得到不同曝光模式下的图像,构建图像曝光校正神经网络,联合上述图像白平衡校正神经网络和图像曝光校正神经网络,对相机拍摄的作物冠层照片进行校正。利用校正后的作物冠层图像,训练叶片氮含量估测的神经网络模型,并验证其在不同拍摄角度、不同拍摄设备和不同品种中作物的应用效果。The embodiment of the present invention first uses a camera to take a canopy photo of a crop, and then renders the obtained canopy photo to obtain images in different white balance modes, and constructs an image white balance correction neural network. It also renders the obtained canopy photo to obtain images in different exposure modes, and constructs an image exposure correction neural network. The above-mentioned image white balance correction neural network and image exposure correction neural network are combined to correct the crop canopy photo taken by the camera. The corrected crop canopy image is used to train a neural network model for estimating leaf nitrogen content, and its application effect on crops at different shooting angles, different shooting equipment, and different varieties is verified.

具体地,如图2所示,通过相机拍摄作物冠层照片,获取真值图像,针对真值图像,分别制作白平衡校正数据集和曝光校正数据集,再由白平衡校正数据集构建白平衡校正神经网络,由曝光校正数据集构建曝光校正神经网络,分别进行图像白平衡校正和图像曝光校正,得到校正后图像,与获取的叶片氮标签训练叶片氮含量估测神经网络,得到叶片氮含量测量模型,最后从拍摄角度、拍摄手机和作物品种三方面进行效果评估。Specifically, as shown in Figure 2, a camera is used to take a photo of the crop canopy to obtain a true image. For the true image, a white balance correction data set and an exposure correction data set are respectively produced. Then, a white balance correction neural network is constructed from the white balance correction data set, and an exposure correction neural network is constructed from the exposure correction data set. Image white balance correction and image exposure correction are performed respectively to obtain the corrected image. The leaf nitrogen content estimation neural network is trained with the obtained leaf nitrogen label to obtain a leaf nitrogen content measurement model. Finally, the effect is evaluated from three aspects: shooting angle, shooting mobile phone, and crop variety.

本发明通过采用具有注意力机制的全卷积神经网络,能够很好地完成相机照片的白平衡和曝光校正,有效降低了复杂光线变化带来的影响。基于白平衡和曝光校正之后的图像,训练出用于作物叶片氮含量估测的卷积神经网络,可以提高作物氮素估计的精度。基于该架构的一系列计算机视觉算法,解决了野外复杂环境下光线变化和用户拍摄设置错误等带来的各种图像质量问题,成功地完成了作物叶片氮含量的估计任务。The present invention uses a fully convolutional neural network with an attention mechanism to effectively complete the white balance and exposure correction of camera photos, effectively reducing the impact of complex light changes. Based on the images after white balance and exposure correction, a convolutional neural network for estimating the nitrogen content of crop leaves is trained to improve the accuracy of crop nitrogen estimation. A series of computer vision algorithms based on this architecture solve various image quality problems caused by light changes in complex outdoor environments and user shooting setting errors, and successfully complete the task of estimating the nitrogen content of crop leaves.

基于上述实施例,采集作物冠层样本照片,包括:Based on the above embodiment, collecting crop canopy sample photos includes:

采用智能手机相机在任一白天时刻拍摄作物冠层,采集任意三个不同预设角度照片,以预设文件格式保存拍摄照片;Use a smartphone camera to photograph crop canopies at any time during the day, collect photos from any three different preset angles, and save the photos in a preset file format;

利用图像处理软件调整所述拍摄照片的白平衡设置和曝光设置,得到真值图像。The white balance setting and exposure setting of the photographed photo are adjusted using image processing software to obtain a true value image.

具体地,本发明实施例采用智能手机的相机拍摄作物的冠层照片,可以在白天的任意时刻进行拍摄,拍摄内容以作物冠层为主体,画面中包含一块色卡,拍摄3个角度的照片,相机与水平方向夹角大约为0°、30°和60°,最终图像保存为RAW文件格式。在Photoshop软件中打开RAW文件,利用色卡调整图像的白平衡和曝光设置,得到真值图像,即正确白平衡和曝光设置的照片。Specifically, the embodiment of the present invention uses a camera of a smart phone to take photos of crop canopies, and the photos can be taken at any time during the day. The crop canopy is the main subject of the photo, a color card is included in the screen, and photos are taken at three angles. The angles between the camera and the horizontal direction are approximately 0°, 30°, and 60°, and the final image is saved in RAW file format. The RAW file is opened in Photoshop software, and the white balance and exposure settings of the image are adjusted using the color card to obtain a true value image, that is, a photo with correct white balance and exposure settings.

基于上述实施例,调整所述作物冠层样本照片的白平衡模式,得到白平衡校正数据集,由所述白平衡校正数据集构建图像白平衡校正神经网络,包括:Based on the above embodiment, the white balance mode of the crop canopy sample photo is adjusted to obtain a white balance correction data set, and an image white balance correction neural network is constructed from the white balance correction data set, including:

调整真值图像的白平衡模式,得到包含不同色温的多个色温偏差图像,将所述多个色温偏差图像与所述真值图像构成所述白平衡校正数据集;Adjusting the white balance mode of the true value image to obtain a plurality of color temperature deviation images including different color temperatures, and combining the plurality of color temperature deviation images and the true value image to form the white balance correction data set;

基于所述白平衡校正数据集,构建白平衡校正全卷积神经网络,采用L1损失函数,以及Adam优化器对所述白平衡校正全卷积神经网络进行训练收敛,得到所述图像白平衡校正神经网络。Based on the white balance correction data set, a white balance correction full convolutional neural network is constructed, and the L1 loss function and the Adam optimizer are used to train and converge the white balance correction full convolutional neural network to obtain the image white balance correction neural network.

具体地,在真值图像基础上,通过Photoshop对图像进行不同的白平衡设置,从而可以渲染出白平衡错误的图像。通过调整图像的白平衡模式,可以得到不同色温下的图片,作为错误白平衡设置的数据集,与真值图片共同组成白平衡校正的数据集,即包含色温为2850K、3800K、5500K、6500K和7500K的图像以及正确白平衡设置的图像,如图3所示,图中已去除色卡部分。Specifically, based on the true value image, different white balance settings are performed on the image through Photoshop, so that an image with incorrect white balance can be rendered. By adjusting the white balance mode of the image, pictures at different color temperatures can be obtained as a data set of incorrect white balance settings, which together with the true value pictures constitute a data set of white balance correction, that is, images with color temperatures of 2850K, 3800K, 5500K, 6500K and 7500K and images with correct white balance settings, as shown in Figure 3, where the color card part has been removed.

基于白平衡校正数据集,构建白平衡校正的全卷积神经网络。在网络训练过程中,损失函数采用L1损失,训练优化器采用Adam算法,初始学习率为0.001,训练过程为500个epoch。Based on the white balance correction dataset, a fully convolutional neural network for white balance correction is constructed. During the network training process, the loss function uses L1 loss, the training optimizer uses the Adam algorithm, the initial learning rate is 0.001, and the training process is 500 epochs.

基于上述实施例,调整所述作物冠层样本照片的曝光模式,得到曝光校正数据集,由所述校正数据集构建图像曝光校正神经网络,包括:Based on the above embodiment, the exposure mode of the crop canopy sample photo is adjusted to obtain an exposure correction data set, and an image exposure correction neural network is constructed from the correction data set, including:

调整真值图像的曝光模式,得到包含不同曝光值的多个曝光偏差图像,将所述多个曝光偏差图像与所述真值图像构成所述曝光校正数据集;Adjusting the exposure mode of the true value image to obtain a plurality of exposure deviation images including different exposure values, and forming the exposure correction data set with the plurality of exposure deviation images and the true value image;

基于所述曝光校正数据集,构建曝光校正全卷积神经网络,采用L1损失函数,以及Adam优化器对所述曝光校正全卷积神经网络进行训练收敛,得到所述图像曝光校正神经网络。Based on the exposure correction data set, an exposure correction full convolutional neural network is constructed, and the exposure correction full convolutional neural network is trained and converged using an L1 loss function and an Adam optimizer to obtain the image exposure correction neural network.

具体地,在真值图像的基础上,通过Photoshop对图像进行不同的曝光设置,从而可以渲染出曝光错误的图像。通过调整图像的曝光量(Exposure Values,EV)值,可以得到不同曝光模式下的图片,作为错误曝光设置的数据集。与真值图片共同组成曝光校正的数据集,即包含EV值为-1.5、-1、+1、+1.5和正确曝光设置的图像,如图4所示,图中已去除色卡部分。Specifically, based on the true value image, different exposure settings are set for the image through Photoshop, so that an image with incorrect exposure can be rendered. By adjusting the exposure values (EV) of the image, images under different exposure modes can be obtained as a data set of incorrect exposure settings. Together with the true value image, the exposure correction data set consists of images with EV values of -1.5, -1, +1, +1.5 and correct exposure settings, as shown in Figure 4, where the color card part has been removed.

基于曝光校正数据集,构建曝光校正的全卷积神经网络。在网络训练过程中,损失函数采用L1损失,训练优化器采用Adam算法,初始学习率为0.001,训练过程为500个epoch。Based on the exposure correction dataset, a fully convolutional neural network for exposure correction is constructed. During the network training process, the loss function uses L1 loss, the training optimizer uses the Adam algorithm, the initial learning rate is 0.001, and the training process is 500 epochs.

基于上述实施例,综合所述图像白平衡校正神经网络和所述图像曝光校正神经网络对所述作物冠层样本照片进行校正,得到校正后数据集,包括:Based on the above embodiment, the image white balance correction neural network and the image exposure correction neural network are integrated to correct the crop canopy sample photos to obtain a corrected data set, including:

将所述作物冠层样本照片输入所述图像白平衡校正神经网络,得到白平衡校正后数据集;Inputting the crop canopy sample photo into the image white balance correction neural network to obtain a white balance corrected data set;

将所述作物冠层样本照片输入所述图像曝光校正神经网络,得到曝光校正后数据集。The crop canopy sample photos are input into the image exposure correction neural network to obtain an exposure-corrected data set.

具体地,将相机拍摄作物的冠层照片输入到构建的白平衡校正神经网络中,得到正确白平衡设置的图像输出。如图5所示,经过白平衡校正,原始图片的色差ΔE明显降低,色温2850K图片的色差ΔE从13.63降至1.64,3800K图片的色差ΔE从7.31降至1.15,5500K图片的色差ΔE从2.00降至0.90,6500K图片的色差ΔE从4.20降至1.30,7500K图片的色差ΔE从5.01降至1.51。总体来看,校正后图片与正确白平衡设置的真值图片已无明显差别。Specifically, the canopy photos of crops taken by the camera are input into the constructed white balance correction neural network to obtain the image output with the correct white balance setting. As shown in Figure 5, after white balance correction, the color difference ΔE of the original image is significantly reduced. The color difference ΔE of the 2850K color temperature image is reduced from 13.63 to 1.64, the color difference ΔE of the 3800K image is reduced from 7.31 to 1.15, the color difference ΔE of the 5500K image is reduced from 2.00 to 0.90, the color difference ΔE of the 6500K image is reduced from 4.20 to 1.30, and the color difference ΔE of the 7500K image is reduced from 5.01 to 1.51. Overall, there is no obvious difference between the corrected image and the true value image with the correct white balance setting.

将相机拍摄作物的冠层照片输入到构建的曝光校正神经网络中,得到正确曝光设置的图像输出。如图6所示,经过曝光校正,原始图片的峰值信噪比(Peak Signal-to-NoiseRatio,PSNR)明显提升,EV值为-1.5的图片PSNR从11.75上升至27.19,EV值为-1.0的图片PSNR从14.62上升至26.79,EV值为+1.0的图片PSNR从14.53上升至24.86,EV值为+1.5的图片PSNR从11.25上升至27.17。总体来看,校正后图片与正确曝光设置的真值图片已无明显差别。The canopy photos of crops taken by the camera are input into the constructed exposure correction neural network to obtain the image output with the correct exposure setting. As shown in Figure 6, after exposure correction, the Peak Signal-to-Noise Ratio (PSNR) of the original image is significantly improved. The PSNR of the image with an EV value of -1.5 increases from 11.75 to 27.19, the PSNR of the image with an EV value of -1.0 increases from 14.62 to 26.79, the PSNR of the image with an EV value of +1.0 increases from 14.53 to 24.86, and the PSNR of the image with an EV value of +1.5 increases from 11.25 to 27.17. Overall, there is no significant difference between the corrected image and the true value image with the correct exposure setting.

基于上述实施例,构建叶片氮含量测量神经网络初始模型,获取叶片氮标签,基于所述校正后数据集和所述叶片氮标签对所述叶片氮含量测量神经网络初始模型进行训练,得到叶片氮含量测量模型之前,还包括:Based on the above embodiment, an initial model of a neural network for measuring leaf nitrogen content is constructed, a leaf nitrogen label is obtained, and the initial model of a neural network for measuring leaf nitrogen content is trained based on the corrected data set and the leaf nitrogen label. Before obtaining the leaf nitrogen content measurement model, the method further includes:

将所述校正后数据集中的色卡部分进行裁剪,得到仅包括作物冠层信息图像的裁剪后数据集;Cropping the color card part in the corrected data set to obtain a cropped data set that only includes crop canopy information images;

对所述裁剪后数据集进行数据增强,得到增强数据集。Data enhancement is performed on the cropped data set to obtain an enhanced data set.

具体地,通过得到的作物冠层图像数据集,首先将图像中的色卡部分裁剪出去,得到只有作物冠层信息的图像,然后进行数据增强,包括随机裁剪、随机旋转和镜像等操作扩充数据集。Specifically, using the obtained crop canopy image dataset, the color card part in the image is first cropped out to obtain an image with only crop canopy information, and then data enhancement is performed, including random cropping, random rotation, and mirroring operations to expand the dataset.

基于上述实施例,构建叶片氮含量测量神经网络初始模型,获取叶片氮标签,基于所述校正后数据集和所述叶片氮标签对所述叶片氮含量测量神经网络初始模型进行训练,得到叶片氮含量测量模型,包括:Based on the above embodiment, an initial model of a neural network for measuring leaf nitrogen content is constructed, leaf nitrogen labels are obtained, and the initial model of a neural network for measuring leaf nitrogen content is trained based on the corrected data set and the leaf nitrogen labels to obtain a leaf nitrogen content measurement model, including:

采用预设卷积神经网络构建所述叶片氮含量测量神经网络初始模型;A preset convolutional neural network is used to construct an initial neural network model for measuring leaf nitrogen content;

通过实验测量所述作物冠层样本照片得到所述叶片氮标签;Obtaining the leaf nitrogen label by experimentally measuring the crop canopy sample photo;

采用均方误差MSE损失函数和Adam优化器对所述叶片氮含量测量神经网络初始模型进行训练收敛,得到所述叶片氮含量测量模型。The mean square error (MSE) loss function and the Adam optimizer are used to train and converge the initial model of the leaf nitrogen content measurement neural network to obtain the leaf nitrogen content measurement model.

具体地,本发明实施例采用的模型为卷积神经网络,包括但不限于AlexNet、Inception_v3、DenseNet161、MobilenetV3、ResNet50和ResNet50_CBAM(具有注意力机制的ResNet50)。模型的输入特征为数据增强后的图像RGB值,标签为通过实验室分析测量得到的作物叶片氮含量。在网络训练过程中,损失函数采用均方根误差(Mean Square Error,MSE)损失,训练优化器采用Adam算法,初始学习率为0.001,训练过程为500个epoch。Specifically, the model used in the embodiment of the present invention is a convolutional neural network, including but not limited to AlexNet, Inception_v3, DenseNet161, MobilenetV3, ResNet50 and ResNet50_CBAM (ResNet50 with attention mechanism). The input feature of the model is the RGB value of the image after data enhancement, and the label is the nitrogen content of the crop leaves measured by laboratory analysis. During the network training process, the loss function uses the mean square error (MSE) loss, the training optimizer uses the Adam algorithm, the initial learning rate is 0.001, and the training process is 500 epochs.

基于上述实施例,还包括:Based on the above embodiment, it also includes:

将不同拍摄角度、不同拍摄设备和不同作物品种的作物冠层图像输入至所述叶片氮含量测量模型,得到不同叶片氮含量测量结果;Inputting crop canopy images of different shooting angles, different shooting equipment and different crop varieties into the leaf nitrogen content measurement model to obtain measurement results of different leaf nitrogen contents;

利用不同预设精度评价指标对所述不同叶片氮含量测量结果进行评价对比。The nitrogen content measurement results of the different leaves are evaluated and compared using different preset accuracy evaluation indicators.

具体地,利用训练好的神经网络进行目标作物叶片氮含量的估测,将不同拍摄角度、不同拍摄设备和不同品种的作物冠层图像输入到网络中,输出相应的叶片氮含量,将其与实验室观测的叶片氮含量进行对比,计算精度评价指标R2、均方根误差(Root MeanSquared Error,RMSE)和相对均方根误差(Relative Root Mean-Squared Error,RRMSE)。结果如表1和图7所示:Specifically, the trained neural network is used to estimate the nitrogen content of target crop leaves. The crop canopy images of different shooting angles, different shooting equipment and different varieties are input into the network, and the corresponding leaf nitrogen content is output. It is compared with the leaf nitrogen content observed in the laboratory, and the accuracy evaluation index R2, root mean square error (RMSE) and relative root mean square error (RRMSE) are calculated. The results are shown in Table 1 and Figure 7:

表1Table 1

AlgorithmsAlgorithms R2R2 RMSERMSE RRMSERRMSE AlexNetAlexNet 0.730.73 0.490.49 0.170.17 Inception_v3Inception_v3 0.810.81 0.410.41 0.140.14 DenseNet161DenseNet161 0.850.85 0.370.37 0.120.12 MobilenetV3MobilenetV3 0.840.84 0.390.39 0.130.13 ResNet50ResNet50 0.850.85 0.380.38 0.130.13 ResNet50_CBAMResNet50_CBAM 0.820.82 0.400.40 0.140.14

从表1和图7中可以看出,比较浅层的网络AlexNet(8层)在作物叶片氮含量估计上表现较差,在测试集上的R2为0.73,RMSE为0.49,RRMSE为0.17;随着神经网络层数的加深,叶片氮含量的估计精度有了很明显的提升,R2在0.81-0.85之间,其中Inception_v3(46层)的R2为0.81,ResNet50(50层)的R2为0.85,DenseNet161(161层)的R2为0.85,此时随着网络层数的继续加深,模型的性能不再继续提升。ResNet50_CBAM是在ResNet50的基础上增加了空间和通道注意力机制,但是并没有提高模型的性能,反而有一点下降。MobilenetV3通过使用网络结构搜索NAS,重新设计了耗时的一些架构,采用了shortcut连接和SE注意力机制,减少了模型的参数,在获得很高的精度(R2为0.84,RMSE为0.39,RRMSE为0.13)的同时,也大大提高了模型的运算效率。As can be seen from Table 1 and Figure 7, the shallower network AlexNet (8 layers) performs poorly in estimating the nitrogen content of crop leaves, with an R2 of 0.73, RMSE of 0.49, and RRMSE of 0.17 on the test set; as the number of neural network layers increases, the estimation accuracy of leaf nitrogen content has been significantly improved, with R2 between 0.81 and 0.85, among which Inception_v3 (46 layers) has an R2 of 0.81, ResNet50 (50 layers) has an R2 of 0.85, and DenseNet161 (161 layers) has an R2 of 0.85. At this time, as the number of network layers continues to increase, the performance of the model no longer continues to improve. ResNet50_CBAM adds spatial and channel attention mechanisms to ResNet50, but does not improve the performance of the model, but rather decreases it a little. MobilenetV3 uses network structure search NAS, redesigns some time-consuming architectures, adopts shortcut connections and SE attention mechanisms, reduces model parameters, and achieves high accuracy (R2 is 0.84, RMSE is 0.39, and RRMSE is 0.13) while greatly improving the computational efficiency of the model.

下面对本发明提供的基于RGB图像的叶片氮含量测量系统进行描述,下文描述的基于RGB图像的叶片氮含量测量系统与上文描述的基于RGB图像的叶片氮含量测量方法可相互对应参照。The leaf nitrogen content measurement system based on RGB images provided by the present invention is described below. The leaf nitrogen content measurement system based on RGB images described below and the leaf nitrogen content measurement method based on RGB images described above can be referenced to each other.

图8是本发明实施例提供的基于RGB图像的叶片氮含量测量系统的结构示意图,如图8所示,包括:采集模块81、白平衡数据处理模块82、曝光数据处理模块83、校正模块84、训练模块85和测量模块86,其中:FIG8 is a schematic diagram of the structure of a leaf nitrogen content measurement system based on RGB images provided by an embodiment of the present invention. As shown in FIG8 , the system comprises: an acquisition module 81, a white balance data processing module 82, an exposure data processing module 83, a correction module 84, a training module 85 and a measurement module 86, wherein:

采集模块81用于采集作物冠层样本照片;白平衡数据处理模块82用于调整所述作物冠层样本照片的白平衡模式,得到白平衡校正数据集,由所述白平衡校正数据集构建图像白平衡校正神经网络;曝光数据处理模块83用于调整所述作物冠层样本照片的曝光模式,得到曝光校正数据集,由所述校正数据集构建图像曝光校正神经网络;校正模块84用于综合所述图像白平衡校正神经网络和所述图像曝光校正神经网络对所述作物冠层样本照片进行校正,得到校正后数据集;训练模块85用于构建叶片氮含量测量神经网络初始模型,获取叶片氮标签,基于所述校正后数据集和所述叶片氮标签对所述叶片氮含量测量神经网络初始模型进行训练,得到叶片氮含量测量模型;测量模块86用于将待测量作物冠层照片输入所述叶片氮含量测量模型,得到叶片氮含量测量结果。The acquisition module 81 is used to acquire crop canopy sample photos; the white balance data processing module 82 is used to adjust the white balance mode of the crop canopy sample photos to obtain a white balance correction data set, and construct an image white balance correction neural network from the white balance correction data set; the exposure data processing module 83 is used to adjust the exposure mode of the crop canopy sample photos to obtain an exposure correction data set, and construct an image exposure correction neural network from the correction data set; the correction module 84 is used to correct the crop canopy sample photos by integrating the image white balance correction neural network and the image exposure correction neural network to obtain a corrected data set; the training module 85 is used to construct an initial model of a leaf nitrogen content measurement neural network, obtain a leaf nitrogen label, and train the initial model of the leaf nitrogen content measurement neural network based on the corrected data set and the leaf nitrogen label to obtain a leaf nitrogen content measurement model; the measurement module 86 is used to input the crop canopy photos to be measured into the leaf nitrogen content measurement model to obtain leaf nitrogen content measurement results.

图9示例了一种电子设备的实体结构示意图,如图9所示,该电子设备可以包括:处理器(processor)910、通信接口(Communications Interface)920、存储器(memory)930和通信总线940,其中,处理器910,通信接口920,存储器930通过通信总线940完成相互间的通信。处理器910可以调用存储器930中的逻辑指令,以执行基于RGB图像的叶片氮含量测量方法,该方法包括:采集作物冠层样本照片;调整所述作物冠层样本照片的白平衡模式,得到白平衡校正数据集,由所述白平衡校正数据集构建图像白平衡校正神经网络;调整所述作物冠层样本照片的曝光模式,得到曝光校正数据集,由所述校正数据集构建图像曝光校正神经网络;综合所述图像白平衡校正神经网络和所述图像曝光校正神经网络对所述作物冠层样本照片进行校正,得到校正后数据集;构建叶片氮含量测量神经网络初始模型,获取叶片氮标签,基于所述校正后数据集和所述叶片氮标签对所述叶片氮含量测量神经网络初始模型进行训练,得到叶片氮含量测量模型;将待测量作物冠层照片输入所述叶片氮含量测量模型,得到叶片氮含量测量结果。Figure 9 illustrates a schematic diagram of the physical structure of an electronic device. As shown in Figure 9, the electronic device may include: a processor (processor) 910, a communication interface (Communications Interface) 920, a memory (memory) 930 and a communication bus 940, wherein the processor 910, the communication interface 920, and the memory 930 communicate with each other through the communication bus 940. The processor 910 can call the logic instructions in the memory 930 to execute the leaf nitrogen content measurement method based on RGB images, which includes: collecting crop canopy sample photos; adjusting the white balance mode of the crop canopy sample photos to obtain a white balance correction data set, and constructing an image white balance correction neural network from the white balance correction data set; adjusting the exposure mode of the crop canopy sample photos to obtain an exposure correction data set, and constructing an image exposure correction neural network from the correction data set; correcting the crop canopy sample photos by combining the image white balance correction neural network and the image exposure correction neural network to obtain a corrected data set; constructing an initial model of the leaf nitrogen content measurement neural network, obtaining a leaf nitrogen label, and training the initial model of the leaf nitrogen content measurement neural network based on the corrected data set and the leaf nitrogen label to obtain a leaf nitrogen content measurement model; inputting the crop canopy photos to be measured into the leaf nitrogen content measurement model to obtain leaf nitrogen content measurement results.

此外,上述的存储器930中的逻辑指令可以通过软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。In addition, the logic instructions in the above-mentioned memory 930 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

另一方面,本发明还提供一种非暂态计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现以执行上述各方法提供的基于RGB图像的叶片氮含量测量方法,该方法包括:采集作物冠层样本照片;调整所述作物冠层样本照片的白平衡模式,得到白平衡校正数据集,由所述白平衡校正数据集构建图像白平衡校正神经网络;调整所述作物冠层样本照片的曝光模式,得到曝光校正数据集,由所述校正数据集构建图像曝光校正神经网络;综合所述图像白平衡校正神经网络和所述图像曝光校正神经网络对所述作物冠层样本照片进行校正,得到校正后数据集;构建叶片氮含量测量神经网络初始模型,获取叶片氮标签,基于所述校正后数据集和所述叶片氮标签对所述叶片氮含量测量神经网络初始模型进行训练,得到叶片氮含量测量模型;将待测量作物冠层照片输入所述叶片氮含量测量模型,得到叶片氮含量测量结果。On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the leaf nitrogen content measurement method based on RGB images provided by the above-mentioned methods, the method comprising: collecting crop canopy sample photos; adjusting the white balance mode of the crop canopy sample photos to obtain a white balance correction data set, and constructing an image white balance correction neural network from the white balance correction data set; adjusting the exposure mode of the crop canopy sample photos to obtain an exposure correction data set, and constructing an image exposure correction neural network from the correction data set; correcting the crop canopy sample photos by combining the image white balance correction neural network and the image exposure correction neural network to obtain a corrected data set; constructing an initial model of a leaf nitrogen content measurement neural network, obtaining a leaf nitrogen label, and training the initial model of the leaf nitrogen content measurement neural network based on the corrected data set and the leaf nitrogen label to obtain a leaf nitrogen content measurement model; inputting the crop canopy photos to be measured into the leaf nitrogen content measurement model to obtain leaf nitrogen content measurement results.

以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative work.

通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到各实施方式可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行各个实施例或者实施例的某些部分所述的方法。Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM/RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (7)

1.一种基于RGB图像的叶片氮含量测量方法,其特征在于,包括:1. A method for measuring leaf nitrogen content based on RGB images, comprising: 采集作物冠层样本照片;Collect photos of crop canopy samples; 调整所述作物冠层样本照片的白平衡模式,得到白平衡校正数据集,由所述白平衡校正数据集构建图像白平衡校正神经网络;Adjusting the white balance mode of the crop canopy sample photo to obtain a white balance correction data set, and constructing an image white balance correction neural network based on the white balance correction data set; 调整所述作物冠层样本照片的曝光模式,得到曝光校正数据集,由所述校正数据集构建图像曝光校正神经网络;Adjusting the exposure mode of the crop canopy sample photo to obtain an exposure correction data set, and constructing an image exposure correction neural network based on the correction data set; 综合所述图像白平衡校正神经网络和所述图像曝光校正神经网络对所述作物冠层样本照片进行校正,得到校正后数据集;Correcting the crop canopy sample photo by integrating the image white balance correction neural network and the image exposure correction neural network to obtain a corrected data set; 构建叶片氮含量测量神经网络初始模型,获取叶片氮标签,基于所述校正后数据集和所述叶片氮标签对所述叶片氮含量测量神经网络初始模型进行训练,得到叶片氮含量测量模型;Constructing an initial neural network model for measuring leaf nitrogen content, obtaining leaf nitrogen labels, and training the initial neural network model for measuring leaf nitrogen content based on the corrected data set and the leaf nitrogen labels to obtain a leaf nitrogen content measurement model; 将待测量作物冠层照片输入所述叶片氮含量测量模型,得到叶片氮含量测量结果;Inputting a photo of the crop canopy to be measured into the leaf nitrogen content measurement model to obtain a leaf nitrogen content measurement result; 采集作物冠层样本照片,包括:Collect sample photographs of crop canopies, including: 采用智能手机相机在任一白天时刻拍摄作物冠层,采集任意三个不同预设角度照片,以预设文件格式保存拍摄照片;Use a smartphone camera to photograph crop canopies at any time during the day, collect photos from any three different preset angles, and save the photos in a preset file format; 利用图像处理软件调整所述拍摄照片的白平衡设置和曝光设置,得到真值图像;Using image processing software to adjust the white balance setting and exposure setting of the photograph to obtain a true value image; 构建叶片氮含量测量神经网络初始模型,获取叶片氮标签,基于所述校正后数据集和所述叶片氮标签对所述叶片氮含量测量神经网络初始模型进行训练,得到叶片氮含量测量模型之前,还包括:Before constructing an initial neural network model for measuring leaf nitrogen content, obtaining leaf nitrogen labels, and training the initial neural network model for measuring leaf nitrogen content based on the corrected data set and the leaf nitrogen labels to obtain the leaf nitrogen content measurement model, the method further includes: 将所述校正后数据集中的色卡部分进行裁剪,得到仅包括作物冠层信息图像的裁剪后数据集;Cropping the color card part in the corrected data set to obtain a cropped data set that only includes crop canopy information images; 对所述裁剪后数据集进行数据增强,得到增强数据集;Performing data enhancement on the cropped data set to obtain an enhanced data set; 构建叶片氮含量测量神经网络初始模型,获取叶片氮标签,基于所述校正后数据集和所述叶片氮标签对所述叶片氮含量测量神经网络初始模型进行训练,得到叶片氮含量测量模型,包括:Constructing an initial model of a neural network for measuring leaf nitrogen content, obtaining leaf nitrogen labels, and training the initial model of a neural network for measuring leaf nitrogen content based on the corrected data set and the leaf nitrogen labels to obtain a leaf nitrogen content measurement model, including: 采用预设卷积神经网络构建所述叶片氮含量测量神经网络初始模型;A preset convolutional neural network is used to construct an initial neural network model for measuring leaf nitrogen content; 通过实验测量所述作物冠层样本照片得到所述叶片氮标签;Obtaining the leaf nitrogen label by experimentally measuring the crop canopy sample photo; 采用均方误差MSE损失函数和Adam优化器对所述叶片氮含量测量神经网络初始模型进行训练收敛,得到所述叶片氮含量测量模型。The mean square error (MSE) loss function and the Adam optimizer are used to train and converge the initial model of the leaf nitrogen content measurement neural network to obtain the leaf nitrogen content measurement model. 2.根据权利要求1所述的基于RGB图像的叶片氮含量测量方法,其特征在于,调整所述作物冠层样本照片的白平衡模式,得到白平衡校正数据集,由所述白平衡校正数据集构建图像白平衡校正神经网络,包括:2. The leaf nitrogen content measurement method based on RGB images according to claim 1, characterized in that the white balance mode of the crop canopy sample photo is adjusted to obtain a white balance correction data set, and an image white balance correction neural network is constructed from the white balance correction data set, comprising: 调整真值图像的白平衡模式,得到包含不同色温的多个色温偏差图像,将所述多个色温偏差图像与所述真值图像构成所述白平衡校正数据集;Adjusting the white balance mode of the true value image to obtain a plurality of color temperature deviation images including different color temperatures, and combining the plurality of color temperature deviation images and the true value image to form the white balance correction data set; 基于所述白平衡校正数据集,构建白平衡校正全卷积神经网络,采用L1损失函数,以及Adam优化器对所述白平衡校正全卷积神经网络进行训练收敛,得到所述图像白平衡校正神经网络。Based on the white balance correction data set, a white balance correction full convolutional neural network is constructed, and the L1 loss function and the Adam optimizer are used to train and converge the white balance correction full convolutional neural network to obtain the image white balance correction neural network. 3.根据权利要求1所述的基于RGB图像的叶片氮含量测量方法,其特征在于,调整所述作物冠层样本照片的曝光模式,得到曝光校正数据集,由所述校正数据集构建图像曝光校正神经网络,包括:3. The leaf nitrogen content measurement method based on RGB images according to claim 1 is characterized in that the exposure mode of the crop canopy sample photo is adjusted to obtain an exposure correction data set, and an image exposure correction neural network is constructed based on the correction data set, comprising: 调整真值图像的曝光模式,得到包含不同曝光值的多个曝光偏差图像,将所述多个曝光偏差图像与所述真值图像构成所述曝光校正数据集;Adjusting the exposure mode of the true value image to obtain a plurality of exposure deviation images including different exposure values, and forming the exposure correction data set with the plurality of exposure deviation images and the true value image; 基于所述曝光校正数据集,构建曝光校正全卷积神经网络,采用L1损失函数,以及Adam优化器对所述曝光校正全卷积神经网络进行训练收敛,得到所述图像曝光校正神经网络。Based on the exposure correction data set, an exposure correction full convolutional neural network is constructed, and the exposure correction full convolutional neural network is trained and converged using an L1 loss function and an Adam optimizer to obtain the image exposure correction neural network. 4.根据权利要求1所述的基于RGB图像的叶片氮含量测量方法,其特征在于,综合所述图像白平衡校正神经网络和所述图像曝光校正神经网络对所述作物冠层样本照片进行校正,得到校正后数据集,包括:4. The leaf nitrogen content measurement method based on RGB images according to claim 1 is characterized in that the image white balance correction neural network and the image exposure correction neural network are used to correct the crop canopy sample photo to obtain a corrected data set, including: 将所述作物冠层样本照片输入所述图像白平衡校正神经网络,得到白平衡校正后数据集;Inputting the crop canopy sample photo into the image white balance correction neural network to obtain a white balance corrected data set; 将所述作物冠层样本照片输入所述图像曝光校正神经网络,得到曝光校正后数据集。The crop canopy sample photos are input into the image exposure correction neural network to obtain an exposure-corrected data set. 5.根据权利要求1所述的基于RGB图像的叶片氮含量测量方法,其特征在于,还包括:5. The method for measuring leaf nitrogen content based on RGB images according to claim 1, further comprising: 将不同拍摄角度、不同拍摄设备和不同作物品种的作物冠层图像输入至所述叶片氮含量测量模型,得到不同叶片氮含量测量结果;Inputting crop canopy images of different shooting angles, different shooting equipment and different crop varieties into the leaf nitrogen content measurement model to obtain measurement results of different leaf nitrogen contents; 利用不同预设精度评价指标对所述不同叶片氮含量测量结果进行评价对比。The nitrogen content measurement results of the different leaves are evaluated and compared using different preset accuracy evaluation indicators. 6.一种基于RGB图像的叶片氮含量测量系统,其特征在于,包括:6. A leaf nitrogen content measurement system based on RGB images, comprising: 采集模块,用于采集作物冠层样本照片;A collection module for collecting sample photos of crop canopies; 白平衡数据处理模块,用于调整所述作物冠层样本照片的白平衡模式,得到白平衡校正数据集,由所述白平衡校正数据集构建图像白平衡校正神经网络;A white balance data processing module, used for adjusting the white balance mode of the crop canopy sample photo to obtain a white balance correction data set, and constructing an image white balance correction neural network based on the white balance correction data set; 曝光数据处理模块,用于调整所述作物冠层样本照片的曝光模式,得到曝光校正数据集,由所述校正数据集构建图像曝光校正神经网络;An exposure data processing module, used for adjusting the exposure mode of the crop canopy sample photo to obtain an exposure correction data set, and constructing an image exposure correction neural network based on the correction data set; 校正模块,用于综合所述图像白平衡校正神经网络和所述图像曝光校正神经网络对所述作物冠层样本照片进行校正,得到校正后数据集;A correction module, used to correct the crop canopy sample photo by integrating the image white balance correction neural network and the image exposure correction neural network to obtain a corrected data set; 训练模块,用于构建叶片氮含量测量神经网络初始模型,获取叶片氮标签,基于所述校正后数据集和所述叶片氮标签对所述叶片氮含量测量神经网络初始模型进行训练,得到叶片氮含量测量模型;A training module is used to construct an initial model of a neural network for measuring leaf nitrogen content, obtain leaf nitrogen labels, and train the initial model of the neural network for measuring leaf nitrogen content based on the corrected data set and the leaf nitrogen labels to obtain a leaf nitrogen content measurement model; 测量模块,用于将待测量作物冠层照片输入所述叶片氮含量测量模型,得到叶片氮含量测量结果;A measurement module, used for inputting a canopy photo of a crop to be measured into the leaf nitrogen content measurement model to obtain a leaf nitrogen content measurement result; 所述采集模块具体用于:The acquisition module is specifically used for: 采用智能手机相机在任一白天时刻拍摄作物冠层,采集任意三个不同预设角度照片,以预设文件格式保存拍摄照片;Use a smartphone camera to photograph crop canopies at any time during the day, collect photos from any three different preset angles, and save the photos in a preset file format; 利用图像处理软件调整所述拍摄照片的白平衡设置和曝光设置,得到真值图像;Using image processing software to adjust the white balance setting and exposure setting of the photograph to obtain a true value image; 所述训练模块具体用于:The training module is specifically used for: 将所述校正后数据集中的色卡部分进行裁剪,得到仅包括作物冠层信息图像的裁剪后数据集;Cropping the color card part in the corrected data set to obtain a cropped data set that only includes crop canopy information images; 对所述裁剪后数据集进行数据增强,得到增强数据集;Performing data enhancement on the cropped data set to obtain an enhanced data set; 采用预设卷积神经网络构建所述叶片氮含量测量神经网络初始模型;A preset convolutional neural network is used to construct an initial neural network model for measuring leaf nitrogen content; 通过实验测量所述作物冠层样本照片得到所述叶片氮标签;Obtaining the leaf nitrogen label by experimentally measuring the crop canopy sample photo; 采用均方误差MSE损失函数和Adam优化器对所述叶片氮含量测量神经网络初始模型进行训练收敛,得到所述叶片氮含量测量模型。The mean square error (MSE) loss function and the Adam optimizer are used to train and converge the initial model of the leaf nitrogen content measurement neural network to obtain the leaf nitrogen content measurement model. 7.一种电子设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述程序时实现如权利要求1至5任一项所述基于RGB图像的叶片氮含量测量方法。7. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method for measuring nitrogen content in leaves based on RGB images as described in any one of claims 1 to 5 is implemented.
CN202311108046.0A 2023-08-30 2023-08-30 A method and system for measuring leaf nitrogen content based on RGB images Active CN117197062B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311108046.0A CN117197062B (en) 2023-08-30 2023-08-30 A method and system for measuring leaf nitrogen content based on RGB images

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311108046.0A CN117197062B (en) 2023-08-30 2023-08-30 A method and system for measuring leaf nitrogen content based on RGB images

Publications (2)

Publication Number Publication Date
CN117197062A CN117197062A (en) 2023-12-08
CN117197062B true CN117197062B (en) 2024-09-06

Family

ID=88995348

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311108046.0A Active CN117197062B (en) 2023-08-30 2023-08-30 A method and system for measuring leaf nitrogen content based on RGB images

Country Status (1)

Country Link
CN (1) CN117197062B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110346305A (en) * 2019-07-17 2019-10-18 浙江大学 A kind of method and apparatus measuring plant leaf blade nitrogen content
CN112399162A (en) * 2019-08-16 2021-02-23 浙江宇视科技有限公司 White balance correction method, device, equipment and storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10154624B2 (en) * 2016-08-08 2018-12-18 The Climate Corporation Estimating nitrogen content using hyperspectral and multispectral images
CN106841051B (en) * 2016-12-19 2019-05-10 中国科学院南京土壤研究所 A crop nitrogen nutrition detection method based on visible light image fusion value
CN110555395A (en) * 2019-08-19 2019-12-10 浙江大学 Classified evaluation method for nitrogen content grade of rape canopy
JP7504629B2 (en) * 2020-03-09 2024-06-24 キヤノン株式会社 IMAGE PROCESSING METHOD, IMAGE PROCESSING APPARATUS, IMAGE PROCESSING PROGRAM, AND STORAGE MEDIUM
CN113705937B (en) * 2021-10-27 2022-01-14 武汉大学 Farmland yield estimation method combining machine vision and crop model

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110346305A (en) * 2019-07-17 2019-10-18 浙江大学 A kind of method and apparatus measuring plant leaf blade nitrogen content
CN112399162A (en) * 2019-08-16 2021-02-23 浙江宇视科技有限公司 White balance correction method, device, equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于可见光光谱和BP人工神经网络的冬小麦生物量估算研究;崔日鲜 等;《光谱学与光谱分析》;20150930;第1、2节 *

Also Published As

Publication number Publication date
CN117197062A (en) 2023-12-08

Similar Documents

Publication Publication Date Title
CN111461052B (en) Identification method of wheat lodging area in multiple growth stages based on transfer learning
CN108985588B (en) Crop yield per unit remote sensing estimation method, device and system
CN104132897B (en) A kind of nitrogenous measuring method of plant leaf blade based on handheld device and device
CN109859101B (en) Method and system for thermal infrared image recognition of crop canopy
CN109522929A (en) It is a kind of based on multi-source image fusion natural environment under wheat weeds recognition methods
CN112330672B (en) Inversion method of crop leaf area index based on PROSAIL model and canopy coverage optimization
CN111881851A (en) Garden seedling intelligent detection and counting method based on UAV and convolutional neural network
CN112967176A (en) Method for analyzing plant coverage by using Image J and Photoshop
Zhang et al. A 250m annual alpine grassland AGB dataset over the Qinghai-Tibetan Plateau (2000–2019) based on in-situ measurements, UAV images, and MODIS Data
CN115018920B (en) Camera array calibration method and device, electronic equipment and storage medium
CN116844053B (en) Wheat planting area identification method, system, electronic equipment and storage medium
CN117765385A (en) Method, device and equipment for constructing plant growth monitoring model
CN114782669A (en) Automatic identification, positioning and reading method of digital instruments based on deep learning
CN117994680A (en) Crop growth monitoring method and system based on multi-source images
Pei et al. Segmenting vegetation from UAV images via spectral reconstruction in complex field environments
Zhuang et al. Maize emergence rate and leaf emergence speed estimation via image detection under field rail-based phenotyping platform
CN117197062B (en) A method and system for measuring leaf nitrogen content based on RGB images
CN115830442B (en) A remote sensing method and system for estimating wheat stem and tiller density based on machine learning
CN110647781B (en) Crop growth information acquisition method and device based on spectrogram fusion
CN113256567B (en) Banana leaf area index detection method and system
CN110728205A (en) AI cloud computing-based portable intelligent rice seed test system
CN117893410A (en) A method, system and device for super-resolution reconstruction of unmanned aerial vehicle images
CN115205366A (en) Leaf area index measuring method and measuring device thereof
CN115655157A (en) Leaf Area Index Calculation Method Based on Fisheye Image
CN115100550A (en) A kind of fruit tree crown identification and counting method, system, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant