Method, device and medium for rapid detection of drugs based on photonic crystal image

By employing photonic crystal image processing technology, combined with image preprocessing, color feature extraction, and support vector machine recognition, the problems of poor specificity and high cost in on-site drug detection have been solved. This enables rapid, low-cost, and high-volume drug detection, improving on-site law enforcement efficiency. It also addresses the technical challenges of specificity and operational complexity in existing drug detection technologies, achieving rapid and low-cost drug detection for large-scale drug testing.

CN115272710BActive Publication Date: 2026-02-17INST OF FORENSIC SCI OF MIN OF PUBLIC SECURITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210930983.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-04
Publication Date
2026-02-17
Estimated Expiration
2042-08-04

AI Technical Summary

Technical Problem

Existing drug testing methods suffer from problems such as poor specificity, the need for large instruments, high cost, and complex operation in on-site testing, especially in achieving three-dimensional specific detection of amphetamine-type drugs.

Method used

Using image processing technology based on photonic crystals, drug identification is performed through image preprocessing, color feature extraction, and dimensionality reduction. The drug is then identified using a support vector machine, and rapid detection is achieved by combining the color change after the photonic crystal reacts with the drug.

Benefits of technology

It enables rapid, low-cost, high-volume drug testing, improves on-site law enforcement efficiency, retains the advantages of low detection limits and high analysis efficiency, and avoids the disadvantages of large instruments and complex operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115272710B_ABST
    Figure CN115272710B_ABST
Patent Text Reader

Abstract

The present application relates to a kind of drug rapid detection method, equipment and medium based on photonic crystal image, comprising: image pre-processing, to locate the position of photonic crystal in image and cut image, so that only photonic crystal is left in the image after cutting;Extract the color feature vector of the photonic crystal, and carry out dimension reduction processing;The color feature vector after dimension reduction is converted, identified and compared based on support vector machine, and the drug identification of the to-be-measured body fluid is completed.The present application is based on the color difference of different drugs and photonic crystal after reaction, judges what kind of drug, such as amphetamine, pseudoephedrine, chloroephedrine, methylcathinone or methamphetamine, contained in the to-be-measured liquid by comparing with standard spectrum, fast, low cost, mass detection, low equipment cost.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to a photonic crystal image-based rapid drug detection method, device and medium, and relates to the technical field of drug detection. BACKGROUND

[0002] Drug abuse has become a global problem. In recent years, due to the development of social economy and science and technology, the types and transmission modes of drugs have become more diversified.

[0003] Current detection methods mainly include gas chromatography-mass spectrometry, high performance liquid chromatography-mass spectrometry, nuclear magnetic resonance, and capillary electrophoresis detection. Among them, gas chromatography-mass spectrometry, high performance liquid chromatography-mass spectrometry, and nuclear magnetic resonance all require large instruments to test under relatively standard external conditions, and are difficult to transplant to on-site detection. Capillary electrophoresis detection has the characteristics of low detection limit and miniaturization, and has rapidly developed and been applied in enantiomer separation. However, capillary electrophoresis detection separation requires certain markers (fluorescent markers) and a series of auxiliary compounds, such as essential electrolytes for capillary electrophoresis, chiral recognition ligands for chiral recognition, standard substances for quantitative detection, and fluorescent markers. The detection is usually based on laser-induced fluorescence, which has a high cost.

[0004] On-site detection of amphetamines such as ephedrine, pseudoephedrine, chloroephedrine, methcathinone, and methamphetamine has very important significance for criminal investigation, accurate identification of drugs, and inference of drug sources. In the field of on-site detection, there are currently some relatively mature detection methods, such as colorimetric / colorimetric method and immunoassay method, which can be made into test paper to achieve rapid detection. However, due to the inability to use instruments such as chromatography, mass spectrometry, and fluorescence spectroscopy, the detection specificity is poor. The current on-site detection of amphetamines is easily interfered by similar compounds, especially stereospecific detection. SUMMARY

[0005] To solve the above problems, the present application provides a photonic crystal image-based rapid drug detection method, device and medium based on the different colors of different drugs after reaction with photonic crystals to rapidly detect whether the body fluid to be tested contains drug substances.

[0006] To achieve the above-mentioned application purposes, the technical solutions adopted by the present application are as follows:

[0007] In a first aspect, the present application provides a photonic crystal image-based rapid drug detection method, which comprises:

[0008] Image preprocessing is performed to locate the position of the photonic crystal in the image and crop the image, so that only the photonic crystal remains in the cropped image;

[0009] Extract the color feature vector of the photonic crystal and perform dimension reduction processing;

[0010] Convert, identify and compare the color feature vector after dimension reduction based on a support vector machine to complete the identification of the to-be-tested body fluid drug.

[0011] Further, image preprocessing includes:

[0012] Convert the RGB color space of the image to the HSV color space;

[0013] Filter the image background under the HSV color space;

[0014] Perform binary processing on the image and image cropping, so that only the photonic crystal is left after cropping.

[0015] Further, converting the RGB color space of the image to the HSV color space includes:

[0016] Iterate through all pixel points in the RGB color space, and perform HSV color space conversion on each pixel point in the RGB color space, the process being:

[0017] V1 = max(R, G, B);

[0018] If: V1 ≠ 0, S1 = (V1-min(R, G, B)) / V1;

[0019] Otherwise: V1 = 0, S1 = 0;

[0020] If V1 = R, H1 = 60(G-B) / (V1-min(R, G, B)) and H1 < 0, then H = H1+360 / 360*255, S = 255*S1, V = V1; If V1 = R, H1 = 60(G-B) / (V1-min(R, G, B)) and H1 ≥ 0, then H = H1 / 360*255, S = 255*S1, V = V1;

[0021] If V1 = G, H1 = 120+60(B-R) / (V1-min(R, G, B)) and H1 < 0, then H = H1+360 / 360*255, S = 255*S1, V = V1; If V1 = G, H1 = 120+60(B-R) / (V1-min(R, G, B)) and H1 ≥ 0, then H = H1 / 360*255, S = 255*S1, V = V1;

[0022] If V1=B, H1=240+60(R-G) / (V1-min(R,G,B)) and H1<0, then H=H1+360 / 360*255, S=255*S1, V=V1; if V1=B, H1=240+60(R-G) / (V1-min(R,G,B)) and H1≥0, then H=H1 / 360*255, S=255*S1, V=V1;

[0023] If R=G=B, H=0, S=255*S1, V=V1.

[0024] Further, filtering the image background under the HSV color space, comprising:

[0025] Traversing the HSV color space pixel points;

[0026] If the condition (Hmin, Smin, Vmin)≤(H, S, V)≤(Hmax, Smax, Vmax) is met, then (H, S, V)=(H, S, V).

[0027] If the above condition is not met, then (H, S, V)=(0, 0, 0).

[0028] Further, the image is binarized and cropped, so that only the photonic crystal is left after cropping, comprising:

[0029] The image is binarized: if (H, S, V)=(0, 0, 0), then (H, S, V)=0; if (H, S, V)≠(0, 0, 0), then (H, S, V)=1.

[0030] Calculate the center distance: center distance coordinates (Pxc, Pyc)=(M 10 / M 00 ,M 01 / M 00 ), wherein M10, M00 and M01 are respectively:

[0031] M 10 =∑ 1,0 p·(p·Px 0 )·(p·Py 1 );

[0032] M 00 =∑ 0,0 p·(p·Px 0 )·(p·Py 0 );

[0033] M 01 =∑ 0,1 p·(p·Px 1 )·(p·Py0 );

[0034] wherein, p is the value 0 or 1 in the binarized pixel point, Px is the x coordinate of the pixel point, and Py is the y coordinate of the pixel point;

[0035] The center distance is taken as the center point to perform image cropping, so that only the image of the photonic crystal remains after the cropping: when cropping, all pixel points p are traversed, and if the current pixel point coordinates (Px, Py) satisfy Pxc min <Px<Pxc max , Pyc min <Py<Pyc max , then it is retained, Pxc max is the maximum x coordinate of the retained pixel point, and Pyc mac is the maximum y coordinate of the retained pixel point, to obtain the cropped image.

[0036] Further, the color feature vector of the photonic crystal is extracted, and dimension reduction processing is performed, including:

[0037] The color feature three-dimensional vector of the photonic crystal is extracted by using the mean value method: ((∑ n H) / n, (∑ n S) / n, (∑ n V) / n), and n is the total number of pixels:

[0038] The color feature three-dimensional vector is multiplied by a dimension reduction matrix obtained by pre-training to obtain a two-dimensional feature vector.

[0039] Further, the dimension reduction matrix is obtained by pre-training using the principal component analysis method, including:

[0040] The average value of all training data is calculated, wherein the training data is a t*3 training set matrix obtained by extracting the color features of t training pictures by using the mean value method, t≥b, b is the number of drug varieties, and 3 is the color channel of HSV;

[0041] Each training data is subtracted from the average value to complete standardization;

[0042] A 3*3 covariance matrix is calculated based on the standardized training data;

[0043] The eigenvalues and eigenvectors of the covariance matrix are calculated;

[0044] The eigenvalues are sorted from large to small, the adjustment coefficient K is determined based on the principal component analysis method, a 3*K feature matrix is obtained, and the t*3 training set matrix is multiplied by the 3*K feature matrix to obtain a t*K dimension reduction matrix.

[0045] Further, the color feature vector after dimension reduction is converted, identified and compared based on a support vector machine to complete identification of the to-be-tested body fluid drug, including:

[0046] The two-dimensional vector after dimension reduction is converted by a kernel function, and the position of the standard spectrum graph relative to the hyperplane is calculated and compared by an identification function, so that the type of the drug in the to-be-tested liquid is judged, wherein:

[0047] The identification function is f dec (x) = (w T x + b), w is a normal vector of the hyperplane, b is a hyperplane constant, and w and b are provided with a plurality of values, which are used to judge whether the drug is included or the type of the drug:

[0048] Firstly, the non-drug standard w and b are used for judgment, and when f dec (x) > 0, it is a non-drug; when f dec (x) ≤ 0, it is a drug-containing drug;

[0049] Secondly, the w and b of other drug standards are used for judgment respectively, and when f dec (x) > 0, it is an A drug; when f dec (x) ≤ 0, it is a non-A drug, and the judgment is sequentially performed.

[0050] Secondly, the w and b of other drug standards are used for judgment respectively, and when f dec (x) > 0, it is an A drug; when f dec (x) ≤ 0, it is a non-A drug, and the judgment is sequentially performed.

[0050] Secondly, the w and b of other drug standards are used for judgment respectively, and when f dec (x) > 0, it is an A drug; when f dec (x) ≤ 0, it is a non-A drug, and the judgment is sequentially performed.

[0051] Thirdly, the present application further provides a computer storage medium having computer readable instructions stored thereon, wherein the computer readable instructions can be executed by a processor to implement the method.

[0052] The present application has the following characteristics due to the above technical solutions:

[0053] 1. The present application is based on the different colors of different drugs after reacting with photonic crystals, and the type of drug contained in the to-be-tested liquid, such as amphetamines, ephedrine, pseudoephedrine, chloroephedrine, methcathinone or methamphetamine, is determined by comparison with a standard spectrum graph, which is fast, low in cost, and suitable for large-scale detection with low equipment cost.

[0054] 2. The present application uses the matching of photonic crystals and to-be-tested body fluid to quickly detect whether the to-be-tested body fluid contains drug substances, which is convenient for on-site law enforcement and improves the efficiency of law enforcement.

[0055] 3. Compared with the prior art technical schemes of detecting amphetamine drugs by chromatography, capillary electrophoresis, nuclear magnetic resonance and the like, the present application retains the advantages of low detection limit, high analysis efficiency and miniaturization of the detection unit of the prior art technical schemes, and effectively corrects the disadvantages of the prior art technical schemes, i.e., the need to carry multiple auxiliary substances, complex operation and the need for large-scale instruments and equipment.

[0056] In summary, the present application can be widely applied to rapid drug detection. BRIEF DESCRIPTION OF DRAWINGS

[0057] Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The accompanying drawings are included to provide a description of the preferred embodiments and are not intended to limit the scope of the application. Throughout the drawings, like reference numerals will be used to refer to like components. In the drawings:

[0058] Figure 1 The figure is a schematic diagram of the electronic device structure of the embodiment of the present application. DETAILED DESCRIPTION

[0059] It should be understood that the terms used herein are for the purpose of describing particular example embodiments and are not intended to be limiting. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. The terms "comprises", "comprising", "includes", "including" and "has" are inclusive and therefore specify the presence of stated features, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, steps, operations, elements, components, and / or groups thereof. The method steps, processes, and operations described herein are not to be construed as necessarily requiring their performance in the particular order in which they are described, unless specifically identified as an order dependent step. It is also to be understood that additional or alternative steps can be employed.

[0060] Although the terms first, second, third, and the like can be used herein to describe various elements, components, regions, layers and / or sections, these elements, components, regions, layers and / or sections should not be limited by these terms. These terms can be only used to differentiate one element, component, region, layer or section from another region, layer or section. Unless the context clearly indicates otherwise, terms such as "first", "second", and the like are used herein to describe a variety of elements, components, regions, layers and / or sections. Therefore, a first element, component, region, layer or section discussed below can be referred to as a second element, component, region, layer or section without departing from the teachings of the example embodiments.

[0061] For the convenience of description, spatial relative terms can be used in the description to describe the relationship of one element or feature relative to another element or feature as shown in the drawings, such as "inner", "outer", "inboard", "outboard", "under", "above", and the like. Such spatial relative terms are intended to include different orientations of the device in use or operation in addition to the orientations depicted in the drawings.

[0062] The photonic crystal itself has a specific spectrum, and when it is not combined with a specific substance, it forms coherent diffraction on the crystal surface with a periodic structure, so that the camera can shoot the photonic crystal with a specific spectrum. When the photonic crystal is combined with a specific drug substance, the maximum reflection spectrum of the photonic crystal is shifted, causing the color of the photonic crystal to change. After the camera shoots the photonic crystal after the color change, it is compared with the historical picture, and it can be judged whether the body fluid to be tested contains a certain drug substance.

[0063] The application provides a photonic crystal image-based drug rapid detection method, device and medium, which comprises the following steps: image preprocessing, positioning the position of the photonic crystal in the image and cutting the image, so that only the photonic crystal remains in the cut image; extracting the color feature vector of the photonic crystal and performing dimension reduction processing; converting, identifying and comparing the color feature vector after dimension reduction processing based on a support vector machine to complete drug identification of the body fluid to be tested. The application is based on the fact that different drugs react with the photonic crystal to produce different colors. By comparing with a standard spectrum, it can be judged which drug, such as amphetamine, pseudoephedrine, chloroamphetamine, methcathinone or methamphetamine, is contained in the liquid to be tested. The application has the advantages of fast speed, low cost, large batch detection and low equipment cost.

[0064] Exemplary embodiments of the present application will be described in greater detail below, with reference to the accompanying drawings. Although exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that the present application can be more thoroughly understood, and the scope of the present application can be accurately conveyed to those skilled in the art.

[0065] The photonic crystal image-based drug rapid detection method provided in the embodiment is used for processing the image of the body fluid to be tested and the photonic crystal, and comprises the following steps:

[0066] S1, image preprocessing is performed to position the position of the photonic crystal in the acquired image and cut the image, so that only the photonic crystal remains in the cut image, comprising the following steps:

[0067] S11, convert the original color space of the image into an HSV (H hue, S saturation, V brightness) color space to separate color information and brightness information and reduce noise caused by uneven illumination, wherein the original color space of the image in the embodiment is an RGB (R red, G green, B blue) color space.

[0068] Specifically, all pixel points in the RGB color space are traversed during conversion, and HSV color space conversion is performed on each pixel point in the RGB color space:

[0069] V1 = max (R, G, B)

[0070] If V1 ≠ 0, S1 = (V1 - min (R, G, B)) / V1.

[0071] If V1 = 0, S1 = 0.

[0072] If V1 = R, H1 = 60 (G - B) / (V1 - min (R, G, B)) and H1 < 0, then H = H1 + 360 / 360*255, S = 255*S1, V = V1; if V1 = R, H1 = 60 (G - B) / (V1 - min (R, G, B)) and H1 ≥ 0, then H = H1 / 360*255, S = 255*S1, V = V1.

[0073] If V1 = G, H1 = 120 + 60 (B - R) / (V1 - min (R, G, B)) and H1 < 0, then H = H1 + 360 / 360*255, S = 255*S1, V = V1; if V1 = G, H1 = 120 + 60 (B - R) / (V1 - min (R, G, B)) and H1 ≥ 0, then H = H1 / 360*255, S = 255*S1, V = V1.

[0074] If V1 = B, H1 = 240 + 60 (R - G) / (V1 - min (R, G, B)) and H1 < 0, then H = H1 + 360 / 360*255, S = 255*S1, V = V1; if V1 = B, H1 = 240 + 60 (R - G) / (V1 - min (R, G, B)) and H1 ≥ 0, then H = H1 / 360*255, S = 255*S1, V = V1.

[0075] If R = G = B, H1 = 0; H = H1 = 0, S = 255*S1, V = V1.

[0076] Further, assuming that the RGB value of an image is (255, 100, 0), the conversion method is obtained according to the above conversion method:

[0077] V = V1 = max (255, 100, 0) = 255.

[0078] S = S1 * 255 = (V1 - min(R, G, B) / V1) * 255 = ((255 - 0) / 255) * 255 = 255;

[0079] H = H1 / 360 * 255 = 60 (G - B) / (V1 - min(R, G, B)) / 360 * 255 = 60 (100 - 0) / (255 - 0) / 360 * 255 = 17;

[0080] It can be seen that the RGB value of a certain pixel point of the image is (255, 100, 0) and the HSV value is (17, 255, 255) after color space conversion.

[0081] S12, filter the image background under the HSV color space, filter part of the background by fixing the threshold value, so as to facilitate image binarization processing or image cropping, comprising:

[0082] Traverse the HSV color space pixel point, and the background filtering process is:

[0083] If (Hmin, Smin, Vmin) ≤ (H, S, V) ≤ (Hmax, Smax, Vmax);

[0084] Then: (H, S, V) = (H, S, V);

[0085] If the above condition is not met, (H, S, V) = (0, 0, 0).

[0086] Further, assuming that (Hmin, Smin, Vmin) is (40, 90, 20) and (Hmax, Smax, Vmax) is (120, 255, 255) in this embodiment, the pixel point converted above is (17, 255, 255) = (0, 0, 0), and similarly, (150, 255, 255) = (0, 0, 0)

[0087] S13, image binarization processing and center distance calculation are performed, so as to obtain the center coordinates of the photonic crystal, and the image is cropped with the center coordinates as the center point, so that only the photonic crystal remains after cropping.

[0088] S131, binarization processing

[0089] Binarization processing is to convert non-zero pixels in the HSV color space into 1 and pure black pixels into 0. The pure black pixel is (0, 0, 0). Binarization processing is performed according to the following steps:

[0090] If (H, S, V) = (0, 0, 0), then (H, S, V) = 0;

[0091] If (H, S, V)≠(0, 0, 0), then (H, S, V)=1.

[0092] S132, center distance calculation

[0093] Center distance coordinates (Pxc, Pyc)=(M 10 / M 00 ,M 01 / M 00 ), Pxc and Pyc are center distance x coordinate and y coordinate respectively; wherein, the calculation formula of M (matrix) is:

[0094]

[0095] Wherein, p is the value (0 or 1) in the pixel point after binarization, Px is the x coordinate of the pixel point, Py is the y coordinate of the pixel point, M10, M00, M01 are respectively:

[0096]

[0097]

[0098]

[0099] The center distance coordinates can be regarded as the average value of the sum of the x coordinate and y coordinate of the pixel point, which reflects the distribution of the pixels in the region, and the center distance represents the center position of the distribution of all pixels.

[0100] S133, image cropping with the center distance as the center point, so that the cropped image only remains the image of photonic crystal;

[0101] Specifically, when cropping, all pixel points p are traversed, if the current pixel point coordinate is less than or greater than the maximum and minimum coordinate, it is removed, that is: if Px≥Pxc max Or Px≤Pxc min Or Py≥Pyc max Or Py≤Pyc min , remove, get the cropped picture, that is, Pxc min <Px<Pxc max , Pyc min <Py<Pyc max , then keep, Pxc max is the maximum x coordinate of the retained pixel point, and Pyc mac is the maximum y coordinate of the retained pixel point.

[0102] Further, an image matrix with a target of h*w’*3 is calculated, h is the height of the cropped picture, w’ is the width of the cropped picture, and the size of the crystal ball is actually adjusted, h and w’ in this embodiment are taken as 100 for example, but are not limited thereto; Pxc min = Pxc-50; Pxc max = Pxc+50; Pyc min = Py c -50; Pyc max = Pyc+50.

[0103] S2, color features of the cropped image are extracted, principal component analysis (PCA) method is used for dimension reduction, and a three-dimensional feature vector of the color features is reduced to a two-dimensional feature vector, including:

[0104] The mean method is used to extract the color features, n is the total number of pixels, n = h*w’, and a three-dimensional feature vector of the color features is extracted as:

[0105] ((∑ n H) / n, (∑ n S) / n, (∑ n V) / n)

[0106] Further, assuming that there are 2 pixel points, the color features extracted by the mean method are (17+18) / 2, (255+255) / 2, (255+255) / 2), n = h*w’ in the above, h and w’ are taken as 100 for example, n = 100*100, and the color feature vector is the number of pixels in each color channel divided by n.

[0107] When the principal component analysis method is used for dimension reduction, a two-dimensional dimension-reduced feature vector is obtained by multiplying the extracted color feature vector by a dimension-reduced matrix, wherein the dimension-reduced matrix is obtained by pre-training, and the dimension-reduced feature vector is obtained by multiplying the extracted color feature by the dimension-reduced matrix.

[0108] Further, the pre-training of the dimension-reduced matrix includes:

[0109] S21, the average value of all training data is calculated: the training data is a t*3 training set matrix obtained by the above steps (after the color features are extracted by the mean method) of t training pictures, the t*3 training set matrix is trainset, and the average value is

[0110]

[0111] wherein t≥b, b is the number of drug varieties, 3 is the color channel of HSV, the training set is a data set (equivalent to a standard spectrum) composed of historically collected crystal pictures and corresponding picture drug variety labels soaked in the crystal ball, used for calculating the covariance matrix and precomputing the hyperplane position.

[0112] S22, subtract the average value of each training data to complete the standardization.

[0113] S23, calculate the covariance matrix, and calculate the 3*3 covariance matrix of all training data through the Cov formula:

[0114] The Cov formula is

[0115] Wherein, is the average of all u and i.

[0116] S24, calculate the eigenvalues and eigenvectors of the covariance matrix, and the three eigenvalues and the corresponding three eigenvectors of the matrix correspond to the eigenvalues and eigenvectors of the color channel of the HSV color space.

[0117] S25, sort the eigenvalues from large to small, adjust the coefficient K based on the principal component analysis method through the proportion, obtain the 3*K feature matrix, multiply the t*3 training set matrix by the 3*K feature matrix, obtain the t*K dimension reduction matrix, and project the standardized training data into the new space through the dimension reduction matrix, that is, when receiving a new image, multiply the extracted color feature vector of the new image by the dimension reduction matrix, to obtain the two-dimensional vector after dimension reduction, thereby reducing the three-dimensional vector of the extracted color feature to a two-dimensional vector.

[0118] S3, calculate the position of the relative hyperplane using the support vector machine, and calculate and compare the position of the relative hyperplane of the standard spectrum graph through the identification function, and identify the drug type corresponding to the feature.

[0119] Specifically, the two-dimensional vector after dimension reduction is first converted through the kernel function, and then calculated and compared with the position of the relative hyperplane of the known standard spectrum graph, so as to judge the type of the drug in the to-be-tested liquid.

[0120] Wherein, the kernel function is the radial basis function kernel:

[0121]

[0122] The identification function is f dec (x)=(w T x+b), w is the normal vector of the hyperplane, t represents the number of samples, and b is the constant of the hyperplane. There are multiple w and b, for example, w1-w r , b1 can be the normal vector and constant of the hyperplane corresponding to the photonic crystal which has not reacted with the drug, w2, b2 can be the normal vector and constant corresponding to the standard spectrum graph of the methamphetamine after reacting with the photonic crystal, which is known to be methamphetamine, and similarly, w3-w r , b3-b rIt can be ephedrine, amphetamine other class, etc. Taking methamphetamine and ephedrine as an example, the two-dimensional vector after dimension reduction of the known standard spectrum (pre-acquired training set) of methamphetamine and ephedrine is optimized by kernel function and objective function, and the standard classification result is obtained, that is, the normal vector and constant of the standard hyperplane are obtained.

[0123] Further, the relative hyperplane position calculation of the known standard spectrum includes:

[0124] The two-dimensional vector after dimension reduction of the training set (standard spectrum) is first converted by kernel function, and the kernel function is radial basis function kernel:

[0125]

[0126] After conversion, according to the objective function

[0127]

[0128] Subject to Yi[(wx)+b]≥1-ξ i (i = 1, 2, …, t)

[0129] In the formula, i represents the sample serial number, C is the penalty factor, ξ i > 0, ξ i is the outlier quantity;

[0130] The optimal solution of the normal vector and constant of the hyperplane is obtained by optimization, so that the standard classification effect of the drug is obtained, and further, the optimization method adopts the sequential minimal optimization algorithm.

[0131] In actual detection, the newly collected photonic crystal image (referring to the image taken after the field liquid to be measured reacts with the photonic crystal, and it is unknown whether it contains drugs) is pre-processed, PCA is reduced, and kernel function is converted. When identifying by using the identification function, first use the non-drug standard w and b to judge, when f dec (x) > 0 is a non-drug; when f dec (x) ≤ 0, it contains drugs; then use the w and b of other drug standards to judge respectively, when f dec (x) > 0 is A drug; when f dec (x) ≤ 0, it is not A drug; judge in turn.

[0132] In a preferred embodiment, the acquisition of the photonic crystal image: the image of the interaction between the body fluid to be tested and the photonic crystal can be achieved by using a camera to take a picture of the photonic crystal reacting with the body fluid to be tested in a darkroom environment. For example, the photonic crystal can be immersed in a buffer solution in a capillary chip, one end of the capillary chip is placed in the body fluid to be tested, and the other end is connected to a syringe for extraction of the body fluid to be tested. The body fluid to be tested fills the capillary chip and pushes the buffer solution out of the capillary chip, so that the body fluid to be tested can react with the photonic crystal. The body fluid to be tested is generally saliva, urine, etc. The camera takes a picture of the photonic crystal after the body fluid to be tested in the capillary chip reacts with the photonic crystal to obtain the photonic crystal image.

[0133] Embodiment II: The present embodiment provides an electronic device corresponding to the rapid drug detection method based on the photonic crystal image provided in Embodiment I. The electronic device can be an electronic device for a client, such as a mobile phone, a notebook computer, a tablet computer, a desktop computer, etc., to execute the method of Embodiment I.

[0134] As shown in Figure 1 , the electronic device includes a processor, a memory, a communication interface, and a bus. The processor, the memory, and the communication interface are connected through the bus to complete communication with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component (PCI) bus, or an Extended Industry Standard Component (EISA) bus, etc. The memory stores a computer program that can run on the processor. When the processor runs the computer program, it executes the rapid drug detection method based on the photonic crystal image provided in Embodiment I. Those skilled in the art can understand that Figure 1 the structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computing device to which the scheme of the present application is applied. A specific computing device can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0135] In some implementations, the logic instructions in the memory described above can be implemented in the form of software functional units and sold or used as standalone products, and can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the parts that make contributions to the prior art or parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The foregoing storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), optical disc, and various media that can store program codes.

[0136] In some other implementations, the processor can be a central processing unit (CPU), a digital signal processor (DSP), or various types of general-purpose processors, which are not limited herein.

[0137] Embodiment three: the drug rapid detection method based on photonic crystal image of embodiment one can be specifically implemented as a computer program product, and the computer program product can include a computer readable storage medium, which has loaded computer readable program instructions for executing the drug rapid detection method based on photonic crystal image of embodiment one.

[0138] The computer readable storage medium can be a tangible device that maintains and stores instructions for use by an instruction execution device. The computer readable storage medium can be, for example but not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any combination thereof.

[0139] Each of the embodiments in the specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In the description of the specification, the description referring to the terms "one embodiment", "some implementations", and the like means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiments of the specification. In the specification, the illustrative description of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in any appropriate manner in any one or more embodiments or examples. In addition, the person skilled in the art can combine and combine the different embodiments or examples described in the specification and the features of the different embodiments or examples without contradiction.

[0140] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 one or more flow or blocks. Figure 1 one or more flow or blocks.

[0141] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 one or more flow or blocks. Figure 1 one or more flow or blocks.

[0142] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 one or more flow or blocks. Figure 1 one or more flow or blocks.

[0143] Finally, it should be noted that the above-mentioned embodiments are merely used to illustrate the technical solutions of the present application, rather than limit the technical solutions of the present application; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can be modified or equivalent replacements can be made to some of the technical features; and the modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A rapid detection method of drugs based on photonic crystal images, the photonic crystal images being images of photonic crystals after reacting with body fluids to be detected, characterized in that Comprise: Image preprocessing to locate the position of photonic crystals in the image and crop the image so that only the photonic crystals remain in the cropped image, the process being: Image binarization: if (H, S, V)=(0, 0, 0), then (H, S, V)=0; if (H, S, V)≠(0, 0, 0), then (H, S, V)=1; Calculate the center distance: center distance coordinates (Pxc, Pyc) = (M 10 / M 00 ,M 01 / M 00 ), wherein M10, M00 and M01 are respectively: ; ; ; Wherein, p is the value 0 or 1 in the binarized pixel point, Px is the x coordinate of the pixel point, and Py is the y coordinate of the pixel point; The image is cropped with the center distance as the center point, so that only the image of the photonic crystal remains: when cropping, all pixel points p are traversed, if the current pixel point coordinates (Px, Py) satisfy Pxc min <Px<Pxc max , Pyc min <Py<Pyc max , then it is retained, Pxc max is the maximum x coordinate of the retained pixel point, Pyc mac is the maximum y coordinate of the retained pixel point, to obtain the cropped picture; Extract the color feature vector of the photonic crystal and perform dimensionality reduction processing; The dimensionality-reduced color feature vector is converted, identified and compared based on a support vector machine to complete identification of the to-be-tested body fluid drug, comprising: The dimensionality-reduced two-dimensional vector is converted by a kernel function, and the position of the standard spectrum graph relative to the hyperplane is calculated and compared, so as to judge the type of the drug in the to-be-tested liquid, wherein: The recognition function is w is a normal vector of the hyperplane, b is a constant of the hyperplane, and multiple w and b are set to determine whether the drug or the drug category is included. First, the non-drug criteria w and b are used to make a decision, when > 0 is non-drug; when ≤ 0 is a drug-containing Second, the w and b of other drug standards are used to judge respectively, when > 0 is A drug; when ≤ 0, is non-A drug, in turn to judge.

2. The method for rapid detection of drugs based on photonic crystal image according to claim 1, characterized in that, Image preprocessing, comprising: Converting the RGB color space of the image into the HSV color space; Filtering the image background under the HSV color space; Binarizing the image and performing image cropping so that only the photonic crystals remain in the cropped image.

3. The method for rapid detection of drugs based on photonic crystal image according to claim 2, characterized in that, Converting the RGB color space of the image into the HSV color space, comprising: Traversing all pixel points in the RGB color space, and converting each pixel point in the RGB color space into the HSV color space, the process being: V1=max(R, G, B); If: V1≠0, S1=V1-min(R, G, B)) / V1; Otherwise: V1=0, S1=0; If V1=R, H1=60(G-B) / (V1-min(R, G, B)) and H1<0, then H=H1+360 / 360*255, S=255*S1, V=V1; if V1=R, H1=60(G-B) / (V1-min(R, G, B)) and H1≥0, then H=H1 / 360*255, S=255*S1, V=V1; If V1=G, H1=120+60(B-R) / (V1-min(R, G, B)) and H1<0, then H=H1+360 / 360*255, S=255*S1, V=V1; if V1=G, H1=120+60(B-R) / (V1-min(R, G, B)) and H1≥0, then H=H1 / 360*255, S=255*S1, V=V1; If V1=B, H1=240+60(R-G) / (V1-min(R, G, B)) and H1<0, then H=H1+360 / 360*255, S=255*S1, V=V1; if V1=B, H1=240+60(R-G) / (V1-min(R, G, B)) H1≥0, then H=H1 / 360*255, S=255*S1, V=V1; If R=G=B, H=0, S=255*S1, V=V1.

4. The method for rapid detection of drugs based on photonic crystal image according to claim 3, characterized in that, Filtering the image background under the HSV color space, comprising: Traversing the pixel points in the HSV color space; If the condition (Hmin, Smin, Vmin) <= (H, S, V) <= (Hmax, Smax, Vmax) is met, then (H, S, V) = (H, S, V); If the condition is not met, then (H, S, V) = (0, 0, 0).

5. The method for rapid detection of drugs based on photonic crystal image according to claim 3, characterized in that, The color feature vector of the photonic crystal is extracted, and dimension reduction processing is performed, including: Extracting the three-dimensional vector of color features from a photonic crystal using the mean method: (( ) / n, ( ) / n, ( () / n), where n is the total number of pixels: The color feature three-dimensional vector is multiplied by a dimension reduction matrix obtained by pre-training to obtain a two-dimensional feature vector.

6. The method for rapid detection of drugs based on photonic crystal image according to claim 5, characterized in that, The dimension reduction matrix is obtained by pre-training using a principal component analysis method, including: An average value of all training data is calculated, wherein the training data is a t*3 training set matrix obtained by extracting color features from t training pictures by a mean method, t >= b, b is the number of drug types, and 3 is the color channel of HSV. Each training data is subtracted from the average value to complete standardization. A 3*3 covariance matrix is calculated based on the standardized training data. Eigenvalues and eigenvectors of the covariance matrix are calculated. The eigenvalues are sorted from large to small, and an adjustment coefficient K is determined based on the principal component analysis method to obtain a 3*K feature matrix, and the t*3 training set matrix is multiplied by the 3*K feature matrix to obtain a t*K dimension reduction matrix.

7. An electronic device comprising at least a processor and a memory having stored thereon a computer program, characterized in that, The processor executes the computer program to implement the method of any one of claims 1 to 6.

8. A computer storage medium, characterized in that Computer readable instructions are stored thereon, and the computer readable instructions can be executed by the processor to implement the method of any one of claims 1 to 6.

Citation Information

Patent Citations

  • Photon crystal gel material for detecting glucose and glucose detection method

    CN107056981A

  • A silkworm cocoon classification method based on color features and a support vector machine

    CN109409440A