CN110400278B - A fully automatic correction method, device and equipment for image color and geometric distortion - Google Patents
A fully automatic correction method, device and equipment for image color and geometric distortion Download PDFInfo
- Publication number
- CN110400278B CN110400278B CN201910695090.3A CN201910695090A CN110400278B CN 110400278 B CN110400278 B CN 110400278B CN 201910695090 A CN201910695090 A CN 201910695090A CN 110400278 B CN110400278 B CN 110400278B
- Authority
- CN
- China
- Prior art keywords
- image
- color
- card
- gray
- image information
- 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
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/90—Dynamic range modification of images or parts thereof
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/80—Geometric correction
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/80—Analysis of captured images to determine intrinsic or extrinsic camera parameters, i.e. camera calibration
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/10—Image acquisition modality
- G06T2207/10024—Color image
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/30—Subject of image; Context of image processing
- G06T2207/30196—Human being; Person
- G06T2207/30201—Face
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Image Processing (AREA)
- Image Analysis (AREA)
Abstract
本发明公开了一种图像颜色和几何畸变的全自动校正方法,获取包含目标物和扩展二维码的图像信息;对扩展二维码的定位标志进行识别并计算,得到相机外参;根据相机外参对目标物图像进行三维转动和平移转换;对扩展二维码的颜色卡的边缘和灰度卡的边缘进行模式拟合,得出计算相机内参;利用相机内参对目标物图像进行镜头几何畸变校正;对扩展二维码的色块和灰度块进行识别,以对目标物图像进行颜色校正和灰度校正;得到目标物的真实图像。本发明降低了图像识别的误判几率,提高了图像识别结果的准确度。本发明还公开了一种图像颜色和几何畸变的全自动校正装置、系统及存储介质,具有相应技术效果。
The invention discloses a fully automatic correction method for image color and geometric distortion, which acquires image information including a target object and an extended two-dimensional code; identifies and calculates the positioning mark of the extended two-dimensional code to obtain camera external parameters; The external parameter performs three-dimensional rotation and translation transformation of the target image; model fitting is performed on the edge of the color card of the extended QR code and the edge of the gray card, and the internal parameters of the camera are calculated; the camera internal parameters are used to perform lens geometry on the target image. Distortion correction; identify the color blocks and gray blocks of the extended two-dimensional code to perform color correction and gray correction on the target image; obtain the real image of the target. The invention reduces the misjudgment probability of image recognition and improves the accuracy of the image recognition result. The invention also discloses an automatic correction device, system and storage medium for image color and geometric distortion, which have corresponding technical effects.
Description
技术领域technical field
本发明涉及图像处理技术领域,特别是涉及一种图像颜色和几何畸变的全自动校正方法、装置、系统及计算机可读存储介质。The present invention relates to the technical field of image processing, in particular to a fully automatic correction method, device, system and computer-readable storage medium for image color and geometric distortion.
背景技术Background technique
当前的人工智能技术发展迅速,其中的计算机视觉技术更是应用广泛。在利用图像采集设备进行图像拍摄时,由于使用的照明灯光的差异,拍射时相机角度的不同,摄像头几何畸变的存在等,使得图像采集设备采集的图像存在较强的颜色、灰度和几何畸变。如果不能校准这些畸变和扭曲,将造成对图像识别的误判几率增加,会对图像识别结果产生比较大的误差。The current artificial intelligence technology is developing rapidly, and the computer vision technology is widely used. When using an image acquisition device to capture images, due to the difference in the lighting used, the different angles of the camera when shooting, the existence of geometric distortion of the camera, etc., the images captured by the image capture device have strong color, grayscale and geometric distortion. If these distortions and distortions cannot be calibrated, the probability of misjudgment of image recognition will increase, which will result in relatively large errors in image recognition results.
综上所述,如何有效地解决图像的颜色、灰度和几何畸变对图像识别结果产生比较大的误差等问题,是目前本领域技术人员急需解决的问题。To sum up, how to effectively solve the problem that the color, grayscale and geometric distortion of the image cause a relatively large error in the image recognition result is an urgent problem for those skilled in the art.
发明内容SUMMARY OF THE INVENTION
本发明的目的是提供一种图像颜色和几何畸变的全自动校正方法,该方法较大地降低了图像识别的误判几率,较大地提高了图像识别结果的准确度;本发明的另一目的是提供一种图像颜色和几何畸变的全自动校正装置、系统及计算机可读存储介质。The purpose of the present invention is to provide a fully automatic correction method for image color and geometric distortion, which greatly reduces the misjudgment probability of image recognition and greatly improves the accuracy of image recognition results; another purpose of the present invention is A fully automatic correction device, system and computer-readable storage medium for image color and geometric distortion are provided.
为解决上述技术问题,本发明提供如下技术方案:In order to solve the above-mentioned technical problems, the present invention provides the following technical solutions:
一种图像颜色和几何畸变的全自动校正方法,包括:A fully automatic correction method for image color and geometric distortion, including:
获取包含目标物和扩展二维码的图像信息;其中,所述扩展二维码包括由多个不同颜色区域构成的颜色卡,由多个不同灰度区域构成的灰度卡,包含定位标志的二维码;Obtain the image information including the target object and the extended two-dimensional code; wherein, the extended two-dimensional code includes a color card composed of a plurality of different color regions, a grayscale card composed of a plurality of different grayscale regions, and an image containing a positioning mark. QR code;
对所述图像信息中所述扩展二维码的所述定位标志进行识别并计算,得到相机外参;根据所述相机外参对所述图像信息中所述目标物对应的目标物图像进行三维转动和平移变换,得到转动和平移修正后图像;Identify and calculate the positioning mark of the extended two-dimensional code in the image information to obtain camera external parameters; perform a three-dimensional image of the target object corresponding to the target object in the image information according to the camera external parameters Rotation and translation transformation to get the image after rotation and translation correction;
通过对所述图像信息中所述扩展二维码的所述颜色卡的边缘和所述灰度卡的边缘进行模式拟合,利用镜头畸变模型计算相机内参;利用所述相机内参对所述转动和平移修正后图像的镜头几何畸变进行校正,得到镜头几何畸变校正后图像;By performing pattern fitting on the edge of the color card of the extended two-dimensional code and the edge of the gray card in the image information, the camera internal parameters are calculated by using the lens distortion model; Correct the lens geometric distortion of the image after translation correction to obtain the image after lens geometric distortion correction;
对所述图像信息中所述颜色卡的色块和所述灰度卡的灰度块进行识别,得到识别结果;根据所述识别结果对所述镜头几何畸变校正后图像进行颜色校正和灰度校正,得到所述目标物的真实图像。Identify the color blocks of the color card and the grayscale blocks of the grayscale card in the image information to obtain a recognition result; perform color correction and grayscale on the image after the lens geometric distortion correction according to the recognition result Correction to obtain the real image of the target.
在本发明的一种具体实施方式中,所述定位标志包括分别位于所述扩展二维码三个角黑白相间的三个位置标识符,对所述图像信息中所述扩展二维码的所述定位标志进行识别并计算,得到相机外参,包括:In a specific embodiment of the present invention, the positioning mark includes three position identifiers that are respectively located at three corners of the extended two-dimensional code in black and white. Identify and calculate the positioning marks to obtain the camera external parameters, including:
分别计算所述定位标志中三个所述位置标识符的中心点坐标;Calculate the coordinates of the center points of the three position identifiers in the positioning marks respectively;
利用三个所述位置标识符的几何关系及各所述位置标识符在所述图像信息中的位置,计算所述图像信息的逆透视变换矩阵,得到所述相机外参。Using the geometric relationship of the three position identifiers and the position of each of the position identifiers in the image information, an inverse perspective transformation matrix of the image information is calculated to obtain the camera extrinsic parameters.
在本发明的一种具体实施方式中,通过对所述图像信息中所述扩展二维码的所述颜色卡的边缘和所述灰度卡的边缘进行模式拟合,利用镜头畸变模型计算相机内参,包括:In a specific embodiment of the present invention, by performing pattern fitting on the edge of the color card and the edge of the gray card of the extended two-dimensional code in the image information, the camera is calculated by using the lens distortion model. Internal reference, including:
通过对所述图像信息中所述扩展二维码的所述颜色卡的边缘和所述灰度卡的边缘进行模式拟合,结合镜头畸变模型和最陡速降算法计算相机内参。By performing pattern fitting on the edge of the color card and the edge of the gray card of the extended two-dimensional code in the image information, the camera internal parameters are calculated in combination with the lens distortion model and the steepest descent algorithm.
在本发明的一种具体实施方式中,对所述图像信息中所述颜色卡的色块和所述灰度卡的灰度块进行识别,包括:In a specific embodiment of the present invention, identifying the color blocks of the color card and the gray blocks of the gray card in the image information includes:
利用多项式回归法对所述图像信息中所述颜色卡的色块和所述灰度卡的灰度块进行识别。A polynomial regression method is used to identify the color blocks of the color card and the gray blocks of the gray card in the image information.
在本发明的一种具体实施方式中,对所述图像信息中所述颜色卡的色块和所述灰度卡的灰度块进行识别,包括:In a specific embodiment of the present invention, identifying the color blocks of the color card and the gray blocks of the gray card in the image information includes:
利用BP神经网络法对所述图像信息中所述颜色卡的色块和灰度卡的灰度块进行识别。The BP neural network method is used to identify the color blocks of the color card and the gray blocks of the gray card in the image information.
在本发明的一种具体实施方式中,对所述图像信息中所述颜色卡的色块和所述灰度卡的灰度块进行识别,包括:In a specific embodiment of the present invention, identifying the color blocks of the color card and the gray blocks of the gray card in the image information includes:
利用支持向量机算法对所述图像信息中所述颜色卡的色块和所述灰度卡的灰度块进行识别。A support vector machine algorithm is used to identify the color blocks of the color card and the gray blocks of the gray scale in the image information.
一种图像颜色和几何畸变的全自动校正装置,包括:A fully automatic correction device for image color and geometric distortion, comprising:
图像信息获取模块,用于获取包含目标物和扩展二维码的图像信息;其中,所述扩展二维码包括由多个不同颜色区域构成的颜色卡,由多个不同灰度区域构成的灰度卡,包含定位标志的二维码;The image information acquisition module is used to acquire the image information including the target object and the extended two-dimensional code; wherein, the extended two-dimensional code includes a color card composed of a plurality of different color regions, and a gray scale composed of a plurality of different grayscale regions. Degree card, a QR code containing a positioning mark;
倾斜扭曲校正模块,用于对所述图像信息中所述扩展二维码的所述定位标志进行识别并计算,得到相机外参;根据所述相机外参对所述图像信息中所述目标物对应的目标物图像进行三维转动和平移变换,得到转动和平移修正后图像;a tilt distortion correction module, used for identifying and calculating the positioning mark of the extended two-dimensional code in the image information, to obtain camera external parameters; according to the camera external parameters, the target object in the image information The corresponding target image is subjected to three-dimensional rotation and translation transformation to obtain an image after rotation and translation correction;
镜头几何畸变校正模块,用于通过对所述图像信息中所述扩展二维码的所述颜色卡的边缘和所述灰度卡的边缘进行模式拟合,利用镜头畸变模型计算相机内参;利用所述相机内参对所述转动和平移修正后图像的镜头几何畸变进行校正,得到镜头几何畸变校正后图像;a lens geometric distortion correction module, configured to perform mode fitting on the edge of the color card of the extended two-dimensional code in the image information and the edge of the gray card, and use the lens distortion model to calculate the camera internal parameters; using The camera internal parameter corrects the lens geometric distortion of the image after rotation and translation correction to obtain an image after lens geometric distortion correction;
真实图像获得模块,用于对所述图像信息中所述颜色卡的色块和所述灰度卡的灰度块进行识别,得到识别结果;根据所述识别结果对所述镜头几何畸变校正后图像进行颜色校正和灰度校正,得到所述目标物的真实图像,以便根据所述真实图像对所述目标物对应的患者进行诊断。A real image obtaining module is used to identify the color blocks of the color card and the gray blocks of the gray scale card in the image information, and obtain the identification result; after correcting the geometric distortion of the lens according to the identification result The image is subjected to color correction and grayscale correction to obtain a real image of the target, so that a patient corresponding to the target can be diagnosed according to the real image.
一种图像颜色和几何畸变的全自动校正系统,包括扩展二维码、图像采集设备、图像预处理终端及服务器,所述扩展二维码包括由多个不同色块构成的颜色卡,由多个不同灰度块构成的灰度卡,包含定位标志的二维码;其中:An automatic correction system for image color and geometric distortion, comprising an extended two-dimensional code, an image acquisition device, an image preprocessing terminal and a server, the extended two-dimensional code includes a color card composed of a plurality of different color blocks, A grayscale card composed of different grayscale blocks, including the QR code of the positioning mark; of which:
所述图像采集设备,用于获取所述扩展二维码和目标物的图像信息;并将所述图像信息发送给所述图像预处理终端;The image acquisition device is used to acquire the image information of the extended two-dimensional code and the target object; and send the image information to the image preprocessing terminal;
所述图像预处理终端,用于对所述图像信息中所述扩展二维码的所述定位标志进行识别并计算,得到相机外参;根据所述相机外参对所述图像信息中所述目标物对应的目标物图像进行三维转动和平移变换,得到转动和平移修正后图像;并将所述转动和平移修正后图像发送给所述服务器;The image preprocessing terminal is configured to identify and calculate the positioning mark of the extended two-dimensional code in the image information, and obtain camera external parameters; Performing three-dimensional rotation and translation transformation on the image of the target object corresponding to the target to obtain an image after rotation and translation correction; and sending the rotation and translation corrected image to the server;
所述服务器,用于通过对所述图像信息中所述扩展二维码的所述颜色卡的边缘和所述灰度卡的边缘进行模式拟合,利用镜头畸变模型计算相机内参;利用所述相机内参对所述转动和平移修正后图像的镜头几何畸变进行校正,得到镜头几何畸变校正后图像;对所述图像信息中所述颜色卡的色块和所述灰度卡的灰度块进行识别,得到识别结果;根据所述识别结果对所述镜头几何畸变校正后图像进行颜色校正和灰度校正,得到所述目标物的真实图像,根据所述真实图像对所述目标物对应的患者进行诊断。The server is configured to perform mode fitting on the edge of the color card of the extended two-dimensional code in the image information and the edge of the gray card, and use the lens distortion model to calculate the camera internal parameters; use the The camera internal parameter corrects the lens geometric distortion of the image after rotation and translation correction to obtain an image after lens geometric distortion correction; Recognition to obtain a recognition result; color correction and grayscale correction are performed on the image after geometric distortion correction of the lens according to the recognition result to obtain the real image of the target, and the patient corresponding to the target is determined according to the real image. Diagnose.
在本发明的一种具体实施方式中,所述定位标志包括分别位于所述扩展二维码三个角黑白相间的三个位置标识符,In a specific embodiment of the present invention, the positioning mark includes three position identifiers that are located in black and white at three corners of the extended two-dimensional code, respectively,
所述图像预处理终端,具体用于分别计算所述定位标志中三个所述位置标识符的中心点坐标;利用三个所述位置标识符的几何关系及各所述位置标识符在所述图像信息中的位置,计算所述图像信息的逆透视变换矩阵,得到所述相机外参。The image preprocessing terminal is specifically configured to calculate the center point coordinates of the three position identifiers in the positioning mark respectively; The position in the image information is calculated, and the inverse perspective transformation matrix of the image information is calculated to obtain the camera extrinsic parameters.
一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如前所述图像颜色和几何畸变的全自动校正方法的步骤。A computer-readable storage medium having a computer program stored on the computer-readable storage medium, when the computer program is executed by a processor, realizes the steps of the fully automatic correction method for image color and geometric distortion as described above.
本发明提供了一种图像颜色和几何畸变的全自动校正方法:获取包含目标物和扩展二维码的图像信息;其中,扩展二维码包括由多个不同色块构成的颜色卡,由多个不同灰度块构成的灰度卡,包含定位标志的二维码;对图像信息中扩展二维码的定位标志进行识别并计算,得到相机外参;根据相机外参对图像信息中目标物对应的目标物图像进行三维转动和平移变换,得到转动和平移修正后图像;通过对图像信息中扩展二维码的颜色卡的边缘和灰度卡的边缘进行模式拟合,利用镜头畸变模型计算相机内参;利用相机内参对转动和平移修正后图像的镜头几何畸变进行校正,得到镜头几何畸变校正后图像;对图像信息中颜色卡的色块和灰度卡的灰度块进行识别,得到识别结果;根据识别结果对镜头几何畸变校正后图像进行颜色校正和灰度校正,得到目标物的真实图像。The invention provides an automatic correction method for image color and geometric distortion: acquiring image information including a target object and an extended two-dimensional code; wherein, the extended two-dimensional code includes a color card composed of a plurality of different color blocks, which are composed of multiple A grayscale card composed of different grayscale blocks, including the two-dimensional code of the positioning mark; identify and calculate the positioning mark of the extended two-dimensional code in the image information to obtain the camera external parameters; according to the camera external parameters, the target object in the image information is identified and calculated The corresponding target image is transformed by three-dimensional rotation and translation, and the image after rotation and translation correction is obtained; by pattern fitting the edge of the color card and the edge of the gray card in the image information, the lens distortion model is used to calculate Camera internal parameters; use the camera internal parameters to correct the lens geometric distortion of the image after rotation and translation correction, and obtain the image after lens geometric distortion correction; identify the color blocks of the color card and the gray blocks of the gray card in the image information, and get the recognition Results: According to the recognition results, color correction and grayscale correction are performed on the image after lens geometric distortion correction, and the real image of the target object is obtained.
通过上述技术方案可知,通过预先设置包括由多个不同色块构成的颜色卡,由多个不同灰度块构成的灰度卡,包含定位标志的二维码的扩展二维码,获取包含扩展二维码和目标物的图像信息,利用扩展二维码得到相机外参,完成对目标物图像的转动和平移修正;利用镜头畸变模型计算相机内参,完成对目标物图像的镜头几何畸变校正;通过对图像信息中颜色卡的色块和灰度卡的灰度块进行识别,完成对目标物图像的颜色校正和灰度校正。最终得到真实图像,从而能够基于真实图像进行图像识别,较大地降低了图像识别的误判几率,较大地提高了图像识别结果的准确度。It can be seen from the above technical solutions that by presetting a color card composed of a plurality of different color blocks, a gray scale card composed of a plurality of different gray blocks, and an extended two-dimensional code containing a two-dimensional code of a positioning mark, the extended two-dimensional code containing the extended two-dimensional code can be obtained. The two-dimensional code and the image information of the target object, use the extended two-dimensional code to obtain the camera external parameters, complete the rotation and translation correction of the target object image; use the lens distortion model to calculate the camera internal parameters, complete the lens geometric distortion correction of the target object image; By identifying the color blocks of the color card and the gray blocks of the gray scale in the image information, the color correction and gray scale correction of the target image are completed. Finally, a real image is obtained, so that image recognition can be performed based on the real image, which greatly reduces the misjudgment probability of image recognition and greatly improves the accuracy of the image recognition result.
相应的,本发明实施例还提供了与上述图像颜色和几何畸变的全自动校正方法相对应的图像颜色和几何畸变的全自动校正装置、系统和计算机可读存储介质,具有上述技术效果,在此不再赘述。Correspondingly, the embodiments of the present invention also provide a fully automatic correction device, system and computer-readable storage medium for image color and geometric distortion corresponding to the above-mentioned automatic correction method for image color and geometric distortion, which have the above technical effects. This will not be repeated here.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to explain the embodiments of the present invention or the technical solutions in the prior art more clearly, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained according to these drawings without creative efforts.
图1为本发明实施例中图像颜色和几何畸变的全自动校正方法的一种实施流程图;Fig. 1 is a kind of implementation flow chart of the automatic correction method of image color and geometric distortion in the embodiment of the present invention;
图2为本发明实施例中一种扩展二维码的结构示意图;2 is a schematic structural diagram of an extended two-dimensional code in an embodiment of the present invention;
图3为本发明实施例中获取的一种包含目标物和扩展二维码的图像的结构图;3 is a structural diagram of an image containing a target and an extended two-dimensional code obtained in an embodiment of the present invention;
图4为本发明实施例中图像颜色和几何畸变的全自动校正方法的另一种实施流程图;4 is another implementation flow chart of the fully automatic correction method for image color and geometric distortion in the embodiment of the present invention;
图5为本发明实施例中图像颜色和几何畸变的全自动校正方法的另一种实施流程图;5 is another implementation flow chart of the fully automatic correction method for image color and geometric distortion in the embodiment of the present invention;
图6为本发明实施例中一种BP神经网络的结构图;6 is a structural diagram of a BP neural network in an embodiment of the present invention;
图7为本发明实施例中图像颜色和几何畸变的全自动校正方法的另一种实施流程图;7 is another implementation flow chart of the fully automatic correction method for image color and geometric distortion in the embodiment of the present invention;
图8为本发明实施例中一种图像颜色和几何畸变的全自动校正装置的结构框图;8 is a structural block diagram of a fully automatic correction device for image color and geometric distortion in an embodiment of the present invention;
图9为本发明实施例中一种图像颜色和几何畸变的全自动校正系统的结构框图;9 is a structural block diagram of a fully automatic correction system for image color and geometric distortion in an embodiment of the present invention;
图10为本发明实施例中一种图像颜色和几何畸变的全自动校正系统的示意图。FIG. 10 is a schematic diagram of a fully automatic correction system for image color and geometric distortion in an embodiment of the present invention.
附图中标记如下:The figures are marked as follows:
11-图像、21-相机、22-摄像机、23-用户移动终端、31-客户端、4-服务器。11-image, 21-camera, 22-camera, 23-user mobile terminal, 31-client, 4-server.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本发明方案,下面结合附图和具体实施方式对本发明作进一步的详细说明。显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make those skilled in the art better understand the solution of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some, but not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
实施例一:Example 1:
参见图1,图1为本发明实施例中图像颜色和几何畸变的全自动校正方法的一种实施流程图,该方法可以包括以下步骤:Referring to FIG. 1, FIG. 1 is an implementation flowchart of an automatic correction method for image color and geometric distortion in an embodiment of the present invention, and the method may include the following steps:
S101:获取包含目标物和扩展二维码的图像信息。S101: Acquire image information including a target object and an extended two-dimensional code.
其中,扩展二维码包括由多个不同颜色区域构成的颜色卡,由多个不同灰度区域构成的灰度卡,包含定位标志的二维码。Wherein, the extended two-dimensional code includes a color card composed of a plurality of different color regions, a grayscale card composed of a plurality of different gray-scale regions, and a two-dimensional code including a positioning mark.
参见图2,图2为本发明实施例中一种扩展二维码的结构示意图。可以预先设置包括由多个不同颜色区域构成的颜色卡,由多个不同灰度区域构成的灰度卡,包含定位标志的二维码的扩展二维码。二维码也就是QR(Quick Response)Code,其具有全方位(360°)识读特点,二维码自身具有由三个黑白相间的大正方形嵌套组成的定位标志,分别位于二维码左上角、右上角、左下角,目的是为了确定二维码的大小和位置。由三个黑白相间的小正方形嵌套组成的校正标志和由两条黑白相间的直线组成的定时标志,便于确定二维码的位置和转动角。在二维码的下面增加颜色卡和灰度卡,颜色卡由多个不同颜色的矩形构成,而灰度卡采用自制的多阶灰度卡,由不同灰度的矩形构成,灰度卡的设计由第1阶接上第n阶再接第2阶的顺序排列,这样排列的灰度卡可以在后期更好的聚类计算并分离每块灰度块。不同的颜色和不同的灰度,使用黑色的边界划分,使得计算机视觉可容易地提取颜色、灰度和划分不同颜色和灰度的格子。颜色、灰度用于系统的颜色和灰度校正,格子则用于校正镜头的几何畸变。灰度卡与一般的灰度渐变不一样,灰度分为多个离散的色阶,从白色渐变到黑色。Referring to FIG. 2, FIG. 2 is a schematic structural diagram of an extended two-dimensional code in an embodiment of the present invention. An extended two-dimensional code including a color card composed of a plurality of different color regions, a grayscale card composed of a plurality of different gray-scale regions, and a two-dimensional code containing a positioning mark can be preset. The two-dimensional code is also called QR (Quick Response) Code, which has the characteristics of omnidirectional (360°) reading. The two-dimensional code itself has a positioning mark composed of three black and white large squares, which are located on the upper left of the two-dimensional code. Corner, upper right corner, lower left corner, the purpose is to determine the size and position of the QR code. The calibration mark composed of three black and white small squares nested and the timing mark composed of two black and white straight lines are easy to determine the position and rotation angle of the QR code. Add a color card and a grayscale card below the QR code. The color card is composed of multiple rectangles of different colors, while the grayscale card adopts a self-made multi-level grayscale card, which is composed of rectangles of different grayscales. The design is arranged in the order of the first order followed by the nth order and then the second order, so that the grayscale cards arranged in this way can be better clustered in the later stage to calculate and separate each grayscale block. Different colors and different grayscales are divided using black borders, making it easy for computer vision to extract colors, grayscales, and divide grids of different colors and grayscales. Color and grayscale are used for color and grayscale correction of the system, and lattice is used to correct the geometric distortion of the lens. The grayscale card is different from the general grayscale gradient, and the grayscale is divided into multiple discrete color levels, graduating from white to black.
在需要采集目标物的照片或视频时,可以在目标物旁边放置一个本发明实施例所提供的扩展二维码,目标物与扩展二维码两者之间保持适当的距离,获取包含目标物和扩展二维码的图像信息。参见图3,图3为本发明实施例中获取的一种包含目标物和扩展二维码的图像的结构图。图3中是获取人脸的图像信息,在人脸旁放置一个本发明实施例所提供的扩展二维码,获取包含人脸和扩展二维码的图像信息。When a photo or video of a target needs to be collected, an extended two-dimensional code provided by the embodiment of the present invention can be placed next to the target, and an appropriate distance is maintained between the target and the extended two-dimensional code, and the target object can be obtained by placing an extended two-dimensional code provided by the embodiment of the present invention. and the image information of the extended QR code. Referring to FIG. 3 , FIG. 3 is a structural diagram of an image including a target object and an extended two-dimensional code obtained in an embodiment of the present invention. In FIG. 3, image information of a human face is acquired, an extended two-dimensional code provided by an embodiment of the present invention is placed beside the human face, and image information including the human face and the extended two-dimensional code is acquired.
颜色卡和灰度卡可以为麦克贝斯色卡,但是不限于麦克贝斯色卡。The color card and the grayscale card can be Macbeth color chips, but are not limited to Macbeth color chips.
S102:对图像信息中扩展二维码的定位标志进行识别并计算,得到相机外参;根据相机外参对图像信息中目标物对应的目标物图像进行三维转动和平移变换,得到转动和平移修正后图像。S102: Identify and calculate the positioning mark of the extended two-dimensional code in the image information to obtain camera external parameters; perform three-dimensional rotation and translation transformation on the target image corresponding to the target object in the image information according to the camera external parameters to obtain rotation and translation corrections post image.
在获取到包含目标物和扩展二维码的图像信息之后,可以对图像信息中扩展二维码的定位标志进行识别并计算,得到欧拉角和平移矢量,进而得到相机外参。根据相机外参对图像信息中目标物对应的目标物图像进行三维转动和平移变换,得到转动和平移修正后图像。After acquiring the image information including the target object and the extended two-dimensional code, the positioning marks of the extended two-dimensional code in the image information can be identified and calculated to obtain the Euler angle and translation vector, and then the camera extrinsic parameters can be obtained. According to the external parameters of the camera, three-dimensional rotation and translation transformation is performed on the target image corresponding to the target in the image information, and the image after rotation and translation correction is obtained.
S103:通过对图像信息中扩展二维码的颜色卡的边缘和灰度卡的边缘进行模式拟合,利用镜头畸变模型计算相机内参;利用相机内参对转动和平移修正后图像的镜头几何畸变进行校正,得到镜头几何畸变校正后图像。S103: By performing pattern fitting on the edge of the color card of the extended two-dimensional code and the edge of the gray card in the image information, the camera internal parameters are calculated by using the lens distortion model; Correction to obtain the image after lens geometric distortion correction.
可以通过对图像信息中扩展二维码的颜色卡的边缘和灰度卡的边缘进行模式拟合,如可以通过RANSAC方法识别颜色卡边缘和灰度卡的边缘,利用镜头畸变模型计算相机内参,利用相机内参对转动和平移修正后图像的镜头几何畸变进行校正,得到镜头几何畸变校正后图像。对于有镜头畸变的图片,只有用标定了的畸变系数和内参矩阵才能将畸变了的图片还原为无畸变的图片。利用镜头畸变模型计算相机内参的过程如下:Pattern fitting can be performed on the edge of the color card of the extended QR code and the edge of the gray card in the image information. For example, the RANSAC method can be used to identify the edge of the color card and the edge of the gray card, and the lens distortion model can be used to calculate the camera internal parameters. The camera's internal parameters are used to correct the lens geometric distortion of the image after rotation and translation correction, and the image after lens geometric distortion correction is obtained. For pictures with lens distortion, only the calibrated distortion coefficient and internal parameter matrix can be used to restore the distorted picture to an undistorted picture. The process of calculating the camera internal parameters using the lens distortion model is as follows:
首先,考虑镜头无畸变模型,用如下公式表示:First, consider the lens distortion-free model, which is expressed by the following formula:
其中,(X,Y,Z)表示世界坐标系中的一点,(u,v)表示世界坐标中的该点对应的图像平面的像素点坐标,fx、fy分别是标定出的摄像头横向和纵向焦距,u0和v0是标定出的摄像头图像中心点,R和T分别表示相机外参中的旋转矩阵和平移矩阵,zc为物点(X,Y,Z)在摄像头坐标系下的沿Z轴的坐标。Among them, (X, Y, Z) represents a point in the world coordinate system, (u, v) represents the pixel coordinates of the image plane corresponding to this point in the world coordinates, and f x and f y are the calibrated camera lateral directions, respectively. and the longitudinal focal length, u 0 and v 0 are the calibrated camera image center points, R and T respectively represent the rotation matrix and translation matrix in the camera external parameters, z c is the object point (X, Y, Z) in the camera coordinate system The coordinate along the Z axis below.
令P为:Let P be:
镜头无畸变模型变为:The lens distortion-free model becomes:
P是一个3行4列的矩阵。可以设为:P is a matrix with 3 rows and 4 columns. Can be set to:
到此,世界坐标系的点(X,Y,Z)就通过P跟像素平面坐标系下的点(u,v)建立了联系。由世界坐标下的6个已知点与它们对应的像素点坐标就可以求解得到P矩阵。在一般的标定工作中,靶标上往往不止6个已知点,使方程的个数大大超过未知数的个数,从而可以利用最小二乘法求解以降低误差造成的影响。At this point, the point (X, Y, Z) of the world coordinate system is connected to the point (u, v) in the pixel plane coordinate system through P. The P matrix can be obtained by solving the six known points in world coordinates and their corresponding pixel coordinates. In general calibration work, there are often more than 6 known points on the target, so that the number of equations greatly exceeds the number of unknowns, so that the least squares method can be used to solve the problem to reduce the influence of errors.
靶标泛指镜头标定板,或者是标定参照物,在本发明实施例中指扩展二维码。The target generally refers to a lens calibration plate, or a calibration reference, and in this embodiment of the present invention refers to an extended two-dimensional code.
P矩阵求出来了就可以反求出内外参数矩阵。假设给定n组像素坐标的点到世界坐标系下的点则镜头无畸变模型如下:Once the P matrix is obtained, the internal and external parameter matrices can be reversed. Suppose a point given n sets of pixel coordinates to a point in the world coordinate system Then the lens distortion-free model is as follows:
其中,φ(P,Mi)是物方点Mi=(Xi,Yi,Zi)由相机投影而成的像点。Wherein, φ(P, M i ) is the image point projected by the camera at the object-side point M i =(X i , Y i , Z i ).
上面考虑的是镜头无畸变模型,现在考虑加入了畸变后的镜头成像模型,加入了畸变后的镜头成像模型如下:The above considers the lens without distortion model. Now consider the lens imaging model after adding distortion. The lens imaging model after adding distortion is as follows:
其中,R和T分别代表相机外参中的旋转矩阵和平移矩阵,(x,y,z)是从三维世界坐标点变换到摄像头坐标系下的坐标。径向畸变和切向畸变表示如下:Among them, R and T respectively represent the rotation matrix and translation matrix in the camera external parameters, and (x, y, z) are the coordinates transformed from the three-dimensional world coordinate point to the camera coordinate system. Radial distortion and tangential distortion are expressed as follows:
δx1=x′(1+k1r2+k2r4+…);δ x1 =x'(1+k 1 r 2 +k 2 r 4 +...);
δy1=y′(1+k1r2+k2r4+…);δ y1 =y'(1+k 1 r 2 +k 2 r 4 +...);
δx2=[2p1xy+p2(r2+2x2)](1+p3r2+…);δ x2 =[2p 1 xy+p 2 (r 2 +2x 2 )](1+p 3 r 2 +…);
δy2=[p1(r2+2y2)+2p2xy](1+p3r2+…);δ y2 =[p 1 (r 2 +2y 2 )+2p 2 xy](1+p 3 r 2 +…);
其中,是加入了畸变量后在成像坐标系下的坐标;δx和δy是x和y方向上的畸变量,通常δx和δy包含两部分,一部分是径向畸变,另一部分是切向畸变;r2=x′2+y′2,k1和k2就是要标定的径向畸变系数,更高阶的系数一般会忽略。p1和p2就是要标定的切向畸变系数,更高阶的系数也会忽略掉。in, is the coordinate in the imaging coordinate system after adding the distortion amount; δ x and δ y are the distortion amounts in the x and y directions, usually δ x and δ y contain two parts, one part is radial distortion, and the other part is tangential Distortion; r 2 =x′ 2 +y′ 2 , k1 and k2 are radial distortion coefficients to be calibrated, and higher-order coefficients are generally ignored. p1 and p2 are the tangential distortion coefficients to be calibrated, and higher-order coefficients are also ignored.
所以总的畸变就表示如下:So the total distortion is expressed as:
δx=δx1+δx2;δ x =δ x1 +δ x2 ;
δy=δy1+δy2;δ y =δ y1 +δ y2 ;
像点坐标可以表示为:image point coordinates It can be expressed as:
设:Assume:
假设给定n组像素坐标的点到世界坐标系下的点:Suppose a point given n sets of pixel coordinates to a point in the world coordinate system:
则加入了畸变后的镜头成像模型如下:The lens imaging model after adding distortion is as follows:
其中,φ(R,T,A,k1,k2,p1,p2,Mi)是物方点Mi=(Xi,Yi,Zi)由相机投影而成的像点。Among them, φ(R,T,A,k 1 ,k 2 ,p 1 ,p 2 ,M i ) is the image point projected by the camera at the object point Mi =(X i ,Y i ,Z i ) .
上面的是一个非线性优化过程,可以用非线性优化的方法求出满足要求的解来,从而提取到上公式的内参系数,得到相机内参。The above is a nonlinear optimization process. The nonlinear optimization method can be used to find a solution that meets the requirements, so as to extract the internal parameter coefficients of the above formula and obtain the camera internal parameters.
S104:对图像信息中颜色卡的色块和灰度卡的灰度块进行识别,得到识别结果;根据识别结果对镜头几何畸变校正后图像进行颜色校正和灰度校正,得到目标物的真实图像。S104: Identify the color blocks of the color card and the gray scale blocks of the gray scale in the image information to obtain the identification result; perform color correction and gray scale correction on the image after lens geometric distortion correction according to the identification result to obtain the real image of the target object .
对图像信息中颜色卡的色块和灰度卡的灰度块进行识别,得到识别结果;根据识别结果对镜头几何畸变校正后图像进行颜色校正和灰度校正,得到目标物的真实图像。如可以采用多项式回归法、BP神经网络法或者支持向量机算法对图像信息中扩展二维码的颜色卡和灰度卡进行识别。Identify the color block of the color card and the gray scale of the gray card in the image information, and obtain the identification result; according to the identification result, perform color correction and gray correction on the image after lens geometric distortion correction to obtain the real image of the target object. For example, the polynomial regression method, the BP neural network method or the support vector machine algorithm can be used to identify the color card and gray card of the extended two-dimensional code in the image information.
通过上述技术方案可知,通过预先设置包括由多个不同色块构成的颜色卡,由多个不同灰度块构成的灰度卡,包含定位标志的二维码的扩展二维码,获取包含扩展二维码和目标物的图像信息,利用扩展二维码得到相机外参,完成对目标物图像的转动和平移修正;利用镜头畸变模型计算相机内参,完成对目标物图像的镜头几何畸变校正;通过对图像信息中颜色卡的色块和灰度卡的灰度块进行识别,完成对目标物图像的颜色校正和灰度校正。最终得到真实图像,从而能够基于真实图像进行图像识别,较大地降低了图像识别的误判几率,较大地提高了图像识别结果的准确度。It can be seen from the above technical solutions that by presetting a color card composed of a plurality of different color blocks, a gray scale card composed of a plurality of different gray blocks, and an extended two-dimensional code containing a two-dimensional code of a positioning mark, the extended two-dimensional code containing the extended two-dimensional code can be obtained. The two-dimensional code and the image information of the target object, use the extended two-dimensional code to obtain the camera external parameters, complete the rotation and translation correction of the target object image; use the lens distortion model to calculate the camera internal parameters, complete the lens geometric distortion correction of the target object image; By identifying the color blocks of the color card and the gray blocks of the gray scale in the image information, the color correction and gray scale correction of the target image are completed. Finally, a real image is obtained, so that image recognition can be performed based on the real image, which greatly reduces the misjudgment probability of image recognition and greatly improves the accuracy of the image recognition result.
需要说明的是,基于上述实施例一,本发明实施例还提供了相应的改进方案。在后续实施例中涉及与上述实施例一中相同步骤或相应步骤之间可相互参考,相应的有益效果也可相互参照,在下文的改进实施例中不再一一赘述。It should be noted that, based on the foregoing first embodiment, the embodiment of the present invention also provides a corresponding improvement solution. In subsequent embodiments, the same steps or corresponding steps in the above-mentioned first embodiment can be referred to each other, and corresponding beneficial effects can also be referred to each other, which will not be repeated in the following improved embodiments.
实施例二:Embodiment 2:
参见图4,图4为本发明实施例中图像颜色和几何畸变的全自动校正方法的另一种实施流程图,该方法可以包括以下步骤:Referring to FIG. 4, FIG. 4 is another implementation flowchart of the fully automatic correction method for image color and geometric distortion in the embodiment of the present invention, and the method may include the following steps:
S401:获取包含目标物和扩展二维码的图像信息。S401: Acquire image information including a target object and an extended two-dimensional code.
其中,扩展二维码包括由多个不同色块构成的颜色卡,由多个不同灰度块构成的灰度卡,包含定位标志的二维码。Wherein, the extended two-dimensional code includes a color card composed of a plurality of different color blocks, a grayscale card composed of a plurality of different gray blocks, and a two-dimensional code including a positioning mark.
S402:分别计算定位标志中三个位置标识符的中心点坐标。S402: Calculate the coordinates of the center points of the three position identifiers in the positioning mark respectively.
首先载入拍摄好的图像信息,对载入的图像信息先进行灰度转换,然后对图像信息进行配置校验,下一步对图像信息先进行逐行扫描,扫描路径为Z字型,以一个像素点为增量在一行内扫描过去,并且完成滤波,求取边缘梯度,梯度阈值自适应,确定边缘,转化成明暗宽度流。其中确定边缘之后,使用当前边缘跟上一次保存下来的边缘相减得到一个宽度,并将本次边缘信息保存下来。之后对保存下来的明暗宽度流进行计算,将当前宽度流描述为一个自定义的线段结构,包含两端端点及长度等信息,并将满足条件的横向线段结构变量存入一个容器的横向线段集合中。对整幅图像进行逐列扫描,步骤同逐行扫描一样,扫描路径为N字型,找出边缘最后求取出纵向的明暗高度流,将符合二维码的纵向线段存入容器的纵向线段集合中。故在对二维码解析的过程中,首先要分别计定位标志中三个位置标识符的中心点坐标。可以对之前求出的横向、纵向线段集合用比例1:1:3:1:1对宽度流线段进行筛选并且聚类之后求出横向、纵向的交叉点,求出定位标志中三个位置标识符的中心点坐标。First load the captured image information, first perform grayscale conversion on the loaded image information, and then perform configuration verification on the image information. Next, scan the image information line by line. The pixel points are scanned in one line in increments, and the filtering is completed, the edge gradient is obtained, the gradient threshold is adaptive, the edge is determined, and it is converted into a light and dark width flow. After the edge is determined, the current edge is subtracted from the last saved edge to obtain a width, and the current edge information is saved. Then calculate the saved light and dark width flow, describe the current width flow as a custom line segment structure, including information such as endpoints and lengths at both ends, and store the horizontal line segment structure variables that meet the conditions into a horizontal line segment collection of a container middle. Scan the entire image column by column, the steps are the same as the line by line scan, the scanning path is N-shaped, find the edge and finally obtain the vertical light and dark height flow, and store the vertical line segments that conform to the QR code into the vertical line segment set of the container. middle. Therefore, in the process of parsing the two-dimensional code, firstly, the coordinates of the center points of the three position identifiers in the positioning mark should be calculated separately. The horizontal and vertical line segments obtained before can be screened with a ratio of 1:1:3:1:1, and the horizontal and vertical intersections can be obtained after clustering, and the three positions in the positioning mark can be obtained. The coordinates of the center point of the identifier.
位置标识符可以为位于扩展二维码的三个角黑白相间的三个位置标识符,如三个位置标识符可以分别位于扩展二维码的左上角、右下角及左下角。The location identifiers may be three black and white location identifiers located at three corners of the extended two-dimensional code. For example, the three location identifiers may be located at the upper left corner, the lower right corner and the lower left corner of the extended two-dimensional code, respectively.
需要说明的是,本发明实施例对三个位置标识符的形状不做限定,如可以将其设置为正方形,也可以设置为圆形。It should be noted that, the embodiments of the present invention do not limit the shapes of the three location identifiers, for example, they may be set as squares or circles.
S403:利用三个位置标识符的几何关系及各位置标识符在图像信息中的位置,计算图像信息的逆透视变换矩阵,得到相机外参。S403: Using the geometric relationship of the three position identifiers and the position of each position identifier in the image information, calculate an inverse perspective transformation matrix of the image information to obtain the camera extrinsic parameters.
在计算出定位标志中三个位置标识符的中心点坐标之后,可以利用三个位置标识符的几何关系及各位置标识符在图像信息中的位置,计算图像信息的逆透视变换矩阵,从而得到相机外参。After calculating the center point coordinates of the three position identifiers in the positioning mark, the inverse perspective transformation matrix of the image information can be calculated by using the geometric relationship of the three position identifiers and the position of each position identifier in the image information, thereby obtaining Camera external parameters.
S404:根据相机外参对图像信息中目标物对应的目标物图像进行三维转动和平移变换,得到转动和平移修正后图像。S404: Perform three-dimensional rotation and translation transformation on the target image corresponding to the target in the image information according to the external parameters of the camera, to obtain an image after rotation and translation correction.
S405:通过对图像信息中扩展二维码的颜色卡的边缘和灰度卡的边缘进行模式拟合,结合镜头畸变模型和最陡速降算法计算相机内参;利用相机内参对转动和平移修正后图像的镜头几何畸变进行校正,得到镜头几何畸变校正后图像。S405: By performing pattern fitting on the edge of the color card of the extended two-dimensional code and the edge of the gray card in the image information, and combining the lens distortion model and the steepest descent algorithm, calculate the camera internal parameters; use the camera internal parameters to correct the rotation and translation. The lens geometric distortion of the image is corrected to obtain an image after lens geometric distortion correction.
在获取到镜头畸变模型之后,可以使用最陡速降算法从模型中提取相机内参。梯度下降法实现简单,当目标函数是凸函数时,梯度下降法的解是全局解。梯度下降法的优化思想是用当前位置负梯度方向作为搜索方向,因为该方向为当前位置的最快下降方向,所以也被称为是“最速下降法”。最速下降法越接近目标值,步长越小,前进越慢。一般情况下,其解不保证是全局最优解,梯度下降法的速度也未必是最快的。于是本发明实施例采用莱文贝格-马夸特方法(Levenberg-Marquardt),即最陡速降算法,来求取参数,Levenberg-Marquardt算法能提供非线性最小化(局部最小)的数值解。此算法能在执行时修改参数达到结合高斯-牛顿算法以及梯度下降法的优点,并对两者之不足作改善。After the lens distortion model is obtained, the camera intrinsic parameters can be extracted from the model using the steepest descent algorithm. The gradient descent method is simple to implement. When the objective function is a convex function, the solution of the gradient descent method is a global solution. The optimization idea of the gradient descent method is to use the negative gradient direction of the current position as the search direction, because this direction is the fastest descent direction of the current position, so it is also called the "steepest descent method". The closer the steepest descent method is to the target value, the smaller the step size and the slower the progress. In general, the solution is not guaranteed to be the global optimal solution, and the speed of the gradient descent method is not necessarily the fastest. Therefore, in the embodiment of the present invention, the Levenberg-Marquardt method, that is, the steepest descent algorithm, is used to obtain the parameters. The Levenberg-Marquardt algorithm can provide a numerical solution of nonlinear minimization (local minimization). . This algorithm can modify the parameters during execution to combine the advantages of the Gauss-Newton algorithm and the gradient descent method, and improve the shortcomings of the two.
S406:利用多项式回归法对图像信息中颜色卡的色块和灰度卡的灰度块进行识别,得到识别结果;根据识别结果对镜头几何畸变校正后图像进行颜色校正和灰度校正,得到目标物的真实图像。S406: Use the polynomial regression method to identify the color blocks of the color card and the gray blocks of the gray scale in the image information, and obtain the identification result; perform color correction and gray scale correction on the image after the lens geometric distortion correction according to the identification result, and obtain the target real images of things.
可以利用多项式回归法对图像信息中颜色卡的色块和灰度卡的灰度块进行识别。设颜色卡上共有N个色块,第i个色块的颜色三刺激值在标准空间下为Roi、Goi、Boi,在自然光照环境下采集到的待校正比色板上的第i个色块颜色三刺激值为Ri、Gi、Bi,其中i=1,2,3.......N,则:The polynomial regression method can be used to identify the color blocks of the color card and the gray blocks of the gray scale in the image information. Suppose there are N color blocks on the color card, and the color tristimulus values of the i-th color block are Roi , Goi , and Boi in the standard space, and the No. The color tristimulus values of i color blocks are R i , G i , B i , where i=1, 2, 3....N, then:
Roi=a11v1i+a12v2i+...+a1ivji; Roi =a 11 v 1i +a 12 v 2i +...+a 1i v ji ;
Goi=a21v1i+a22v2i+...+a2ivji;G oi =a 21 v 1i +a 22 v 2i +...+a 2i v ji ;
Boi=a31v1i+a32v2i+...+a3ivji; Boi =a 31 v 1i +a 32 v 2i +...+a 3i v ji ;
其中,vji(j=1,...,J)由Ri、Gi、Bi的多项式构成,有各种不同的多项式形式,例如,V=[R,G,B,1],V=[R,G,B,RG,RB,GB,1],V=[R,G,B,RGB,1]等,V的形式可以根据需要来组合成不同的形式。Among them, v ji (j=1,...,J) consists of polynomials of R i , G i , B i , and there are various polynomial forms, for example, V=[R,G,B,1], V=[R, G, B, RG, RB, GB, 1], V=[R, G, B, RGB, 1], etc. The form of V can be combined into different forms as required.
上式的矩阵形式为:The matrix form of the above formula is:
X=AT*V;X=A T *V;
其中,X是校正后图像的R、G、B三刺激值矩阵,维数为3×M;V是由原始图像所有像素的R、G、B值对应的多项式的项所构成的矩阵,维数为J×M;M为原始图像的像素总数。A是维数为J×3的转换系数矩阵,A可利用最小二乘法优化得到,A即为所求的模型参数。将A带入上述矩阵式中,即可计算出校正后图像的各像素的R、G、B值,实现在线的颜色校正。通过设计合理的多项式项数形式,利用多项式回归算法对图像信息中扩展二维码的颜色卡和灰度卡进行识别,从而得到好的识别结果。Among them, X is the R, G, B tristimulus value matrix of the corrected image, the dimension is 3×M; V is the matrix composed of the polynomial terms corresponding to the R, G, B values of all pixels of the original image, the dimension The number is J×M; M is the total number of pixels of the original image. A is a conversion coefficient matrix with dimension J×3, A can be obtained by least squares optimization, and A is the required model parameter. By bringing A into the above matrix formula, the R, G, and B values of each pixel of the corrected image can be calculated to realize online color correction. By designing a reasonable polynomial term form, the polynomial regression algorithm is used to identify the color card and gray card of the extended two-dimensional code in the image information, so as to obtain a good identification result.
实施例三:Embodiment three:
参见图5,图5为本发明实施例中图像颜色和几何畸变的全自动校正方法的另一种实施流程图,该方法可以包括以下步骤:Referring to FIG. 5, FIG. 5 is another implementation flowchart of the fully automatic correction method for image color and geometric distortion in the embodiment of the present invention, and the method may include the following steps:
S501:获取包含目标物和扩展二维码的图像信息。S501: Acquire image information including the target object and the extended two-dimensional code.
其中,扩展二维码包括由多个不同色块构成的颜色卡,由多个不同灰度块构成的灰度卡,包含定位标志的二维码。Wherein, the extended two-dimensional code includes a color card composed of a plurality of different color blocks, a grayscale card composed of a plurality of different gray blocks, and a two-dimensional code including a positioning mark.
S502:分别计算定位标志中三个位置标识符的中心点坐标。S502: Calculate the coordinates of the center points of the three position identifiers in the positioning mark respectively.
S503:利用三个位置标识符的几何关系及各位置标识符在图像信息中的位置,计算图像信息的逆透视变换矩阵,得到相机外参。S503: Calculate the inverse perspective transformation matrix of the image information by using the geometric relationship of the three position identifiers and the position of each position identifier in the image information to obtain the camera extrinsic parameters.
S504:根据相机外参对图像信息中目标物对应的目标物图像进行三维转动和平移变换,得到转动和平移修正后图像。S504: Perform three-dimensional rotation and translation transformation on the target image corresponding to the target in the image information according to the external parameters of the camera, to obtain an image after rotation and translation correction.
S505:通过对图像信息中扩展二维码的颜色卡的边缘和灰度卡的边缘进行模式拟合,结合镜头畸变模型和最陡速降算法计算相机内参;利用相机内参对转动和平移修正后图像的镜头几何畸变进行校正,得到镜头几何畸变校正后图像。S505: By performing pattern fitting on the edge of the color card of the extended two-dimensional code and the edge of the gray card in the image information, and combining the lens distortion model and the steepest descent algorithm, calculate the camera internal parameters; use the camera internal parameters to correct the rotation and translation. The lens geometric distortion of the image is corrected to obtain an image after lens geometric distortion correction.
S506:利用BP神经网络法对所述图像信息中所述颜色卡的色块和灰度卡的灰度块进行识别,得到识别结果;根据识别结果对镜头几何畸变校正后图像进行颜色校正和灰度校正,得到目标物的真实图像。S506: Use the BP neural network method to identify the color blocks of the color card and the gray scale blocks of the gray scale in the image information, and obtain a recognition result; perform color correction and grayscale on the image after the lens geometric distortion correction according to the recognition result. degree correction to get the real image of the target.
可以利用前馈(BP)神经网络法对所述图像信息中所述颜色卡的色块和灰度卡的灰度块进行识别。具体的,处理端可以采用归一化平方差匹配法对图片中的标准色块进行模板匹配,模板匹配是一项在一幅图像中寻找与另一幅模板图像最匹配部分的技术。是通过在输入图像上滑动模板图像块,对实际的图像和输入的图像进行匹配的一种方法。用T(·)表示模板图像,I(·)表示待匹配图像,R(·)用表示匹配结果,公式中(x,y)表示待匹配图像的像素点,(x’,y’)表示模板图像的像素点,匹配方法如公式:A feedforward (BP) neural network method can be used to identify the color blocks of the color card and the gray blocks of the gray scale in the image information. Specifically, the processing end may use the normalized squared difference matching method to perform template matching on the standard color blocks in the picture, and template matching is a technique of finding the part in one image that best matches another template image. It is a method of matching the actual image and the input image by sliding the template image block on the input image. Use T( ) to represent the template image, I( ) to represent the image to be matched, R( ) to represent the matching result, in the formula (x, y) represent the pixels of the image to be matched, and (x', y') represent The pixel points of the template image, the matching method is as follows:
将图片中匹配后的色卡截取出来并保存。色卡有多个色块,将色块中的颜色值进行聚类,聚类中心的颜色值代表采集后的每个色块的颜色值Q1,色卡中的颜色值可作为BP神经网络的输出参考值Q2。对于训练的BP神经网络,Q1为实际颜色输入值,Q2为期望颜色输出值。Cut out the matched color card in the picture and save it. The color card has multiple color blocks, and the color values in the color blocks are clustered. The color value of the cluster center represents the color value Q1 of each color block after collection, and the color value in the color card can be used as the BP neural network. The reference value Q2 is output. For the trained BP neural network, Q1 is the actual color input value, and Q2 is the expected color output value.
设计的BP神经网络的结构如图6所示,输出层和输入层分别为3个神经元,BP神经网络有一个隐藏层。隐藏层的神经元数目为7个。BP神经网络的激活函数为非线性函数,同时将数据进行归一化处理后输入神经网络。使用多个色块的数据对BP神经网络进行训练,得到颜色校正模型系数。将整幅图像的颜色三刺激值数据R、G、B输入得到的颜色校正模型进行颜色校正并保存。The structure of the designed BP neural network is shown in Figure 6. The output layer and the input layer are 3 neurons respectively, and the BP neural network has a hidden layer. The number of neurons in the hidden layer is 7. The activation function of the BP neural network is a nonlinear function, and the data is normalized and input to the neural network. The BP neural network is trained using the data of multiple color blocks, and the color correction model coefficients are obtained. The color correction model obtained by inputting the color tristimulus value data R, G, and B of the entire image is color corrected and saved.
实施例四:Embodiment 4:
参见图7,图7为本发明实施例中图像颜色和几何畸变的全自动校正方法的另一种实施流程图,该方法可以包括以下步骤:Referring to FIG. 7, FIG. 7 is another implementation flowchart of the fully automatic correction method for image color and geometric distortion in the embodiment of the present invention, and the method may include the following steps:
S701:获取包含目标物和扩展二维码的图像信息。S701: Acquire image information including the target object and the extended two-dimensional code.
其中,扩展二维码包括由多个不同色块构成的颜色卡,由多个不同灰度块构成的灰度卡,包含定位标志的二维码。Wherein, the extended two-dimensional code includes a color card composed of a plurality of different color blocks, a grayscale card composed of a plurality of different gray blocks, and a two-dimensional code including a positioning mark.
S702:分别计算定位标志中三个位置标识符的中心点坐标。S702: Calculate the coordinates of the center points of the three position identifiers in the positioning mark respectively.
S703:利用三个位置标识符的几何关系及各位置标识符在图像信息中的位置,计算图像信息的逆透视变换矩阵,得到相机外参。S703: Using the geometric relationship of the three position identifiers and the position of each position identifier in the image information, calculate the inverse perspective transformation matrix of the image information to obtain the camera extrinsic parameters.
S704:根据相机外参对图像信息中目标物对应的目标物图像进行三维转动和平移变换,得到转动和平移修正后图像。S704: Perform three-dimensional rotation and translation transformation on the target image corresponding to the target in the image information according to the external parameters of the camera, to obtain an image after rotation and translation correction.
S705:通过对图像信息中扩展二维码的颜色卡的边缘和灰度卡的边缘进行模式拟合,结合镜头畸变模型和最陡速降算法计算相机内参;利用相机内参对转动和平移修正后图像的镜头几何畸变进行校正,得到镜头几何畸变校正后图像。S705: By performing pattern fitting on the edge of the color card of the extended two-dimensional code and the edge of the gray card in the image information, and combining the lens distortion model and the steepest descent algorithm, calculate the camera internal parameters; use the camera internal parameters to correct the rotation and translation The lens geometric distortion of the image is corrected to obtain an image after lens geometric distortion correction.
S706:利用支持向量机算法对图像信息中颜色卡的色块和灰度卡的灰度块进行识别,得到识别结果;根据识别结果对镜头几何畸变校正后图像进行颜色校正和灰度校正,得到目标物的真实图像。S706: Use the support vector machine algorithm to identify the color blocks of the color card and the gray blocks of the gray scale in the image information, and obtain the identification result; perform color correction and gray scale correction on the image after the lens geometric distortion correction according to the identification result, and obtain Real image of the target.
可以利用支持向量机算法对图像信息中颜色卡的色块和灰度卡的灰度块进行识别,或者采用支持向量机算法,将标准色卡上的颜色块作为训练样本集,采用非线性核函数把训练数据转化到高维特征空间。首先采集在标准环境下拍摄的色卡参考图像的色块和非标准环境下拍摄的色卡图像的色块RGB值,然后将它们从RGB色彩空间转化到Lab色彩空间,Lab色彩模型是由亮度(L)和有关色彩的a,b三个要素组成。L表示明度(Luminosity),a表示从洋红色至绿色的范围,b表示从黄色至蓝色的范围。将得到的Lab色彩空间的训练集合中的训练数据分成L,a,b三个分量,从而得到了L,a,b三个训练子集,然后以非标准环境下拍摄的色卡图像的色块作为源,以标准环境下拍摄的色卡参考图像的色块作为目标,将L,a,b的三个子集的分别进行训练,就可以得到三个支持向量回归模型和L,a,b的支持向量回归函数fL_SVR,fa_SVR,fb_SVR。最后将需要校正图像的RGB色彩空间转换到Lab色彩空间,用训练得到的回归函数进行回归。设需要校正图像的第i个像素点的颜色值为Li,ai,bi,其中i=1,2,3,...,N,N为图像像素总个数,分别通过支持向量回归函数fL_SVR,fa_SVR,fb_SVR,计算该像素点校正后的颜色值L_SVRi,a_SVRi,b_SVRi,其形式为:The support vector machine algorithm can be used to identify the color blocks of the color card and the gray blocks of the gray card in the image information, or the support vector machine algorithm can be used to use the color blocks on the standard color card as the training sample set, and the nonlinear kernel can be used. The function transforms the training data into a high-dimensional feature space. First collect the color patch of the color card reference image shot in the standard environment and the color patch RGB value of the color card image shot in the non-standard environment, and then convert them from the RGB color space to the Lab color space. The Lab color model is determined by brightness (L) is composed of three elements a and b related to color. L represents Luminosity, a represents the range from magenta to green, and b represents the range from yellow to blue. The training data in the training set of the obtained Lab color space is divided into three components, L, a, and b, thereby obtaining three training subsets of L, a, and b, and then using the color of the color card image taken in a non-standard environment. The block is used as the source, the color block of the reference image of the color card taken in the standard environment is used as the target, and the three subsets of L, a, b are trained separately, and three support vector regression models and L, a, b can be obtained. The support vector regression functions f L_SVR , f a_SVR , f b_SVR . Finally, the RGB color space of the image to be corrected is converted to the Lab color space, and the regression function obtained by training is used for regression. Suppose the color value of the i-th pixel of the image to be corrected is L i , a i , b i , where i=1, 2, 3,..., N, N is the total number of image pixels, respectively through the support vector Regression functions f L_SVR , f a_SVR , f b_SVR , calculate the corrected color value L_SVR i , a_SVR i , b_SVR i of the pixel, and its form is:
L_SVRi=fL_SVR(Li);L_SVR i =f L_SVR (L i );
a_SVRi=fa_SVR(ai);a_SVR i =f a_SVR (a i );
b_SVRi=fb_SVR(bi);b_SVR i =f b_SVR (b i );
最终得到经过支持向量机算法校正的图像。其中支持向量回归模型和支持向量回归函数fL_SVR,fa_SVR,fb_SVR的具体形式和求解过程如下:Finally, the image corrected by the support vector machine algorithm is obtained. The specific form and solution process of the support vector regression model and the support vector regression functions f L_SVR , f a_SVR , f b_SVR are as follows:
首先需要定义一个损失函数,在医学图像领域,主要采用ε-不敏感损失函数,相比于最小平方差损失函数、拉普拉斯损失函数、Huber损失函数,ε-不敏感损失函数可以忽略真实值某个范围内的误差,且可以帮助获得较少的支持向量,具有很好的鲁棒性。First of all, a loss function needs to be defined. In the field of medical images, the ε-insensitive loss function is mainly used. Compared with the least squared difference loss function, the Laplace loss function, and the Huber loss function, the ε-insensitive loss function can ignore the real loss function. The error is within a certain range of the value, and it can help to obtain less support vectors, which has good robustness.
ε-不敏感损失函数可以表示为:The ε-insensitive loss function can be expressed as:
Lε(y)=max(0,|f(x)-y|-ε);L ε (y)=max(0,|f(x)-y|-ε);
其中,y表示通过ε-不敏感损失函数计算后得到的值。where y represents the value calculated by the ε-insensitive loss function.
核函数采用高斯辐射核函数,对任意向量xi,xj∈X∈Rn,δ为带宽,其控制高斯核函数的局部作用范围:The kernel function adopts the Gaussian radiation kernel function. For any vector x i , x j ∈X∈R n , δ is the bandwidth, which controls the local scope of the Gaussian kernel function:
求解回归参数得到拉格朗日乘子α,α*:Solve the regression parameters to get the Lagrange multipliers α,α * :
上式满足的约束条件为:The constraints satisfied by the above formula are:
且满足Karush-Kuhn-Tucker(KKT)条件:And satisfy the Karush-Kuhn-Tucker (KKT) condition:
在上述约束条件下求解上述回归参数方程,可以得到拉格朗日乘子因此支持向量是指那些拉格朗日乘子大于零的点。Solving the above regression parameter equation under the above constraints, the Lagrange multiplier can be obtained So support vectors are those points where the Lagrange multiplier is greater than zero.
得到如下形式的回归方程为:The regression equation of the following form is obtained as:
其中:in:
K(xi,xj)为核函数,为偏置,xr和xs分别为核函数的某个x向量。K(x i ,x j ) is the kernel function, is the bias, x r and x s are a certain x vector of the kernel function, respectively.
故支持向量回归函数fL_SVR,fa_SVR,fb_SVR的具体形式如上述回归方程。Therefore, the specific forms of the support vector regression functions f L_SVR , f a_SVR , and f b_SVR are the same as the above regression equations.
通过将图片中匹配后的灰度块截取出来并保存。灰度卡有多个灰度阶,将多个灰度阶进行聚类处理并计算其值,根据标准的多个灰度阶的准确值,计算在拍摄后的图片灰度的变化系数,这种不同灰度的变化系数可以用于图片的不同灰度阶进行校正,最后得到没有颜色畸变、没有灰度畸变的图像。By cutting out the matched grayscale blocks in the picture and saving them. The grayscale card has multiple grayscales. The multiple grayscales are clustered and their values are calculated. According to the accurate values of the standard multiple grayscales, the coefficient of variation of the grayscale of the picture after shooting is calculated. The variation coefficients of different gray levels can be used to correct different gray levels of the picture, and finally an image without color distortion and gray level distortion can be obtained.
相应于上面的方法实施例,本发明实施例还提供了一种图像颜色和几何畸变的全自动校正装置,下文描述的图像颜色和几何畸变的全自动校正装置与上文描述的图像颜色和几何畸变的全自动校正方法可相互对应参照。Corresponding to the above method embodiments, the embodiments of the present invention also provide a fully automatic correction device for image color and geometric distortion. The fully automatic correction device for image color and geometric distortion described below is the same as the image color and geometric distortion described above. The fully automatic correction methods for distortion can be referenced against each other.
参见图8,图8为本发明实施例中一种图像颜色和几何畸变的全自动校正装置的结构框图,该装置可以包括:Referring to FIG. 8, FIG. 8 is a structural block diagram of a fully automatic correction device for image color and geometric distortion in an embodiment of the present invention, and the device may include:
图像信息获取模块81,用于获取包含目标物和扩展二维码的图像信息;其中,扩展二维码包括由多个不同色块构成的颜色卡,由多个不同灰度块构成的灰度卡,包含定位标志的二维码;The image
转动和平移修正模块82,用于对图像信息中扩展二维码的定位标志进行识别并计算,得到相机外参;根据相机外参对图像信息中目标物对应的目标物图像进行三维转动和平移变换,得到转动和平移修正后图像;The rotation and
镜头几何畸变校正模块83,用于通过对图像信息中扩展二维码的颜色卡的边缘和灰度卡的边缘进行模式拟合,利用镜头畸变模型计算相机内参;利用相机内参对转动和平移修正后图像的镜头几何畸变进行校正,得到镜头几何畸变校正后图像;The lens geometric
真实图像获得模块84,用于对图像信息中颜色卡的色块和灰度卡的灰度块进行识别,得到识别结果;根据识别结果对镜头几何畸变校正后图像进行颜色校正和灰度校正,得到目标物的真实图像以便根据真实图像对目标物对应的患者进行诊断。The real
通过上述技术方案可知,通过预先设置包括由多个不同色块构成的颜色卡,由多个不同灰度块构成的灰度卡,包含定位标志的二维码的扩展二维码,获取包含扩展二维码和目标物的图像信息,利用扩展二维码得到相机外参,完成对目标物图像的转动和平移修正;利用镜头畸变模型计算相机内参,完成对目标物图像的镜头几何畸变校正;通过对图像信息中颜色卡的色块和灰度卡的灰度块进行识别,完成对目标物图像的颜色校正和灰度校正。最终得到真实图像,从而能够基于真实图像进行图像识别,较大地降低了图像识别的误判几率,较大地提高了图像识别结果的准确度。It can be seen from the above technical solutions that by presetting a color card composed of a plurality of different color blocks, a gray scale card composed of a plurality of different gray blocks, and an extended two-dimensional code containing a two-dimensional code of a positioning mark, the extended two-dimensional code containing the extended two-dimensional code can be obtained. The two-dimensional code and the image information of the target object, use the extended two-dimensional code to obtain the camera external parameters, complete the rotation and translation correction of the target object image; use the lens distortion model to calculate the camera internal parameters, complete the lens geometric distortion correction of the target object image; By identifying the color blocks of the color card and the gray blocks of the gray scale in the image information, the color correction and gray scale correction of the target image are completed. Finally, a real image is obtained, so that image recognition can be performed based on the real image, which greatly reduces the misjudgment probability of image recognition and greatly improves the accuracy of the image recognition result.
在本发明的一种具体实施方式中,定位标志包括分别位于扩展二维码三个角黑白相间的三个位置标识符,转动和平移修正模块82包括相机外参获得子模块,相机外参获得子模块包括:In a specific embodiment of the present invention, the positioning mark includes three position identifiers that are respectively located at three corners of the extended two-dimensional code in black and white, and the rotation and
坐标计算单元,用于分别计算定位标志中三个位置标识符的中心点坐标The coordinate calculation unit is used to calculate the coordinates of the center point of the three position identifiers in the positioning mark respectively
相机外参获得单元,用于利用三个位置标识符的几何关系及各位置标识符在图像信息中的位置,计算图像信息的逆透视变换矩阵,得到相机外参。The camera extrinsic parameter obtaining unit is used for calculating the inverse perspective transformation matrix of the image information by using the geometric relationship of the three position identifiers and the position of each position identifier in the image information to obtain the camera extrinsic parameters.
在本发明的一种具体实施方式中,镜头几何畸变校正模块83包括相机内参计算子模块,In a specific embodiment of the present invention, the lens geometric
相机内参计算子模块具体为通过对图像信息中扩展二维码的颜色卡的边缘和灰度卡的边缘进行模式拟合,结合镜头畸变模型和最陡速降算法计算相机内参的模块。The camera internal parameter calculation sub-module is a module that calculates the camera internal parameters by combining the lens distortion model and the steepest descent algorithm by performing pattern fitting on the edge of the color card of the extended two-dimensional code and the edge of the gray card in the image information.
在本发明的一种具体实施方式中,真实图像获得模块94包括颜色卡和灰度卡识别子模块,In a specific embodiment of the present invention, the real image obtaining module 94 includes a color card and a gray card identification sub-module,
颜色卡和灰度卡识别子模块具体为利用多项式回归法对图像信息中颜色卡的色块和灰度卡的灰度块进行识别的模块。The color card and gray card identification sub-module is specifically a module that uses the polynomial regression method to identify the color blocks of the color card and the gray blocks of the gray card in the image information.
在本发明的一种具体实施方式中,真实图像获得模块84包括颜色卡和灰度卡识别子模块,In a specific embodiment of the present invention, the real
颜色卡和灰度卡识别子模块具体为利用BP神经网络法对图像信息中颜色卡的色块和灰度卡的灰度块进行识别的模块。The color card and gray card identification sub-module is specifically a module that uses the BP neural network method to identify the color blocks of the color card and the gray blocks of the gray card in the image information.
在本发明的一种具体实施方式中,真实图像获得模块84包括颜色卡和灰度卡识别子模块,In a specific embodiment of the present invention, the real
颜色卡和灰度卡识别子模块具体为利用支持向量机算法对所述图像信息中所述颜色卡的色块和所述灰度卡的灰度块进行识别的模块。The color card and gray card identification sub-module is specifically a module that uses the support vector machine algorithm to identify the color blocks of the color card and the gray blocks of the gray card in the image information.
相应于上面的方法实施例,本发明实施例还提供了一种图像颜色和几何畸变的全自动校正系统,下文描述的图像颜色和几何畸变的全自动校正系统与上文描述的图像颜色和几何畸变的全自动校正方法可相互对应参照。Corresponding to the above method embodiments, the embodiments of the present invention also provide a fully automatic correction system for image color and geometric distortion. The fully automatic correction system for image color and geometric distortion described below is the same as the image color and geometric distortion described above. The fully automatic correction methods for distortion can be referenced against each other.
参见图9,图9为本发明实施例中一种图像颜色和几何畸变的全自动校正系统的结构框图,该系统可以包括扩展二维码1、图像采集设备2、图像预处理终端3及服务器4,扩展二维码1包括由多个不同色块构成的颜色卡,由多个不同灰度块构成的灰度卡,包含定位标志的二维码;其中:Referring to FIG. 9, FIG. 9 is a structural block diagram of a fully automatic correction system for image color and geometric distortion in an embodiment of the present invention. The system may include an extended two-
图像采集设备2,用于获取扩展二维码1和目标物的图像信息;并将图像信息发送给图像预处理终端3;The
图像预处理终端3,用于对图像信息中扩展二维码1的定位标志进行识别并计算,得到相机外参;根据相机外参对图像信息中目标物对应的目标物图像进行三维转动和平移变换,得到转动和平移修正后图像;并将转动和平移修正后图像发送给服务器4;The
服务器4,用于通过对图像信息中扩展二维码1的颜色卡的边缘和灰度卡的边缘进行模式拟合,利用镜头畸变模型计算相机内参;利用相机内参对转动和平移修正后图像的镜头几何畸变进行校正,得到镜头几何畸变校正后图像;对图像信息中颜色卡的色块和灰度卡的灰度块进行识别,得到识别结果;根据识别结果对镜头几何畸变校正后图像进行颜色校正和灰度校正,得到目标物的真实图像,根据真实图像对目标物对应的患者进行诊断。The
通过上述技术方案可知,通过预先设置包括由多个不同色块构成的颜色卡,由多个不同灰度块构成的灰度卡,包含定位标志的二维码的扩展二维码,获取包含扩展二维码和目标物的图像信息,利用扩展二维码得到相机外参,完成对目标物图像的转动和平移修正;利用镜头畸变模型计算相机内参,完成对目标物图像的镜头几何畸变校正;通过对图像信息中颜色卡的色块和灰度卡的灰度块进行识别,完成对目标物图像的颜色校正和灰度校正。最终得到真实图像,从而能够基于真实图像进行图像识别,较大地降低了图像识别的误判几率,较大地提高了图像识别结果的准确度。It can be seen from the above technical solutions that by presetting a color card composed of a plurality of different color blocks, a gray scale card composed of a plurality of different gray blocks, and an extended two-dimensional code containing a two-dimensional code of a positioning mark, the extended two-dimensional code containing the extended two-dimensional code can be obtained. The two-dimensional code and the image information of the target object, use the extended two-dimensional code to obtain the camera external parameters, complete the rotation and translation correction of the target object image; use the lens distortion model to calculate the camera internal parameters, complete the lens geometric distortion correction of the target object image; By identifying the color blocks of the color card and the gray blocks of the gray scale in the image information, the color correction and gray scale correction of the target image are completed. Finally, a real image is obtained, so that image recognition can be performed based on the real image, which greatly reduces the misjudgment probability of image recognition and greatly improves the accuracy of the image recognition result.
在本发明的一种具体实施方式中,定位标志包括分别位于扩展二维码1三个角黑白相间的三个位置标识符,In a specific embodiment of the present invention, the positioning mark includes three position identifiers located in black and white at the three corners of the extended two-
图像预处理终端3,具体用于分别计算定位标志中三个位置标识符的中心点坐标;利用三个位置标识符的几何关系及各位置标识符在图像信息中的位置,计算图像信息的逆透视变换矩阵,得到相机外参。The
在本发明的一种具体实施方式中,服务器4,具体用于通过对图像信息中扩展二维码1的颜色卡的边缘和灰度卡的边缘进行模式拟合,结合镜头畸变模型和最陡速降算法计算相机内参。In a specific embodiment of the present invention, the
在本发明的一种具体实施方式中,服务器4,具体用于利用多项式回归法对图像信息中颜色卡的色块和灰度卡的灰度块进行识别。In a specific embodiment of the present invention, the
在本发明的一种具体实施方式中,服务器4,具体用于利用BP神经网络法对图像信息中颜色卡的色块和灰度卡的灰度块进行识别。In a specific embodiment of the present invention, the
在本发明的一种具体实施方式中,服务器4,具体用于利用支持向量机算法对所述图像信息中所述颜色卡的色块和所述灰度卡的灰度块进行识别。In a specific implementation manner of the present invention, the
在一种具体实例应用中,参见图10,图10为本发明实施例中一种图像颜色和几何畸变的全自动校正系统的示意图。如当前是在通过对患者的脸部颜色进行观察对患者进行针对性诊断的过程,首先可以通过相机21、摄像机22或者用户移动终端23采集包含患者脸部图像和扩展二维码的图像11。若通过相机21或摄像机22进行的图像采集,则可以将采集到的图像11发送给客户端31,相机21和摄像机22与客户端31之间可以通过有线方式进行通信连接,也可以通过无线通信方式进行通信连接,利用客户端31对脸部图像进行三维转动和平移变换;若通过用户移动终端23进行的图像采集,则可以直接利用用户移动终端23对脸部图像进行三维转动和平移变换。在对脸部图像进行三维转动和平移变换之后,通过客户端31或用户移动终端23将转动和平移修正后图像发送给服务器4,客户端31与服务器4之间可以通过有线方式进行通信连接,也可以通过无线通信方式进行通信连接,利用服务器4对脸部图像进一步进行镜头几何畸变校正和颜色及灰度校正,最终得到患者真实的脸部图像,服务器4基于患者真实的脸部图像进行针对性诊断,将诊断结果返回给用户移动终端23或客户端31,较大地提高了诊断系统的识别率,较大地降低了诊断系统的误判率。In a specific example application, referring to FIG. 10 , FIG. 10 is a schematic diagram of a fully automatic correction system for image color and geometric distortion in an embodiment of the present invention. If currently in the process of diagnosing a patient by observing the color of the patient's face, first, the
图10所示的图像颜色和几何畸变的全自动校正系统也可以是用于人脸识别的防盗或签到系统,人脸图像的采集过程和处理过程可以参照上述过程,通过对获取到的人脸图像信息进行三维转动和平移变换、镜头几何畸变校正和颜色及灰度校正,能够较大地提升人脸图像的真实度,提升识别效果和识别效率。当人本发明实施所提及的目标物不仅限于人脸,也可以是其它的图像识别对象,本发明实施例对此不做限定。The fully automatic correction system for image color and geometric distortion shown in Figure 10 can also be an anti-theft or sign-in system for face recognition. The collection process and processing process of face images can refer to the above process. The image information undergoes three-dimensional rotation and translation transformation, lens geometric distortion correction, and color and grayscale correction, which can greatly improve the authenticity of face images, and improve the recognition effect and efficiency. When the target object mentioned in the implementation of the present invention is not limited to a human face, it can also be other image recognition objects, which is not limited in this embodiment of the present invention.
相应于上面的方法实施例,本发明还提供一种计算机可读存储介质,计算机可读存储介质上存储有计算机程序,计算机程序被处理器执行时可实现如下步骤:Corresponding to the above method embodiments, the present invention also provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the following steps can be implemented:
获取包含目标物和扩展二维码的图像信息;其中,扩展二维码包括由多个不同色块构成的颜色卡,由多个不同灰度块构成的灰度卡,包含定位标志的二维码;对图像信息中扩展二维码的定位标志进行识别并计算,得到相机外参;根据相机外参对图像信息中目标物对应的目标物图像进行三维转动和平移变换,得到转动和平移修正后图像;通过对图像信息中扩展二维码的颜色卡的边缘和灰度卡的边缘进行模式拟合,利用镜头畸变模型计算相机内参;利用相机内参对转动和平移修正后图像的镜头几何畸变进行校正,得到镜头几何畸变校正后图像;对图像信息中颜色卡的色块和灰度卡的灰度块进行识别,得到识别结果;根据识别结果对镜头几何畸变校正后图像进行颜色校正和灰度校正,得到目标物的真实图像。Obtain the image information including the target object and the extended two-dimensional code; wherein, the extended two-dimensional code includes a color card composed of a plurality of different color blocks, a gray scale card composed of a plurality of different gray blocks, and a two-dimensional image containing a positioning mark. Identify and calculate the positioning marks of the extended two-dimensional code in the image information to obtain the camera external parameters; perform three-dimensional rotation and translation transformation on the target image corresponding to the target object in the image information according to the camera external parameters to obtain the rotation and translation corrections After image; by pattern fitting the edge of the color card of the extended QR code and the edge of the gray card in the image information, the lens distortion model is used to calculate the camera internal parameters; the camera internal parameters are used to correct the lens geometric distortion of the image after rotation and translation Perform correction to obtain the image after lens geometric distortion correction; identify the color block of the color card and the gray scale block of the gray card in the image information, and obtain the recognition result; according to the recognition result, perform color correction and grayscale on the image after lens geometric distortion correction. degree correction to get the real image of the target.
该计算机可读存储介质可以包括:U盘、移动硬盘、只读存储器(Read-OnlyMemory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The computer-readable storage medium may include: a USB flash drive, a removable hard disk, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk or an optical disk, etc., which can store program codes. medium.
对于本发明提供的计算机可读存储介质的介绍请参照上述方法实施例,本发明在此不做赘述。For the introduction of the computer-readable storage medium provided by the present invention, please refer to the foregoing method embodiments, which will not be repeated in the present invention.
本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其它实施例的不同之处,各个实施例之间相同或相似部分互相参见即可。对于实施例公开的装置、系统及计算机可读存储介质而言,由于其与实施例公开的方法相对应,所以描述的比较简单,相关之处参见方法部分说明即可。The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments may be referred to each other. As for the apparatus, system and computer-readable storage medium disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and for related parts, please refer to the description of the method section.
本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的技术方案及其核心思想。应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以对本发明进行若干改进和修饰,这些改进和修饰也落入本发明权利要求的保护范围内。The principles and implementations of the present invention are described herein by using specific examples, and the descriptions of the above embodiments are only used to help understand the technical solutions and core ideas of the present invention. It should be pointed out that for those skilled in the art, without departing from the principle of the present invention, several improvements and modifications can also be made to the present invention, and these improvements and modifications also fall within the protection scope of the claims of the present invention.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910695090.3A CN110400278B (en) | 2019-07-30 | 2019-07-30 | A fully automatic correction method, device and equipment for image color and geometric distortion |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910695090.3A CN110400278B (en) | 2019-07-30 | 2019-07-30 | A fully automatic correction method, device and equipment for image color and geometric distortion |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN110400278A CN110400278A (en) | 2019-11-01 |
| CN110400278B true CN110400278B (en) | 2021-10-01 |
Family
ID=68326582
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201910695090.3A Active CN110400278B (en) | 2019-07-30 | 2019-07-30 | A fully automatic correction method, device and equipment for image color and geometric distortion |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN110400278B (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US12153979B1 (en) | 2023-06-30 | 2024-11-26 | Kao Corporation | Card for identifying a tone of a sample of human skin |
Families Citing this family (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111008564B (en) * | 2019-11-01 | 2023-05-09 | 南京航空航天大学 | Non-matching type face image recognition method and system |
| CN114730456A (en) * | 2019-12-12 | 2022-07-08 | 华为技术有限公司 | Training method of neural network model, image processing method and device thereof |
| CN113132693B (en) * | 2019-12-31 | 2024-10-01 | 长沙云知检信息科技有限公司 | Color correction method |
| CN111353952B (en) * | 2020-01-21 | 2023-05-05 | 佛山科学技术学院 | A Method of Eliminating Black Boundary after Image Distortion Correction |
| CN111915524B (en) * | 2020-08-04 | 2024-03-29 | 深圳企业云科技股份有限公司 | Full-automatic image perspective correction method based on cross ratio operation |
| CN112307786B (en) * | 2020-10-13 | 2022-07-08 | 上海迅邦电子科技有限公司 | Batch positioning and identifying method for multiple irregular two-dimensional codes |
| CN113850227A (en) * | 2021-10-18 | 2021-12-28 | 中国神华能源股份有限公司哈尔乌素露天煤矿 | Coal level information determining method, system and storage medium |
| CN114782841B (en) * | 2022-04-21 | 2023-12-15 | 广州中科云图智能科技有限公司 | Correction method and device based on landing pattern |
| CN117615080B (en) * | 2023-11-02 | 2024-06-21 | 江南大学 | Printing color separation method and system |
Citations (13)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101630444A (en) * | 2009-08-06 | 2010-01-20 | 杭州六易科技有限公司 | Automatic identification warning system of vehicle-mounted traffic annunciator |
| CN203396705U (en) * | 2013-05-13 | 2014-01-15 | 深圳市宝凯仑科技有限公司 | Rapid detection card |
| CN103985118A (en) * | 2014-04-28 | 2014-08-13 | 无锡观智视觉科技有限公司 | Parameter calibration method for cameras of vehicle-mounted all-round view system |
| CN104657728A (en) * | 2015-03-19 | 2015-05-27 | 江苏物联网研究发展中心 | Barcode recognition system based on computer vision |
| CN107609451A (en) * | 2017-09-14 | 2018-01-19 | 斯坦德机器人(深圳)有限公司 | A kind of high-precision vision localization method and system based on Quick Response Code |
| CN107689061A (en) * | 2017-07-11 | 2018-02-13 | 西北工业大学 | Rule schema shape code and localization method for indoor mobile robot positioning |
| CN107944324A (en) * | 2017-11-16 | 2018-04-20 | 凌云光技术集团有限责任公司 | A kind of Quick Response Code distortion correction method and device |
| CN108090542A (en) * | 2018-01-10 | 2018-05-29 | 深圳市深大极光科技有限公司 | A kind of two-dimensional code anti-counterfeiting label and preparation method thereof |
| CN108305291A (en) * | 2018-01-08 | 2018-07-20 | 武汉大学 | Utilize the monocular vision positioning and orientation method of the wall advertisement comprising positioning Quick Response Code |
| CN108549397A (en) * | 2018-04-19 | 2018-09-18 | 武汉大学 | The unmanned plane Autonomous landing method and system assisted based on Quick Response Code and inertial navigation |
| CN108765328A (en) * | 2018-05-18 | 2018-11-06 | 凌美芯(北京)科技有限责任公司 | A kind of high-precision multiple features plane template and its distort optimization and scaling method |
| CN109805891A (en) * | 2019-01-08 | 2019-05-28 | 中南大学湘雅医院 | Postoperative recovery state monitoring method, device, system, readable medium and color card |
| CN109829524A (en) * | 2019-01-17 | 2019-05-31 | 柳州康云互联科技有限公司 | A kind of compound characteristics of image code and preparation method thereof |
Family Cites Families (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| TW201113815A (en) * | 2009-10-09 | 2011-04-16 | Primax Electronics Ltd | QR code processing method and apparatus thereof |
| CN104517109B (en) * | 2013-09-29 | 2018-03-06 | 北大方正集团有限公司 | A kind of bearing calibration of QR codes image and system |
| CN109461126B (en) * | 2018-10-16 | 2020-06-30 | 重庆金山科技(集团)有限公司 | Image distortion correction method and system |
-
2019
- 2019-07-30 CN CN201910695090.3A patent/CN110400278B/en active Active
Patent Citations (13)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101630444A (en) * | 2009-08-06 | 2010-01-20 | 杭州六易科技有限公司 | Automatic identification warning system of vehicle-mounted traffic annunciator |
| CN203396705U (en) * | 2013-05-13 | 2014-01-15 | 深圳市宝凯仑科技有限公司 | Rapid detection card |
| CN103985118A (en) * | 2014-04-28 | 2014-08-13 | 无锡观智视觉科技有限公司 | Parameter calibration method for cameras of vehicle-mounted all-round view system |
| CN104657728A (en) * | 2015-03-19 | 2015-05-27 | 江苏物联网研究发展中心 | Barcode recognition system based on computer vision |
| CN107689061A (en) * | 2017-07-11 | 2018-02-13 | 西北工业大学 | Rule schema shape code and localization method for indoor mobile robot positioning |
| CN107609451A (en) * | 2017-09-14 | 2018-01-19 | 斯坦德机器人(深圳)有限公司 | A kind of high-precision vision localization method and system based on Quick Response Code |
| CN107944324A (en) * | 2017-11-16 | 2018-04-20 | 凌云光技术集团有限责任公司 | A kind of Quick Response Code distortion correction method and device |
| CN108305291A (en) * | 2018-01-08 | 2018-07-20 | 武汉大学 | Utilize the monocular vision positioning and orientation method of the wall advertisement comprising positioning Quick Response Code |
| CN108090542A (en) * | 2018-01-10 | 2018-05-29 | 深圳市深大极光科技有限公司 | A kind of two-dimensional code anti-counterfeiting label and preparation method thereof |
| CN108549397A (en) * | 2018-04-19 | 2018-09-18 | 武汉大学 | The unmanned plane Autonomous landing method and system assisted based on Quick Response Code and inertial navigation |
| CN108765328A (en) * | 2018-05-18 | 2018-11-06 | 凌美芯(北京)科技有限责任公司 | A kind of high-precision multiple features plane template and its distort optimization and scaling method |
| CN109805891A (en) * | 2019-01-08 | 2019-05-28 | 中南大学湘雅医院 | Postoperative recovery state monitoring method, device, system, readable medium and color card |
| CN109829524A (en) * | 2019-01-17 | 2019-05-31 | 柳州康云互联科技有限公司 | A kind of compound characteristics of image code and preparation method thereof |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US12153979B1 (en) | 2023-06-30 | 2024-11-26 | Kao Corporation | Card for identifying a tone of a sample of human skin |
Also Published As
| Publication number | Publication date |
|---|---|
| CN110400278A (en) | 2019-11-01 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN110400278B (en) | A fully automatic correction method, device and equipment for image color and geometric distortion | |
| CN113920205B (en) | A Calibration Method for Non-Coaxial Cameras | |
| CN111429533B (en) | Camera lens distortion parameter estimation device and method | |
| CN114693760B (en) | Image correction method, device, system, and electronic equipment | |
| CN110223226B (en) | Panoramic image stitching method and system | |
| CN109410207B (en) | NCC (non-return control) feature-based unmanned aerial vehicle line inspection image transmission line detection method | |
| US8199202B2 (en) | Image processing device, storage medium storing image processing program, and image pickup apparatus | |
| CN111353961B (en) | Document curved surface correction method and device | |
| CN110866871A (en) | Text image correction method and device, computer equipment and storage medium | |
| WO2019227615A1 (en) | Method for correcting invoice image, apparatus, computer device, and storage medium | |
| CN110838086B (en) | An Outdoor Image Mosaic Method Based on Correlation Template Matching | |
| CN109961013A (en) | Lane line identification method, device, device, and computer-readable storage medium | |
| CN112825141A (en) | Method and device for recognizing text, recognition equipment and storage medium | |
| CN113808033A (en) | Image document correction method, system, terminal and medium | |
| CN110569845A (en) | A test paper image correction method and related device | |
| CN113112531B (en) | Image matching method and device | |
| CN112733773A (en) | Object detection method and device, computer equipment and storage medium | |
| CN117522803A (en) | Precise positioning method of bridge components based on binocular vision and target detection | |
| CN111368573A (en) | Positioning method based on geometric feature constraint | |
| KR20190027165A (en) | Image Adjustment System and Method for Unifying Features of Multiple Images | |
| CN110751690B (en) | Visual positioning method for milling machine tool bit | |
| CN110245674B (en) | Template matching method, device, equipment and computer storage medium | |
| CN119359601A (en) | A geometric correction method for images collected by rail transit linear array cameras | |
| US20100177959A1 (en) | Color form dropout using dynamic geometric solid thresholding | |
| CN116433494B (en) | File scanning image automatic correction and trimming method based on deep learning |
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 |