A hyperspectral online detection system and method
By performing segmentation processing and model training on hyperspectral images in the hyperspectral online detection system, the problem of low detection accuracy in the existing technology is solved and more accurate sample identification and detection is achieved.
Patent Information
- Application Number
- CN202111189802.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-12
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2041-10-12
AI Technical Summary
Existing hyperspectral online detection systems and detection methods have low accuracy, making it difficult to accurately screen out samples to be tested.
Provides a hyperspectral online detection system, including a data acquisition module, a data processing module, a model training module and an online detection module. By segmenting hyperspectral images and model training, the trained model is used to detect the sample to be tested, and Optimize detection results with model evaluation and data visualization modules.
The accuracy of hyperspectral detection is improved. Through the combination of segmentation processing and model training module, more accurate data recognition and detection results are obtained, which enhances the recognition ability of the system.
Smart Images

Figure CN113933248B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of hyperspectral detection, and in particular relates to a hyperspectral online detection system and an online detection method. Background Art
[0002] Compared with traditional chemical analysis and identification methods, hyperspectral imaging detection technology has a faster detection speed and does not cause damage to samples. In the process of hyperspectral imaging, by simultaneously collecting the image and spectral information of the sample, the image information can reflect the external characteristics of the sample such as size, shape, defects, etc., and the spectral information can reflect the composition characteristics of the sample. Combining the image characteristics and composition characteristics of the sample can effectively identify the sample. The training model of hyperspectral data is the basis of hyperspectral detection. How to make the established model accurately screen out the samples to be tested has been a problem that people have been studying for a long time. Summary of the invention
[0003] In order to overcome the deficiencies of the prior art, the present invention provides a hyperspectral online detection system and an online detection method to improve the problem that the existing hyperspectral online detection system and detection method have low accuracy.
[0004] One embodiment of the present invention provides a hyperspectral online detection system, comprising:
[0005] A data acquisition module, used for acquiring hyperspectral images of standard samples;
[0006] A data processing module is used to segment the collected hyperspectral images;
[0007] A model training module, used for performing model training on the hyperspectral image after segmentation processing; and
[0008] The online detection module is used to perform hyperspectral image detection on the samples to be tested using the trained model.
[0009] In one embodiment, the hyperspectral online detection system further includes:
[0010] The model evaluation module is used to evaluate the trained model.
[0011] In one embodiment, the hyperspectral online detection system further includes:
[0012] Data visualization module, used to display hyperspectral images of preset bands.
[0013] In one of the embodiments, the data visualization module converts the hyperspectral image of a preset band into a grayscale image and outputs it to a display device for display.
[0014] In one embodiment, in the process of performing hyperspectral image detection on the sample to be tested using the trained model, the hyperspectral images of the sample to be tested that are identical or similar to the hyperspectral images of the standard sample are screened out, and the screened images of the sample to be tested are filled with the first color.
[0015] In one embodiment, the data acquisition module is also used to collect hyperspectral images of the second standard sample. In the process of performing hyperspectral image detection on the sample to be tested using the trained model, the hyperspectral images of the sample to be tested that are the same as or similar to the hyperspectral images of the second standard sample are screened out, and the screened images of the sample to be tested are filled with the second color.
[0016] In one embodiment, the process of segmenting the acquired hyperspectral image includes the following steps:
[0017] Display preset algorithm parameters and hyperspectral images corresponding to the preset algorithm parameters;
[0018] Receive adjustment values of algorithm parameters from users;
[0019] The displayed hyperspectral image is adjusted according to the values of the adjusted algorithm parameters.
[0020] In one of the embodiments, the preset algorithm parameters include one or more of the following parameters: image threshold, segmentation granularity, minimum screening area, and maximum screening area.
[0021] In one embodiment, the hyperspectral online detection system further includes:
[0022] The pseudo color image display module is used to select three different bands to form a pseudo red-green-blue image, and output the formed pseudo red-green-blue image to a display device for display.
[0023] In one embodiment, the hyperspectral online detection system uses a linear array camera to collect the hyperspectral image of the sample to be tested, and the collection process includes the following steps:
[0024] Step S201: creating a template image, wherein the length of the template image is the same as the length of a frame of image taken by the line array camera;
[0025] Step S202: obtaining a frame of image captured by the line array camera;
[0026] Step S203: splicing the image obtained in step S202 with the template image to form a new template image;
[0027] Step S204: Segment the new template image to obtain a segmentation sequence, and detect whether the segmentation sequence contains the image information of the sample to be tested. If not, remove the current image stitching process and return to step S202; if so, proceed to step S205;
[0028] Step S205: removing the segmentation sequence items intersecting with the image captured by the linear array camera from the segmentation sequence to obtain a real-time segmentation sequence;
[0029] Step S206: Generate a binary image with the same size as the new template image, set the value of the same position as the segmentation sequence in the binary image to 1, and set the value of the same position as the real-time segmentation sequence in the binary image to 0;
[0030] Step S207: Scan the binary image in the opposite direction of the image taken by the linear array camera and stitched into the template image in a manner of 1 pixel in width and the length of one frame of image. If all values are 0, record the position to obtain a position sequence;
[0031] Step S208: remove the position sequence in the new template image and return to step S202.
[0032] One embodiment of the present invention further provides a hyperspectral online detection method, comprising the hyperspectral online detection system as described in any one of the above embodiments, and the hyperspectral online detection method comprises the following steps:
[0033] Step S101: collecting hyperspectral images of standard samples;
[0034] Step S102: performing segmentation processing on the collected hyperspectral image;
[0035] Step S103: performing model training on the hyperspectral image after segmentation processing; and
[0036] Step S104: Use the trained model to perform hyperspectral image detection on the sample to be tested.
[0037] In one embodiment, step S102 includes the following steps:
[0038] Step S1021: displaying preset algorithm parameters and hyperspectral images corresponding to the preset algorithm parameters;
[0039] Step S1022: receiving the adjustment values of the algorithm parameters from the user;
[0040] Step S1023: adjusting the displayed hyperspectral image according to the adjusted values of the algorithm parameters.
[0041] In one of the embodiments, the preset algorithm parameters include one or more of the following parameters: image threshold, segmentation granularity, minimum screening area, and maximum screening area.
[0042] In one embodiment, in step S104, in the process of performing hyperspectral image detection on the sample to be tested using the trained model, the hyperspectral image of the sample to be tested that is identical or similar to the hyperspectral image of the standard sample is screened out, and the screened image of the sample to be tested is filled with the first color; and
[0043] The hyperspectral images of the samples to be tested that are identical or similar to the hyperspectral image of the second standard sample are screened out, and the screened images of the samples to be tested are filled with the second color.
[0044] In the hyperspectral online detection system and detection method provided in the embodiments of the present invention, the collected hyperspectral images are segmented by the data processing module. In the process of using the model training module to perform model training on the hyperspectral images after segmentation, the obtained training model can more accurately identify the data. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in 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 only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the structures shown in these drawings without paying creative work.
[0046] Figure 1 A schematic diagram of a module of a hyperspectral online detection system provided by an embodiment of the present invention;
[0047] Figure 2 yes Figure 1 Schematic diagram of the structure of the hyperspectral detection device;
[0048] Figure 3 yes Figure 1 Schematic diagram of the process of the image processing module in FIG.
[0049] Figure 4 yes Figure 1 Schematic diagram of the original spectrum curve of the image visualization module;
[0050] Figure 5 for Figure 1 Schematic diagram of the first-order derivative of the original spectral curve of the image visualization module;
[0051] Figure 6 for Figure 1Schematic diagram of image segmentation when performing hyperspectral image detection on a sample to be tested;
[0052] Figure 7 It is a schematic flow chart of a hyperspectral online detection method provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0053] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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.
[0054] It should be noted that if the embodiments of the present invention involve directional indications (such as up, down, left, right, front, back, etc.), the directional indications are only used to explain the relative position relationship, movement status, etc. between the components in a certain specific posture. If the specific posture changes, the directional indication will also change accordingly.
[0055] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present invention, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features limited to "first" and "second" may explicitly or implicitly include at least one of the features. In addition, if "and / or" or "and / or" appears in the full text, its meaning includes three parallel solutions. Taking "A and / or B" as an example, it includes solution A, solution B, or solutions that satisfy both A and B. In addition, the technical solutions between the various embodiments can be combined with each other, but it must be based on the ability of ordinary technicians in this field to implement. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0056] See also Figure 1 One embodiment of the present invention provides a hyperspectral online detection system 100. The hyperspectral online detection system 100 includes a data acquisition module 110, a data processing module 120, a model training module 130 and an online detection module 140.
[0057] The data acquisition module 110 is used to acquire a hyperspectral image of the standard sample. Figure 2In one embodiment, the data acquisition module 110 is connected to a hyperspectral detection device. The hyperspectral detection device includes a conveyor belt 111, a light source 112, a spectrometer 113, and a camera 114. In the actual detection process, the sample 200 is placed on the conveyor belt 111 and can move with the movement of the conveyor belt 111. The light source 112 provides illumination for the hyperspectral detection device. After the light emitted by the light source 112 irradiates the surface of the sample 200, the reflected light on the surface of the sample 200 passes through the spectrometer 113 and then is transmitted to the camera 114. Specifically, the spectrometer 113 disperses the mixed light of wide wavelengths into single wavelength light of different frequencies through optical elements, and projects the dispersed light onto the camera 114. That is, the light generated by the light source 112 becomes a carrier of physical or chemical information after interacting with the sample 200, and then is projected to the camera 114 through the spectrometer 113. The camera 114 then transmits the captured image to the data acquisition module 110 of the hyperspectral online detection system 100. Then, the hyperspectral online detection system 100 processes and analyzes the image and spectral data, and can also provide storage space for the hyperspectral image taken by the camera 114. As needed, the sample 200 can be Chinese medicine, Western medicine, barley, tomato, soybean, grape or corn, etc. When the sample 200 is a Chinese medicine, it can also be further subdivided into angelica, angelica pubescens, rehmannia glutinosa, polygonatum, salvia miltiorrhiza, platycodon grandiflorum, tangerine peel, etc.
[0058] In fact, in the process of using the data acquisition module 110 to collect hyperspectral images of standard samples, the spectral data of the sample can be collected and a certain band can be selected for visualization, and the path can be customized for saving. If the quality of the collected hyperspectral image is not good, the collected hyperspectral image can be deleted and re-collected. Generally speaking, the collected images are automatically named in chronological order. The user can also rename the collected hyperspectral image. When clicking on the sample subclass, the number of image data contained in the sample subclass can be displayed. When clicking on a specific hyperspectral image in the sample subclass, the path of image storage can be seen. In the actual operation process, the device is initialized first, and then a new sample category is created. The sample categories include: barley, tomato, soybean, grape, corn, Chinese medicine, western medicine or others. After the new sample category is created, a new sample subclass can be created under the sample category. For example, under the sample category of Chinese medicine, a new sample subclass such as angelica, angelica pubescens, etc. can be created. Then start scanning, and the scanned image is displayed in real time on the hyperspectral online detection system 100. After the image is scanned, the corresponding scanned image will be automatically saved in the column of the data set and the file name will be displayed. The user can also modify the corresponding file name.
[0059] The data processing module 120 is used to segment the collected hyperspectral images. The process of segmenting the hyperspectral images is mainly used to process two-dimensional images to extract the area of interest. According to needs, in the process of segmenting the hyperspectral images, visual operations can also be performed on different objects to adjust their segmentation parameters, and the image processing after the segmentation parameters are adjusted can be previewed in real time. Figure 3 In one embodiment, the process of segmenting the acquired hyperspectral image includes the following steps:
[0060] Step S1021: displaying preset algorithm parameters and hyperspectral images corresponding to the preset algorithm parameters;
[0061] Step S1022: receiving the adjustment values of the algorithm parameters from the user;
[0062] Step S1023: adjusting the displayed hyperspectral image according to the adjusted values of the algorithm parameters.
[0063] In one of the embodiments, the preset algorithm parameters include one or more of the following parameters: image threshold, segmentation granularity, minimum screening area, and maximum screening area.
[0064] Specifically, in the actual operation process, you can select information such as the category, sample set, and data processing model of sample 200, and then segment the collected hyperspectral image. For example, the selected categories include barley, tomatoes, soybeans, grapes, western medicine, corn, traditional Chinese medicine, etc. After the category is selected, hyperspectral test images of various samples in the category will appear in the sample set. For example, there are two images in the Angelica sample set: 20210609-1.bmp and 20210609-2.bmp, which represent two hyperspectral images of Angelica samples taken on June 9, 2021. For another example, there are two images in the Angelica sample set: 20210610-1.bmp and 20210610-2.bmp, which represent two hyperspectral images of Angelica samples taken on June 10, 2021. As needed, the data processing model can select an existing data processing model, such as: Chinese medicine_model, barley_model, grape_model, corn_model, soybean_model, western medicine_model. As needed, any one of the models is not limited to establishing one model. For example, the data processing model can also be: western medicine 1_model, western medicine 2_model, western medicine 3_model, etc. As needed, the data processing model can select a new data processing model, which will not be repeated here. Afterwards, the algorithm parameters of the corresponding model will be displayed on the display device.
[0065] Specifically, in this embodiment, for the Angelica sinensis sample set, the image threshold is 39 mm, the segmentation granularity is 3 mm, the minimum screening area is 510 mm, and the maximum screening area is 20000 mm. In fact, according to different types of samples, the image threshold, the segmentation granularity, the minimum screening area, and the maximum screening area can be adjusted according to actual needs.
[0066] The model training module 130 is used to perform model training on the hyperspectral image after segmentation processing. In the specific model training process, different model types can be newly created, and then data, image processing methods, parameters of the configuration learning process, and training equipment can be selected to start the training process. For example, the user can select an existing model type, such as: classified barley, classified soybeans, classified Chinese medicine, classified corn, etc. The user can also choose to create a new model type, such as: classified corn 1, classified corn 2, classified corn 3, etc. The user can also select different data types for training, for example, the data type can be selected as an average point spectrum, a point spectrum, or a 3D matrix, etc. As needed, the user can also select different algorithms for training, and the algorithms used include: CNN_1D (one-dimensional convolutional neural network), ONE_CLASS (single value classification) or SVM (support vector machine), etc. In the specific learning process, the parameters of the learning process can be configured. For example, in this embodiment, the learning rate can be configured to 0.001, the batch training number can be configured to 64, and the number of training times can be configured to 2000. In addition, the user can also select the corresponding training equipment. For example, when there are multiple CPUs (CPU0, CPU1, CPU2, ...), a specific CPU (e.g., CPU0) can be specified for training. For another example, when there are multiple GPUs (GPU0, GPU1, GPU2, ...), a specific GPU (e.g., GPU1) can be specified for training. After all parameters are selected, the model training can be performed on the corresponding hyperspectral image.
[0067] The online detection module 140 is used to perform hyperspectral image detection on the sample to be tested using the trained model. Figure 2 In the hyperspectral detection device shown in FIG. 1 . As the conveyor belt 111 operates, the camera 114 can detect the hyperspectral image of the reflected light of each band of the sample to be tested. At this time, the hyperspectral image of the sample to be tested is input into the trained model to detect the components in the sample to be tested. Figure 4 As shown, in this embodiment, the task currently being performed is the task of classifying traditional Chinese medicines. After the sample to be tested is subjected to hyperspectral image detection, the classification results obtained are 58% for Angelica sinensis and 41% for Radix Angelicae Pubescentis.
[0068] In fact, in one of the embodiments, in the process of using the trained model to perform hyperspectral image detection on the sample to be tested, the hyperspectral image of the sample to be tested that is the same as or similar to the hyperspectral image of the standard sample is screened out, and the screened image of the sample to be tested is filled with the first color. That is, in this embodiment, the screened Angelica sinensis sample can be displayed in green on the analysis result, so as to facilitate the user to identify and process it.
[0069] In fact, in one of the embodiments, the data acquisition module 110 is also used to perform hyperspectral image acquisition on the second standard sample. In the process of performing hyperspectral image detection on the sample to be tested using the trained model, the hyperspectral image of the sample to be tested that is the same as or similar to the hyperspectral image of the second standard sample is screened out, and the screened image of the sample to be tested is filled with a second color. That is, in this embodiment, hyperspectral image acquisition can also be performed on the Angelica dahurica sample, and model training can be performed. After the model is trained, the trained model can be used to perform hyperspectral image detection on the sample to be tested, and the hyperspectral image of the sample to be tested that is the same as or similar to the hyperspectral image of the Angelica dahurica sample is screened out, and the screened image of the sample to be tested is filled with a second color. In this embodiment, the screened Angelica dahurica sample can be displayed in red on the analysis result, so as to facilitate user identification and processing.
[0070] As required, during the actual detection process, the hyperspectral online detection system 100 can also display the running status of the program in real time, automatically read the running status of the camera or motor and display it on the program interface. The corresponding status information includes the motor forward speed, the motor zeroing speed, and the data processing time. In this embodiment, the motor forward speed is 45cm / s; the motor zeroing speed is 80cm / s; and the data processing time is 7.195s. As required, the motor forward speed, the motor zeroing speed, and the data processing time can be selected according to the actual situation.
[0071] In the hyperspectral online detection system 100 provided in the embodiment of the present invention, the collected hyperspectral image is segmented by the data processing module 120. In the process of using the model training module 130 to perform model training on the hyperspectral image after segmentation, the obtained training model recognizes the data more accurately.
[0072] According to the needs, before using the hyperspectral detection device to detect the standard sample 200 or the sample to be tested, the hyperspectral detection device can also be debugged in advance. For example, before the detection, the black and white calibration frame of the camera can be collected, or the focal length of the camera can be debugged, or the performance of the motor can be debugged, and the real-time status can be displayed on the display interface of the hyperspectral online detection system 100. For example, the stepping distance of the motor can be set to 500mm, and the stepping speed of the motor can be set to 50mm / s to observe the actual running status of the motor.
[0073] In one embodiment, the hyperspectral online detection system 100 further includes:
[0074] The model evaluation module 150 is used to perform model evaluation on the trained model.
[0075] After the model training is completed, the trained model can be evaluated by the model evaluation module 150. During the evaluation process, you only need to scan a test sample, and then save it to evaluate the accuracy of the trained model. In fact, when performing model evaluation, the standard sample is first divided into two parts, one part of the standard sample is used for model training; the other part is used to evaluate the trained model. In fact, the process of model evaluation is similar to the process of model training. Specifically, first select the data type (average point spectrum, point spectrum, 3D matrix), then select the corresponding algorithm (cnn_1d, one_class, svm), and then select the corresponding model under the algorithm. At this time, the relevant information of the model will be output in the hyperspectral online detection system 100. Then, based on the scanned test sample and the corresponding image processing method, the accuracy of the training model can be evaluated.
[0076] In one embodiment, the hyperspectral online detection system 100 further includes:
[0077] The data visualization module 160 is used to display the hyperspectral image of the preset band.
[0078] In fact, in the data visualization module 160, the collected spectral image can be visualized. Figure 4 As shown, at this time, the user can see the spectral images in different bands (converted into grayscale visualization images). In addition, the user can also focus on any point or multiple points on the image, and observe the curve and contrast relationship of the point or multiple points in the spectral dimension. As needed, the user can choose to display the original spectral curve, or choose to display the curve after the original spectral curve is first-order derived, such as Figure 5As shown. The user may also select a three-dimensional visualization view of the image as needed. In addition, visualizing the acquired spectral image is more helpful in assisting the user to determine the quality of the hyperspectral image, select which algorithm to train the corresponding sample model, or select which algorithm parameters to segment the image. In one embodiment, the data visualization module 160 converts the hyperspectral image of a preset band into a grayscale image and outputs it to a display device for display, so as to assist the user in selecting different sample models or algorithm parameters.
[0079] In one embodiment, the hyperspectral online detection system 100 further includes:
[0080] The pseudo color image display module 170 is used to select three different bands to form a pseudo red-green-blue image, and output the formed pseudo red-green-blue image to a display device for display.
[0081] Because the spectrum range of the hyperspectral online detection system 100 does not include visible light, when displaying the hyperspectral image in pseudo-color, three different bands can be selected to form a pseudo-RGB image to achieve the function of previewing the color image.
[0082] In one embodiment, the hyperspectral online detection system 100 uses a linear array camera to collect the hyperspectral image of the sample to be tested, and the collection process includes the following steps:
[0083] Step S201: creating a template image, wherein the length of the template image is the same as the length of a frame of image taken by the line array camera;
[0084] Step S202: obtaining a frame of image captured by the line array camera;
[0085] Step S203: splicing the image obtained in step S202 with the template image to form a new template image;
[0086] Step S204: Segment the new template image to obtain a segmentation sequence, and detect whether the segmentation sequence contains the image information of the sample to be tested. If not, remove the current image stitching process and return to step S202; if so, proceed to step S205;
[0087] Step S205: removing the segmentation sequence items intersecting with the image captured by the linear array camera from the segmentation sequence to obtain a real-time segmentation sequence;
[0088] Step S206: Generate a binary image with the same size as the new template image, set the value of the same position as the segmentation sequence in the binary image to 1, and set the value of the same position as the real-time segmentation sequence in the binary image to 0;
[0089] Step S207: Scan the binary image in the opposite direction of the image taken by the linear array camera and stitched into the template image in a manner of 1 pixel in width and the length of one frame of image. If all values are 0, record the position to obtain a position sequence;
[0090] Step S208: remove the position sequence in the new template image and return to step S202.
[0091] Figure 6 The schematic diagram of the above acquisition process is shown in Figure 2. Figure 6 In the image, the light-colored part is the background image information G2, and the dark-colored part is the object image information G1 of the sample to be tested. In the actual detection process, the background image information and the object image information can be distinguished by setting the corresponding color threshold. In this embodiment, the background image information is the image of the conveyor belt. In this embodiment, the conveyor belt moves from left to right. The line array camera is set at the rightmost position. The line array camera takes a frame of image after a preset time interval. At this time, in the first time period, the line array camera takes the image of the first column of pixel units from right to left; in the second time period, the line array camera takes the image of the second column of pixel units from right to left; in the third time period, the line array camera takes the image of the third column of pixel units from right to left; and so on. In the specific acquisition process, a template image A is first created inside the computer. The length of the template image A is the same as the length of a frame of image taken by the line array camera. In this embodiment, the initial width of the template image A is 0, which represents an empty image.
[0092] In the first time period, the line array camera captures the image B1 of the first column of pixel units from right to left. Image B1 is spliced into image A, and then the spliced image A is segmented to obtain a segmentation sequence L1. It is detected whether the segmentation sequence L1 contains the item image information of the sample to be tested. Since the first column of pixel units does not include the item image information of the sample to be tested, the splicing process is removed.
[0093] The processes in the second and third time periods are similar to those in the first time period and will not be described in detail here.
[0094] In the fourth time period, the linear array camera captures the image B4 of the fourth column of pixel units from right to left. Image B4 is spliced into image A, and then the spliced image A is segmented to obtain a segmentation sequence L4. It is detected whether the segmentation sequence L4 contains the item image information of the sample to be tested. Since image B4 contains the item image information of the sample to be tested, at this time, the segmentation sequence items in the segmentation sequence L4 that intersect with the image captured by the linear array camera are removed to obtain a real-time segmentation sequence L4'. In this embodiment, the segmentation sequence L4 represents the position of the item image information in image B4, and the real-time segmentation sequence L4' represents the position of the background image information in image B4. A binary image with the same size as the new template image is generated, and the value of the same position in the binary image as the segmentation sequence L4 is set to 1, and the value of the same position in the binary image as the real-time segmentation sequence L4' is set to 0. The binary image is scanned in the opposite direction from the splicing of the image captured by the linear array camera into the template image in a manner of 1 pixel in width and the length of one frame of image. Because its values are not all 0, at this time, proceed to the next step of the shooting process.
[0095] In the 5th time period, the linear array camera captures the image B5 of the 5th column of pixel units from right to left. Image B5 is spliced into image A, where image A is image B4 captured in the 4th time period. Then the spliced image A is segmented to obtain a segmentation sequence L5. Detect whether the segmentation sequence L5 contains the item image information of the sample to be tested. Since image B5 contains the item image information of the sample to be tested, at this time, the segmentation sequence items in the segmentation sequence L5 that intersect with the image captured by the linear array camera are removed to obtain a real-time segmentation sequence L5'. In this embodiment, the segmentation sequence L5 represents the position of the item image information in image B5, and the real-time segmentation sequence L5' represents the position of the background image information in image B5. Generate a binary image of the same size as the new template image, set the value of the same position as the segmentation sequence L5 in the binary image to 1, and set the value of the same position as the real-time segmentation sequence L5' in the binary image to 0. The binary image is scanned in the opposite direction of the image taken by the linear array camera and spliced into the template image in a manner of 1 pixel in width and the length of one frame of image. Because its value is not all 0, at this time, the next step of shooting process is carried out.
[0096] The process of time periods 6-11 is similar to that of time period 5 and will not be described again here.
[0097] In the 12th time period, the linear array camera captures the image B12 of the 12th column of pixel units from right to left. Image B12 is spliced into image A, and then the spliced image A is segmented to obtain a segmentation sequence L12. Detect whether the segmentation sequence L12 contains the item image information of the sample to be tested. Since image B12 contains the item image information of the sample to be tested, at this time, the segmentation sequence items in the segmentation sequence L12 that intersect with the image captured by the linear array camera are removed to obtain a real-time segmentation sequence L12'. In this embodiment, the segmentation sequence L12 represents the position of the item image information in image B12, and the real-time segmentation sequence L12' represents the position of the background image information in image B12. Generate a binary image of the same size as the new template image, set the value of the same position as the segmentation sequence L12 in the binary image to 1, and set the value of the same position as the real-time segmentation sequence L12' in the binary image to 0. The binary image is scanned in the opposite direction of the image taken by the linear array camera and spliced into the template image in a manner of 1 pixel in width and the length of one frame of image. At this time, since the values of the binary image of image B12 are all 0, the positions are recorded to obtain the position sequence R1. Then the corresponding position sequence R1 is removed from image A.
[0098] The process of the 13th time period is similar to that of the 12th time period and will not be repeated here.
[0099] In the conventional hyperspectral image acquisition process, when the line array camera is used for object detection on a conveyor belt or linear guide rail, since the width of the image captured by the line array camera each time is only one or a few pixels, it is impossible to capture the entire object in one shot, so the image can only be segmented by splicing each frame of the image.
[0100] Due to the different sizes of the detected objects (such as fruits, medicinal materials, etc.), different spacings, or the detected objects passing through the camera in parallel, if the spliced image is too long, the real-time performance cannot be guaranteed. If it is too short, it cannot be guaranteed to be spliced into one detected object or the spliced image contains one or more parts of the detected object, making it difficult to accurately perform real-time image segmentation of the detected object.
[0101] In the acquisition process in the above embodiment, the image is segmented to obtain the segmentation sequence and the real-time segmentation sequence, and the image is binarized so that the value at the position of the segmentation sequence is set to 1, and the value at the position of the real-time segmentation sequence is set to 0. At this time, when it is detected that the values of a column in the binary image are all 0, the information of the corresponding position sequence can be removed from the image. In this way, it can be ensured that the spliced image will not be too long, thereby ensuring the real-time nature of the detection result.
[0102] See also Figure 7 One embodiment of the present invention further provides a hyperspectral online detection method, comprising the hyperspectral online detection system 100 as described in any one of the above embodiments. The hyperspectral online detection method comprises the following steps:
[0103] Step S101: collecting hyperspectral images of standard samples;
[0104] Step S102: performing segmentation processing on the collected hyperspectral image;
[0105] Step S103: performing model training on the hyperspectral image after segmentation processing; and
[0106] Step S104: Use the trained model to perform hyperspectral image detection on the sample to be tested.
[0107] Similarly, in the hyperspectral online detection method provided by the embodiment of the present invention, by performing segmentation processing on the collected hyperspectral image, in the process of model training on the hyperspectral image after the segmentation processing, the obtained training model can more accurately recognize the data.
[0108] In one embodiment, step S102 includes the following steps:
[0109] Step S1021: displaying preset algorithm parameters and hyperspectral images corresponding to the preset algorithm parameters;
[0110] Step S1022: receiving the adjustment values of the algorithm parameters from the user;
[0111] Step S1023: adjusting the displayed hyperspectral image according to the adjusted values of the algorithm parameters.
[0112] In one of the embodiments, the preset algorithm parameters include one or more of the following parameters: image threshold, segmentation granularity, minimum screening area, and maximum screening area.
[0113] In one embodiment, in step S104, in the process of performing hyperspectral image detection on the sample to be tested using the trained model, the hyperspectral image of the sample to be tested that is identical or similar to the hyperspectral image of the standard sample is screened out, and the screened image of the sample to be tested is filled with the first color; and
[0114] The hyperspectral images of the samples to be tested that are identical or similar to the hyperspectral image of the second standard sample are screened out, and the screened images of the samples to be tested are filled with the second color.
[0115] The above description is only a preferred embodiment of the present invention, and does not limit the patent scope of the present invention. All equivalent structural changes made by using the contents of the present invention specification and drawings under the inventive concept of the present invention, or directly / indirectly applied in other related technical fields are included in the patent protection scope of the present invention.
Claims
1. A hyperspectral online detection system, characterized in that: include: A data acquisition module, used for acquiring hyperspectral images of standard samples; A data processing module is used to segment the collected hyperspectral images; A model training module is used to perform model training on the hyperspectral image after segmentation processing; as well as Online detection module, used to use the trained model to perform hyperspectral image detection on the sample to be tested; The hyperspectral online detection system uses a linear array camera to collect the hyperspectral image of the sample to be tested, and the collection process includes the following steps: Step S201: creating a template image, wherein the length of the template image is the same as the length of a frame of image taken by the line array camera; Step S202: obtaining a frame of image captured by the line array camera; Step S203: splicing the image obtained in step S202 with the template image to form a new template image; Step S204: Segment the new template image to obtain a segmentation sequence, and detect whether the segmentation sequence contains the image information of the sample to be tested. If not, remove the current image stitching process and return to step S202; if so, proceed to step S205; Step S205: removing the segmentation sequence items intersecting with the image captured by the linear array camera from the segmentation sequence to obtain a real-time segmentation sequence; Step S206: Generate a binary image with the same size as the new template image, set the value of the same position as the segmentation sequence in the binary image to 1, and set the value of the same position as the real-time segmentation sequence in the binary image to 0; Step S207: Scan the binary image in the opposite direction of the image taken by the linear array camera and stitched into the template image in a manner of 1 pixel in width and the length of one frame of image. If all values are 0, record the position to obtain a position sequence; Step S208: remove the position sequence in the new template image and return to step S202.
2. The hyperspectral online detection system according to claim 1, characterized in that: Also includes: Model evaluation module, used to evaluate the trained model; And / or, a pseudo color image display module is used to select three different bands to form a pseudo red-green-blue image, and output the formed pseudo red-green-blue image to a display device for display.
3. The hyperspectral online detection system according to claim 1, characterized in that: Also includes: Data visualization module, used to display hyperspectral images of preset bands; The data visualization module converts the hyperspectral image of a preset band into a grayscale image and outputs it to a display device for display.
4. The hyperspectral online detection system according to claim 2, characterized in that: In the process of performing hyperspectral image detection on the sample to be tested using the trained model, the hyperspectral images of the sample to be tested that are identical or similar to the hyperspectral images of the standard samples are screened out, and the screened images of the sample to be tested are filled with the first color.
5. The hyperspectral online detection system according to claim 4, characterized in that: The data acquisition module is also used to acquire a hyperspectral image of the second standard sample. In the process of performing hyperspectral image detection on the sample to be tested using the trained model, the hyperspectral image of the sample to be tested that is identical or similar to the hyperspectral image of the second standard sample is screened out, and the screened image of the sample to be tested is filled with the second color.
6. The hyperspectral online detection system according to claim 1, characterized in that: The process of segmenting the acquired hyperspectral image includes the following steps: Display preset algorithm parameters and hyperspectral images corresponding to the preset algorithm parameters; Receive adjustment values of algorithm parameters from users; The displayed hyperspectral image is adjusted according to the values of the adjusted algorithm parameters.
7. The hyperspectral online detection system according to claim 6, characterized in that: The preset algorithm parameters include one or more of the following parameters: image threshold, segmentation granularity, minimum screening area, and maximum screening area.
8. A hyperspectral online detection method, characterized in that: The method comprises the following steps: Step S101: collecting hyperspectral images of standard samples; Step S102: performing segmentation processing on the collected hyperspectral image; Step S103: performing model training on the hyperspectral image after segmentation processing; and Step S104: Use the trained model to perform hyperspectral image detection on the sample to be tested.
9. The hyperspectral online detection method according to claim 8, characterized in that: In step S104, in the process of performing hyperspectral image detection on the sample to be tested using the trained model, the hyperspectral image of the sample to be tested that is the same as or similar to the hyperspectral image of the standard sample is screened out, and the screened image of the sample to be tested is filled with the first color; as well as The hyperspectral images of the samples to be tested that are identical or similar to the hyperspectral image of the second standard sample are screened out, and the screened images of the samples to be tested are filled with the second color.
