Summary of the invention
The object of the present invention is to provide a kind of definition of text images judgment method and systems, to solve the above problems.
To achieve the above object, the present invention provides a kind of definition of text images judgment methods, which comprises
Image preprocessing is carried out to image to be discriminated, obtains pretreatment image;
The bianry image clarity evaluation of estimate of the pretreatment image is calculated using binarization method;
The gradient image clarity evaluation of estimate of the pretreatment image is calculated using gradient method;
Image definition is judged according to the bianry image clarity evaluation of estimate and the gradient image clarity evaluation of estimate
And calculate the confidence level of definition judgment.
Optionally, described that image preprocessing is carried out to image to be discriminated, it specifically includes:
The edge gray value of the image to be discriminated is detected, edge gray value described in the image to be discriminated is rejected and is greater than
The point of white bright spot gray threshold, obtains noise filtering image;
The noise filtering image is zoomed in or out and is sized, pretreatment image is obtained.
Optionally, the bianry image clarity evaluation of estimate that the pretreatment image is calculated using binarization method, tool
Body includes:
Fuzzy Processing is carried out according to setting fuzziness to the pretreatment image;
Different first edge threshold values are chosen, according to edge pixel number setting value, are extracted using canny edge detection algorithm
The edge of the image to be discriminated, obtains first edge image;
The rotation angle of image is calculated according to the lines in the edge image, and affine according to the rotation angle calculation
Matrix;The horizontal line that affine transformation makes horizontal frame in the image containing table or contains is carried out according to the affine matrix
Level, obtain rotation image;
Binaryzation Local treatment is carried out to the rotation image and obtains binary image;It is filtered out in the binary image again
Lines and non-legible region, obtain filter and make an uproar bianry image;
The multiple and different second edge threshold values for being different from the first edge threshold value are chosen, according to edge pixel number
Mesh setting value is extracted the edge of the image to be discriminated using canny edge detection algorithm, obtains second edge image;
The first edge image and the second edge image are negated, reference picture is obtained;
Filter out the non-legible region of the first edge image;The first edge image is corrected in conjunction with the reference picture
Marginal information, obtain amendment image;
The marginal information for filtering bianry image of making an uproar is modified using the amendment image, obtains amendment binary map
Picture;
Contour area is positioned to the amendment bianry image;To the contour area of positioning, non-legible region is deleted, is contained
There is the binary image of character area:
The character area is traversed, is contained respectively using OTSU algorithm to described with binarization threshold th+5, th and th-5
The binary image of character area carries out binary conversion treatment, respectively obtains threshold binarization image rect1, rect, rect2, unites
Count described threshold binarization image rect1, rect2 and the threshold binarization image rect pixel number not etc. and null element
Number;
Calculate the pixel of the threshold binarization image rect and described threshold binarization image rect1, rect2 not etc.
Several and total pixel number purpose ratio bw_delta2area, calculates the threshold binarization image rect null element number and total pixel
The ratio bw_delta2bpc of number obtains bianry image clarity evaluation of estimate.
Optionally, the gradient image clarity evaluation of estimate that the pretreatment image is calculated using gradient method, specifically
Include:
The horizontal gradient value and pixel of the pixel horizontal direction in the pretreatment image are calculated using Sobel operator
The vertical gradient value of vertical direction;
Calculate horizontal gradient value square root and vertical gradient value subduplicate and absolute value SMD_val, obtain ladder
Spend image definition evaluation value.
Optionally, described to be judged according to the bianry image clarity evaluation of estimate and the gradient image clarity evaluation of estimate
Image definition and the confidence level for calculating definition judgment, specifically include:
According to gradient image clarity Evaluation threshold SMD_thresh and bianry image clarity Evaluation threshold bw_
Delta2area_thresh, bw_delta2bpc_thresh judge whether the condition for meeting image clearly: smd_val >
SMD_thresh) | | (bw_delta2area < bw_delta2area_thresh) | | (bw_delta2bpc < bw_
Delta2bpc_thresh), definition judgment result is obtained;
When definition judgment result expression is, then judge that the image to be discriminated is clear, and it is clear to calculate judgement
Clear confidence level.
When the definition judgment result indicates no, then the image to be discriminated is judged to be unintelligible, calculating judgement is not
Clear confidence level.
The present invention also provides a kind of definition of text images to judge system, the system comprises:
Pretreatment unit obtains pretreatment image for carrying out image preprocessing to image to be discriminated;
Binarization unit, for calculating the bianry image clarity evaluation of the pretreatment image using binarization method
Value;
Gradient computing unit, for calculating the gradient image clarity evaluation of the pretreatment image using gradient method
Value;
Definition judgment unit, for being commented according to the bianry image clarity evaluation of estimate and the gradient image clarity
Value judgement image definition and the confidence level for calculating definition judgment.
Optionally, the pretreatment unit specifically includes:
Noise filtering subelement rejects the image to be discriminated for detecting the edge gray value of the image to be discriminated
Described in edge gray value be greater than the point of white bright spot gray threshold, obtain noise filtering image;
Subelement is scaled, is sized for zooming in or out the noise filtering image, obtains pretreatment image.
Optionally, the binarization unit specifically includes:
It is blurred subelement, for carrying out Fuzzy Processing according to setting fuzziness to the pretreatment image;
Second edge detection sub-unit, for choosing different first edge threshold values, according to edge pixel number setting value, benefit
The edge that the image to be discriminated is extracted with canny edge detection algorithm, obtains first edge image;
Image rotation subelement, for the rotation angle according to the lines calculating image in the edge image, and according to
The rotation angle calculation affine matrix;Affine transformation, which is carried out, according to the affine matrix makes the water in the image containing table
Pingbian frame or the horizontal level contained obtain rotation image;
Two-value filters subelement of making an uproar, and obtains binary image for carrying out binaryzation Local treatment to the rotation image;Again
The lines in the binary image and non-legible region are filtered out, obtains filtering bianry image of making an uproar;
Second edge detection sub-unit, for choosing multiple and different described second for being different from the first edge threshold value
Edge threshold extracts the side of the image to be discriminated using canny edge detection algorithm according to edge pixel number setting value
Edge obtains second edge image;
Subelement is negated, for negating to the first edge image and the second edge image, obtains reference picture;
Edge revise subelemen, for filtering out the non-legible region of the first edge image;In conjunction with the reference picture
The marginal information for correcting the first edge image obtains amendment image;
Two-value revise subelemen, for being repaired using the amendment image to the marginal information for filtering bianry image of making an uproar
Just, amendment bianry image is obtained;
Character area screens subelement, for positioning contour area to the amendment bianry image;To the profile region of positioning
Non-legible region is deleted in domain, obtains the binary image containing character area:
Threshold binarization subelement is adopted respectively with binarization threshold th+5, th and th-5 for traversing the character area
Binary conversion treatment is carried out to the binary image containing character area with OTSU algorithm, respectively obtains threshold binarization image
Rect1, rect, rect2 count described threshold binarization image rect1, rect2 and the threshold binarization image rect not
Deng pixel number and null element number;
Ratio calculation subelement, for calculating the threshold binarization image rect and the threshold binarization image
The pixel number and total pixel number purpose ratio bw_delta2area of rect1, rect2 not etc., calculate the threshold binarization figure
As rect null element number and total pixel number purpose ratio bw_delta2bpc, bianry image clarity evaluation of estimate is obtained.
Optionally, the gradient computing unit specifically includes:
Gradient value computation subunit, for calculating the pixel level side in the pretreatment image using Sobel operator
To horizontal gradient value and pixel vertical direction vertical gradient value;
Cumulative subelement, for calculate horizontal gradient value square root and vertical gradient value subduplicate and absolute value
SMD_val obtains gradient image clarity evaluation of estimate.
Optionally, the definition judgment unit specifically includes:
Condition judgment sub-unit, for clear according to gradient image clarity Evaluation threshold SMD_thresh and bianry image
Evaluation threshold bw_delta2area_thresh, bw_delta2bpc_thresh are spent, judges whether the item for meeting image clearly
Part: smd_val > SMD_thresh) | | (bw_delta2area < bw_delta2area_thresh) | | (bw_delta2bpc
< bw_delta2bpc_thresh), obtain definition judgment result;
It is clear to determine subelement, for when definition judgment result expression is, then judging the image to be discriminated
To be clear, and calculate and judge clear confidence level.
Unintelligible determining subelement, for when the definition judgment result indicates no, then judging the figure to be discriminated
As be it is unintelligible, calculating judge unintelligible confidence level.
The specific embodiment provided according to the present invention, the invention discloses following technical effects: text provided by the invention
Image definition judgment method and system have the advantage that
1, compared with the performance with traditional images sharpness evaluation function in text image, the present invention is special for text image
Point is handled in conjunction with real image noise that may be present, more stable to the definition judgment performance of text image.
2, compared with using the algorithm of an evaluation function, the present invention combines three evaluation index (bianry image clarity
Two ratios and gradient image clarity evaluation of estimate in evaluation of estimate) judged, improve the accuracy of judgement.
3, compared with for the clarity evaluation method of concrete application design, the present invention to the image containing text information,
There is certain versatility to all kinds of images met in size range, it can be with by parameter and structural adjustment in conjunction with concrete application
Improve specificity or enhancing universal performance.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on
Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other
Embodiment shall fall within the protection scope of the present invention.
The object of the present invention is to provide a kind of definition of text images judgment method and systems, a kind of versatile to provide
And the definition judgment scheme that stability is good.
In order to make the foregoing objectives, features and advantages of the present invention clearer and more comprehensible, with reference to the accompanying drawing and specific real
Applying mode, the present invention is described in further detail.
As shown in Figure 1, definition of text images judgment method provided in this embodiment includes:
Step 101: image preprocessing being carried out to image to be discriminated, obtains pretreatment image;
Image to be discriminated in the present embodiment can for shot with digital camera image data, shot with mobile phone
To image data, obtained with scanner image data, read pre-existing image data file in data and decompression
One of image data obtained afterwards is a variety of.But the image has a denominator, i.e., all contains textual portions, the present invention
It is by the difference of text and image background to realize the accurate judgement to image integrity degree.
In practical applications, which specifically includes:
S11: the edge gray value of the detection image to be discriminated rejects edge gray value described in the image to be discriminated
Greater than the point of white bright spot gray threshold, noise filtering image is obtained;
The step will affect the white bright spot removal of subsequent detection, improves the precision of subsequent edges information, is also entire
The accuracy of definition judgment is laid a good foundation.
S12: the noise filtering image is zoomed in or out and is sized, pretreatment image is obtained.
In order to preferably adapt to the processing of subsequent image, it can be to be sized by Image Adjusting, can protect in this way
Demonstrate,prove different size of picture can should the definition judgment method carry out definition judgment.
Step 102: the bianry image clarity evaluation of estimate of the pretreatment image is calculated using binarization method;
Step 102 specifically includes:
S21: Fuzzy Processing is carried out according to setting fuzziness to the pretreatment image;
The Fuzzy Processing can be improved the robustness of the method for the present invention.
S22: choosing different first edge threshold values, according to edge pixel number setting value, utilizes canny edge detection algorithm
The edge for extracting the image to be discriminated, obtains first edge image;
In fact, the extraction of this edge image can also be realized using other Edge extraction algorithms, for different
Picture size, then the size at edge also difference, therefore mentioning for image border is being realized using Edge extraction algorithm
When taking, edge threshold can be set, and since image is quadrangle or other shapes, then its edge threshold can not
Together, therefore the multiple and different edge threshold of setting is more advantageous to the extraction of image border, and can be improved edge extracting precision.
S23: the rotation angle of image is calculated according to the lines in the edge image, and according to the rotation angle calculation
Affine matrix;The water that affine transformation makes horizontal frame in the image containing table or contains is carried out according to the affine matrix
The level of horizontal line obtains rotation image;
Some images may be inclined, or distortion, it is therefore desirable to these images are subjected to rotation transformation, image is put
Just, subsequent image procossing can be facilitated in this way, can be improved the accuracy of image definition judgement to a certain extent.
S24: binaryzation Local treatment is carried out to the rotation image and obtains binary image;The binary picture is filtered out again
Lines and non-legible region as in obtain filtering bianry image of making an uproar;
S25: the multiple and different second edge threshold values for being different from the first edge threshold value are chosen, according to edge picture
Prime number mesh setting value is extracted the edge of the image to be discriminated using canny edge detection algorithm, obtains second edge image;
S26: the first edge image and the second edge image are negated, reference picture is obtained;
S27: the non-legible region of the first edge image is filtered out;The first edge is corrected in conjunction with the reference picture
The marginal information of image obtains amendment image;
S28: the marginal information for filtering bianry image of making an uproar is modified using the amendment image, obtains amendment two-value
Image;
Above-mentioned filter process of making an uproar all can filter out together original part edge information, also will influence image border really
It is fixed, certainly also will subsequent image clarity judgement, it is therefore desirable to marginal information is modified.
S29: contour area is positioned to the amendment bianry image;To the contour area of positioning, non-legible region is deleted, is obtained
To the binary image containing character area:
S210: traversing the character area, uses OTSU algorithm to described with binarization threshold th+5, th and th-5 respectively
Binary image containing character area carries out binary conversion treatment, respectively obtain threshold binarization image rect1, rect,
Rect2 counts the pixel number of described threshold binarization image rect1, rect2 and the threshold binarization image rect not etc.
With null element number;
S211: the threshold binarization image rect and described threshold binarization image rect1, rect2 are not calculated not etc.
Pixel number and total pixel number purpose ratio bw_delta2area, calculate the threshold binarization image rect null element number with
Total pixel number purpose ratio bw_delta2bpc, obtains bianry image clarity evaluation of estimate.
Step 103: the gradient image clarity evaluation of estimate of the pretreatment image is calculated using gradient method;
Step 103 specifically includes:
S31: the horizontal gradient value and picture of the pixel horizontal direction in the pretreatment image are calculated using Sobel operator
The vertical gradient value of vegetarian refreshments vertical direction;
S32: calculate the square root of horizontal gradient value and the subduplicate of vertical gradient value and absolute value SMD_val, obtain
To gradient image clarity evaluation of estimate.
Step 104: according to the bianry image clarity evaluation of estimate and gradient image clarity evaluation of estimate judgement figure
Image sharpness and the confidence level for calculating definition judgment.
Step 104 specifically includes:
S31: according to gradient image clarity Evaluation threshold SMD_thresh and bianry image clarity Evaluation threshold bw_
Delta2area_thresh, bw_delta2bpc_thresh judge whether the condition for meeting image clearly: smd_val >
SMD_thresh) | | (bw_delta2area < bw_delta2area_thresh) | | (bw_delta2bpc < bw_
Delta2bpc_thresh), definition judgment result is obtained;
S32: when definition judgment result expression is, then judge that the image to be discriminated is clear, and calculate and sentence
Break clear confidence level.
S33: when the definition judgment result indicates no, then the image to be discriminated is judged to be unintelligible, calculating is sentenced
Break unintelligible confidence level.
In practical applications, specific judgment method is as follows:
Image is pre-processed, normalize size scaling, using the processing method of canny edge algorithms and binaryzation very
Good extraction text glyph calculates three clarity evaluation indexes then in conjunction with text image feature, finally integrates three and comment
Valence index provides definition judgment conclusion and confidence level, and accuracy rate is high, versatile, has achieved the purpose that definition judgment, has been
Text image, which is further processed, provides foundation.
Three evaluation index Computing Principles:
1. adjacent pixel gray variance method
Variance is discrete (inclined between one group of discrete data and its expectation (i.e. the mean values of data) for investigating in probability theory
From) measure in Chengdu.Variance is larger, indicates the deviation between this group of data with regard to larger, and the data in group have larger,
Some is smaller, is unevenly distributed weighing apparatus;Variance is smaller, indicates that the deviation between this group of data is smaller, is distributed between the data in group
Average, size is close.Clearly image compares the fuzzy image of focusing for focusing, and the gray difference between its data should be more
Greatly, i.e., its variance should be larger, and the clarity of image can be measured by the variance of image gradation data, and variance is bigger,
Indicate that clarity is better.
If gray level image I, long w, wide h, gradient material calculation step, evaluation of estimate smd_val.
2. clear image marginal information is abundant, the variation of binarization threshold is smaller on obtained binary image influence, and
Blurred picture is big by threshold interference, the small range variation of threshold value, and the bianry image quality being likely to be obtained is different.Threshold value is investigated to change
Become, the region area that binarization result changes, available two parameters.
To each character area navigated to, binarization result brect and optimal threshold are obtained with OTSU Binarization methods
Thresh is that threshold value respectively obtains two binarization results brect1 and brect2 with thresh ± 5.To brect1 and brect2
It is reference with brect, compares pixel-by-pixel, if value is different, changing value delta+1, while the picture of the accumulative background area brect
Plain value totalbpc, character area gross area totalarea.
Obtain two evaluation indexes:
Confidence level calculation method
If being directed to threshold value SMD_thresh, bw_delta2area_thresh, bw_delta2bpc_ of three evaluation indexes
Thresh, definition judgment confidence level p, if intermediate variable beliefrate.
1. judging clear confidence level
2. judging unintelligible confidence level
This definition judgment method is judged respectively from the angle of pixel and the angle of pixel orientation, is more fully obtained
The clarity of image has been arrived, and has all had pixel and pixel orientation for image, therefore the definition judgment method energy
Enough applications and various images, improve the versatility of definition judgment method.
The present embodiment additionally provides a kind of definition of text images corresponding with above-mentioned definition of text images judgment method
Judgement system, as shown in Fig. 2, the system comprises:
Pretreatment unit 201 obtains pretreatment image for carrying out image preprocessing to image to be discriminated;
The pretreatment unit 201 specifically includes:
Noise filtering subelement rejects the image to be discriminated for detecting the edge gray value of the image to be discriminated
Described in edge gray value be greater than the point of white bright spot gray threshold, obtain noise filtering image;
Subelement is scaled, is sized for zooming in or out the noise filtering image, obtains pretreatment image.
Binarization unit 202, the bianry image clarity for calculating the pretreatment image using binarization method are commented
Value;
The binarization unit 202 specifically includes:
It is blurred subelement, for carrying out Fuzzy Processing according to setting fuzziness to the pretreatment image;
Second edge detection sub-unit, for choosing different first edge threshold values, according to edge pixel number setting value, benefit
The edge that the image to be discriminated is extracted with canny edge detection algorithm, obtains first edge image;
Image rotation subelement, for the rotation angle according to the lines calculating image in the edge image, and according to
The rotation angle calculation affine matrix;Affine transformation, which is carried out, according to the affine matrix makes the water in the image containing table
Pingbian frame or the horizontal level contained obtain rotation image;
Two-value filters subelement of making an uproar, and obtains binary image for carrying out binaryzation Local treatment to the rotation image;Again
The lines in the binary image and non-legible region are filtered out, obtains filtering bianry image of making an uproar;
Second edge detection sub-unit, for choosing multiple and different described second for being different from the first edge threshold value
Edge threshold extracts the side of the image to be discriminated using canny edge detection algorithm according to edge pixel number setting value
Edge obtains second edge image;
Subelement is negated, for negating to the first edge image and the second edge image, obtains reference picture;
Edge revise subelemen, for filtering out the non-legible region of the first edge image;In conjunction with the reference picture
The marginal information for correcting the first edge image obtains amendment image;
Two-value revise subelemen, for being repaired using the amendment image to the marginal information for filtering bianry image of making an uproar
Just, amendment bianry image is obtained;
Character area screens subelement, for positioning contour area to the amendment bianry image;To the profile region of positioning
Non-legible region is deleted in domain, obtains the binary image containing character area:
Threshold binarization subelement is adopted respectively with binarization threshold th+5, th and th-5 for traversing the character area
Binary conversion treatment is carried out to the binary image containing character area with OTSU algorithm, respectively obtains threshold binarization image
Rect1, rect, rect2 count described threshold binarization image rect1, rect2 and the threshold binarization image rect not
Deng pixel number and null element number;
Ratio calculation subelement, for calculating the threshold binarization image rect and the threshold binarization image
The pixel number and total pixel number purpose ratio bw_delta2area of rect1, rect2 not etc., calculate the threshold binarization figure
As rect null element number and total pixel number purpose ratio bw_delta2bpc, bianry image clarity evaluation of estimate is obtained.
Gradient computing unit 203, the gradient image clarity for calculating the pretreatment image using gradient method are commented
Value;
The gradient computing unit 203 specifically includes:
Gradient value computation subunit, for calculating the pixel level side in the pretreatment image using Sobel operator
To horizontal gradient value and pixel vertical direction vertical gradient value;
Cumulative subelement, for calculate horizontal gradient value square root and vertical gradient value subduplicate and absolute value
SMD_val obtains gradient image clarity evaluation of estimate.
Definition judgment unit 204, for clear according to the bianry image clarity evaluation of estimate and the gradient image
Degree evaluation of estimate judges image definition and calculates the confidence level of definition judgment.
The definition judgment unit 204 specifically includes:
Condition judgment sub-unit, for clear according to gradient image clarity Evaluation threshold SMD_thresh and bianry image
Evaluation threshold bw_delta2area_thresh, bw_delta2bpc_thresh are spent, judges whether the item for meeting image clearly
Part: smd_val > SMD_thresh) | | (bw_delta2area < bw_delta2area_thresh) | | (bw_delta2bpc
< bw_delta2bpc_thresh), obtain definition judgment result;
It is clear to determine subelement, for when definition judgment result expression is, then judging the image to be discriminated
To be clear, and calculate and judge clear confidence level.
Unintelligible determining subelement, for when the definition judgment result indicates no, then judging the figure to be discriminated
As be it is unintelligible, calculating judge unintelligible confidence level.
It should be noted that for the system disclosed in the embodiment, since it is opposite with method disclosed in embodiment
It answers, so being described relatively simple, reference may be made to the description of the method.
Definition of text images judgment method proposed by the present invention is using the technology in the fields such as image procossing, for text
This feature of image extracts character area using canny edge detection algorithm and binarization method to image, and localized region is used
OTSU algorithm obtains binary map and threshold value, and given threshold increment carries out binary conversion treatment again, statistics binary map null element quantity and
Threshold delta acts on the pixel number of the variation of lower binary image, using the ratio of two values and sum of all pixels as evaluation of estimate, knot
The evaluation of estimate that gradient calculates to be closed, by the multilevel iudge image definition with reference threshold, evaluates accuracy rate height, versatility is good,
Achieve the purpose that definition of text images judges.
Application example of the invention is as follows:
Application example 1:
On general computer, text information medical clinic charge bill abundant is handled, the present invention is used
The method, after obtaining image data, by step 101 image preprocessing, step 102 is calculated by binarization method
Gradient image clarity evaluation of estimate is calculated by gradient method by step 103, finally in bianry image clarity evaluation of estimate
Judge that the clarity of image meets eye-observation characteristic by step 104.
Application example 2
On general computer, the various regions medical clinic charge bill obtained to scanning is handled, and uses the present invention
The method, after obtaining image data, by step 101 image preprocessing, step 102 is calculated by binarization method
Gradient image clarity evaluation of estimate is calculated by gradient method by step 103, finally in bianry image clarity evaluation of estimate
Judge that the clarity of image meets eye-observation characteristic by step 104.
Application example 3
On general computer, identity card is handled, using method of the present invention, obtains image data
Afterwards, by step 101 image preprocessing, bianry image clarity evaluation of estimate is calculated by binarization method in step 102, warp
It crosses step 103 and gradient image clarity evaluation of estimate is calculated by gradient method, finally judge the clear of image by step 104
Clear degree meets eye-observation characteristic.
Used herein a specific example illustrates the principle and implementation of the invention, and above embodiments are said
It is bright to be merely used to help understand method and its core concept of the invention;At the same time, for those skilled in the art, foundation
Thought of the invention, there will be changes in the specific implementation manner and application range.In conclusion the content of the present specification is not
It is interpreted as limitation of the present invention.