Disclosure of Invention
The invention provides a coconut seed germination detection and sorting method and system based on X-rays for solving the problems.
The first object of the invention is to provide a coconut seed germination detection and sorting system based on X-ray, comprising: the device comprises a region to be detected, a conveyor belt, an objective table, a first mechanical arm, an X-ray imaging device, a second mechanical arm, a sample storage region and a computer system;
the object stage is arranged on the conveyor belt and is used for placing a sample to be tested; the conveyor belt is used for bearing a sample to be tested and receiving an instruction of the computer system so as to realize a translation function;
the X-ray imaging device comprises an X-ray source and an X-ray detection plate, wherein the X-ray source and the X-ray detection plate are respectively arranged on two sides of the conveyor belt, the X-ray source is used for realizing automatic X-ray imaging of coconut seeds, the X-ray detection plate is used for collecting transmission ray information during X-ray scanning and transmitting the transmission ray information back to the computer system, and the computer system is used for carrying out image processing, classifying, distinguishing, displaying and storing measurement results;
the first mechanical arm is used for grabbing a coconut seed sample to be detected, then is placed on the object stage, and the conveying belt conveys the coconut seed sample to be detected forwards to a position between the X-ray source and the X-ray detection plate;
the sample storage area comprises a germinated sample storage box, an ungerminated sample storage box and a damaged sample storage box;
the second mechanical arm is used for receiving an operation instruction sent by the computer system, grabbing and placing the detected sample into the germinated sample storage box, the ungerminated sample storage box or the damaged sample storage box;
the computer system is connected with four PLC controllers through serial ports; the first PLC is connected with a servo motor and a driver of the conveyor belt and used for controlling the starting and stopping time and the stepping distance of the conveyor belt; the other three PLC controllers are respectively connected with the first mechanical arm, the X-ray source and the second mechanical arm and are used for enabling the first mechanical arm, the X-ray source and the second mechanical arm to respectively execute instructions sent by the computer system.
The second object of the invention is to provide a coconut seed germination detection and sorting method based on X-ray, which adopts a coconut seed germination detection and sorting system based on X-ray, and specifically comprises the following steps:
s1, preheating and calibrating an X-ray source;
s2, placing a coconut seed sample to be detected in a region to be detected;
s3, sequentially grabbing a coconut seed sample to be detected by the first mechanical arm, placing the coconut seed sample on an objective table of the conveyor belt, and then withdrawing the first mechanical arm;
s4, the coconut seed sample to be detected is transmitted between an X-ray source and an X-ray detection plate through a conveyor belt, the X-ray source is started for imaging, and data are collected through the X-ray detection plate and transmitted back to a computer system;
s5, performing image processing and classification discrimination through a computer system, and displaying and storing processing results;
and S6, giving categories to the coconut seed samples to be detected according to the processing results, sending control signals of the corresponding categories to the second mechanical arm, and placing the detected coconut seed samples to the corresponding areas of the sample storage areas by the second mechanical arm to finish classification of the coconut seeds.
Preferably, step S5 comprises the following sub-steps:
s501, obtaining a coconut seed projection surface array image with a single view angle through a reconstruction algorithm;
s502, performing differential labeling on each tissue through coconut seed projection surface array images to obtain a labeling file;
s503, collecting paired coconut seed projection surface array images and annotation files as training sets, and training a segmentation model based on a U-type convolutional neural network; the segmentation model is used for learning image features of the internal structure, the position and the form of germination points of coconut seeds;
s504, preprocessing the images of the training set under the condition that the input shape of the segmentation model is met;
s505, inputting a preprocessed U-type convolutional neural network, performing iterative training through random gradient descent, and performing similarity comparison on an output result and a coconut seed projection surface array image from the average interaction ratio and the Dice coefficient until the output result is higher than a fixed threshold value, and completing the training process;
s506, predicting the input image by utilizing the trained network parameters, and counting the pixel number of each region in the prediction result; when the total number of pixels in a certain area is more than 100 x 100, the tissue is considered to exist; marking an input sample according to an output result, recording according to a three-bit 0/1 character string method, wherein 0 corresponds to the absence of the organization and 1 corresponds to the presence of the organization; the first position of the character string corresponds to the rhizome, the second position corresponds to the aspirator, and the last position corresponds to the coconut water; the character strings are classified and then provided with different differentiation labels, and the labels comprise germinated, ungerminated and damaged; wherein the germinated tag codes correspond to 110, 101, and 111, the ungerminated tag code corresponds to 001, and the damaged tag code corresponds to 000.
Preferably, in step S6, the location information of the germinated sample storage boxes, the ungerminated sample storage boxes and the damaged sample storage boxes are coded in the computer system as 01, 10 and 11, respectively; after the computer system receives the tag code in step S506, control signals of corresponding categories are sent to the second robot according to the corresponding rules of 110-01, 101-01, 111-01, 001-10 and 000-11.
Preferably, the coconut seed projection area array image is 8-bit single channel image data, with a size of 2512 x 3008 pixels.
Preferably, the labeling file in step S502 is a single-channel 8-bit gray map, wherein the gray value of the rhizome region is 1, the gray value of the aspirator region is 2, the gray value of the coconut water region is 3, and the gray values of the rest regions are all 0; the rhizome tissue is labeled as label_1, the aspirator tissue is labeled as label_2, and the coconut water area is labeled as label_3.
Preferably, the segmentation model in step S503 includes four downsampling layers, four upsampling layers, and a softmax layer for classification; each downsampling layer comprises a full convolution relu activation layer, a batch normalization layer and a maximum pooling layer, and each upsampling layer comprises a full convolution relu activation layer, a deconvolution layer and a feature fusion layer.
Preferably, the preprocessing of step S504 includes image size normalization, feature enhancement, and image rotation, and is calculated from the receptive field of the segmentation model.
Preferably, the fixed threshold of step S505 is set to 0.9.
Compared with the prior art, the invention has the following beneficial effects:
(1) The X-ray imaging device is used for continuously and rapidly imaging the coconut seeds;
(2) The X-ray source and the X-ray detector are kept still, the movement of a detection sample is realized by utilizing a computer system and a PLC controller to control a conveyor belt, the movement distance is easy to accurately control, and the system is simple to construct;
(3) Based on an X-ray imaging technology and an image processing technology, obtaining a high-quality coconut seed internal structure image, and providing a necessary premise for coconut germination classification;
(4) Based on the coconut seed imaging result, classifying samples by using a U-shaped convolutional neural network and a classification module, so as to realize accurate detection of coconut seed germination conditions;
(5) Converting the detection result into an operation instruction, transmitting the operation instruction to the second mechanical arm, and controlling the second mechanical arm to move the detected sample to a storage area corresponding to each category; and finally, the extracted data is stored as a spreadsheet, so that a user can index, manage and analyze the measured data conveniently.
Detailed Description
Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. In the following description, like modules are denoted by like reference numerals. In the case of the same reference numerals, their names and functions are also the same. Therefore, a detailed description thereof will not be repeated.
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be further described in detail with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not to be construed as limiting the invention.
Referring to fig. 1, there is provided an X-ray based coconut seed germination detection, sorting system comprising: the detection device comprises a region to be detected 1, a conveyor belt 2, an object stage 3, a first mechanical arm 4, an X-ray imaging device, a second mechanical arm 7, a sample storage region and a computer system 11;
the object stage 3 is arranged on the conveyor belt 2 and is used for placing a sample to be tested; the conveyor belt 2 is used for bearing a sample to be tested and receiving an instruction of the computer system 11 so as to realize a translation function;
the X-ray imaging device comprises an X-ray source 5 and an X-ray detection plate 6, wherein the X-ray source 5 and the X-ray detection plate 6 are respectively arranged on two sides of the conveyor belt 2, the X-ray source 5 is used for realizing automatic X-ray imaging of coconut seeds, the X-ray detection plate 6 is used for collecting transmission ray information during X-ray scanning and transmitting the transmission ray information back to the computer system 11, and the computer system 11 is used for carrying out image processing, classifying, distinguishing, displaying and storing measurement results;
the coconut seed sample to be detected is placed in a region to be detected 1, after the first mechanical arm 4 grabs the coconut seed sample to be detected, the coconut seed sample to be detected is placed on the object stage 3 on the conveyor belt 2, and the conveyor belt 2 forwards conveys the coconut seed sample to be detected to a position between the X-ray source 5 and the X-ray detection plate 6;
the sample storage area comprises a germinated sample storage box 8, an ungerminated sample storage box 9 and a damaged sample storage box 10, and after receiving an operation instruction sent by the computer system 11, the second mechanical arm 7 grabs and places the detected sample into the germinated sample storage box 8, the ungerminated sample storage box 9 or the damaged sample storage box 10;
the computer system 11 is connected with four PLC controllers through serial ports; the first PLC is connected with a servo motor and a driver of the conveyor belt 2 and is used for controlling the starting and stopping time and the stepping distance of the conveyor belt 2; the other three PLC controllers are respectively connected with the first mechanical arm 4, the X-ray source 5 and the second mechanical arm 7, and the first mechanical arm 4, the X-ray source 5 and the second mechanical arm 7 respectively execute instructions sent by the computer system 11.
The invention provides an X-ray-based coconut seed germination detection and sorting method, which adopts the detection and sorting system to detect and sort, and specifically comprises the following steps:
s1, preheating and calibrating the X-ray source 5.
S2, placing the coconut seed sample to be detected in the region 1 to be detected.
S3, the first mechanical arm 4 sequentially grabs coconut seed samples to be detected and places the coconut seed samples on the object stage 3 of the conveyor belt 2, and then the first mechanical arm 4 withdraws.
S4, the coconut seed sample to be detected is transmitted between an X-ray source 5 and an X-ray detection plate 6 through a conveyor belt 2, the X-ray source 5 is started for imaging, and data are collected through the X-ray detection plate 6 and transmitted back to a computer system 11;
specifically, the coconut seed sample to be detected is conveyed between an X-ray source 5 and an X-ray detection plate 6 through a conveyor belt 2, the coconut seed sample to be detected, the X-ray source 5 and the X-ray detection plate 6 are kept stationary, a scanning mode of the X-ray source 5 is fixed, the coconut seed sample to be detected is scanned at an angle parallel to the sample, the parameters of the X-ray source 5 are 100 kilovolts and 50 microamps, and the single scanning duration is 1 second; the X-ray detection board 6 returns the received data in real time to the computer system 11.
S5, performing image processing and classification discrimination through a computer system, and displaying and storing processing results;
specifically, the method comprises the following substeps:
s501, obtaining a coconut seed projection surface array image with a single view angle through a reconstruction algorithm; the coconut seed projection area array image is 8-bit single channel image data, with a size of 2512 x 3008 pixels.
S502, performing differential labeling on each tissue through coconut seed projection surface array images to obtain a labeling file; the marked file is an 8-bit gray map with a single channel, wherein the gray value of a rhizome region is 1, the gray value of a sucker region is 2, the gray value of a coconut water region is 3, and the gray values of the other regions are all 0; the rhizome tissue is labeled as label_1, the aspirator tissue is labeled as label_2, and the coconut water area is labeled as label_3.
S503, collecting paired coconut seed projection surface array images and annotation files as training sets, and training a segmentation model based on a U-type convolutional neural network; the segmentation model comprises four downsampling layers, four upsampling layers and a softmax layer for classification; each downsampling layer comprises a full convolution relu activating layer, a batch normalization layer and a maximum pooling layer, and each upsampling layer comprises a full convolution relu activating layer, a deconvolution layer and a feature fusion layer; the segmentation model is used for learning image features such as the internal structure of the seeds, the positions and the forms of germination points and the like.
S504, preprocessing the images of the training set under the condition that the input shape of the segmentation model is met; preprocessing comprises image size normalization (1/2 downsampling), feature enhancement, image rotation and the like, and is calculated according to the receptive field of the segmentation model.
S505, inputting a preprocessed U-type convolutional neural network, performing iterative training through random gradient descent, and performing similarity comparison on an output result and a coconut seed projection surface array image from an average interaction ratio and a Dice coefficient until the output result is higher than a fixed threshold value, wherein the training process is considered to be completed; the threshold is typically set to 0.9.
S506, predicting the input image by utilizing the trained network parameters, and counting the pixel number of each region in the prediction result; setting that the tissue is considered to exist when the total number of pixels in a certain area is more than 100 x 100; marking an input sample according to an output result, recording according to a three-bit 0/1 character string method, wherein 0 corresponds to the absence of the organization and 1 corresponds to the presence of the organization; the first position of the character string corresponds to the rhizome, the second position corresponds to the aspirator, and the last position corresponds to the coconut water; the character strings are classified and then are endowed with different differentiation labels, and the labels comprise germinated, ungerminated and damaged; wherein the germinated tag codes correspond to 110, 101 and 111, the ungerminated tag code corresponds to 001, the damaged tag code corresponds to 000, and the rest of the codes are objectively absent;
principle of: the germination of the coconut seeds is judged mainly by the existence relation of the rhizome, the sucker and the coconut water; when the rootstalk and the aspirator appear, the coconut is indicated to start to germinate and belongs to the germinated state; when the rhizome and the aspirator are not present and coconut water is present, the coconut has germination potential, and the coconut belongs to an ungerminated state; when the rhizome, the aspirator and the coconut water are all absent or the coconut meat is missing in a large area, the coconut seeds are not provided with germination conditions, and the coconut seeds are in a damaged state; the rhizome, the aspirator and the coconut water can be obviously identified from the sample projection map file obtained by analyzing imaging data, enhancing the image and correcting the image.
S6, giving categories to the coconut seed samples to be detected according to the processing results, and sending control signals of the corresponding categories to the second mechanical arm 7, wherein the second mechanical arm 7 places the coconut seed samples to be detected in the corresponding areas of the sample storage areas;
the corresponding areas of the sample storage area comprise germinated sample storage boxes 8, ungerminated sample storage boxes 9 and damaged sample storage boxes 10;
specifically, the location information of germinated sample storage boxes 8, ungerminated sample storage boxes 9, and damaged sample storage boxes 10 are encoded in computer system 11 as 01, 10, and 11, respectively; when the computer system 11 receives the classification labels of the samples, the operation instructions are transmitted to the second mechanical arm 7 according to the corresponding rules of 110-01, 101-01, 111-01, 001-10 and 000-11. And controlling the conveyor belt to rotate so as to convey the object placing table and the detected sample to the completion area from left to right, and controlling the mechanical arm to grasp the sample and place the sample in the corresponding area for storage.
Example 1
A coconut seed germination detection and sorting method based on X-ray adopts a coconut seed germination detection and sorting system based on X-ray, wherein the distance between an X-ray source 5 and an X-ray detection plate 6 is 75cm, and when a sample is placed, the distance between the coconut seed sample to be detected and the X-ray source 5 and the X-ray detection plate 6 is 50cm and 25cm respectively; fig. 2 shows the flow of the method, which specifically comprises the following steps:
s1, preheating and calibrating the X-ray source 5.
S2, placing the coconut seed sample to be detected in the region 1 to be detected.
S3, the first mechanical arm 4 sequentially grabs coconut seed samples to be detected and places the coconut seed samples on the object stage 3 of the conveyor belt 2, and then the first mechanical arm 4 withdraws.
S4, the coconut seed sample to be detected is transmitted between an X-ray source 5 and an X-ray detection plate 6 through a conveyor belt 2, the X-ray source 5 is started for imaging, and data are collected through the X-ray detection plate 6 and transmitted back to a computer system 11;
specifically, the coconut seed sample to be detected is conveyed between an X-ray source 5 and an X-ray detection plate 6 through a conveyor belt 2, the coconut seed sample to be detected, the X-ray source 5 and the X-ray detection plate 6 are kept stationary, a scanning mode of the X-ray source 5 is fixed, the coconut seed sample to be detected is scanned at an angle parallel to the sample, the parameters of the X-ray source 5 are 100 kilovolts and 50 microamps, and the single scanning duration is 1 second; the X-ray detection board 6 returns the received data in real time to the computer system 11.
S5, performing image processing and classification discrimination through a computer system, and displaying and storing processing results; specifically, the method comprises the following substeps:
s501, obtaining a coconut seed projection surface array image with a single view angle through a reconstruction algorithm; the coconut seed projection area array image is 8-bit single channel image data, with a size of 2512 x 3008 pixels.
S502, performing differential labeling on each tissue through coconut seed projection surface array images to obtain a labeling file; the marked file is an 8-bit gray map with a single channel, wherein the gray value of a rhizome region is 1, the gray value of a sucker region is 2, the gray value of a coconut water region is 3, and the gray values of the other regions are all 0; the rhizome tissue is labeled as label_1, the aspirator tissue is labeled as label_2, and the coconut water area is labeled as label_3.
S503, collecting paired coconut seed projection surface array images and annotation files as training sets, and training a segmentation model based on a U-type convolutional neural network; the segmentation model comprises four downsampling layers, four upsampling layers and a softmax layer for classification; each downsampling layer comprises a full convolution relu activating layer, a batch normalization layer and a maximum pooling layer, and each upsampling layer comprises a full convolution relu activating layer, a deconvolution layer and a feature fusion layer; the segmentation model is used for learning image features such as the internal structure of the seeds, the positions and the forms of germination points and the like.
S504, preprocessing the images of the training set under the condition that the input shape of the segmentation model is met; preprocessing comprises image size normalization (1/2 downsampling), feature enhancement, image rotation and the like, and is calculated according to the receptive field of the segmentation model.
S505, inputting a preprocessed U-type convolutional neural network, performing iterative training through random gradient descent, and performing similarity comparison on an output result and a coconut seed projection surface array image from an average interaction ratio and a Dice coefficient until the output result is higher than a fixed threshold value, wherein the training process is considered to be completed; the fixed threshold is typically set to 0.9.
S506, predicting the input image by utilizing the trained network parameters, and counting the pixel number of each region in the prediction result; in the embodiment, the distances between the coconut seed sample to be detected and the X-ray source 5 and the X-ray detection plate 6 are respectively 50cm and 25cm, and the single pixel size is about 0.067mm; setting that the tissue is considered to exist when the total number of pixels in a certain area is more than 100 x 100; marking an input sample according to an output result, recording according to a three-bit 0/1 character string method, wherein 0 corresponds to the absence of the organization and 1 corresponds to the presence of the organization; the first position of the character string corresponds to the rhizome, the second position corresponds to the aspirator, and the last position corresponds to the coconut water; the character strings are classified and then are endowed with different differentiation labels, and the labels comprise germinated, ungerminated and damaged; wherein the germinated tag codes correspond to 110, 101 and 111, the ungerminated tag code corresponds to 001, the damaged tag code corresponds to 000, and the rest of the codes are objectively absent;
principle of: the germination of the coconut seeds is judged mainly by the existence relation of the rhizome, the sucker and the coconut water; when the rootstalk and the aspirator appear, the coconut is indicated to start to germinate and belongs to the germinated state; when the rhizome and the aspirator are not present and coconut water is present, the coconut has germination potential, and the coconut belongs to an ungerminated state; when the rhizome, the aspirator and the coconut water are all absent or the coconut meat is missing in a large area, the coconut seeds are not provided with germination conditions, and the coconut seeds are in a damaged state; the rhizome, the aspirator and the coconut water can be obviously identified from the sample projection map file obtained by analyzing imaging data, enhancing the image and correcting the image.
S6, giving categories to the coconut seed samples to be detected according to the processing results, and sending control signals of the corresponding categories to the second mechanical arm 7, wherein the second mechanical arm 7 places the coconut seed samples to be detected in the corresponding areas of the sample storage areas;
the corresponding areas of the sample storage area comprise germinated sample storage boxes 8, ungerminated sample storage boxes 9 and damaged sample storage boxes 10;
specifically, the location information of germinated sample storage boxes 8, ungerminated sample storage boxes 9, and damaged sample storage boxes 10 are encoded in computer system 11 as 01, 10, and 11, respectively; when the computer system 11 receives the classification labels of the samples, the operation instructions are transmitted to the second mechanical arm 7 according to the corresponding rules of 110-01, 101-01, 111-01, 001-10 and 000-11. And controlling the conveyor belt to rotate so as to convey the object placing table and the detected sample to the completion area from left to right, and controlling the mechanical arm to grasp the sample and place the sample in the corresponding area for storage.
The invention has the advantages that: the automatic imaging work is completed by the X-ray imaging device, imaging images of detection samples can be acquired through the X-ray detection plate, then the internal structure of coconut fruits can be acquired simultaneously based on the deep learning technology of the computer system, key features in the germination process of coconut seeds can be automatically identified based on the internal structure of the coconut fruits, complex preprocessing operation is not needed, the software compatibility is good, the integration with the existing plant phenotype extraction technology (structured light, hyperspectral, micro CT and the like) is easy, and the method can be conveniently applied to seed germination classification of other tropical crops after the software parameters are slightly adjusted.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present disclosure may be performed in parallel, sequentially, or in a different order, provided that the desired results of the technical solutions of the present disclosure are achieved, and are not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.