CN110487737B - Image information extraction and calculation method and system for spectrum detection of smart phone - Google Patents
Image information extraction and calculation method and system for spectrum detection of smart phone Download PDFInfo
- Publication number
- CN110487737B CN110487737B CN201910914772.9A CN201910914772A CN110487737B CN 110487737 B CN110487737 B CN 110487737B CN 201910914772 A CN201910914772 A CN 201910914772A CN 110487737 B CN110487737 B CN 110487737B
- Authority
- CN
- China
- Prior art keywords
- value
- image
- gray
- sample
- spectral
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000004364 calculation method Methods 0.000 title claims abstract description 27
- 238000001514 detection method Methods 0.000 title claims abstract description 21
- 238000000605 extraction Methods 0.000 title claims abstract description 19
- 238000001228 spectrum Methods 0.000 title claims abstract description 9
- 238000002835 absorbance Methods 0.000 claims abstract description 31
- 238000012360 testing method Methods 0.000 claims abstract description 9
- 230000003595 spectral effect Effects 0.000 claims description 55
- 239000011159 matrix material Substances 0.000 claims description 10
- 238000000034 method Methods 0.000 claims description 10
- 238000010586 diagram Methods 0.000 claims description 5
- 239000000284 extract Substances 0.000 claims description 5
- 238000006243 chemical reaction Methods 0.000 claims description 4
- 238000012545 processing Methods 0.000 claims description 4
- 238000012886 linear function Methods 0.000 claims description 3
- 238000002834 transmittance Methods 0.000 claims description 3
- 238000004422 calculation algorithm Methods 0.000 abstract description 5
- 238000002798 spectrophotometry method Methods 0.000 abstract description 2
- 239000000126 substance Substances 0.000 description 5
- XKMRRTOUMJRJIA-UHFFFAOYSA-N ammonia nh3 Chemical compound N.N XKMRRTOUMJRJIA-UHFFFAOYSA-N 0.000 description 3
- 230000008569 process Effects 0.000 description 3
- 239000012491 analyte Substances 0.000 description 2
- 239000006185 dispersion Substances 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000011002 quantification Methods 0.000 description 2
- 239000000090 biomarker Substances 0.000 description 1
- 239000003086 colorant Substances 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000007613 environmental effect Effects 0.000 description 1
- 239000000203 mixture Substances 0.000 description 1
- 238000012821 model calculation Methods 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 102000004169 proteins and genes Human genes 0.000 description 1
- 108090000623 proteins and genes Proteins 0.000 description 1
- 238000004445 quantitative analysis Methods 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 210000003296 saliva Anatomy 0.000 description 1
- 238000000926 separation method Methods 0.000 description 1
- 238000007493 shaping process Methods 0.000 description 1
- 238000004611 spectroscopical analysis Methods 0.000 description 1
- 210000004243 sweat Anatomy 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01N—INVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
- G01N21/00—Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
- G01N21/17—Systems in which incident light is modified in accordance with the properties of the material investigated
- G01N21/25—Colour; Spectral properties, i.e. comparison of effect of material on the light at two or more different wavelengths or wavelength bands
- G01N21/31—Investigating relative effect of material at wavelengths characteristic of specific elements or molecules, e.g. atomic absorption spectrometry
- G01N21/3103—Atomic absorption analysis
Landscapes
- Physics & Mathematics (AREA)
- Spectroscopy & Molecular Physics (AREA)
- Health & Medical Sciences (AREA)
- Life Sciences & Earth Sciences (AREA)
- Chemical & Material Sciences (AREA)
- Analytical Chemistry (AREA)
- Biochemistry (AREA)
- General Health & Medical Sciences (AREA)
- General Physics & Mathematics (AREA)
- Immunology (AREA)
- Pathology (AREA)
- Investigating Or Analysing Materials By Optical Means (AREA)
- Spectrometry And Color Measurement (AREA)
Abstract
Description
技术领域technical field
本发明涉及光谱检测与图像处理技术领域,具体地涉及一种用于智能手机光谱检测的图像信息提取与计算方法及系统。The invention relates to the technical field of spectral detection and image processing, in particular to an image information extraction and calculation method and system for smart phone spectral detection.
背景技术Background technique
光谱分析可以用于确定物质的化学组成和相对含量,在食品安全、生物安全、环境监测和医疗保健等领域具有重要的作用。实验室用的大型光谱仪沉重且昂贵,无法满足人们对目标样品进行实时、实地检测的需求,因此,便携式光谱分析仪取得不断发展。现代智能手机包含不同的传感器技术,可以作为独立的测量仪器在各个领域广泛使用。在光谱检测中,可以将光学分光部分集成做成手机外部装置,将其与手机进行配合,利用智能手机的CMOS传感器将透过样品光信号转变为电信号,通过解读电信号在手机屏幕上显示出图像,再配合具有颜色量化模型的手机软件即可实现待测样品的定量分析。Spectroscopic analysis can be used to determine the chemical composition and relative content of substances, and plays an important role in the fields of food safety, biosecurity, environmental monitoring, and healthcare. Large-scale spectrometers used in the laboratory are heavy and expensive, and cannot meet the needs of real-time, on-site detection of target samples. Therefore, portable spectrometers have continued to develop. Modern smartphones contain different sensor technologies and can be used in a wide range of fields as stand-alone measuring instruments. In spectral detection, the optical spectroscopic part can be integrated into an external device of the mobile phone, and it can be matched with the mobile phone, and the CMOS sensor of the smart phone can be used to convert the light signal passing through the sample into an electrical signal, which is displayed on the screen of the mobile phone by interpreting the electrical signal. Quantitative analysis of the sample to be tested can be realized by using the mobile phone software with a color quantification model to output the image.
目前,国内外许多学者对颜色量化模型进行过研究。Abbaspour等人将图像的RGB颜色值转化为吸光度,计算了Fe+2、Fe3+浓度;Oncescu提出使用HSV模型中的H值来代表颜色,检测汗和唾液中的生物标志物;Suzuki等利用CIE XYZ的色度坐标对Li+,NH4+和蛋白质进行了测定。结果表明使用图像颜色信息测试出的待测物浓度与大型仪器测试结果相近,具有很强的可行性。但不同的颜色模型对图像的量化方式存在差异,对于显色反应不同的物质,需要使用特定的颜色模型,因此上述颜色模型难以广泛使用。At present, many scholars at home and abroad have conducted research on the color quantification model. Abbaspour et al. converted the RGB color values of the image into absorbance, and calculated the Fe +2 and Fe 3+ concentrations; Oncescu proposed to use the H value in the HSV model to represent color to detect biomarkers in sweat and saliva; Suzuki et al. The chromaticity coordinates of CIE XYZ were determined for Li+, NH4+ and protein. The results show that the concentration of the analyte tested by using the image color information is similar to the test result of the large-scale instrument, which has a strong feasibility. However, different color models have different ways of quantifying images. For substances with different color reactions, a specific color model needs to be used, so the above color model is difficult to be widely used.
中国专利文献CN 107084790A公开了一种基于智能手机的便携式光谱仪的光谱检测方法,包括:1)收集待测光信号;(2)对待测光信号进行准直整形和色散分光,形成按波长依次排列的色散条纹;(3)通过智能手机对步骤(2)得到的色散条纹进行拍摄,形成按波长依次排列的彩色条纹图片;(4)获取步骤(3)得到的彩色条纹图片每个像素位置点的RGB值,并计算每个像素位置点对应的光强值I,得到数组I(x),其中x为图片像素位置点坐标;(5)根据波长-像素位置标定数据λ(x),将数组I(x)中的x以对应的λ替换,得到波长与光强的对应关系I(λ),绘制数据I(λ)对应的光谱曲线,完成光谱检测。上述颜色模型难以广泛使用。除此之外,不同型号手机的图像显示存在差异,使用像素固定的方法能适用于同一型号的手机,但是在不同型号的手机上使用可能存在图片信息加载失败,或者数据误差过大等问题。因此,开发一个能应用于不同型号手机的图像信息提取与计算方法就显得至关重要。Chinese patent document CN 107084790A discloses a spectrum detection method of a portable spectrometer based on a smart phone, including: 1) collecting the light signal to be measured; (2) performing collimation shaping and dispersion light separation on the light signal to be measured to form a sequence of wavelengths (3) photographing the dispersion fringes obtained in step (2) by a smartphone to form a color fringe picture arranged in order of wavelength; (4) acquiring each pixel position point of the color fringe picture obtained in step (3) and calculate the light intensity value I corresponding to each pixel position point to obtain an array I(x), where x is the coordinate of the pixel position point of the picture; (5) According to the wavelength-pixel position calibration data λ(x), the The x in the array I(x) is replaced with the corresponding λ to obtain the corresponding relationship between the wavelength and the light intensity I(λ), and the spectral curve corresponding to the data I(λ) is drawn to complete the spectral detection. The above color models are difficult to use widely. In addition, there are differences in the image display of different models of mobile phones. The pixel fixing method can be applied to the same model of mobile phones. However, when used on different models of mobile phones, there may be problems such as failure to load image information or excessive data errors. Therefore, it is very important to develop an image information extraction and calculation method that can be applied to different types of mobile phones.
发明内容SUMMARY OF THE INVENTION
为了解决上述存在的技术问题,本发明提供了一种用于智能手机光谱检测的图像信息提取与计算方法及系统,提升手机光谱仪图像处理的精度以及APP在各型号手机上的兼容性。In order to solve the above-mentioned technical problems, the present invention provides an image information extraction and calculation method and system for smartphone spectral detection, which improves the image processing accuracy of the mobile phone spectrometer and the compatibility of the APP on various types of mobile phones.
本发明的技术方案是:The technical scheme of the present invention is:
一种用于智能手机光谱检测的图像信息提取与计算方法,包括以下步骤:An image information extraction and calculation method for smartphone spectral detection, comprising the following steps:
S01:获得光谱图像的RGB图像,并将图像旋转到统一的角度;S01: Obtain the RGB image of the spectral image, and rotate the image to a uniform angle;
S02:根据不同的样品,选定图像的有效图像区域;S02: According to different samples, select the effective image area of the image;
S03:提取选定区域中的RGB值,将区域内的RGB值转化为灰度值;S03: Extract the RGB values in the selected area, and convert the RGB values in the area into grayscale values;
S04:通过图像灰度值反演模型,计算样品的吸光度,根据测试得到不同浓度标准样品的吸光度,以样品浓度为横坐标,吸光度为纵坐标,绘制浓度-吸光度散点图建立样品标准曲线,计算实际样品的浓度。S04: Calculate the absorbance of the sample through the image gray value inversion model, obtain the absorbance of standard samples with different concentrations according to the test, take the sample concentration as the abscissa and the absorbance as the ordinate, draw a concentration-absorbance scatter diagram to establish a sample standard curve, Calculate the concentration of the actual sample.
优选的技术方案中,所述步骤S02中选定图像的有效图像区域包括以下步骤:In a preferred technical solution, the effective image area of the image selected in the step S02 includes the following steps:
S21:设定多个大于等于2×2的颜色块信息,在RGB图像上获取连续满足条件的颜色点组成的颜色块,记录颜色块的位置信息(x,y);S21: Set a plurality of color block information greater than or equal to 2×2, obtain color blocks composed of consecutive color points that meet the conditions on the RGB image, and record the position information (x, y) of the color blocks;
S22:将所有颜色块的位置取并集得到xmax、xmin、ymax、ymin,通过这四点确定一个矩形区域,在此矩形区域的基础上缩放光谱衍射垂直方向y的坐标大小,缩放公式如下:S22: Take the union of the positions of all color blocks to obtain x max , x min , y max , y min , determine a rectangular area through these four points, and scale the coordinate size of the vertical direction y of the spectral diffraction on the basis of this rectangular area, The scaling formula is as follows:
(y1,y2)=(ymax-(ymax-ymin)/a,ymin+(ymax-ymin)/a)(y 1 ,y 2 )=(y max -(y max -y min )/a,y min +(y max -y min )/a)
其中y1,y2为缩放后的坐标;a为设置的缩放倍数,a不能小于2;Among them, y 1 and y 2 are the coordinates after scaling; a is the set scaling factor, and a cannot be less than 2;
S23:有效图像区域为(xmax,y1),(xmin,y1),(xmax,y2),(xmin,y2)这四点确定的矩形区域。S23: The effective image area is a rectangular area determined by four points (x max , y 1 ), (x min , y 1 ), (x max , y 2 ), and (x min , y 2 ).
优选的技术方案中,所述步骤S03中RGB值转化为灰度值的公式如下:In a preferred technical solution, the formula for converting RGB values into gray values in step S03 is as follows:
Gray=(Rvalue+Gvalue+Bvalue)/3Gray=(R value +G value +B value )/3
其中Gray为灰度值,Rvalue、Gvalue、Bvalue为R、G、B各分量的值;Among them, Gray is the grayscale value, and R value , G value , and B value are the values of each component of R, G, and B;
优选的技术方案中,将获得的灰度值二维矩阵降为一维,计算光谱衍射垂直方向的灰度值平均值,灰度平均值的计算公式如下:In a preferred technical solution, the obtained two-dimensional matrix of gray values is reduced to one dimension, and the average value of gray values in the vertical direction of spectral diffraction is calculated. The calculation formula of the average value of gray values is as follows:
其中,为灰度平均值,n为y1-y2,i为y2到y1之间的坐标值;in, is the average value of grayscale, n is y 1 -y 2 , i is the coordinate value between y 2 and y 1 ;
用计算得到的沿光谱衍射方向的一维矩阵绘制灰度值-像素曲线图。The gray value-pixel plot is plotted with the calculated one-dimensional matrix along the spectral diffraction direction.
优选的技术方案中,所述步骤S04中将未经过样品生成的光谱图像区域中灰度最大值作为入射光强,经过样品生成的光谱图像区域中灰度最大值作为出射光强,图像灰度值反演模型计算公式如下:In a preferred technical solution, in the step S04, the maximum gray value in the spectral image region generated without the sample is taken as the incident light intensity, and the gray maximum value in the spectral image region generated by the sample is taken as the outgoing light intensity, and the image gray scale The calculation formula of the value inversion model is as follows:
A=lg(1/T)=lg(gray1/gray2)A=lg(1/T)=lg(gray 1 /gray 2 )
其中,A为吸光度,T为透射比,gray1为未经过样品生成的光谱图像区域灰度最大值,gray2为经过样品生成的光谱图像区域灰度最大值。Among them, A is the absorbance, T is the transmittance, gray 1 is the maximum gray value of the spectral image area generated without the sample, and gray 2 is the maximum gray value of the spectral image area generated by the sample.
优选的技术方案中,所述步骤S04中根据最小二乘法,拟合出一条一次函数曲线,作为样品标准曲线,标准曲线公式如下:In a preferred technical solution, according to the least squares method in the step S04, a linear function curve is fitted as a sample standard curve, and the standard curve formula is as follows:
Y=aX+bY=aX+b
其中,Y为样品浓度,X为样品的吸光度,a为拟合出的斜率,b为拟合出的截距。Among them, Y is the sample concentration, X is the absorbance of the sample, a is the fitted slope, and b is the fitted intercept.
本发明还公开了一种用于智能手机光谱检测的图像信息提取与计算系统,包括:The invention also discloses an image information extraction and calculation system for smart phone spectrum detection, comprising:
光谱图像处理模块,获得光谱图像的RGB图像,并将图像旋转到统一的角度;The spectral image processing module obtains the RGB image of the spectral image, and rotates the image to a uniform angle;
有效图像区域提取模块,根据不同的样品,选定图像的有效图像区域;The effective image area extraction module selects the effective image area of the image according to different samples;
转化模块,提取选定区域中的RGB值,将区域内的RGB值转化为灰度值;The conversion module extracts the RGB values in the selected area, and converts the RGB values in the area into grayscale values;
样品标准曲线建立模块,通过图像灰度值反演模型,计算样品的吸光度,根据测试得到不同浓度标准样品的吸光度,以样品浓度为横坐标,吸光度为纵坐标,绘制浓度-吸光度散点图建立样品标准曲线,计算实际样品的浓度。The sample standard curve building module, through the image gray value inversion model, calculate the absorbance of the sample, obtain the absorbance of standard samples with different concentrations according to the test, take the sample concentration as the abscissa and the absorbance as the ordinate, draw the concentration-absorbance scatter diagram to establish Sample standard curve to calculate the concentration of the actual sample.
优选的技术方案中,所述选定图像的有效图像区域包括以下步骤:In a preferred technical solution, the effective image area of the selected image includes the following steps:
S21:设定多个大于等于2×2的颜色块信息,在RGB图像上获取连续满足条件的颜色点组成的颜色块,记录颜色块的位置信息(x,y);S21: Set a plurality of color block information greater than or equal to 2×2, obtain color blocks composed of consecutive color points that meet the conditions on the RGB image, and record the position information (x, y) of the color blocks;
S22:将所有颜色块的位置取并集得到xmax、xmin、ymax、ymin,通过这四点确定一个矩形区域,在此矩形区域的基础上缩放光谱衍射垂直方向y的坐标大小,缩放公式如下:S22: Take the union of the positions of all color blocks to obtain x max , x min , y max , y min , determine a rectangular area through these four points, and scale the coordinate size of the vertical direction y of the spectral diffraction on the basis of this rectangular area, The scaling formula is as follows:
(y1,y2)=(ymax-(ymax-ymin)/a,ymin+(ymax-ymin)/a)(y 1 ,y 2 )=(y max -(y max -y min )/a,y min +(y max -y min )/a)
其中y1,y2为缩放后的坐标;a为设置的缩放倍数,a不能小于2;Among them, y 1 and y 2 are the coordinates after scaling; a is the set scaling factor, and a cannot be less than 2;
S23:有效图像区域为(xmax,y1),(xmin,y1),(xmax,y2),(xmin,y2)这四点确定的矩形区域。S23: The effective image area is a rectangular area determined by four points (x max , y 1 ), (x min , y 1 ), (x max , y 2 ), and (x min , y 2 ).
优选的技术方案中,所述RGB值转化为灰度值的公式如下:In a preferred technical solution, the formula for converting the RGB values into grayscale values is as follows:
Gray=(Rvalue+Gvalue+Bvalue)/3Gray=(R value +G value +B value )/3
其中Gray为灰度值,Rvalue、Gvalue、Bvalue为R、G、B各分量的值;Among them, Gray is the grayscale value, and R value , G value , and B value are the values of each component of R, G, and B;
优选的技术方案中,将获得的灰度值二维矩阵降为一维,计算光谱衍射垂直方向的灰度值平均值,灰度平均值的计算公式如下:In a preferred technical solution, the obtained two-dimensional matrix of gray values is reduced to one dimension, and the average value of gray values in the vertical direction of spectral diffraction is calculated. The calculation formula of the average value of gray values is as follows:
其中,为灰度平均值,n为y1-y2,i为y2到y1之间的坐标值;in, is the average value of grayscale, n is y 1 -y 2 , i is the coordinate value between y 2 and y 1 ;
用计算得到的沿光谱衍射方向的一维矩阵绘制灰度值-像素曲线图。The gray value-pixel plot is plotted with the calculated one-dimensional matrix along the spectral diffraction direction.
与现有技术相比,本发明的优点是:Compared with the prior art, the advantages of the present invention are:
本发明针对不同的待测物质,框选出需要使用的光谱图像区域,可以减少手机的运算量,优化APP的运行速度,并且可以提升后续计算过程中数据的精确度。本发明广泛适用于可由分光光度法测试的样品,以及适用于多种型号的智能手机,算法运行简单且精确度高。According to different substances to be tested, the invention can frame and select the spectral image area to be used, which can reduce the calculation amount of the mobile phone, optimize the running speed of the APP, and improve the accuracy of the data in the subsequent calculation process. The invention is widely applicable to samples that can be tested by spectrophotometry, as well as to various types of smart phones, and the algorithm is simple to run and has high accuracy.
附图说明Description of drawings
下面结合附图及实施例对本发明作进一步描述:Below in conjunction with accompanying drawing and embodiment, the present invention is further described:
图1为本发明用于智能手机光谱检测的图像信息提取与计算方法的流程图;Fig. 1 is the flow chart of the image information extraction and calculation method used for smart phone spectrum detection of the present invention;
图2为框选出的有效图像区域;Fig. 2 is the effective image area of frame selection;
图3为灰度值-像素曲线图;FIG. 3 is a gray value-pixel curve diagram;
图4为不同浓度氨氮标准样品的灰度值曲线;Fig. 4 is the gray value curve of different concentrations of ammonia nitrogen standard samples;
图5为氨氮标准曲线。Figure 5 is the ammonia nitrogen standard curve.
具体实施方式Detailed ways
为使本发明的目的、技术方案和优点更加清楚明了,下面结合具体实施方式并参照附图,对本发明进一步详细说明。应该理解,这些描述只是示例性的,而并非要限制本发明的范围。此外,在以下说明中,省略了对公知结构和技术的描述,以避免不必要地混淆本发明的概念。In order to make the objectives, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the specific embodiments and the accompanying drawings. It should be understood that these descriptions are exemplary only and are not intended to limit the scope of the invention. Also, in the following description, descriptions of well-known structures and techniques are omitted to avoid unnecessarily obscuring the concepts of the present invention.
实施例:Example:
下面结合附图,对本发明的较佳实施例作进一步说明。The preferred embodiments of the present invention will be further described below with reference to the accompanying drawings.
本实施例以氨氮测试为例。This embodiment takes the ammonia nitrogen test as an example.
如图1所示,一种用于智能手机光谱检测的图像信息提取与计算方法,本发明的算法运行简单且精确度高,一般配置的手机即可运行,当然还可以为PAD等等其他终端设备,它包括识别并取得由外接装置生成的光谱图像,并基于手机摆放角度,调整图片角度,通过设置颜色块参数,获得有效图像区域,最终通过RGB颜色模型获得光谱衍射方向图像的灰度值,带入建立的模型中,计算出待测物(样品)的浓度。具体包含以下步骤:As shown in Figure 1, an image information extraction and calculation method for smartphone spectral detection, the algorithm of the present invention is simple to operate and has high accuracy, and can be run by a mobile phone with a general configuration, and of course other terminals such as PAD can also be used. The device includes identifying and obtaining the spectral image generated by the external device, adjusting the picture angle based on the placement angle of the mobile phone, obtaining the effective image area by setting the color block parameters, and finally obtaining the grayscale of the spectral diffraction direction image through the RGB color model. The value is brought into the established model to calculate the concentration of the analyte (sample). Specifically includes the following steps:
1)将手机拍摄到的图像投影到二维canvas画布上,获得RGB图像;1) Project the image captured by the mobile phone onto a two-dimensional canvas to obtain an RGB image;
2)从手机相机中调取图像旋转角度信息,将canvas画布上的RGB图像旋转到统一设定的角度;2) Retrieve the image rotation angle information from the mobile phone camera, and rotate the RGB image on the canvas to the uniformly set angle;
3)针对不同的待测物质,框选出需要使用的光谱图像区域,可以减少手机的运算量,优化APP的运行速度,并且可以提升后续计算过程中数据的精确度。此过程的核心是使用tracking.js数据库,在设定的颜色块参数的基础上判断出颜色块在整个图像上的位置,具体的颜色块参数可通过一个配置文件设置;3) For different substances to be tested, the spectral image area to be used can be selected by box, which can reduce the calculation amount of the mobile phone, optimize the running speed of the APP, and improve the accuracy of the data in the subsequent calculation process. The core of this process is to use the tracking.js database to determine the position of the color block on the entire image based on the set color block parameters. The specific color block parameters can be set through a configuration file;
3.1)配置文件通过设定多个大于等于2×2的颜色块信息(RGB值),在RGB图像上获取连续满足条件的颜色点组成的颜色块,记录下这些颜色快的位置信息(x,y),x为光谱衍射方向坐标,y为光谱衍射垂直方向坐标。将这些颜色块的位置取并集得到xmax、xmin、ymax、ymin,通过这四点可确定一个矩形区域,在此矩形区域的基础上缩放垂直于光谱衍射方向的坐标大小,减少光谱图像两侧与中间部分的差异带来的计算误差。具体缩放公式如下:3.1) The configuration file obtains color blocks composed of consecutive color points that meet the conditions on the RGB image by setting multiple color block information (RGB values) greater than or equal to 2×2, and records the location information of these colors (x, y), x is the coordinate of the spectral diffraction direction, and y is the vertical coordinate of the spectral diffraction. Take the union of the positions of these color blocks to obtain x max , x min , y max , y min , and a rectangular area can be determined through these four points. Computational error due to the difference between the two sides and the middle part of the spectral image. The specific scaling formula is as follows:
(y1,y2)=(ymax-(ymax-ymin)/a,ymin+(ymax-ymin)/a)(y 1 ,y 2 )=(y max -(y max -y min )/a,y min +(y max -y min )/a)
其中y1,y2为缩放后的坐标;a为根据具体情况设置的缩放倍数,a越小缩放倍数越大,a越大缩放倍数越小,a不能小于2;Among them, y 1 and y 2 are the coordinates after scaling; a is the scaling factor set according to the specific situation, the smaller a is, the larger the scaling factor is; the larger a is, the smaller the scaling factor is, and a cannot be less than 2;
3.2)(xmax,y1),(xmin,y1),(xmax,y2),(xmin,y2)为最终参与计算的矩形图像区域的四个顶点,如图2所示。3.2) (x max , y 1 ), (x min , y 1 ), (x max , y 2 ), (x min , y 2 ) are the four vertices of the rectangular image area that are finally involved in the calculation, as shown in Figure 2 Show.
4)将步骤(3)获得的图像信息转变为数字信息;4) converting the image information obtained in step (3) into digital information;
4.1)提取有效图像区域的RGB值,将区域内的RGB值转化为灰度值。RGB转灰度的算法有很多种,本方法经过尝试,选取效果最好的平均值算法,RGB转灰度值的具体公式如下:4.1) Extract the RGB values of the effective image area, and convert the RGB values in the area into grayscale values. There are many algorithms for RGB to grayscale conversion. After trying this method, the average algorithm with the best effect is selected. The specific formula of RGB to grayscale value is as follows:
Gray=(Rvalue+Gvalue+Bvalue)/3Gray=(R value +G value +B value )/3
其中Gray为灰度值,Rvalue、Gvalue、Bvalue为R、G、B各分量的值。Among them, Gray is the gray value, and R value , G value , and B value are the values of each component of R, G, and B.
4.2)将获得的灰度值二维矩阵降为一维,计算光谱衍射垂直方向的灰度值平均值,y为垂直于光谱衍射方向的坐标,灰度平均值具体计算公式如下:4.2) Reduce the obtained two-dimensional matrix of gray values to one dimension, calculate the average value of gray values in the vertical direction of spectral diffraction, y is the coordinate perpendicular to the direction of spectral diffraction, and the specific calculation formula of the average gray value is as follows:
其中,为灰度平均值,n为y1-y2,i为y2到y1之间的坐标值;in, is the average value of grayscale, n is y 1 -y 2 , i is the coordinate value between y 2 and y 1 ;
用计算得到的沿光谱衍射方向的一维矩阵做出灰度值-像素曲线图,如图3所示,此曲线图包含上述选图范围内的灰度平均值;Use the calculated one-dimensional matrix along the spectral diffraction direction to make a gray value-pixel curve, as shown in Figure 3, this curve includes the gray average value within the above selection range;
5)运用图像灰度值反演模型,建立样品标准曲线;5) Use the image gray value inversion model to establish the sample standard curve;
5.1)图像灰度值反演模型模拟朗伯—比尔定律,为使信号响应值最大,将未经过样品生成的光谱图像区域中灰度最大值作为入射光强,经过样品生成的光谱图像区域中灰度最大值作为出射光强,模型计算公式如下:5.1) The image gray value inversion model simulates the Lambert-Beer law. In order to maximize the signal response value, the maximum gray value in the spectral image area generated without the sample is taken as the incident light intensity, and in the spectral image area generated by the sample. The maximum gray value is used as the outgoing light intensity, and the model calculation formula is as follows:
A=lg(1/T)=lg(gray1/gray2)A=lg(1/T)=lg(gray 1 /gray 2 )
其中,A为吸光度,T为透射比,gray1为未经过样品生成的光谱图像区域灰度最大值,gray2为经过样品生成的光谱图像区域灰度最大值;Among them, A is the absorbance, T is the transmittance, gray 1 is the maximum gray value of the spectral image region generated without the sample, and gray 2 is the maximum gray value of the spectral image region generated by the sample;
5.2)测试出不同浓度标准样品的吸光度,如图4所示,其中黑色方框为框选出的有效区域,I0为为未经过样品生成的光谱图像的灰度值曲线,0-2为经过不同浓度标准样品生成的光谱图像的灰度值曲线。5.2) Test the absorbance of standard samples with different concentrations, as shown in Figure 4, where the black box is the effective area selected by the box, I0 is the gray value curve of the spectral image generated without the sample, 0-2 is the after Gray value curves of spectral images generated from standard samples with different concentrations.
以样品浓度为横坐标,吸光度为纵坐标,做出浓度—吸光度散点图,根据最小二乘法,拟合出一条一次函数曲线,该曲线即为样品的标准曲线,如图5所示。标准曲线公式如下:Taking the sample concentration as the abscissa and the absorbance as the ordinate, draw a concentration-absorbance scattergram, and fit a linear function curve according to the least squares method, which is the standard curve of the sample, as shown in Figure 5. The standard curve formula is as follows:
Y=aX+bY=aX+b
其中,Y为样品浓度,X为样品的吸光度,a为拟合出的斜率,b为拟合出的截距;Among them, Y is the sample concentration, X is the absorbance of the sample, a is the fitted slope, and b is the fitted intercept;
将测试得到的实际样品吸光度值代入标准曲线,即可算出实际样品的浓度。Substitute the absorbance value of the actual sample obtained by the test into the standard curve to calculate the concentration of the actual sample.
应当理解的是,本发明的上述具体实施方式仅仅用于示例性说明或解释本发明的原理,而不构成对本发明的限制。因此,在不偏离本发明的精神和范围的情况下所做的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。此外,本发明所附权利要求旨在涵盖落入所附权利要求范围和边界、或者这种范围和边界的等同形式内的全部变化和修改例。It should be understood that the above-mentioned specific embodiments of the present invention are only used to illustrate or explain the principle of the present invention, but not to limit the present invention. Therefore, any modifications, equivalent replacements, improvements, etc. made without departing from the spirit and scope of the present invention should be included within the protection scope of the present invention. Furthermore, the appended claims of this invention are intended to cover all changes and modifications that fall within the scope and boundaries of the appended claims, or the equivalents of such scope and boundaries.
Claims (8)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910914772.9A CN110487737B (en) | 2019-09-26 | 2019-09-26 | Image information extraction and calculation method and system for spectrum detection of smart phone |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910914772.9A CN110487737B (en) | 2019-09-26 | 2019-09-26 | Image information extraction and calculation method and system for spectrum detection of smart phone |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110487737A CN110487737A (en) | 2019-11-22 |
CN110487737B true CN110487737B (en) | 2020-09-04 |
Family
ID=68544347
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910914772.9A Active CN110487737B (en) | 2019-09-26 | 2019-09-26 | Image information extraction and calculation method and system for spectrum detection of smart phone |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110487737B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110887761A (en) * | 2019-12-07 | 2020-03-17 | 宁夏大学 | A kind of surface soil moisture content determination method and system |
CN111321078B (en) * | 2020-03-05 | 2023-12-22 | 吉林大学 | Cell culture box, control method thereof and culture dish |
CN111986113B (en) * | 2020-08-20 | 2024-03-22 | 浙江理工大学 | A method and system for eliminating light and shadow in optical images |
CN113640225B (en) * | 2021-08-23 | 2024-04-19 | 广西埃索凯新材料科技有限公司 | Sulfuric acid concentration monitoring system applied to manganese sulfate production |
CN116309505B (en) * | 2023-03-28 | 2024-04-05 | 北京理工大学 | A hydrogen concentration visualization image calibration system, method and detection method |
CN117074321A (en) * | 2023-08-15 | 2023-11-17 | 浙江大学 | Method for detecting chemical components of extracting solution based on infrared light information smart phone |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN202856815U (en) * | 2012-10-18 | 2013-04-03 | 深圳市中达瑞和科技有限公司 | Intelligent handset capable of acquiring high spectral image and spectrums |
CN108051434B (en) * | 2017-12-13 | 2021-03-19 | 深圳市在田翊方科技有限公司 | Color recognition-based quantitative detection method for concentration of liquid to be detected |
CN109323999B (en) * | 2018-10-24 | 2020-06-16 | 大连理工大学 | Spectrophotometric detection method based on image numerical analysis |
-
2019
- 2019-09-26 CN CN201910914772.9A patent/CN110487737B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN110487737A (en) | 2019-11-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110487737B (en) | Image information extraction and calculation method and system for spectrum detection of smart phone | |
CN102721651B (en) | Method and system for detecting moisture content of plant leaves based on multispectral images | |
Nixon et al. | Accurate device-independent colorimetric measurements using smartphones | |
CN106991679A (en) | One kind quantifies recognition methods based on cloud platform urine test paper physical signs | |
CN110926609B (en) | A Spectral Reconstruction Method Based on Sample Feature Matching | |
CN104318550A (en) | Eight-channel multi-spectral imaging data processing method | |
CN116630148B (en) | Spectral image processing method and device, electronic equipment and storage medium | |
CN111750994B (en) | A Spectral Measurement Method Based on Digital Camera Imaging Model | |
US20230146924A1 (en) | Neural network analysis of lfa test strips | |
Wu et al. | A simple digital imaging method for estimating black-soil organic matter under visible spectrum | |
Liu et al. | On the acquisition of high-quality digital images and extraction of effective color information for soil water content testing | |
Raza et al. | Accuracy of hyperspectral imaging systems for color and lighting research | |
Meng et al. | Smartphone-based colorimetric detection platform using color correction algorithms to reduce external interference | |
CN114527116A (en) | Ambient light correction array type colorimetric analysis system and method based on intelligent equipment | |
Maksimainen et al. | Calculation of mesopic luminance using per pixel S/P ratios measured with digital imaging | |
CN113272639B (en) | Method for extracting spectral information of substance to be detected | |
CN104880422B (en) | A kind of characterization method of visualized array sensor | |
Skauli et al. | Simplified measurement of point spread functions of hyperspectral cameras for assessment of spatial coregistration | |
WO2023004904A1 (en) | On-chip integrated mobile phone spectrometer and mobile phone | |
Medberry et al. | Overview of digital electrophoresis analysis | |
Wu et al. | Recovering sensor spectral sensitivity from raw data | |
Moomaw et al. | Overview of digital electrophoresis analysis | |
Javoršek et al. | Comparison of two digital cameras based on spectral data estimation obtained with two methods | |
WO2020241111A1 (en) | Image processing method, image processing device, imaging system, and program | |
Heng et al. | MatSpectNet: Material Segmentation Network with Domain-Aware and Physically-Constrained Hyperspectral Reconstruction |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right | ||
TR01 | Transfer of patent right |
Effective date of registration: 20221129 Address after: 215000 2F, building 1, No. 100, Guangqi Road, high tech Zone, Suzhou City, Jiangsu Province Patentee after: Suzhou Aopu Smart Core Technology Co.,Ltd. Address before: 215000 building 16, 158 Jinfeng Road, science and Technology City, Suzhou high tech Zone, Jiangsu Province Patentee before: RESEARCH INSTITUTE FOR ENVIRONMENTAL INNOVATION (SUZHOU) TSINGHUA Patentee before: TSINGHUA University |