Tobacco leaf water content nondestructive testing method and system
By extracting the RGB color moment from the tobacco leaf image and inputting it into the detection model, the existing tobacco leaf moisture content detection method requires high cost of damage tobacco leaf and equipment, and the lossless and accurate tobacco leaf moisture content detection is achieved.
Patent Information
- Application Number
- CN202411768992.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-04-25
AI Technical Summary
The existing tobacco leaf moisture content detection methods have problems such as long time, large labor investment, large environmental humidity impact, and the detection process requires damage to tobacco leaves.
By collecting the tobacco leaf images, extracting the RGB color moment as the characteristic value, and inputting the pre-trained detection model to detect the moisture content of the tobacco leaf non-destructively.
The non-destructive testing of the moisture content of tobacco leaves has been achieved, the cost of testing equipment has been reduced, and the improvement of tobacco leaves cultivation and baking technology has been supported.
Smart Images

Figure CN119887625A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of tobacco leaf moisture content detection, and in particular to a tobacco leaf moisture content non-destructive detection method and system. Background Art
[0002] At present, the moisture content of flue-cured tobacco leaves is mainly tested by baking. The moisture content of tobacco leaves is obtained by comparing the quality of tobacco leaves before and after baking. This method has great defects: 1. The baking time is long and requires more manpower; 2. The weight of tobacco leaves after baking is greatly affected by the humidity of the environment; 3. The tobacco leaves need to be damaged during the testing process. In addition to flue-cured tobacco, there are non-destructive testing methods for other crops, such as corn, strawberries, etc. The non-destructive testing of the moisture content of crops mostly uses hyperspectral imaging technology, which has high requirements for image acquisition equipment and cannot be widely used.
[0003] Therefore, how to solve the above problems is an issue that needs to be solved urgently. Summary of the invention
[0004] The object of the present invention is to provide a method and system for non-destructive detection of moisture content in tobacco leaves, so as to solve the problems raised in the above-mentioned background technology.
[0005] In a first aspect, the present application provides a method for nondestructive detection of moisture content of tobacco leaves, the method comprising:
[0006] Collect tobacco leaf images of tobacco leaves to be tested;
[0007] Obtaining the RGB color distance of the tobacco leaf image;
[0008] The RGB color distance is input into a pre-trained detection model, and the moisture content of the tobacco leaf to be tested is output.
[0009] In a possible embodiment, obtaining the RGB color distance of the tobacco leaf image includes:
[0010] Extracting a tobacco leaf image from the tobacco leaf image;
[0011] Extract the first-order color moment, the second-order color moment and the third-order color moment corresponding to the red channel, the green channel and the blue channel in the tobacco leaf image respectively; wherein the first-order color moment, the second-order color moment and the third-order color moment are used as RGB color moments.
[0012] In a possible embodiment, the first-order color moment satisfies:
[0013]
[0014] Among them, E irepresents the first-order color moment of the i-th color channel, corresponding to the image in RGB color space; p ij represents the color value of the jth color channel of the ith pixel; N is the total number of pixels in the tobacco leaf image.
[0015] In a possible embodiment, the second-order color moment satisfies:
[0016]
[0017] In a possible embodiment, the third-order color moment satisfies:
[0018]
[0019] In a possible embodiment, extracting the tobacco leaf image from the tobacco leaf image includes:
[0020] Get the pixel size of the tobacco leaf image;
[0021] Determine a cut width according to the width of the pixel size and a first threshold;
[0022] Determine the interception length according to the length of the pixel size and a second threshold;
[0023] A tobacco leaf image is extracted from the tobacco leaf image according to the cut width and the cut length.
[0024] In a possible embodiment, the interception width satisfies:
[0025]
[0026] Wherein, M is the width of the pixel size, w1 is the first threshold; fix() is a rounding function;
[0027] The interception length satisfies:
[0028]
[0029] Wherein, Q is the length of the pixel size, and w2 is the second threshold.
[0030] In a possible embodiment, the detection model is trained using a random subspace recognition algorithm.
[0031] In a second aspect, the present application provides a tobacco leaf moisture content non-destructive detection system, the system comprising:
[0032] A collection unit, used for collecting tobacco leaf images of the tobacco leaves to be tested;
[0033] A processing unit, used for obtaining the RGB color distance of the tobacco leaf image;
[0034] The detection unit is used to input the RGB color distance into a pre-trained detection model and output the moisture content of the tobacco leaf to be tested.
[0035] In a possible embodiment, the detection unit is specifically used to:
[0036] Extracting a tobacco leaf image from the tobacco leaf image;
[0037] Extract the first-order color moment, the second-order color moment and the third-order color moment corresponding to the red channel, the green channel and the blue channel in the tobacco leaf image respectively; wherein the first-order color moment, the second-order color moment and the third-order color moment are used as RGB color moments.
[0038] The above-mentioned application provides a method and system for non-destructive detection of moisture content of tobacco leaves. The application directly collects tobacco leaf images of the tobacco leaves to be tested, and performs image processing on the tobacco leaf images to extract the RGB color distance of the tobacco leaf images, that is, extracts 9 eigenvalues of the R channel, G channel and B channel of the tobacco leaf images. Finally, the 9 eigenvalues are input into a pre-trained detection model to detect the moisture content of the tobacco leaves to be tested. The moisture content of the tobacco leaves can be obtained without damaging the tobacco leaves, which provides technical support for the cultivation and baking of flue-cured tobacco leaves and can effectively reduce the cost of detection equipment. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0040] Figure 1 A schematic diagram of the structure of an electronic device provided in the first embodiment of the present application;
[0041] Figure 2 A flow chart of a method for nondestructive detection of moisture content of tobacco leaves provided in the second embodiment of the present application;
[0042] Figure 3 for Figure 2 The tobacco leaf image collected in a tobacco leaf moisture content non-destructive detection method is shown;
[0043] Figure 4 To adopt Figure 2 A non-destructive detection method for moisture content of tobacco leaves is shown in Figure 3 The tobacco leaf image obtained by intercepting the tobacco leaf image shown;
[0044] Figure 5To adopt Figure 2 A schematic diagram showing a comparison between the moisture content detected by a tobacco leaf moisture content non-destructive detection method and the moisture content actually measured;
[0045] Figure 6 To adopt Figure 2 A schematic diagram showing the error comparison between the moisture content detected by a tobacco leaf moisture content non-destructive detection method and the actually measured moisture content;
[0046] Figure 7 A schematic diagram of the functional modules of a nondestructive detection system for moisture content in tobacco leaves provided in the third embodiment of the present application. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present application.
[0048] First embodiment
[0049] Figure 1 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application, which can be used in the present application Figure 1 The schematic diagram shown is used to describe an example electronic device 100 for implementing the method and system for non-destructive detection of moisture content of tobacco leaves according to an embodiment of the present application.
[0050] like Figure 1 The electronic device 100 includes one or more processors 102, one or more storage devices 104, an input device 106, and an output device 108. These components are interconnected via a bus system and / or other forms of connection mechanisms (not shown). It should be noted that Figure 1 The components and structures of the electronic device 100 shown are only exemplary and not restrictive. The electronic device may have Figure 1 Some of the components shown may also have Figure 1 Other components and structures are not shown.
[0051] The processor 102 may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 100 to perform desired functions.
[0052] It should be understood that the processor 102 in the embodiment of the present application may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0053] The storage device 104 may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media.
[0054] It should be understood that the storage device 104 in the embodiment of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct rambus RAM (DR RAM).
[0055] Among them, one or more computer program instructions can be stored on the computer-readable storage medium, and the processor 102 can execute the program instructions to implement the client functions (implemented by the processor) in the embodiments of the present application described below and / or other desired functions. Various applications and various data, such as various data used and / or generated by the application, can also be stored in the computer-readable storage medium.
[0056] The input device 106 may be a device used by a user to input instructions, and may include one or more of a keyboard, a mouse, a microphone, a touch screen, and the like.
[0057] The output device 108 may be a device for outputting the test result, so as to output the moisture content of the tobacco leaf to be tested.
[0058] Second embodiment:
[0059] Reference Figure 2 The flowchart of a method for nondestructive detection of moisture content of tobacco leaves is shown, and the method specifically comprises the following steps:
[0060] Step S201, collecting tobacco leaf images of tobacco leaves to be tested.
[0061] As an implementation method, tobacco leaves are photographed using photographing devices such as mobile phones and cameras to obtain tobacco leaf image information.
[0062] Among them, the tobacco leaf image is an RGB image, that is, a full-color image.
[0063] It is understandable that capturing images by photographing will not cause damage to tobacco leaves and has low requirements for image capture equipment.
[0064] Step S202, obtaining the RGB color distance of the tobacco leaf image.
[0065] As an implementation mode, step S202 includes: extracting a tobacco leaf image from the tobacco leaf image; extracting the first-order color moment, the second-order color moment and the third-order color moment corresponding to the red channel, the green channel and the blue channel in the tobacco leaf image respectively; wherein the first-order color moment, the second-order color moment and the third-order color moment are used as RGB color moments.
[0066] Optionally, extracting a tobacco leaf image from the tobacco leaf image includes: obtaining the pixel size of the tobacco leaf image; determining a cutoff width based on the width of the pixel size and a first threshold; determining a cutoff length based on the length of the pixel size and a second threshold; and extracting the tobacco leaf image from the tobacco leaf image based on the cutoff width and the cutoff length.
[0067] It is understandable that the pixel size of the tobacco leaf image can be directly extracted by extracting image information.
[0068] Of course, the pixel size of the tobacco leaf image may also be obtained by checking the properties of the tobacco leaf image, and no specific limitation is made here.
[0069] Optionally, the intercept width satisfies:
[0070]
[0071] Wherein, M is the width of the pixel size, w1 is the first threshold; fix() is a rounding function;
[0072] The interception length satisfies:
[0073]
[0074] Wherein, Q is the length of the pixel size, and w2 is the second threshold.
[0075] For example, it is assumed that the following is obtained through step S201: Figure 3 In the image shown, w1 is 500 and w2 is 500. Assuming the pixel size of the image before cropping is M×Q, the crop width is Pixels to pixels, length from Pixels to The sub-image of pixels is cut into Figure 4 shown.
[0076] It can be understood that by intercepting the rectangular area between the two specified vertices, the influence of the tobacco leaves not being located in the center of the image due to the artificial placement of the tobacco leaves during the photo shooting process is eliminated, so as to improve the accuracy of the moisture content detection of the tobacco leaves.
[0077] Optionally, the first-order color moment satisfies:
[0078]
[0079] Among them, E i represents the first-order color moment of the i-th color channel, corresponding to the image in RGB color space; p ij represents the color value of the jth color channel of the ith pixel; N is the total number of pixels in the tobacco leaf image.
[0080] Optionally, the second-order color moment satisfies:
[0081]
[0082] Optionally, the third-order color moment satisfies:
[0083]
[0084] It should be noted that the same-order color moments of different color channels are the same, that is, the first-order color moments of the red channel, green channel, and blue channel are all the above E i .
[0085] For example, the RGB color moment is extracted from the cut tobacco leaf image as the color feature of the tobacco leaf image. The color features of some tobacco leaf samples extracted by the above color moment extraction method are shown in Table 1 below:
[0086]
[0087] Table 1
[0088] It should be understood that the above Table 1 is only an example and not a limitation.
[0089] Step S203, inputting the RGB color distance into a pre-trained detection model, and outputting the moisture content of the tobacco leaf to be tested.
[0090] Optionally, the detection model is trained using a random subspace recognition algorithm. In simple terms, the training process is as follows:
[0091] Assume that the training data set is X, X i ={X1,X2...,X n}Where X is an m-dimensional vector, that is, X i ={x i1 ,x i2 ...,x im Specifically, the random subspace recognition algorithm uses random sampling to randomly select r (r < m) features from the m original features to obtain data from multiple r-dimensional random subspaces. Each r-dimensional random subspace generates a modified training data set, so multiple r-dimensional samples can be constructed. i=1,2,…,n is a new training subset That is, the original sample is represented by a randomly selected feature vector. Each selected feature vector represents a view of the original sample. Therefore, multiple random feature vector selections will result in multiple views, that is, the same sample is analyzed and represented from different angles. For example: Assuming that the features of a sample are randomly extracted T times, the sample has T different representations, that is, T views. The classifier trained for each view of the training sample is used to test the test sample under that view, and finally the final classification result of the test sample is obtained through a certain integration strategy.
[0092] The tobacco leaf samples after color feature value extraction are sampled, and 70% are selected as training samples and 30% as test samples.
[0093] 70% of the data was extracted and the RSM (random subspace recognition) algorithm was used to train the detection model as follows:
[0094] function[y1]=myNeuralNetworkFunction(x1)
[0095] x1_step1.xoffset=[3;0.0621396233196205;0.0932673759023886;0.0517633078954116;0.0265943033160198;0.029367412140441 3;0.0206110904445681;-0.0707640641307112;-0.0807987430305746;-0.0652964378564089;4.6947;0.7269;0.723610036991139];
[0096] x1_step1.gain=[0.00537634408602151;4.92197124954078;4.13174556697059;7.7216704001434;17.9582817859119;19.6669980303776;21 .6529975747649;11.0040947818094;11.2286750203743;12.38893649 56657;0.0908223968030516;0.515570220664055;11.5582169459799];
[0097] x1_step1.ymin = -1;
[0098] b1=[2.6270355785859443;0.78942736227153365;-0.71858342983050849;2.4798815278187885;2.0608784728806699;-2.1843119724158955;-1.7650091061048931;0.77985101932745349;2.5814203775320972;-0.050126538158069826;-0.24342259916713671;-0.016259294859700159;-1.5406151106536123;0.085343551653966815;-0.0058978881782702627;-0.011612780223982742;0.034657781297303167;0.02160408448595514;0.014147079222145104;0.44431853789760933;-0.032686050599716958;0.10479850567249338;-0.059002944119853983;0.58497333872417223;1.0527865260226827;-1.9494467545234633;-1.8919536663669376;-1.7503921122846196;-2.4639206061637964;-2.7679977534441829];
[0099] IW1_1=[-0.028475811259544331 0.08647372117179293 -0.27710233079934288 0.10619575255718906 -0.583674870321770010.29768021561515079 0.31423230422166909 0.34463305689998197 -0.15220121271918791 0.072516799160285708 0.55914819714628172 -0.62592692202268296 -0.33135874330151466;0.0045342148105433156 -0.21694003605298956 0.4074641883669724 -0.0699985905019350490.11023521203547927 0.17225599235345088 0.252832891205199030.10477545257634585 0.0019623185719165725 -0.20797772153785163 -0.028705020691833779 0.049526719656818249 0.00098928885713123215;-0.031861595148694237 -0.17899358467467308 0.445310241055022540.15084540189859449 -0.10669785139368074 0.10004325388787175 -0.12384300315442444 0.023236457222420071 0.128711309319961330.26765634730709587 -0.037322110127419358 0.0243790857366002370.023513431888633127;-0.076054250164578993 0.76150263445900046 -0.46853264616419976 -0.00044300798722904649 -0.277036525977745920.39761959323568119 -0.21014421466885844 0.33507287058932328 -0.099723335472719776-0.0022626873540066948 0.16481073655177411 -0.2272052218951521 -0.069912600973277089;-0.0069190455514260450.52578782690400216-0.24429688293819163 -0.28528222641142359 -0.18530249228020595 -0.087018632983850028 0.301648448974112030.23660517067932724 0.079594605891912265 -0.43608177359349631 -0.27312366726219151 0.27593239025368066 0.13141725026285445;-0.021650032300646192 -0.43388701349221021 0.4253964436812156 -0.13916395678205518 0.087750311638016956 -0.353029689440988060.36086469644496444 0.17736354311504726 0.039510992494545441 -0.37403217195253358 0.0246404969267088530.013485027381527867 -0.041630787515515771;0.009544926098408367 0.047330272127621933 -0.040231151672057291 -0.18556647813328672 0.34640832700127894 -0.383433517028671730.240410682837204460.013279944447877496 0.066899305930638281 -0.27880443057459797 -0.040111628726337646 0.031204173108263501-0.011720138999056471;-0.0044423031997342976 -0.12659191605329012 -0.12009028625897845 -0.069777397056807952 -0.0521764384966172180.027373290681349007 0.068541421785015003 0.055834274487316878 -0.11909030654186009 -0.26545584032428843 -0.0202239087013706690.031776091549963088 0.026507914449959088;-0.452519588474677050.04325031222179173 0.25639835412138301 0.089951384622501379 -0.39593643775430953 0.12118798970115199 -0.121613359042342930.34050287538646301 0.081223723867835496 0.61035338279659868 -0.65470568010872598 0.40009484968831388 0.82308304098832474;0.014234619985230849 -0.16257811439777009 0.2032944718131931 -0.15348004126932513 -0.20931560841228658 0.167580852212825540.15194243185574335 0.089496444811823173 0.049243384253736068 -0.050461199733017638 0.036265782540354667 -0.037227355329903705 -0.016082737814844365;0.00028261364706117268 -0.243774241079894450.26412416480026613 0.011094812388389264 0.22108076742472307 -0.18556822710578538 -0.0061404060583137776 -0.114312077304315090.0059720010975364401 0.26519046802099749 -0.00910012520555317750.0042752722050435014 -0.004692185799838859;-0.010636989569367069 -0.35700877559911898 0.073878209438683118 0.098366016307106688 -0.017558884398460432 -0.032307450701787602 0.0558761515702229720.027228942346588104 0.020138810450003129 0.032783860632195704 -0.035111385539173701 0.075263268475277215 0.059528528565096051;0.078597884743243682 -0.0639181227878948820.032487429457545076 -0.0033735209885373831 0.1398647820395692 -0.028893018553004208 -0.01705125846363343 -0.32867839038770785 0.053640217993504297 -0.014807844440002636 0.15124784188404355 -0.11449301873626208 -0.17281204923270352;0.0014302393591108249 0.3296805779625257 -0.4118767242400454 -0.050915397610865283 -0.0892109663632464080.16537442058609242 0.26399483333607993 -0.437069902824085310.26880441148057455 0.076183588029881497 0.012874381274672435 -0.049870572110938538 0.014906376236408803;0.0336884790199461910.58718023018076149 -0.31862326662361734 -0.199237353911110250.21447810159595729 -0.11939653877988493 -0.128885568608538250.20311737361640553 -0.024622407008768471 -0.16464435553571380.042801430311919311 -0.026199871328768005 0.0048057265161945183;-0.038323308977416391 0.097420913691928998 0.018332920389939007 -0.16800331488386103 -0.14774359093538403 -0.157369093381252020.29408105374782378 0.14282639370111971 -0.067870648743234202 -0.19174348204489675 -0.059694228048262542 0.0712285531001307370.050702489854485583;0.0091309618298885693 0.25231194068287816 -0.24995553969572806 0.21717247538086831 -0.125593344260263170.18944626889463079 -0.17331495366160279 0.15170111074977080.035065489685370828 -0.22762888432739456 0.040590049332438073 -0.035232838141063365 0.014318075956751986;0.023273305679823161 -0.29612454756487816 0.35547094066077134 0.069693872978351251 -0.30358486314540623 0.15667502347283621 0.058424760092192614 -0.00072092661636571681 -0.092019025117030168 0.0183752261314252160.039356594006199341 -0.037282208055292067 -0.023464660622762753;-0.004161018025601892 0.089827871735701489 -0.0063949984801036008 -0.036278015582916816 -0.099930757902205541 0.0169963289985776840.053461536375363029 0.0090959992429514649 0.16734855747338293 -0.052159239658219982 -0.021615402986468666 0.021161836385723828 -0.017597883061897485;-0.012221185471662909 0.0118441639705441240.34574296748598704 0.12910180021123652 0.0217689991122752420.0022357471339613704 -0.11242114786676674 -0.0339699949094425520.17287153926488649 0.37949973677814192 -0.0074261666714436148 -0.011912675335181349 -0.0086268475252502617;-0.0036179206607428538 -1.5707801605719334e-05 0.23337510582888446 -0.111145927176140250.053453592664890998 0.23268832258897285 -0.336956522607260.069574539631966734 -0.034633388580249065 -0.0190067376507243520.015100510450894321 -0.023336574732926437 -0.0067321497634922527;0.016023773881244176 0.68861138500199726 -0.39701477915203393 -0.12592098079749808 -0.20734152933636413 0.31357441420046778 -0.15135412437410109 -0.27977994172146931 0.126429990667423080.029095972161721027 0.034511236562402091 -0.0159830605360353690.02287584246303399;-0.0088627379951117264 0.61432806632095593 -0.75597356915564384 -0.0056791709461051863 -0.175668702861116580.081300174693190841 0.1781632073364684 0.17677199836504448 -0.10692261316693316 0.093188763081685361 -0.0161500702814712030.022546435058200472 0.019328465700614552;-0.00369376893870428880.19621240782167812 -0.36470445138320567 0.0577804674030101 -0.10204136196428769 -0.15361211873538871 -0.22057085628757411 -0.091527554720593762 -0.00084416968467831521 0.18203592064496460.024052534609822148 -0.042334692371980981 -0.00072043248689781505;0.045054608096063847 -0.34625219052284339 0.32592017190959127 -0.041264403150065652 -0.096977579259370547 0.105859478291374310.014725881796511917-0.14994704076813686 -0.040554967394302824 0.041238599082579319 -0.11635016480791729 0.13861867624813148 0.043483135147346232;0.092530207832180036 -0.29524895133959328 0.46975969917200228 -0.15782310008225978 -0.21878570773296258 0.37586283169015872 -0.13834440705277931 -0.34880617348381782 -0.0408650746626831530.14583227897987777 -0.45672839299659662 0.47589205660001010.19574808940375668;0.056942117201269141 0.29052779639257681 -0.6755649595936174 -0.30149165263385796 0.23866421889050388 -0.21087841522079603 0.25516229470532964 0.0064168870860288113 -0.20596125461033774 -0.39136137958420281 0.0115172684817674721.6831744466490111e-05 -0.019746629254423678;-0.0760444270678013320.39529722446108378 -0.52249888818844292 0.0895398770549885040.26220367723844373 -0.27998695130146245 -0.0107512093904482130.39685062804811982 -0.025230791029103763 -0.0321473029729218290.073627690846643001 -0.10882927857824282 -0.0056960986389090239;0.11713396606324557 0.76698935569368909 -0.30121601219002908 -0.21098609296140824 0.019318503382925914 0.0912202642033555780.076423066555826688 0.0073910289045134745 0.21782037887722139 -0.29041584376376334 0.14483400082592238 -0.19798949399967575 -0.20325679862613777;-0.012376356444682227 -0.758854356929945410.4197367243792951 0.21871566356820132 0.19493699722247471 -0.47958149388906374 0.063683160123324895 0.16357379722255175 -0.032044226022227541 -0.090432628031950735 0.0190964386150553610.031104892327262892 -0.0044585382828698341];.
[0100] b2=[-0.20808414792466562;-0.54607492733489593;-0.7476499321280069;0.3646269643462548;-0.62971540054080233;0.57775641265132938;0.69800684743577646;0.72736639698352579;0.072828929662808739];
[0101] <h2 style=";text-align:left;direction:ltr">LW2_1 = [-0.52118960720276697 0.49225993301781379 0.523258605628500570.59804886862554796 0.48009720371877918 0.348348167099963860.35584493444004583-0.47653718177916038 0.14222474815624594 -1.290725894858465 0.13243338588565842 -0.844923219166918590.21597600540882606 -0.017168280479725819 0.648399627140649580.64363094928907172 0.10908427723094438 0.85911522037933252 -0.053926947038982098 0.39036510780797834 -0.320414539855043370.55850796140564385 0.10391065161584827 -0.6089608020090771 -0.36009966926990428 -0.054270306630227895 -0.77443797827787442 -0.2369225653417826 -0.087669309288264149 0.069279541069307837;0.028543348340770412 0.50943551363540407 0.58575922432084448 0.48810749272080045 0.21038603717741924 -0.291188041908026940.68402403071953566 -0.55447774112891268 -0.02467236262831211 -0.80415778760861756 0.16547815816681669 -0.487295574105257920.027680625549646141 -0.023094696507181444 0.525149707836645390.7940652425946475 0.032938899640437259 1.0905660292506698 -0.30307680906193607 0.44996156630480094 -0.101483561161134560.29155027456275456 -0.56196513351889166 -0.63121268010149423 -0.18891280924649848 0.046129585290134043 -0.83467367179425322 -0.12393749859552201 -0.12575630458221482 0.15187385036176376;-0.33219467643873668 0.58928512186640436 0.480613138767256090.40196336444225089 0.41317369532249654 0.92604993725301832 -0.15060441696405422 -0.50421290695461152 0.078022895763830633 -1.8609608588259772 -0.048954337026379906 -0.335766082325995640.25406799937919572 0.0023741482719294698 -0.30899621848275133 -0.31466028096362952 1.5233513281475433 0.82824272518945063 -0.42181832391620167 0.38715663476777495 -1.3048493589324812 -0.2398122151265823 0.031766792301435663 -0.73982392616730586 -0.29351771144528011 -0.0004190884055044426 -0.67950318723194059 -0.28855553112675747 -0.18289387840949062 -0.59811091757604395;-0.53054989370682171 1.0571385535249254 0.0973744731978290060.55049879413706704 -0.16510719475162458 -0.765268407247299280.49739885640981996 0.12333964408932419 0.26058174092516767 -0.47254485594551704 0.35056633791564329 0.11285289620806510.24420994703051332 0.3795002059025987 0.32815013634314888 -0.79585694050729472 -0.13876310546815546 -1.0436863679615067 -0.98430821839142757 -0.018639055646972671 0.2876205321855273 -0.34688260590588299 0.1798999416339972 -1.3073171679896458 -0.6345207938795544 -0.33680666897153411 -0.22602659344869283 -0.34948258742358451 0.20333860965505834 0.61070960249322681;0.033015173791858178 1.0682240030066388 0.0384759498516883470.58272587461322412 -0.79996732977377638 -0.50637293632543978 -0.097780922753782695 -0.0084675333930016965 -0.438929100971344190.59033641379026691 -0.50613691394749694 -0.077448986210770523 -0.42033621837065882 0.15499540886097599 -0.89294870660980752 -0.94359147251122544 0.07311059550203422 -0.7890077973197912 -0.79351388912611487 -0.038583160431248167 0.887353592357963630.31279075860955163 0.81606672327854379 -1.32179032125555060.43603236207883844 -0.014255857978783468 -0.248280024548434590.3711575318580343 -0.38547526593508474 0.37731951014333437;-0.10361304122497673 0.96871608709642065 0.244855160158352320.011821127006145963 -0.26887432087052143 -0.631122083780225940.80259148839190331 -0.28683271615968575 0.251662369838041910.39605199420577586 -0.074399668073758321 -0.304428878414119090.15378838990827851 0.43425675180575452 0.0197572944169242290.1264405895987453 -0.21756554288408653 0.12386291327890073 -0.9908571144066044 0.19472295584692995 -1.2927738129198951 -0.12924862245673141 0.47767819133801043 -1.1984670069334913 -0.33482304066684337 -0.42058418698603395 -0.50882528710273833 -0.058993959194397191 0.027140364095117997 0.62497360641500366;-0.28393939177705602 -0.063507330408387935 0.386241005821633120.01411988628070833 0.14438741990698883 0.071834972577678027 -0.26901024581103367 -0.39059670950648517 -0.365973572508632831.2694520119266297 0.081747394157332925 0.53361362639226506 -0.63514606485572622 -0.10609698551827162 0.90096158764971601 -0.23566220569000598 0.54557317086944701 -0.212980645901096170.69699077863928693 0.32118848206635631 0.63593954294284871 -1.3548786736008458 1.0103913575489769 0.0836846122946105080.070806448495630878 0.079093556601107687 -0.424568393300437770.06938439660899999 0.30413928578363397 0.3387277598473501;-0.23883814873588355 -0.28872593815760039 0.522565280242078930.12671802984210073 0.64828509921364685 0.104377857971125320.35298305999311153 -0.39878686417862941 0.0705022325990744822.0318854182246966 0.017792657577918303 0.9181864933361471 -0.014619519168436864 0.23444220038641594 0.30772345975848531 -0.69493955063389723 0.71436232648071019 -1.80925370691875242.1313765773882989 0.35943943836528774 -0.71252420773206082 -0.078763246876040791 -0.7337137418731744 0.36590916677331414 -0.084809701357256975 -0.048440742521939313 -0.6425560713790136 -0.017896498711089903 0.21780059642550015 0.84442962968358515;-0.037743579693653669 -0.16661512171821233 0.65176325186820150.49347821937262143 0.030322822215233938 -0.5890571715925611 -0.26240855448591327 -0.50524896393371144 -0.15788802178156880.59676092769282463 0.49569985230800345 0.64883752208520595 -0.24924821667381902 -0.1007575640798663 0.2791219830853755 -0.73549315285415351 -1.0988902860715926 0.1552952778758952 -0.38482871606977148 0.48963663053448309 0.0258408543512890050.042092955722897681 1.1077419747516681 0.20960392463461966 -0.19090442841767491 0.05860257853123111 -0.72900029916351849 -0.089249623678201509 0.53714875720876532 0.70666752702804392];.
[0102] y1_step1.ymin=-1;
[0103] y1_step1.gain=[4.92197124954078;4.13174556697059;7.7216704001434;17.9582817859119;19.6669980303776;21.6529975747649;11.0040947818094;11.2286750203743;12.3889364956657];
[0104] y1_step1.xoffset=[0.0621396233196205;0.0932673759023886;0.0517633078954116;0.0265943033160198;0.0293674121404413;0.0206110904445681;-0.0707640641307112;-0.0807987430305746;-0.0652964378564089];
[0105] Q=size(x1,1);%samples
[0106] x1=x1';
[0107] xp1=mapminmax_apply(x1,x1_step1);
[0108] a1=tansig_apply(repmat(b1,1,Q)+IW1_1*xp1);
[0109] a2=repmat(b2,1,Q)+LW2_1*a1;
[0110] y1=mapminmax_reverse(a2,y1_step1);
[0111] y1=y1';
[0112] end
[0113] function y=mapminmax_apply(x,settings)
[0114] y=bsxfun(@minus,x,settings.xoffset);
[0115] y=bsxfun(@times,y,settings.gain);
[0116] y=bsxfun(@plus,y,settings.ymin);
[0117] end
[0118] function a=tansig_apply(n,~)
[0119] a=2. / (1+exp(-2*n))-1;
[0120] end
[0121] function x=mapminmax_reverse(y,settings)
[0122] x=bsxfun(@minus,y,settings.ymin);
[0123] x=bsxfun(@rdivide,x,settings.gain);
[0124] x=bsxfun(@plus,x,settings.xoffset);
[0125] end
[0126] It should be understood that the above training process and specific algorithm are only examples and not limitations.
[0127] In this embodiment, after the training is completed, in order to quantify the modeling effect and performance of the measured moisture content and regression value of tobacco leaves based on the RSM algorithm, the determination coefficient (R 2 ), root mean square error (RSME) and relative analytical error (RPD) are used to evaluate the model. 2 It is between 0 and 1, and the closer it is to 1, the higher the modeling accuracy; the smaller the RMSE, the higher the prediction accuracy of the modeling; when RPD≥2.5, it indicates that the model has excellent quantitative regression ability; when 2.0≤RPD<2.5, it indicates that the model has good quantitative regression ability; when 1.8≤RPD<2.0, it indicates that the model has good quantitative regression ability; when 1.4≤RPD<1.8, it indicates that the model has quantitative regression ability; when 1.0≤RPD<1.4, it indicates that the model has the ability to distinguish high values from low values; when RPD<1.0, it indicates that the model has no regression ability.
[0128] 70% of the training data was introduced into the above detection model to obtain the model evaluation, and 30% of the test data was introduced into the model to obtain the regression evaluation. The specific values are shown in Table 2 below.
[0129]
[0130] Table 2
[0131] It can be seen that the RPD values of the detection model (RSM model) trained in this embodiment are all greater than 2.5, so the RSM algorithm can be used for moisture content modeling of flue-cured tobacco leaves. 2 is 0.9944, RMSE is 0.15%, RPD is 13.3213, and the regression evaluation parameter R 2 The value of the regression coefficient is 0.9202, the RMSE is 0.56%, and the RPD is 3.5483, which shows that the RSM model has excellent quantitative regression ability and high model accuracy.
[0132] like Figure 5 As shown, by predicting the moisture content of 30% flue-cured tobacco leaf test samples and comparing the predicted moisture content with the measured moisture content obtained by the baking method, it can be seen that the non-destructive detection method for tobacco leaf moisture content provided in this embodiment can accurately detect the moisture content of tobacco leaves.
[0133] like Figure 6 As shown, the maximum error between the moisture content of tobacco leaves predicted by the nondestructive detection method for moisture content of tobacco leaves provided by this embodiment and the actual measured value is only 3.42%. It can be seen that the nondestructive detection method for moisture content of tobacco leaves provided by this embodiment has a good effect on the prediction value of moisture content of tobacco leaves.
[0134] For example, Figure 3 As an example, the tobacco leaf image is extracted as follows Figure 4 As shown, according to the calculation method of RGB color moment, the characteristic values shown in Table 3 are obtained:
[0135]
[0136] Define the extracted 9 components as a matrix x1 and bring it into the RSM model created above, as shown below:
[0137] x1=[0.13434,0.1949,0.0786,0.0431,0.0518,0.0313,0.0244,-0.0237,0.0265]
[0138] y1=myNeuralNetworkFunction(x1)
[0139] y1=0.7798
[0140] It can be seen that the model output value y1 is the predicted moisture content / moisture content of the tobacco leaf, 77.98%.
[0141] Third embodiment:
[0142] See also Figure 7 A tobacco leaf moisture content non-destructive detection system is shown, and the tobacco leaf moisture content non-destructive detection system includes: a collection unit 510, a processing unit 520 and a detection unit 530. The specific functions of each unit are as follows:
[0143] The acquisition unit 510 is used to acquire tobacco leaf images of the tobacco leaves to be tested;
[0144] The processing unit 520 is used to obtain the RGB color distance of the tobacco leaf image;
[0145] The detection unit 530 is used to input the RGB color distance into a pre-trained detection model and output the moisture content of the tobacco leaf to be tested.
[0146] Optionally, the detection unit 530 is specifically used to: extract a tobacco leaf image from the tobacco leaf image; extract the first-order color moment, second-order color moment and third-order color moment corresponding to the red channel, green channel and blue channel in the tobacco leaf image respectively; wherein the first-order color moment, the second-order color moment and the third-order color moment are used as RGB color moments.
[0147] It should be noted that the specific functions of the above-mentioned units can be found in the description of the method embodiment, which will not be described in detail here.
[0148] Furthermore, this embodiment also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processing device, the steps of any one of the methods for non-destructive detection of moisture content of tobacco leaves provided in the above-mentioned embodiment 2 are executed.
[0149] A computer program product of a method and system for nondestructive detection of moisture content in tobacco leaves provided in an embodiment of the present application includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the previous method embodiments. The specific implementation can be found in the method embodiments, which will not be repeated here.
[0150] It should be noted that the above embodiments can be implemented in whole or in part by software, hardware (such as circuits), firmware or any other combination. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media sets. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a tape), an optical medium (for example, a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.
[0151] It should be understood that the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. A and B can be singular or plural. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship, but it may also indicate an "and / or" relationship. Please refer to the context for specific understanding.
[0152] In this application, "at least one" means one or more, and "more than one" means two or more. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can be represented by: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.
[0153] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0154] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0155] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0156] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0157] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0158] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0159] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application. It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
Claims
1. A non-destructive detection method for moisture content of tobacco leaves, characterized in that: The method comprises: Collect tobacco leaf images of tobacco leaves to be tested; Obtaining the RGB color distance of the tobacco leaf image; The RGB color distance is input into a pre-trained detection model, and the moisture content of the tobacco leaf to be tested is output.
2. The method according to claim 1, characterized in that The step of obtaining the RGB color distance of the tobacco leaf image comprises: Extracting a tobacco leaf image from the tobacco leaf image; Extract the first-order color moment, the second-order color moment and the third-order color moment corresponding to the red channel, the green channel and the blue channel in the tobacco leaf image respectively; wherein the first-order color moment, the second-order color moment and the third-order color moment are used as RGB color moments.
3. The method according to claim 2, characterized in that The first-order color moment satisfies: Among them, E i represents the first-order color moment of the i-th color channel, corresponding to the image in RGB color space; p ij represents the color value of the jth color channel of the ith pixel; N is the total number of pixels in the tobacco leaf image.
4. The method according to claim 3, characterized in that The second-order color moment satisfies:
5. The method according to claim 4, characterized in that The third-order color moment satisfies:
6. The method according to claim 2, characterized in that The step of extracting a tobacco leaf image from the tobacco leaf image comprises: Get the pixel size of the tobacco leaf image; Determine a cut width according to the width of the pixel size and a first threshold; Determine the interception length according to the length of the pixel size and a second threshold; A tobacco leaf image is extracted from the tobacco leaf image according to the cut width and the cut length.
7. The method according to claim 6, characterized in that The interception width satisfies: Wherein, M is the width of the pixel size, w1 is the first threshold; fix() is a rounding function; The interception length satisfies: Wherein, Q is the length of the pixel size, and w2 is the second threshold.
8. The method according to claim 1, characterized in that The detection model is trained using a random subspace recognition algorithm.
9. A non-destructive detection system for tobacco leaf moisture content, characterized in that: The system comprises: A collection unit, used for collecting tobacco leaf images of the tobacco leaves to be tested; A processing unit, used for obtaining the RGB color distance of the tobacco leaf image; The detection unit is used to input the RGB color distance into a pre-trained detection model and output the moisture content of the tobacco leaf to be tested.
10. The system according to claim 9, characterized in that The detection unit is specifically used for: Extracting a tobacco leaf image from the tobacco leaf image; Extract the first-order color moment, the second-order color moment and the third-order color moment corresponding to the red channel, the green channel and the blue channel in the tobacco leaf image respectively; wherein the first-order color moment, the second-order color moment and the third-order color moment are used as RGB color moments.