Picture separation method based on grids

文档序号:1832047 发布日期:2021-11-12 浏览:4次 中文

阅读说明:本技术 一种基于栅格的图片分离方法 (Picture separation method based on grids ) 是由 王志锋 于 2021-07-20 设计创作,主要内容包括:本发明涉及一种基于栅格的图片分离方法,具体包括以下步骤:S1:利用ORB算法提取出空白图像和包含手写图像的特征向量;S2:利用图像特征配准所述空白图像和包含手写字的图像,使所述空白图像和包含手写字的图像中打印体的相对位置一致,获得新图像NP;S3:利用像素的栅格覆盖住所述空白图像,计算每个栅格内部像素的灰度的平均值h;取阈值n,当h>n时标记该栅格为待删除状态;S4:获得步骤S3中所有待删除栅格的位置,将步骤S2中新图像NP中相同位置的栅格全部涂成白色,从而获得原始的手写体文字。该方法能从原图像中完全分离出干净的手写字体字符,且能够保证其灰度值不变同时实现分离出结果更加可靠性的手写体字符图像。(The invention relates to a picture separation method based on grids, which specifically comprises the following steps: s1: extracting blank images and feature vectors containing handwritten images by using an ORB algorithm; s2: registering the blank image and the image containing the handwritten words by utilizing image features to enable the relative positions of the printing bodies in the blank image and the image containing the handwritten words to be consistent, and obtaining a new image NP; s3: covering the blank image by using grids of pixels, and calculating an average value h of the gray scale of the pixels in each grid; taking a threshold value n, and marking the grid as a state to be deleted when h is greater than n; s4: the positions of all the grids to be deleted in step S3 are obtained, and the grids at the same positions in the new image NP in step S2 are all painted white, thereby obtaining the original handwritten text. The method can completely separate clean handwritten font characters from the original image, and can ensure that the gray value of the handwritten font characters is unchanged and simultaneously realize the separation of the handwritten character image with more reliable result.)

1. A picture separation method based on grids is characterized by comprising the following steps:

s1: extracting blank images and feature vectors containing handwritten images by using an ORB algorithm;

s2: registering the blank image and the image containing the handwritten words by using image features to enable the relative positions of the printing bodies in the blank image and the image containing the handwritten words to be consistent, and acquiring a new image NP;

s3: covering the blank image by using grids of n x n pixels, wherein 3< n <10, and calculating the gray average value h of the pixels in each grid; taking a threshold value p, and marking the grid as a state to be deleted when h is greater than p;

s4: the positions of all the grids to be deleted in step S3 are obtained, and the grids at the same positions in the new image NP in step S2 are all painted white, thereby obtaining the original handwritten text.

2. The method for separating grid-based pictures according to claim 1, wherein said ORB algorithm in step S1 is an algorithm combination based on FAST algorithm and BRIEF algorithm, and comprises the following specific steps:

s11 finds key points of the image using FAST algorithm: setting a pixel point P, comparing the pixel point P with a plurality of pixel points which are 2 away from the pixel point P, and if the brightness of at least one pair of continuous pixel points is higher or lower than the pixel point P, selecting the pixel point P as a key point, thereby obtaining a plurality of pairs of key points;

s12 uses the BRIEF algorithm to convert the keypoints into feature quantities: feature vectors are created from the pairs of key points acquired in step S11.

3. The method for separating grid-based pictures according to claim 2, wherein the step S12 specifically comprises the steps of:

s121: taking the key point P as the center of a circle and d as the radius to make a circle A;

s122: n pairs of pixel points are randomly selected within circle a,

s123: let (x, y) be any pair of pixel points, x represents pixel point 1, and y represents pixel point 2; the pair of pixel points is converted by adopting a formula (1), wherein the formula (1) is as follows:

wherein, p (x), p (y) are the gray values of the pixel points x and y respectively;

s124: repeating step S123N times, thereby obtaining a vector with length N, which is the feature vector.

4. The method for separating grid-based pictures according to claim 2, wherein the step S2 specifically comprises the steps of:

s21: using affine transformation matricesDescribing deviation of the handwriting of the printed body in the image of the handwritten word and the handwriting in the blank image;

s22: the affine transformation matrix has 6 degrees of freedom: a. b, c, d, e, f, are applied to a certain point by the formal method of the following formula (2), wherein the formula (2) is:

wherein (x, y) is an old coordinate point, i.e., a coordinate point on the image containing the handwritten word; (x ', y') is the new coordinate point, namely the coordinate point of the blank image; at least 3 groups of corresponding coordinate points are needed for calculating 6 degrees of freedom of the affine transformation matrix;

s23: calculating Hamming distance between the feature vectors according to the feature vectors of the two images obtained in the step S1, if the distance is smaller than a threshold value N, determining that the feature points on the two images can be matched into a pair, calculating an affine transformation matrix by using a least square method, and searching the optimal function matching of the data by minimizing the square sum of errors;

s24: after the corresponding affine transformation matrix has been obtained, a new image NP with the errors removed can be obtained by applying this matrix to the image containing the handwritten words.

Technical Field

The invention relates to the technical field of image processing, in particular to a grid-based picture separation method.

Background

Along with the development of artificial intelligence and big data technology in practical application, intelligent education is initiated from internet terminals and is gradually known by people, and the life concept and life style of people are changed silently. The back of intelligent education can not be supported by huge data, wherein the on-line education platform and the automatic examination reading platform of the examination both need a question bank with large data.

With the widespread use of artificial intelligence, intelligent OCR becomes more and more hot. The image processing technology field related to the OCR is the figure of the human body which is not separated from the combination of artificial intelligence and traditional technology.

In the more popular OCR recognition today, such as: the extraction of handwritten characters involves a complex fingerprint separation technique, and the conventional fingerprint separation technique has many advantages, but has many disadvantages, such as: the separation result has other interference and is not ideal enough, and the original handwritten pixel gray information is lost in the separation graph.

Therefore, the invention aims to solve the problems of the defects of the traditional fingerprint separation technology, and aims at the situations that the separation of printing and handwriting is not clean and the situation that the handwritten character information is lost due to binarization. A processing mode of image rasterization is provided, which can completely separate clean handwritten font characters from an original image and can separate a handwritten character image with more reliable result under the condition of ensuring that the gray value of the handwritten character image is not changed.

Disclosure of Invention

The invention provides a grid-based picture separation method, and provides a grid-based handwritten font image separation method, aiming at further processing by using a grid on the basis of using a blank image and a handwritten character image, and finally separating an original clean handwritten character for identification; and the handwritten character images with more reliable results can be separated under the condition of ensuring that the gray value of the handwritten character images is not changed.

In order to solve the technical problems, the invention adopts the technical scheme that: the picture separation method based on the grids specifically comprises the following steps:

s1: extracting blank images and feature vectors containing handwritten images by using an ORB algorithm;

s2: registering the blank image and the image containing the handwritten words by using image features to enable the relative positions of the printing bodies in the blank image and the image containing the handwritten words to be consistent, and acquiring a new image NP;

s3: covering the blank image by using grids of n x n (3< n <10) pixels, and calculating the gray level average value h of the pixels in each grid; taking a threshold value p, and marking the grid as a state to be deleted when h is greater than p;

s4: the positions of all the grids to be deleted in step S3 are obtained, and the grids at the same positions in the new image NP in step S2 are all painted white, thereby obtaining the original handwritten text.

By adopting the technical scheme, the situation that the separation of printing and handwriting is not clean and the situation that the handwritten character information is lost due to binarization are solved; extracting blank images and images containing handwritten characters by using an ORB algorithm, further processing by using a grid, and finally separating original and clean handwritten characters for identification; the method can completely separate clean handwritten font characters from the original image, and can separate the handwritten font character image with more reliable result under the condition of ensuring that the gray value of the handwritten font character image is not changed.

As a preferred technical solution of the present invention, the ORB algorithm of step S1 is an algorithm combination based on FAST algorithm and BRIEF algorithm, and the specific steps are as follows:

s11 finds key points of the image using FAST algorithm: setting a pixel point P, comparing the pixel point P with a plurality of pixel points which are 2 away from the pixel point P, and if the brightness of at least one pair of continuous pixel points is higher or lower than the pixel point P, selecting the pixel point P as a key point, thereby obtaining a plurality of pairs of key points;

s12 uses the BRIEF algorithm to convert the keypoints into feature quantities: feature vectors are created from the pairs of key points acquired in step S11.

As a preferred technical solution of the present invention, the step S12 includes the following steps:

s121: taking the key point P as the center of a circle and d as the radius to make a circle A;

s122: n pairs of pixel points are randomly selected within circle a,

s123: let (x, y) be any pair of pixel points, x represents pixel point 1, and y represents pixel point 2; the pair of pixel points is converted by adopting a formula (1), wherein the formula (1) is as follows:

wherein, p (x), p (y) are the gray values of the pixel points x and y respectively;

s124: repeating step S123N times, thereby obtaining a vector with length N, which is the feature vector.

As a preferred technical solution of the present invention, the step S2 includes the following steps:

s21: using affine transformation matricesDescribing deviation of the handwriting of the printed body in the image of the handwritten word and the handwriting in the blank image;

s22: the affine transformation matrix has 6 degrees of freedom: a. b, c, d, e, f, are applied to a certain point by the formal method of the following formula (2), wherein the formula (2) is:

wherein (x, y) is an old coordinate point, i.e., a coordinate point on the image containing the handwritten word; (x ', y') is the new coordinate point, namely the coordinate point of the blank image; at least 3 groups of corresponding coordinate points are needed for calculating 6 degrees of freedom of the affine transformation matrix;

s23: calculating Hamming distance between the feature vectors according to all the feature vectors of the two images obtained in the step S1, if the distance is smaller than a threshold value N, determining that the feature points on the two images can be matched into a pair, and calculating an affine transformation matrix by using a universal least square method, wherein the least square method is a mathematical optimization technology; finding the best functional match of the data by minimizing the sum of the squares of the errors;

s24: after the corresponding affine transformation matrix has been obtained, a new image NP with the errors removed can be obtained by applying this matrix to the image containing the handwritten words.

Compared with the prior art, the invention has the beneficial effects that: the picture separation method based on the grids can completely separate clean handwritten font characters from an original image, and can separate a handwritten character image with more reliable result under the condition of ensuring that the gray value of the image is not changed.

Drawings

The technical scheme of the invention is further described by combining the accompanying drawings as follows:

FIG. 1 is a flow chart of a grid-based picture separation method of the present invention;

FIG. 2 is a diagram illustrating the separated effect of the grid-based picture separation method according to the present invention;

fig. 3 is a diagram of the effect of the method for separating the pictures based on the grid according to the present invention on fig. 2.

Detailed Description

For the purpose of enhancing the understanding of the present invention, the present invention will be described in further detail with reference to the accompanying drawings and examples, which are provided for the purpose of illustration only and are not intended to limit the scope of the present invention.

Example (b): as shown in fig. 1, the method for separating a picture based on a grid specifically includes the following steps:

s1: extracting blank images and feature vectors containing handwritten images by using an ORB algorithm;

the ORB algorithm of step S1 is an algorithm combination based on FAST algorithm and BRIEF algorithm, and includes the specific steps of:

s11 finds key points of the image using FAST algorithm: setting a pixel point P, comparing the pixel point P with a plurality of pixel points which are 2 away from the pixel point P, and if the brightness of at least one pair of continuous pixel points is higher or lower than the pixel point P, selecting the pixel point P as a key point, thereby obtaining a plurality of pairs of key points; FAST is an abbreviation for Features from accessed Segments Test;

s12 uses the BRIEF algorithm to convert the keypoints into feature quantities: creating a feature vector according to the plurality of pairs of key points acquired in step S11; BRIEF is a short name of Binary Robust Independent element Features, and is used for creating a feature vector according to a group of key points;

the specific steps of step S12 are:

s121: taking the key point P as the center of a circle and d as the radius to make a circle A;

s122: n pairs of pixel points are randomly selected within circle a,

s123: let (x, y) be any pair of pixel points, x represents pixel point 1, and y represents pixel point 2; the pair of pixel points is converted by adopting a formula (1), wherein the formula (1) is as follows:

wherein, p (x), p (y) are the gray values of the pixel points x and y respectively;

s124: repeating the step S123N times, thereby obtaining a vector with a length N, which is a feature vector;

s2: registering the blank image and the image containing the handwritten words by using image features to enable the relative positions of the printing bodies in the blank image and the image containing the handwritten words to be consistent, and acquiring a new image NP;

the handwriting of the print in the image containing the handwriting is the same as the blank image; but due to scanning/printing problems, the relative position of the printed bodies can be deviated; such deviations may be due to "translation", "rotation", "zooming", "cropping", etc., or a combination thereof; "registration" is to eliminate such deviations and to make the relative positions of the printed bodies in the two images consistent; this deviation can be described mathematically using an affine transformation matrix;

the specific steps of step S2 are:

s21: using affine transformation matricesDescribing deviation of the handwriting of the printed body in the image of the handwritten word and the handwriting in the blank image;

s22: the affine transformation matrix has 6 degrees of freedom: a. b, c, d, e, f, are applied to a certain point by the formal method of the following formula (2), wherein the formula (2) is:

wherein (x, y) is an old coordinate point, i.e., a coordinate point on the image containing the handwritten word; (x ', y') is the new coordinate point, namely the coordinate point of the blank image; at least 3 groups of corresponding coordinate points are needed for calculating 6 degrees of freedom of the affine transformation matrix;

s23: calculating Hamming distance between the feature vectors according to all the feature vectors of the two images obtained in the step S1, if the distance is smaller than a threshold value N, determining that the feature points on the two images can be matched into a pair, and calculating an affine transformation matrix by using a universal least square method, wherein the least square method is a mathematical optimization technology; finding the best functional match of the data by minimizing the sum of the squares of the errors;

s24: after obtaining the corresponding affine transformation matrix, applying the matrix to the image containing the handwritten words to obtain a new image NP without errors;

s3: covering the blank image by using grids of n x n (3< n <10) pixels, and calculating the gray level average value h of the pixels in each grid; taking a threshold value p, and marking the grid as a state to be deleted when h is greater than p; in this embodiment, 5 × 5 pixels of grids are used to cover the blank image, and an average value h of 25 pixels of gray scale in each grid is calculated; taking a threshold value n, and marking the grid as a state to be deleted when h is greater than n;

s4: the positions of all the grids to be deleted in step S3 are obtained, and the grids at the same positions in the new image NP in step S2 are all painted white, thereby obtaining the original handwritten text. As shown in fig. 2 to 3, fig. 2 is an image originally including handwritten words, and fig. 3 is an effect diagram of the image separation method based on the grid according to the present invention after the image separation method based on the grid is adopted to separate the image of fig. 2.

It is obvious to those skilled in the art that the present invention is not limited to the above embodiments, and it is within the scope of the present invention to adopt various insubstantial modifications of the method concept and technical scheme of the present invention, or to directly apply the concept and technical scheme of the present invention to other occasions without modification.

9页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:基于特征加权与网络微调的小样本目标检测方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!