技术领域technical field
本发明涉及图像处理技术领域,具体的说是涉及一种复杂背景下的卡片图像的提取方法及系统。The invention relates to the technical field of image processing, in particular to a method and system for extracting card images under complex backgrounds.
背景技术Background technique
图像目标提取技术是图像处理技术领域重要的组成部分,目前图像目标提取方法主要有:(1)基于区域的目标图像提取方法,(2)基于边缘的目标图像提取方法,(3)区域与边缘相结合的目标图像提取方法,(4)基于数学形态学的目标图像提取方法,(5)基于神经网络的目标图像提取方法,(6)基于支持向量机的目标图像提取方法,(7)基于图论的目标图像提取方法。Image target extraction technology is an important part of the image processing technology field. At present, image target extraction methods mainly include: (1) region-based target image extraction method, (2) edge-based target image extraction method, (3) region and edge Combined target image extraction method, (4) target image extraction method based on mathematical morphology, (5) target image extraction method based on neural network, (6) target image extraction method based on support vector machine, (7) based on Object Image Extraction Methods for Graph Theory.
但是上述目标图像提取方法,应用于针对目标图像为四边形的图像时,如身份证、银行卡等,即卡片图像,尚存在下述问题:But above-mentioned target image extraction method, when being applied to the image that target image is quadrilateral, as identity card, bank card etc., i.e. card image, still has the following problems:
如由于卡片图像数据常常具有不确定性,通常伴随着信息噪声,这就极大影响了卡片图像提取精度的问题,如由于卡片图像提取问题本身的解常常不是唯一的,例如卡片图像中可能含有多个矩形区域,因此难以用统一的方法区分出我们需要的卡片目标,如由于卡片图像提取往往受光照和亮度不均的影响较大,若图像部分区域含有阴影,会对图像纹理和特征的提取造成影响,因而会造成该类卡片图像提取错误等问题。For example, the card image data is often uncertain, usually accompanied by information noise, which greatly affects the accuracy of card image extraction. For example, the solution to the card image extraction problem itself is often not unique, for example, the card image may contain There are multiple rectangular areas, so it is difficult to use a unified method to distinguish the card target we need. For example, because the card image extraction is often greatly affected by uneven illumination and brightness, if some areas of the image contain shadows, it will affect the texture and features of the image. Extraction is affected, which will cause problems such as image extraction errors for this type of card.
发明内容Contents of the invention
鉴于已有技术存在的缺陷,本发明的目的是要提供一种卡片图像的提取方法,该方法能够有效去除图像伪边缘,提高图像提取的效果以及精度,同时该方法可以有效去除复杂背景纹理边缘,对复杂背景图像的鲁棒性好。In view of the defects existing in the prior art, the purpose of the present invention is to provide a method for extracting card images, which can effectively remove image pseudo-edges, improve the effect and accuracy of image extraction, and at the same time, this method can effectively remove complex background texture edges , which is robust to complex background images.
为了实现上述目的,本发明的技术方案:In order to achieve the above object, technical scheme of the present invention:
一种卡片图像的提取方法,其特征在于,包括如下步骤:A method for extracting a card image, comprising the steps of:
S1、对读入的待提取卡片图像进行预处理;S1. Preprocessing the read card image to be extracted;
S2、分别基于彩色图像自适应边缘检测方法、相位一致性检测方法,自经预处理的卡片图像中提取出各自对应的边缘图像,并对当前所提取的两幅边缘图像进行求与运算后合成卡片图像所对应的粗提取图像;S2. Based on the color image adaptive edge detection method and the phase consistency detection method, respectively, extract the corresponding edge images from the preprocessed card images, and perform summing operations on the currently extracted two edge images and synthesize them The coarse extracted image corresponding to the card image;
S3、在HSV空间下,基于相位一致性检测方法对所述粗提取图像进行边缘检测,以获得最终的边缘图像;S3. In the HSV space, perform edge detection on the rough extracted image based on a phase consistency detection method to obtain a final edge image;
S4、基于S3中所获得边缘图像,采用霍夫变换检测直线合成卡片图像最终的提取图像。S4. Based on the edge image obtained in S3, the Hough transform is used to detect straight lines and synthesize the final extracted image of the card image.
进一步的,作为本发明的优选方案,Further, as a preferred solution of the present invention,
所述S2中对当前所提取的两幅边缘图像进行求与运算后合成卡片图像所对应的粗提取图像的过程包括下述步骤:In said S2, the process of summing the currently extracted two edge images and synthesizing the rough extraction image corresponding to the card image comprises the following steps:
S21、对所得到的两幅边缘图像进行去除伪边缘处理,即分别将所得到的两幅边缘图像转为灰度图像,利用直方图确定各自对应的边缘阈值;并通过图像形态学处理去除噪声点区域,以分别得到与彩色图像自适应边缘检测方法所对应的边缘图像img11以及与相位一致性检测方法所对应的边缘图像img12;S21. Perform pseudo-edge removal processing on the obtained two edge images, that is, respectively convert the obtained two edge images into grayscale images, and use the histogram to determine the corresponding edge thresholds; and remove noise through image morphology processing point area, to obtain respectively the edge image img11 corresponding to the color image adaptive edge detection method and the edge image img12 corresponding to the phase consistency detection method;
S22、对所得到的边缘图像img11、边缘图像img12进行求与运算,以得到初始边缘图像;并通过对所述初始边缘图像进行最小外界矩形计算确认卡片提取图像所对应的目标图像区域,通过将目标图像区域与待提取卡片的原始图像进行点乘,获得待提取卡片图像的粗提取图像。S22. Perform summing operation on the obtained edge image img11 and edge image img12 to obtain an initial edge image; and confirm the target image area corresponding to the card extraction image by calculating the minimum outer rectangle of the initial edge image, and The target image area is dot-multiplied with the original image of the card to be extracted to obtain a rough image of the card to be extracted.
进一步的,作为本发明的优选方案,Further, as a preferred solution of the present invention,
所述S3包括下述步骤:Said S3 comprises the following steps:
S31、将读入的粗提取图像转换到HSV颜色空间下;S31. Convert the read-in rough extraction image into the HSV color space;
S32、基于相位一致性检测方法对粗提取图像的H分量进行边缘检测,以得到H分量所对应的边缘强度图像和角度强度图像;并将所获得的边缘强度图像和角度强度图像进行叠加后,进行非极大抑制处理、图像骨架化处理得到H分量下的边缘图像img21;S32. Perform edge detection on the H component of the roughly extracted image based on the phase consistency detection method to obtain an edge intensity image and an angle intensity image corresponding to the H component; and after superimposing the obtained edge intensity image and angle intensity image, Perform non-maximum suppression processing and image skeletonization processing to obtain the edge image img21 under the H component;
S33、基于相位一致性检测方法对粗提取图像的S分量进行边缘检测,以得到S分量所对应的边缘强度图像和角度强度图像;并将所获得的边缘强度图像和角度强度图像进行叠加后,进行非极大抑制处理、图像骨架化处理后得到S分量下的边缘图像img22;S33. Perform edge detection on the S component of the roughly extracted image based on the phase consistency detection method to obtain an edge intensity image and an angle intensity image corresponding to the S component; and after superimposing the obtained edge intensity image and angle intensity image, After non-maximum suppression processing and image skeletonization processing, the edge image img22 under the S component is obtained;
S34、对所述边缘图像img21、边缘图像img22进行求或运算,得到边缘图像img2后与粗提取图像进行求与运算,得到最终的边缘图像img_z。S34 , perform an OR operation on the edge image img21 and the edge image img22 to obtain the edge image img2 and perform an AND operation with the rough extraction image to obtain the final edge image img_z.
本发明的另一目的是要提供一种卡片图像的提取系统,其特征在于,包括:Another object of the present invention is to provide a card image extraction system, characterized in that it includes:
预处理单元,该预处理单元能够对读入的待提取卡片图像进行预处理;A preprocessing unit, which can preprocess the read card image to be extracted;
第一级提取单元,该第一级提取单元能够基于彩色图像自适应边缘检测方法、相位一致性检测方法,分别自经预处理的卡片图像中提取出各自对应的边缘图像,并对当前所提取的两幅边缘图像进行求与运算后合成卡片图像所对应的粗提取图像;The first-level extraction unit, the first-level extraction unit can extract the respective corresponding edge images from the preprocessed card image based on the color image adaptive edge detection method and the phase consistency detection method, and extract the currently extracted The rough extraction image corresponding to the synthesized card image after summing the two edge images of the two edge images;
边缘图像提取单元,该边缘图像提取单元能够在HSV空间下,基于相位一致性检测方法对所述粗提取图像进行边缘检测,获得最终的边缘图像;An edge image extraction unit, which can perform edge detection on the rough extracted image based on a phase consistency detection method in HSV space to obtain a final edge image;
以及第二级提取单元,该第二级提取单元能够基于边缘图像提取单元所获得边缘图像,采用霍夫变换检测直线合成卡片图像最终的提取图像。And a second-level extraction unit, the second-level extraction unit can use Hough transform to detect straight lines and synthesize the final extracted image of the card image based on the edge image obtained by the edge image extraction unit.
与现有技术相比,本发明的有益效果:Compared with prior art, the beneficial effect of the present invention:
1)针对读入的待提取图像预处理,使得图像提取算法效率提升,无需占用很大内存存储空间,便于实时处理;1) Preprocessing the read-in image to be extracted improves the efficiency of the image extraction algorithm, does not need to occupy a large memory storage space, and facilitates real-time processing;
2)读取预处理后的图像,分别利用彩色图像自适应边缘检测方法和相位一致性方法获取两幅图像边缘,并将其求与运算,从而得到卡片的粗提取结果,可以避免图像因光照和亮度不均造成的错误提取,能够有效的去除图像伪边缘,使得图像提取的效果更加优良;2) Read the preprocessed image, use the color image adaptive edge detection method and the phase consistency method to obtain the edges of the two images, and sum them to obtain the rough extraction result of the card, which can avoid the image from being damaged by light. The wrong extraction caused by uneven brightness and brightness can effectively remove the false edge of the image, making the image extraction effect more excellent;
3)将得到的两幅边缘图像转为灰度图,利用直方图自动确定边缘阈值,然后经过形态学操作将图像较小的连通域去除(即我们认为是噪声点的区域),可以有效的去除背景噪声,提高了结果的精度;3) Convert the obtained two edge images into grayscale images, use the histogram to automatically determine the edge threshold, and then remove the smaller connected domains of the image (that is, the area we consider as noise points) through morphological operations, which can effectively Remove background noise and improve the accuracy of the results;
4)在HSV空间中,利用相位一致性算法对粗提取结果的H分量和S分量进行边缘检测,得到的边缘图像利用霍夫变换检测直线得到最终的卡片提取图像可以有效去除复杂背景纹理边缘,对于复杂背景的图像鲁棒性较好。4) In the HSV space, use the phase consistency algorithm to detect the edges of the H and S components of the rough extraction results, and use the Hough transform to detect the straight lines in the obtained edge images to obtain the final card extraction image, which can effectively remove complex background texture edges, It is robust to images with complex backgrounds.
附图说明Description of drawings
图1为本发明所述提取方法对应的步骤流程图;Fig. 1 is a flow chart of steps corresponding to the extraction method of the present invention;
图2为图1对应的步骤流程实例图;Fig. 2 is an example diagram of the step flow chart corresponding to Fig. 1;
图3a为本发明所述待提取卡片图像实例图;Fig. 3a is an example diagram of the image of the card to be extracted according to the present invention;
图3b为图3a的彩色边缘图像rgbx实例图;Figure 3b is an example diagram of the color edge image rgbx of Figure 3a;
图3c为图3a的彩色边缘图像rgby实例图;Fig. 3c is an example diagram of the color edge image rgby of Fig. 3a;
图3d为图3a的彩色边缘图像rgbimg实例图;Figure 3d is an example diagram of the color edge image rgbimg of Figure 3a;
图4为本发明所述S2采用相位一致性算法得到的边缘图像实例图;Fig. 4 is the edge image example diagram that S2 of the present invention adopts phase consistency algorithm to obtain;
图5a为本发明所述边缘图像img11实例图;Fig. 5a is an example diagram of the edge image img11 of the present invention;
图5b为本发明所述边缘图像img12实例图;Fig. 5b is an example diagram of the edge image img12 of the present invention;
图5c为本发明所述粗提取图像img1实例图;Fig. 5c is an example diagram of the rough extraction image img1 of the present invention;
图6为本发明所述边缘图像img2实例图;Fig. 6 is an example diagram of the edge image img2 of the present invention;
图7为本发明所述最终的边缘图像img_z实例图;Fig. 7 is an example diagram of the final edge image img_z of the present invention;
图8为本发明所获得目标卡片图像实例图。Fig. 8 is an example diagram of the target card image obtained in the present invention.
具体实施方式Detailed ways
为使本发明的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purpose, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the implementation of the present invention. example, not all examples. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.
如图1-图2所示,本发明设计了一种基于现有的彩色图像自适应边缘检测法和相位一致性检测法的卡片图像提取方法,包括以下步骤:As shown in Fig. 1-Fig. 2, the present invention designs a kind of card image extraction method based on existing color image self-adaptive edge detection method and phase consistency detection method, comprises the following steps:
S1、对读入的待提取卡片图像进行预处理,以使得图像提取效率提升,无需占用很大内存存储空间,便于实时处理;所述预处理,其包括以下步骤:S11、对读入的待提取卡片图像进行滤波降噪处理;S12、对经滤波降噪处理的图像进行缩放处理。具体作为本方法的优选实例,所述滤波降噪处理包括采用均值滤波处理以完成对前述卡片原始图像的噪声进行抑制;将经滤波降噪处理的图像缩小为原图尺寸的1/2,以提升算法效率并减少内存存储空间。S1. Preprocessing the read-in card image to be extracted, so that the image extraction efficiency is improved without taking up a large memory storage space, which is convenient for real-time processing; the pre-processing includes the following steps: S11. Extracting the image of the card to perform filtering and denoising processing; S12, performing scaling processing on the image subjected to filtering and denoising processing. Specifically as a preferred example of this method, the filtering and denoising processing includes the use of mean value filtering to complete the suppression of the noise of the original image of the aforementioned card; Improve algorithm efficiency and reduce memory storage space.
S2、读取预处理后的图像,分别基于彩色图像自适应边缘检测方法、相位一致性检测方法,自经预处理的卡片图像中提取出各自对应的边缘图像,并对当前所提取的两幅边缘图像进行求与运算后合成卡片图像所对应的粗提取图像;具体作为本方法的优选实例,基于彩色图像自适应边缘检测方法自经预处理的如图3a的卡片图像中提取出对应的边缘图像的过程包括:对经预处理的卡片图像所对应的rgb图像进行水平边缘检测以获得经量化的彩色水平边缘图像rgbx,如图3b,并对所述rgb图像卡片图像进行竖直边缘检测,以获得经量化的彩色垂直边缘图像rgby,如图3c;逐一比较彩色水平边缘图像rgbx、彩色垂直边缘图像rgby对应像素点的像素值的大小并构造系数矩阵rgbmask,该系数矩阵rgbmask构造原则为判断彩色水平边缘图像rgbx中当前像素点所对应的像素值是否大于彩色垂直边缘图像rgby中当前像素点所对应的像素值,是则系数矩阵rgbmask中对应位置置1,否则置0;保留rgbx和rgby的R、G、B三通道每一层x,y方向较明显的边缘,即得到的系数矩阵为1的点,按照下述公式对彩色水平边缘图像rgbx、彩色垂直边缘图像rgby进行边缘图像提取,以获得彩色边缘图像rgbimg,如图3d;所述公式为S2. Read the preprocessed image, respectively extract the corresponding edge images from the preprocessed card image based on the color image adaptive edge detection method and the phase consistency detection method, and perform the two currently extracted After the edge image is summed and calculated, the rough extraction image corresponding to the card image is synthesized; specifically, as a preferred example of this method, the corresponding edge is extracted from the preprocessed card image as shown in Figure 3a based on the color image adaptive edge detection method The image process includes: performing horizontal edge detection on the rgb image corresponding to the preprocessed card image to obtain a quantized color horizontal edge image rgbx, as shown in Figure 3b, and performing vertical edge detection on the rgb image card image, To obtain the quantized color vertical edge image rgby, as shown in Figure 3c; compare the pixel values of the color horizontal edge image rgbx and the color vertical edge image rgby one by one and construct the coefficient matrix rgbmask, the construction principle of the coefficient matrix rgbmask is judgment Whether the pixel value corresponding to the current pixel in the color horizontal edge image rgbx is greater than the pixel value corresponding to the current pixel in the color vertical edge image rgby, if yes, set the corresponding position in the coefficient matrix rgbmask to 1, otherwise set to 0; keep rgbx and rgby For the obvious edges in the x and y directions of each layer of the R, G, and B channels, that is, the points where the obtained coefficient matrix is 1, the edge images of the color horizontal edge image rgbx and the color vertical edge image rgby are extracted according to the following formula , to obtain the color edge image rgbimg, as shown in Figure 3d; the formula is
rgbimg=rgbx·rgbmask+rgby·(1-rgbmask)rgbimg=rgbx rgbmask+rgby (1-rgbmask)
上述公式中,矩阵的点乘就是矩阵各个对应元素相乘。In the above formula, the dot product of the matrix is the multiplication of each corresponding element of the matrix.
具体作为本方法的优选实例,基于相位一致性检测方法,对经预处理的卡片图像进行边缘图像提取处理过程包括:将经预处理的卡片图像转为灰度图像,并基于相位一致性检测算法获得对应的边缘图像,如图4,由于该算法为常用算法,因此这里仅对其应用到本发明的原理背景做简单说明:所谓相位一致性,简单的说就是指图像的各个位置上各个频率成分的相似度的一种度量方式,它是一个无量纲的量,其值是和光照及亮度的变化无关的,其可通过搜索局部能量函数的峰值来得到相位高度一致的位置,即局部能量函数正比于相位一致性,经测试可以得出结论,图像的边缘特征在图像的相位谱一致性上得到了很好的体现,其检测结果和图像的亮度以及对比度变化的剧烈程度无关。因此,该方法在光照不理想或者是图像亮度分布不均匀的情况下能够得到较好的检测效果,读入原始图像,并将其转为灰度图像,利用上述相位一致性算法即可得到边缘图像。Specifically as a preferred example of this method, based on the phase consistency detection method, the edge image extraction process of the preprocessed card image includes: converting the preprocessed card image into a grayscale image, and based on the phase consistency detection algorithm Obtain the corresponding edge image, as shown in Figure 4. Since this algorithm is a commonly used algorithm, here is only a brief description of its application to the principle background of the present invention: the so-called phase consistency simply means that each frequency on each position of the image A measure of the similarity of components, it is a dimensionless quantity, its value is independent of the change of illumination and brightness, it can obtain the position of highly consistent phase by searching the peak value of the local energy function, that is, the local energy The function is proportional to the phase consistency. After testing, it can be concluded that the edge features of the image are well reflected in the phase spectrum consistency of the image, and the detection results have nothing to do with the brightness and contrast of the image. Therefore, this method can obtain better detection results when the illumination is not ideal or the brightness distribution of the image is uneven. The original image is read in and converted into a grayscale image, and the edge image.
同时由于得到的彩色边缘图像和利用相位一致性方法得到的边缘图像不可避免的会有一些边缘是伪边缘,所以需要去除伪边缘,因此所述S2中对当前所提取的两幅边缘图像进行求与运算后合成卡片图像所对应的粗提取图像的过程包括下述步骤:S21、分别将所得到的两幅边缘图像转为灰度图像,利用直方图确定各自对应的边缘阈值;并通过图像形态学处理去除噪声点区域(由于灰度值分布绝大部分值集中在较小值附近,所以我们将灰度值最大的前10%确定为边缘,然后经过形态学操作将图像较小的连通域去除),以分别得到与彩色图像自适应边缘检测方法所对应的边缘图像img11以及与相位一致性检测方法所对应的边缘图像img12,如图5a、5b,;S22、为了进一步去除伪边缘,我们认为经过两种方法检测出的共同边缘为实际图像边缘,因此对所得到的边缘图像img11、边缘图像img12进行求与运算,以得到初始边缘图像;并通过对所述初始边缘图像进行最小外界矩形计算确认卡片提取图像所对应的目标图像区域,通过将目标图像区域与待提取卡片的原始图像进行点乘,获得待提取卡片图像的粗提取图像,如图5c。At the same time, because the obtained color edge image and the edge image obtained by using the phase consistency method inevitably have some edges that are false edges, so it is necessary to remove the false edges, so the two currently extracted edge images are calculated in S2. The process of roughly extracting the image corresponding to the synthesized card image after the operation includes the following steps: S21. Convert the obtained two edge images into grayscale images respectively, and use the histogram to determine the respective corresponding edge thresholds; Remove the noise point area by mathematical processing (because most of the gray value distribution is concentrated around the smaller value, we determine the top 10% of the largest gray value as the edge, and then through the morphological operation, the smaller connected domain of the image removed) to obtain the edge image img11 corresponding to the color image adaptive edge detection method and the edge image img12 corresponding to the phase consistency detection method, as shown in Figures 5a and 5b; S22, in order to further remove false edges, we It is considered that the common edge detected by the two methods is the actual image edge, so the obtained edge image img11 and edge image img12 are summed to obtain the initial edge image; and the minimum outer rectangle of the initial edge image is Calculate and confirm the target image area corresponding to the extracted image of the card, and obtain the rough extracted image of the card image to be extracted by dot multiplying the target image area with the original image of the card to be extracted, as shown in Figure 5c.
对于背景相对复杂的图像,上述操作也会检测出背景纹理的边缘,造成提取错误,因此我们采取在HSV空间中利用相位一致性算法对粗提取结果进行边缘检测,得到最终的图像边缘提取结果,上述过程即为下述步骤S3。For images with relatively complex backgrounds, the above operations will also detect the edges of the background texture, resulting in extraction errors. Therefore, we use the phase consistency algorithm in the HSV space to perform edge detection on the rough extraction results to obtain the final image edge extraction results. The above process is the following step S3.
具体的所述S3、在HSV空间下,基于相位一致性检测方法对所述粗提取图像进行边缘检测,以获得最终的边缘图像;具体作为本方法的优选实例,所述S3包括下述步骤:S31、将读入的粗提取图像转换到HSV颜色空间下,并利用H分量图像和S分量图像进行下一步操作,因为色调和饱和度成分与人们获取颜色的方式密切相关,而且我们已经在S2中解决了亮度不均的问题,故不考虑V分量图像;S32、基于相位一致性检测方法对粗提取图像的H分量进行边缘检测,以得到H分量所对应的边缘强度图像和角度强度图像;并将所获得的边缘强度图像和角度强度图像进行叠加后,进行非极大抑制处理、图像骨架化处理得到H分量下的边缘图像img21;S33、基于相位一致性检测方法对粗提取图像的S分量进行边缘检测,以得到S分量所对应的边缘强度图像和角度强度图像;并将所获得的边缘强度图像和角度强度图像进行叠加后,进行非极大抑制处理、图像骨架化处理后得到S分量下的边缘图像img22;S34、我们认为经过两种方法检测出的边缘都是实际图像边缘,因此对所述边缘图像img21、边缘图像img22进行求或运算得到边缘图像img2,如图6,再与粗提取图像进行求与运算,得到最终的边缘图像img_z,如图7。Specifically, in the S3, in the HSV space, edge detection is performed on the rough extracted image based on a phase consistency detection method to obtain a final edge image; specifically as a preferred example of the method, the S3 includes the following steps: S31. Convert the read-in rough extraction image to the HSV color space, and use the H component image and the S component image to perform the next step, because the hue and saturation components are closely related to the way people obtain colors, and we have already done it in S2 solve the problem of uneven brightness, so the V component image is not considered; S32, based on the phase consistency detection method, edge detection is performed on the H component of the roughly extracted image to obtain the edge intensity image and angle intensity image corresponding to the H component; After superimposing the obtained edge intensity image and angle intensity image, perform non-maximum suppression processing and image skeletonization processing to obtain the edge image img21 under the H component; S33, based on the phase consistency detection method, the S component to perform edge detection to obtain the edge intensity image and angle intensity image corresponding to the S component; and after superimposing the obtained edge intensity image and angle intensity image, perform non-maximum suppression processing and image skeletonization processing to obtain S The edge image img22 under the component; S34, we think that the edge detected by the two methods is the actual image edge, so the edge image img21 and the edge image img22 are summed or calculated to obtain the edge image img2, as shown in Figure 6, and then Perform an AND operation with the rough extraction image to obtain the final edge image img_z, as shown in Figure 7.
S4、基于S3中所获得边缘图像,采用霍夫变换检测直线合成卡片图像最终的提取图像。利用霍夫变换检测直线检测出卡片的四条边,然后计算其最小外界矩形,经过旋转和分割进而得到最终的卡片提取图像,因为在HSV颜色空间中,色彩信息只与H分量和S分量有关,色调和饱和度成分与人们获取颜色的方式密切相关,该方法可以有效去除复杂背景纹理边缘,对于复杂背景的图像鲁棒性较好。S4. Based on the edge image obtained in S3, the Hough transform is used to detect straight lines and synthesize the final extracted image of the card image. Use the Hough transform to detect the four sides of the card, and then calculate its minimum outer rectangle, and then rotate and divide to get the final card extraction image, because in the HSV color space, the color information is only related to the H component and the S component. The hue and saturation components are closely related to the way people obtain colors. This method can effectively remove the edges of complex background textures, and is more robust to images with complex backgrounds.
本发明的另一目的是要提供一种卡片图像的提取系统,其特征在于,包括:Another object of the present invention is to provide a card image extraction system, characterized in that it includes:
1.预处理单元,该预处理单元能够对读入的待提取卡片图像进行预处理;所述预处理,其包括对读入的待提取卡片图像进行滤波降噪处理;对经滤波降噪处理的图像进行缩放处理。具体作为本方法的优选实例,所述滤波降噪处理包括采用均值滤波处理以完成对前述卡片原始图像的噪声进行抑制;将经滤波降噪处理的图像缩小为原图尺寸的1/2,以提升算法效率并减少内存存储空间;1. A preprocessing unit, which can preprocess the read-in card image to be extracted; said pre-processing includes performing filtering and noise reduction processing on the read-in card image to be extracted; The image is scaled. Specifically as a preferred example of this method, the filtering and denoising processing includes the use of mean value filtering to complete the suppression of the noise of the original image of the aforementioned card; Improve algorithm efficiency and reduce memory storage space;
2.第一级提取单元,该第一级提取单元能够基于彩色图像自适应边缘检测方法、相位一致性检测方法,分别自经预处理的卡片图像中提取出各自对应的边缘图像,并对当前所提取的两幅边缘图像进行求与运算后合成卡片图像所对应的粗提取图像;具体作为本方法的优选实例,所述基于彩色图像自适应边缘检测方法自经预处理的卡片图像中提取出对应的边缘图像的过程包括:对经预处理的如图3a的卡片图像所对应的rgb图像进行水平边缘检测以获得经量化的彩色水平边缘图像rgbx,如图3b,并对所述rgb图像卡片图像进行竖直边缘检测,以获得经量化的彩色垂直边缘图像rgby,如图3c;逐一比较彩色水平边缘图像rgbx、彩色垂直边缘图像rgby对应像素点的像素值的大小并构造系数矩阵rgbmask,该系数矩阵rgbmask构造原则为判断彩色水平边缘图像rgbx中当前像素点所对应的像素值是否大于彩色垂直边缘图像rgby中当前像素点所对应的像素值,是则系数矩阵rgbmask中对应位置置1,否则置0;保留rgbx和rgby的R、G、B三通道每一层x,y方向较明显的边缘,即得到的系数矩阵为1的点,按照下述公式对彩色水平边缘图像rgbx、彩色垂直边缘图像rgby进行边缘图像提取,以获得彩色边缘图像rgbimg,如图3d;所述公式为2. The first-level extraction unit, which can extract the respective corresponding edge images from the preprocessed card image based on the color image adaptive edge detection method and the phase consistency detection method, and perform the current The extracted two edge images are summed and then synthesized into a roughly extracted image corresponding to the card image; specifically as a preferred example of the method, the color image-based adaptive edge detection method is extracted from the preprocessed card image. The process of the corresponding edge image includes: performing horizontal edge detection on the preprocessed rgb image corresponding to the card image as shown in Fig. 3a to obtain a quantized color horizontal edge image rgbx, as shown in Fig. Carry out vertical edge detection on the image to obtain the quantized color vertical edge image rgby, as shown in Figure 3c; compare the size of the pixel values of the color horizontal edge image rgbx and the color vertical edge image rgby one by one and construct the coefficient matrix rgbmask, the The construction principle of the coefficient matrix rgbmask is to judge whether the pixel value corresponding to the current pixel point in the color horizontal edge image rgbx is greater than the pixel value corresponding to the current pixel point in the color vertical edge image rgby, then the corresponding position in the coefficient matrix rgbmask is set to 1, otherwise Set to 0; retain the obvious edges in the x and y directions of each layer of the R, G, and B channels of rgbx and rgby, that is, the point where the obtained coefficient matrix is 1, and the color horizontal edge image rgbx, color vertical edge image is calculated according to the following formula The edge image rgby performs edge image extraction to obtain the color edge image rgbimg, as shown in Figure 3d; the formula is
rgbimg=rgbx·rgbmask+rgby·(1-rgbmask)rgbimg=rgbx rgbmask+rgby (1-rgbmask)
上述公式中,矩阵的点乘就是矩阵各个对应元素相乘。In the above formula, the dot product of the matrix is the multiplication of each corresponding element of the matrix.
具体作为本方法的优选实例,基于相位一致性检测方法,对经预处理的卡片图像进行边缘图像提取处理过程包括:将经预处理的卡片图像转为灰度图,并基于相位一致性检测算法获得对应的边缘图像,如图4,由于该算法为常用算法,因此这里仅对其应用到本发明的原理背景做简单说明:所谓相位一致性,简单的说就是指图像的各个位置上各个频率成分的相似度的一种度量方式,它是一个无量纲的量,其值是和光照及亮度的变化无关的,其可通过搜索局部能量函数的峰值来得到相位高度一致的位置,即局部能量函数正比于相位一致性,经测试可以得出结论,图像的边缘特征在图像的相位谱一致性上得到了很好的体现,其检测结果和图像的亮度以及对比度变化的剧烈程度无关。因此,该方法在光照不理想或者是图像亮度分布不均匀的情况下能够得到较好的检测效果,读入原始图像,并将其转为灰度图,利用上述相位一致性算法即可得到边缘图像;Specifically as a preferred example of this method, based on the phase consistency detection method, the edge image extraction process of the preprocessed card image includes: converting the preprocessed card image into a grayscale image, and based on the phase consistency detection algorithm Obtain the corresponding edge image, as shown in Figure 4. Since this algorithm is a commonly used algorithm, here is only a brief description of its application to the principle background of the present invention: the so-called phase consistency simply means that each frequency on each position of the image A measure of the similarity of components, it is a dimensionless quantity, its value has nothing to do with the change of illumination and brightness, it can get the position of highly consistent phase by searching the peak value of the local energy function, that is, the local energy The function is proportional to the phase consistency. After testing, it can be concluded that the edge features of the image are well reflected in the phase spectrum consistency of the image, and the detection results have nothing to do with the brightness and contrast of the image. Therefore, this method can obtain a better detection effect when the illumination is not ideal or the image brightness distribution is uneven, read in the original image, and convert it into a grayscale image, and use the above phase consistency algorithm to get the edge image;
同时由于得到的彩色边缘图像和利用相位一致性方法得到的边缘图像不可避免的会有一些边缘是伪边缘,所以需要去除伪边缘,因此所述第一级提取单元中还能够完成下述功能:1、分别将所得到的两幅边缘图像转为灰度图像,利用直方图确定各自对应的边缘阈值;并通过图像形态学处理去除噪声点区域(由于灰度值分布绝大部分值集中在较小值附近,所以我们将灰度值最大的前10%确定为边缘,然后经过形态学操作将图像较小的连通域去除),以分别得到与彩色图像自适应边缘检测方法所对应的边缘图像img11以及与相位一致性检测方法所对应的边缘图像img12,如图5a、5b;2、为了进一步去除伪边缘,我们认为经过两种方法检测出的共同边缘为实际图像边缘,因此对所得到的边缘图像img11、边缘图像img12进行求与运算,以得到初始边缘图像;并通过对所述初始边缘图像进行最小外界矩形计算确认卡片提取图像所对应的目标图像区域,通过将目标图像区域与待提取卡片的原始图像进行点乘,获得待提取卡片图像的粗提取图像,如图5c。Simultaneously because the color edge image that obtains and the edge image that utilizes the phase coherence method to obtain inevitably have some edges to be false edges, so need to remove false edges, so the following functions can also be completed in the described first-level extraction unit: 1. Convert the obtained two edge images into grayscale images respectively, and use the histogram to determine the corresponding edge thresholds; and remove the noise point area through image morphology processing (because most of the gray value distribution is concentrated in the relatively small near the small value, so we determine the top 10% of the largest gray value as the edge, and then remove the smaller connected domain of the image through morphological operations) to obtain the edge image corresponding to the color image adaptive edge detection method img11 and the edge image img12 corresponding to the phase consistency detection method, as shown in Figure 5a, 5b; 2. In order to further remove false edges, we believe that the common edge detected by the two methods is the actual image edge, so the obtained The edge image img11 and the edge image img12 are summed to obtain the initial edge image; and the minimum outer rectangle calculation is performed on the initial edge image to confirm the target image area corresponding to the card extraction image, and the target image area is compared with the target image area to be extracted The original image of the card is dot-multiplied to obtain a rough image of the card image to be extracted, as shown in Figure 5c.
3.边缘图像提取单元,该边缘图像提取单元能够在HSV空间下,基于相位一致性检测方法对所述粗提取图像进行边缘检测,获得最终的边缘图像;具体作为本方法的优选实例,所述边缘图像提取单元的处理过程包括下述步骤:首先将读入的粗提取图像转换到HSV颜色空间下,并利用H分量图像和S分量图像进行下一步操作,因为色调和饱和度成分与人们获取颜色的方式密切相关,而且我们已经在S2中解决了亮度不均的问题,故不考虑V分量图像;其次基于相位一致性检测方法对粗提取图像的H分量进行边缘检测,以得到H分量所对应的边缘强度图像和角度强度图像;并将所获得的边缘强度图像和角度强度图像进行叠加后,进行非极大抑制处理、图像骨架化处理得到H分量下的边缘图像img21;再次基于相位一致性检测方法对粗提取图像的S分量进行边缘检测,以得到S分量所对应的边缘强度图像和角度强度图像;并将所获得的边缘强度图像和角度强度图像进行叠加后,进行非极大抑制处理、图像骨架化处理后得到S分量下的边缘图像img22;最后,我们认为经过两种方法检测出的边缘都是实际图像边缘,因此对所述边缘图像img21、边缘图像img22进行求或运算得到边缘图像img2,如图6,再与粗提取图像进行求与运算,得到最终的边缘图像img_z,如图7。3. The edge image extraction unit, the edge image extraction unit can carry out edge detection to the rough extraction image based on the phase consistency detection method under the HSV space, and obtain the final edge image; specifically as a preferred example of the method, the The processing process of the edge image extraction unit includes the following steps: first, convert the read-in rough extraction image into the HSV color space, and use the H component image and the S component image to perform the next step, because the hue and saturation components are related to people’s acquisition The way of color is closely related, and we have solved the problem of uneven brightness in S2, so the V component image is not considered; secondly, based on the phase consistency detection method, edge detection is performed on the H component of the roughly extracted image to obtain the H component. The corresponding edge intensity image and angle intensity image; after superimposing the obtained edge intensity image and angle intensity image, perform non-maximum suppression processing and image skeletonization processing to obtain the edge image img21 under the H component; again based on phase consistency The property detection method performs edge detection on the S component of the roughly extracted image to obtain the edge intensity image and angle intensity image corresponding to the S component; and after superimposing the obtained edge intensity image and angle intensity image, perform non-maximum suppression After processing and image skeletonization, the edge image img22 under the S component is obtained; finally, we believe that the edges detected by the two methods are the actual image edges, so the edge image img21 and the edge image img22 are summed or calculated to obtain The edge image img2, as shown in Figure 6, is summed with the rough extraction image to obtain the final edge image img_z, as shown in Figure 7.
4.第二级提取单元,该第二级提取单元能够基于边缘图像提取单元所获得边缘图像,采用霍夫变换检测直线合成卡片图像最终的提取图像,如图8。4. The second-level extraction unit, the second-level extraction unit can use the Hough transform to detect straight lines and synthesize the final extracted image of the card image based on the edge image obtained by the edge image extraction unit, as shown in Figure 8.
以上所述,仅为本发明较佳的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,根据本发明的技术方案及其发明构思加以等同替换或改变,都应涵盖在本发明的保护范围之内。The above is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto, any person familiar with the technical field within the technical scope disclosed in the present invention, according to the technical solution of the present invention Any equivalent replacement or change of the inventive concepts thereof shall fall within the protection scope of the present invention.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201610818707.2ACN106408533B (en) | 2016-09-12 | 2016-09-12 | A card image extraction method and system |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201610818707.2ACN106408533B (en) | 2016-09-12 | 2016-09-12 | A card image extraction method and system |
| Publication Number | Publication Date |
|---|---|
| CN106408533A CN106408533A (en) | 2017-02-15 |
| CN106408533Btrue CN106408533B (en) | 2019-10-22 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201610818707.2AExpired - Fee RelatedCN106408533B (en) | 2016-09-12 | 2016-09-12 | A card image extraction method and system |
| Country | Link |
|---|---|
| CN (1) | CN106408533B (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107798325B (en)* | 2017-08-18 | 2021-04-16 | 中国银联股份有限公司 | Card identification method and device, computer storage medium |
| CN110287851A (en)* | 2019-06-20 | 2019-09-27 | 厦门市美亚柏科信息股份有限公司 | A kind of target image localization method, device, system and storage medium |
| CN111860486B (en)* | 2020-07-27 | 2023-10-31 | 平安科技(深圳)有限公司 | Card identification method, device and equipment |
| CN113989314A (en)* | 2021-10-26 | 2022-01-28 | 深圳前海环融联易信息科技服务有限公司 | Method for removing header and footer based on Hough transform linear detection |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN104217444A (en)* | 2013-06-03 | 2014-12-17 | 支付宝(中国)网络技术有限公司 | Method and apparatus for locating card areas |
| CN104268864A (en)* | 2014-09-18 | 2015-01-07 | 小米科技有限责任公司 | Card edge extracting method and device |
| CN105095900A (en)* | 2014-05-04 | 2015-11-25 | 阿里巴巴集团控股有限公司 | Method and device of extracting specific information in standard card |
| US20150371086A1 (en)* | 2013-06-30 | 2015-12-24 | Google Inc. | Extracting card data from multiple cards |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN104217444A (en)* | 2013-06-03 | 2014-12-17 | 支付宝(中国)网络技术有限公司 | Method and apparatus for locating card areas |
| US20150371086A1 (en)* | 2013-06-30 | 2015-12-24 | Google Inc. | Extracting card data from multiple cards |
| CN105095900A (en)* | 2014-05-04 | 2015-11-25 | 阿里巴巴集团控股有限公司 | Method and device of extracting specific information in standard card |
| CN104268864A (en)* | 2014-09-18 | 2015-01-07 | 小米科技有限责任公司 | Card edge extracting method and device |
| Title |
|---|
| "基于提升小波的铁谱图像边缘检测";陈付梦等;《机械科学与技术》;20131030;第32卷(第10期);摘要* |
| "基于边缘检测的人脸模拟画像检索";马月娜等;《计算机应用与软件》;20090831;第26卷(第8期);第2.2节第(3)节)* |
| Publication number | Publication date |
|---|---|
| CN106408533A (en) | 2017-02-15 |
| Publication | Publication Date | Title |
|---|---|---|
| CN107301661B (en) | High-resolution remote sensing image registration method based on edge point features | |
| CN109741356B (en) | Subpixel edge detection method and system | |
| CN106408533B (en) | A card image extraction method and system | |
| CN102147920B (en) | Shadow detection method for high-resolution remote sensing image | |
| CN107895376A (en) | Based on the solar panel recognition methods for improving Canny operators and contour area threshold value | |
| Hao et al. | Improved self-adaptive edge detection method based on Canny | |
| JP2012008100A (en) | Image processor, image processing method and image processing program | |
| CN109961416B (en) | A business license information extraction method based on multi-scale fusion of morphological gradients | |
| CN105405138B (en) | Waterborne target tracking based on conspicuousness detection | |
| Lo et al. | Joint trilateral filtering for depth map super-resolution | |
| CN107256543B (en) | Image processing method, image processing device, electronic equipment and storage medium | |
| CN115100226B (en) | A Contour Extraction Method Based on Monocular Digital Image | |
| CN108399644A (en) | A kind of wall images recognition methods and its device | |
| Pirzada et al. | Analysis of edge detection algorithms for feature extraction in satellite images | |
| CN106599891A (en) | Remote sensing image region-of-interest rapid extraction method based on scale phase spectrum saliency | |
| CN110263778A (en) | A kind of meter register method and device based on image recognition | |
| CN116563582A (en) | Image template matching method and device based on domestic CPU and opencv | |
| Kumar et al. | Edge detection and denoising medical image using morphology | |
| Kang et al. | An adaptive fusion panoramic image mosaic algorithm based on circular LBP feature and HSV color system | |
| CN107038708A (en) | Application of the image recognition algorithm in paper-cut effect | |
| Xu et al. | Quaternion quasi-Chebyshev non-local means for color image denoising | |
| CN104036492B (en) | A kind of fruit image matching process based on spot extraction with neighbor point vector method | |
| Chandrakar et al. | Study and comparison of various image edge detection techniques | |
| CN103632378A (en) | Multi-threshold edge detection method based on point connection drawing game idea | |
| Divya et al. | Shadow detection and removal by object-wise segmentation |
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant | ||
| CF01 | Termination of patent right due to non-payment of annual fee | ||
| CF01 | Termination of patent right due to non-payment of annual fee | Granted publication date:20191022 |