WO2021042509A1 - Method and apparatus for rectifying deflection of angle of text image, and computer-readable storage medium - Google Patents

Method and apparatus for rectifying deflection of angle of text image, and computer-readable storage medium Download PDF

Info

Publication number
WO2021042509A1
WO2021042509A1 PCT/CN2019/116549 CN2019116549W WO2021042509A1 WO 2021042509 A1 WO2021042509 A1 WO 2021042509A1 CN 2019116549 W CN2019116549 W CN 2019116549W WO 2021042509 A1 WO2021042509 A1 WO 2021042509A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
text image
text
binary copy
projection histogram
Prior art date
Application number
PCT/CN2019/116549
Other languages
French (fr)
Chinese (zh)
Inventor
王博
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2021042509A1 publication Critical patent/WO2021042509A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/24Aligning, centring, orientation detection or correction of the image
    • G06V10/243Aligning, centring, orientation detection or correction of the image by compensating for image skew or non-uniform image deformations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/28Quantising the image, e.g. histogram thresholding for discrimination between background and foreground patterns

Definitions

  • This application relates to the field of artificial intelligence technology, and in particular to a method, device and computer-readable storage medium for correcting the angle of a text image based on projection.
  • optical character recognition refers to the process of recognizing optical characters in pictures through image processing and pattern recognition technology, and translating the optical characters into computer characters.
  • the main process is to input images and perform pre-processing. Processing, binarization, denoising, character cutting, and character recognition.
  • Most of the OCR algorithms today are based on decision trees and Support Vector Machine (SVM).
  • SVM Support Vector Machine
  • the recognition accuracy is very sensitive to character deflection.
  • the collection of text images is difficult to achieve zero deflection, and it is also difficult to accurately calculate the correction angle.
  • the present application provides a method and device for correcting the angle of a text image, and a computer-readable storage medium, the main purpose of which is to present the user with an accurate correction result when the user performs the angle correction of the text image in the knowledge base.
  • a method for correcting the angle of a text image includes:
  • the present application also provides a text image angle correction device, which includes a memory and a processor, and the memory stores a text image angle correction program that can be run on the processor.
  • the text image angle correction program is executed by the processor, the following steps are implemented:
  • the present application also provides a computer-readable storage medium having a text image angle correction program stored on the computer-readable storage medium, and the text image angle correction program can be used by one or more processors. Execute to realize the steps of the method for correcting the angle of the text image as described above.
  • the text image angle correction method, device and computer readable storage medium proposed in this application perform preprocessing operations on the acquired text image when the user performs the text image angle correction, and analyze and process the oblique text image in the text image, Obtain the frequency projection histogram set, calculate the standard deviation of the peak apex and peak valley point of the frequency projection histogram set, and use the maximum standard deviation as the correction angle of the text image, so that accurate text can be presented to the user The result of image angle correction.
  • FIG. 1 is a schematic flowchart of a method for correcting the angle of a text image according to an embodiment of the application
  • FIG. 2 is a schematic diagram of the internal structure of a text image angle correction device provided by an embodiment of the application;
  • Fig. 3 is a schematic diagram of modules of a text image angle correction program in a text image angle correction device provided by an embodiment of the application.
  • This application provides a method for correcting the angle of a text image.
  • FIG. 1 it is a schematic flowchart of a method for correcting the angle of a text image according to an embodiment of this application.
  • the method can be executed by a device, and the device can be implemented by software and/or hardware.
  • the method for correcting the angle of the text image includes:
  • the text image may be image data such as certificates and invoices.
  • the preprocessing operation is: denoising the text image through an adaptive image denoising filter, using a contrast stretching method to enhance the contrast of the denoised text image, and using the OTSU algorithm to increase the contrast of the text image. Thresholding is performed on the text image to obtain the binarized text image.
  • the specific implementation steps of the preprocessing operation are as follows:
  • This application uses an adaptive image noise reduction filter to reduce the noise of the text image, which is used to filter out the salt and pepper noise of the text image, and can protect the details of the text image to a large extent.
  • the salt and pepper noise is a white point or black point that randomly appears in the image
  • the adaptive image noise reduction filter is a signal extractor, which is used to extract the original signal from the signal contaminated by noise.
  • the text image is preset to be f(x, y).
  • a degraded image g(x, y) is obtained.
  • the formula is:
  • Is the noise variance of the text image Is the average gray value of pixels in a window near the point (x, y)
  • the contrast refers to the contrast between the maximum value and the minimum value of the brightness in the imaging system, where low contrast makes image processing more difficult.
  • a contrast stretching method is adopted, which uses a method of increasing the dynamic range of gray levels to achieve the purpose of enhancing the contrast of the text image.
  • the contrast stretching is also called gray scale stretching.
  • the present application performs gray scale stretching on a specific area according to the piecewise linear transformation function in the contrast stretching method, so as to further improve the contrast of the output image.
  • contrast stretching it essentially realizes gray value conversion.
  • This application implements the gray value transformation through linear stretching.
  • the linear stretching refers to a pixel-level operation with a linear relationship between the input and output gray values.
  • the gray conversion formula is as follows:
  • the gray level t is preset to be the segmentation threshold of the foreground and background of the text image after contrast enhancement, and the ratio of the number of front sights to the text image after contrast enhancement is preset to be w 0 ,
  • the average gray level is u 0 ;
  • the proportion of the number of background points in the contrast-enhanced text image is w 1 , and the average gray level is u 1 , so the total average gray level of the text image after the contrast-enhancement is:
  • the variance of the foreground and background image of the text image after contrast enhancement is:
  • the gray level t at this time is the optimal threshold, and the gray level value greater than the gray level t in the text image after the contrast enhancement is set Is 255, the gray value smaller than the gray t is set to 0, and the binary text image of the text image after contrast enhancement is obtained.
  • the preprocessing operation described in the present application may further include reducing the dimension of the binarized text image through a principal component analysis method, so that the binarized text image can be processed more efficiently.
  • the principal component analysis method is a method of transforming a group of potentially correlated variables into a group of linearly uncorrelated variables through orthogonal transformation.
  • the preferred embodiment of the present application detects the skewed text in the binarized text image to the skewed text image through the AdaBoost iterative algorithm.
  • the AdaBoost iterative algorithm is a detection algorithm whose core is iteration. It constructs a weak classifier for different training sets, and combines each base weak classifier to form a final strong classifier.
  • the implementation of the AdaBoost iterative algorithm is to adjust the data distribution, and set the weight of each sample based on judging the correctness of the classification of each sample in each training set and the accuracy of the overall classification of the last sample. The newly obtained weights will be used as the data set for the training of the lower classifier, and then the classifiers trained each time will be combined to form the final decision classifier.
  • the weak classifier constructed in this application is:
  • f is the feature
  • is the threshold
  • p indicates the direction of the inequality sign
  • x indicates a detection sub-window.
  • ⁇ t min f,p, ⁇ ⁇ i (w i / ⁇ w i )
  • w is the feature weight
  • the final strong classifier is obtained:
  • ⁇ t ⁇ t /(1- ⁇ t ).
  • the present application detects the skewed text in the binarized text image by means of cascaded classifiers.
  • the cascade classifier is to form a text detection cascade classifier by cascading the strong classifiers obtained by the training, and the cascade classifier is a degraded decision tree.
  • the classification of the second-level classifier is triggered by the positive samples obtained from the first-level classification
  • the classification of the third-level classifier is triggered by the positive samples obtained from the second-level classification
  • all the skewed text images in the binarized text image in the general environment are detected, and the skewed text images are cropped to obtain the binary copy image.
  • this application progressively rotates the binary copy image according to a preset angle.
  • this application will progressively rotate the binary copy image between -45° and 45° in units of 2°. Rotate, and calculate the number of long and wide pixels in the binary copy image after each progressive rotation.
  • the present application converts the progressively rotated binary copy image into a frequency projection histogram through a Fourier transform algorithm.
  • the Fourier transform method includes:
  • M N.
  • F(u,v) is called the frequency spectrum of the binary copy image signal f(x,y), and the amplitude spectrum and phase spectrum of the binary copy image after Fourier transform are calculated respectively:
  • means the The amplitude spectrum of the binary copy image, ⁇ (u, v) represents the phase spectrum of the binary copy image.
  • the present application constructs a frequency projection histogram according to the calculated amplitude spectrum and phase spectrum of the binary copy image, and according to different angles of progressive rotation of the binary copy image, different frequency projection histograms can be obtained , That is, the frequency projection histogram set of the binary copy image.
  • the method for calculating the standard deviation of the peak vertices and the peak valley points in the frequency projection histogram set is:
  • represents the standard deviation of the frequency projection histogram
  • xi represents the i-th peak vertex in the frequency projection histogram
  • n represents the number of peak vertices in the frequency projection histogram
  • y j represents the i-th peak in the frequency projection histogram.
  • Valley point m represents the number of peak and valley points in the frequency projection histogram
  • is the mean value of all peak vertices and peak valley points.
  • the required standard deviation reflects the degree of dispersion between the peak valley point and the peak apex.
  • the present application calculates the standard deviations of all histograms in the frequency projection histogram set to obtain the standard deviation set, and according to the structural characteristics of the text image, it is obtained that when the standard deviation is the largest, it is the highest corrected text image.
  • the correction angle of the text image is obtained, and the original image is rotated and corrected according to the correction angle.
  • the invention also provides a text image angle correction device.
  • FIG. 2 it is a schematic diagram of the internal structure of a text image angle correction device provided by an embodiment of this application.
  • the text image angle correction device 1 may be a PC (Personal Computer, personal computer), or a terminal device such as a smart phone, a tablet computer, or a portable computer, or a server.
  • the text image angle correction device 1 at least includes a memory 11, a processor 12, a communication bus 13, and a network interface 14.
  • the memory 11 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), magnetic memory, magnetic disk, optical disk, and the like.
  • the memory 11 may be an internal storage unit of the text image angle correction device 1, for example, a hard disk of the text image angle correction device 1.
  • the memory 11 may also be an external storage device of the text image angle correction device 1, such as a plug-in hard disk equipped on the text image angle correction device 1, a smart media card (SMC), and a secure digital (Secure Digital, SD) card, flash card (Flash Card), etc.
  • the memory 11 may also include both an internal storage unit of the text image angle correction device 1 and an external storage device.
  • the memory 11 can be used not only to store application software and various data installed in the text image angle correction device 1, such as the code of the text image angle correction program 01, etc., but also to temporarily store data that has been output or will be output.
  • the processor 12 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chip, for running program codes or processing stored in the memory 11 Data, such as the execution of the text image angle correction program 01 and so on.
  • CPU central processing unit
  • controller microcontroller
  • microprocessor or other data processing chip
  • the communication bus 13 is used to realize the connection and communication between these components.
  • the network interface 14 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface), and is usually used to establish a communication connection between the apparatus 1 and other electronic devices.
  • the device 1 may also include a user interface.
  • the user interface may include a display (Display) and an input unit such as a keyboard (Keyboard).
  • the optional user interface may also include a standard wired interface and a wireless interface.
  • the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode, organic light-emitting diode) touch device, etc.
  • the display can also be appropriately called a display screen or a display unit, which is used to display the information processed in the text image angle correction device 1 and to display a visualized user interface.
  • Figure 2 only shows the text image angle correction device 1 with components 11-14 and the text image angle correction program 01. Those skilled in the art can understand that the structure shown in Figure 1 does not constitute a text image angle correction device
  • the definition of 1 may include fewer or more components than shown, or a combination of certain components, or different component arrangements.
  • the memory 11 stores a text image angle correction program 01; when the processor 12 executes the text image angle correction program 01 stored in the memory 11, the following steps are implemented:
  • Step 1 Obtain a text image, and perform a preprocessing operation on the text image to obtain a binary text image.
  • the text image may be image data such as certificates and invoices.
  • the preprocessing operation is: denoising the text image through an adaptive image denoising filter, using a contrast stretching method to enhance the contrast of the denoised text image, and using the OTSU algorithm to increase the contrast of the text image. Thresholding is performed on the text image to obtain the binarized text image.
  • the specific implementation steps of the preprocessing operation are as follows:
  • This application uses an adaptive image noise reduction filter to reduce the noise of the text image, which is used to filter out the salt and pepper noise of the text image, and can protect the details of the text image to a large extent.
  • the salt and pepper noise is a white point or black point that randomly appears in the image
  • the adaptive image noise reduction filter is a signal extractor, which is used to extract the original signal from the signal contaminated by noise.
  • the text image is preset to be f(x, y).
  • a degraded image g(x, y) is obtained.
  • the formula is:
  • Is the noise variance of the text image Is the average gray value of pixels in a window near the point (x, y)
  • the contrast refers to the contrast between the maximum value and the minimum value of the brightness in the imaging system, where low contrast makes image processing more difficult.
  • a contrast stretching method is adopted, which uses a method of increasing the dynamic range of gray levels to achieve the purpose of enhancing the contrast of the text image.
  • the contrast stretching is also called gray scale stretching.
  • the present application performs gray scale stretching on a specific area according to the piecewise linear transformation function in the contrast stretching method, so as to further improve the contrast of the output image.
  • contrast stretching it essentially realizes gray value conversion.
  • This application implements the gray value transformation through linear stretching.
  • the linear stretching refers to a pixel-level operation with a linear relationship between the input and output gray values.
  • the gray conversion formula is as follows:
  • This application uses the OTSU algorithm to perform an efficient algorithm for binarizing the contrast-enhanced text image to obtain a binarized image. Further, the preferred embodiment of the present application presets the gray level t to be the segmentation threshold of the foreground and background of the text image after contrast enhancement, and presets the ratio of the number of front sights to the text image after contrast enhancement as w 0 , The average gray level is u 0 ; the proportion of the number of background points in the contrast-enhanced text image is w 1 , and the average gray level is u 1 , so the total average gray level of the text image after the contrast-enhancement is:
  • the variance of the foreground and background image of the text image after contrast enhancement is:
  • the gray level t at this time is the optimal threshold, and the gray level value greater than the gray level t in the text image after the contrast enhancement is set Is 255, the gray value smaller than the gray t is set to 0, and the binary text image of the text image after contrast enhancement is obtained.
  • the preprocessing operation described in the present application may further include reducing the dimension of the binarized text image through a principal component analysis method, so that the binarized text image can be processed more efficiently.
  • the principal component analysis method is a method of transforming a group of potentially correlated variables into a group of linearly uncorrelated variables through orthogonal transformation.
  • Step 2 Detect skewed text in the binarized text image by an iterative algorithm to obtain a skewed text image, and extract the skewed text image to obtain a binary copy image.
  • the preferred embodiment of the present application detects the skewed text in the binarized text image to the skewed text image through the AdaBoost iterative algorithm.
  • the AdaBoost iterative algorithm is a detection algorithm whose core is iteration. It constructs a weak classifier for different training sets, and combines each base weak classifier to form a final strong classifier.
  • the implementation of the AdaBoost iterative algorithm is to adjust the data distribution, and set the weight of each sample based on judging the correctness of the classification of each sample in each training set and the accuracy of the overall classification of the last sample. The newly obtained weights will be used as the data set for the training of the lower classifier, and then the classifiers trained each time will be combined to form the final decision classifier.
  • the weak classifier constructed in this application is:
  • f is the feature
  • is the threshold
  • p indicates the direction of the inequality sign
  • x indicates a detection sub-window.
  • ⁇ t min f,p, ⁇ ⁇ i (w i / ⁇ w i )
  • w is the feature weight
  • the final strong classifier is obtained:
  • ⁇ t ⁇ t /(1- ⁇ t ).
  • the present application detects the skewed text in the binarized text image by means of cascaded classifiers.
  • the cascade classifier is to form a text detection cascade classifier by cascading the strong classifiers obtained by the training, and the cascade classifier is a degraded decision tree.
  • the classification of the second-level classifier is triggered by the positive samples obtained from the first-level classification
  • the classification of the third-level classifier is triggered by the positive samples obtained from the second-level classification
  • all the skewed text images in the binarized text image in the general environment are detected, and the skewed text images are cropped to obtain the binary copy image.
  • Step 3 Perform progressive rotation on the binary copy image, convert the binary copy image after the progressive rotation into a frequency projection histogram, and obtain the result according to the progressive rotation angle of the binary copy image The frequency projection histogram set of the binary copy image.
  • this application progressively rotates the binary copy image according to a preset angle.
  • this application will progressively rotate the binary copy image between -45° and 45° in units of 2°. Rotate, and calculate the number of long and wide pixels in the binary copy image after each progressive rotation.
  • the present application converts the progressively rotated binary copy image into a frequency projection histogram through a Fourier transform algorithm.
  • the Fourier transform method includes:
  • M N.
  • F(u,v) is called the frequency spectrum of the binary copy image signal f(x,y), and the amplitude spectrum and phase spectrum of the binary copy image after Fourier transform are calculated respectively:
  • means the The amplitude spectrum of the binary copy image, ⁇ (u, v) represents the phase spectrum of the binary copy image.
  • the present application constructs a frequency projection histogram according to the calculated amplitude spectrum and phase spectrum of the binary copy image, and according to different angles of progressive rotation of the binary copy image, different frequency projection histograms can be obtained , That is, the frequency projection histogram set of the binary copy image.
  • Step 4 Calculate the standard deviations of the peak vertices and peak valley points in the frequency projection histogram set to obtain a standard deviation set, and use the maximum standard deviation in the standard deviation set as the correction angle of the text image to complete the text image The angle correction.
  • the method for calculating the standard deviation of the peak vertices and the peak valley points in the frequency projection histogram set is:
  • represents the standard deviation of the frequency projection histogram
  • xi represents the i-th peak vertex in the frequency projection histogram
  • n represents the number of peak vertices in the frequency projection histogram
  • y j represents the i-th peak in the frequency projection histogram.
  • Valley point m represents the number of peak and valley points in the frequency projection histogram
  • is the mean value of all peak vertices and peak valley points.
  • the required standard deviation reflects the degree of dispersion between the peak valley point and the peak apex.
  • the present application calculates the standard deviations of all histograms in the frequency projection histogram set to obtain the standard deviation set, and according to the structural characteristics of the text image, it is obtained that when the standard deviation is the largest, it is the highest corrected text image.
  • the correction angle of the text image is obtained, and the original image is rotated and corrected according to the correction angle.
  • the text image angle correction program can also be divided into one or more modules, and the one or more modules are stored in the memory 11 and run by one or more processors (in this embodiment). It is executed by the processor 12) to complete this application.
  • the module referred to in this application refers to a series of computer program instruction segments that can complete specific functions, and is used to describe the execution process of the text image angle correction program in the text image angle correction device .
  • FIG. 3 a schematic diagram of the program module of the text image angle correction program in an embodiment of the text image angle correction device of this application.
  • the text image angle correction program can be divided into a text image preview.
  • the processing module 10, the text image detection module 20, the image conversion module 30, and the calculation module 40 are exemplarily:
  • the text image preprocessing module 10 is used to obtain a text image, and perform a preprocessing operation on the text image to obtain a binary text image.
  • the text image detection module 20 is configured to detect skewed text in the binarized text image by an iterative algorithm to obtain a skewed text image, and crop the skewed text image to obtain a binary copy image.
  • the image conversion module 30 is configured to: perform a progressive rotation on the binary copy image, convert the binary copy image after the progressive rotation into a frequency projection histogram, according to the progressive rotation of the binary copy image The angle of rotation is used to obtain the frequency projection histogram set of the binary copy image.
  • the calculation module 40 is configured to: calculate the standard deviation of the peak apex and the peak valley point of the frequency projection histogram set to obtain a standard deviation set, and use the maximum standard deviation in the standard deviation set as the correction angle of the text image, Thus, the angle correction of the text image is completed.
  • an embodiment of the present application also proposes a computer-readable storage medium that stores a text image angle correction program, and the text image angle correction program can be executed by one or more processors to To achieve the following operations:

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Theoretical Computer Science (AREA)
  • Character Input (AREA)
  • Facsimile Image Signal Circuits (AREA)
  • Image Analysis (AREA)
  • Studio Devices (AREA)

Abstract

The present application relates to artificial intelligence technologies. Disclosed is a method for rectifying the deflection of an angle of a text image, the method comprising: acquiring a text image, and performing a pre-processing operation on the text image to obtain a binarized text image; testing deflected text in the binarized text image by means of an iterative algorithm in order to obtain a deflected text image, and cutting the deflected text image to obtain a binary copy image; incrementally rotating the binary copy image, and converting the incrementally rotated binary copy image into a set of frequency projection histograms; and calculating the standard deviation between a peak point and a peak-valley point of the set of frequency projection histograms to obtain a set of standard deviations, and using the maximum standard deviation in the set of standard deviations as a deflection rectification angle for the text image, thus completing the rectification of the deflection of the angle of the text image. Further provided are an apparatus for rectifying the deflection of an angle of a text image, and a computer-readable storage medium. According to the present application, the accurate rectification of the deflection of the angle of the text image angle is realized.

Description

文本图像角度纠偏方法、装置及计算机可读存储介质Method and device for correcting text image angle deviation and computer readable storage medium
本申请要求于2019年09月06日提交中国专利局、申请号为201910846892.X、发明名称为“文本图像角度纠偏方法、装置及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office, the application number is 201910846892.X, and the invention title is "Text image angle correction method, device and computer readable storage medium" on September 6, 2019. All of them The content is incorporated in the application by reference.
技术领域Technical field
本申请涉及人工智能技术领域,尤其涉及一种基于投影的文本图像角度纠偏方法、装置及计算机可读存储介质。This application relates to the field of artificial intelligence technology, and in particular to a method, device and computer-readable storage medium for correcting the angle of a text image based on projection.
背景技术Background technique
光学字符识别技术在当前社会已有极其广泛的应用场景。所述光学字符识别(Optical Character Recognition,OCR)是指通过图像处理和模式识别技术对图片中的光学字符进行识别,并将光学字符翻译成计算机文字的过程,其主要过程为输入图像并进行预处理、二值化处理、去噪、字符切割和字符识别,现今大部分OCR算法基于决策树和支持向量机(Support Vector Machine,SVM)实现的,其识别的精度对于字符的偏转非常敏感,然而文本图像的采集很难做到零偏转,如需精确的计算出纠偏角度也存在一定难度。Optical character recognition technology has extremely wide application scenarios in the current society. The optical character recognition (Optical Character Recognition, OCR) refers to the process of recognizing optical characters in pictures through image processing and pattern recognition technology, and translating the optical characters into computer characters. The main process is to input images and perform pre-processing. Processing, binarization, denoising, character cutting, and character recognition. Most of the OCR algorithms today are based on decision trees and Support Vector Machine (SVM). The recognition accuracy is very sensitive to character deflection. However, The collection of text images is difficult to achieve zero deflection, and it is also difficult to accurately calculate the correction angle.
发明内容Summary of the invention
本申请提供一种文本图像角度纠偏方法、装置及计算机可读存储介质,其主要目的在于当用户在知识库中进行文本图像角度纠偏时,给用户呈现出精准的纠偏结果。The present application provides a method and device for correcting the angle of a text image, and a computer-readable storage medium, the main purpose of which is to present the user with an accurate correction result when the user performs the angle correction of the text image in the knowledge base.
为实现上述目的,本申请提供的一种文本图像角度纠偏方法,包括:In order to achieve the above objective, a method for correcting the angle of a text image provided by this application includes:
获取文本图像,对所述文本图像进行预处理操作,得到二值化文本图像;Acquiring a text image, and performing a preprocessing operation on the text image to obtain a binarized text image;
通过迭代算法检测所述二值化文本图像中偏斜的文本,得到偏斜文本图像,并对所述偏斜文本图像进行裁剪,得到二值拷贝图像;Detecting skewed text in the binary text image by an iterative algorithm to obtain a skewed text image, and crop the skewed text image to obtain a binary copy image;
对所述二值拷贝图像进行递进旋转,将递进旋转后的所述二值拷贝图像转换为频数投影直方图,根据所述二值拷贝图像的递进旋转的角度,得到所述二值拷贝图像的频数投影直方图集;Perform progressive rotation on the binary copy image, convert the progressively rotated binary copy image into a frequency projection histogram, and obtain the binary copy image according to the progressive rotation angle of the binary copy image The frequency projection histogram set of the copied image;
计算所述频数投影直方图集的峰顶点与峰谷点的标准差,得到标准差集,将所述标准差集中最大标准差作为所述文本图像的纠偏角度,从而完成对所述文本图像的角度纠偏。Calculate the standard deviation of the peak vertices and peak valley points of the frequency projection histogram set to obtain a standard deviation set, and use the maximum standard deviation in the standard deviation set as the correction angle of the text image to complete the correction of the text image Angle correction.
此外,为实现上述目的,本申请还提供一种文本图像角度纠偏装置,该装置包括存储器和处理器,所述存储器中存储有可在所述处理器上运行的文本图像角度纠偏程序,所述文本图像角度纠偏程序被所述处理器执行时实现如下步骤:In addition, in order to achieve the above object, the present application also provides a text image angle correction device, which includes a memory and a processor, and the memory stores a text image angle correction program that can be run on the processor. When the text image angle correction program is executed by the processor, the following steps are implemented:
获取文本图像,对所述文本图像进行预处理操作,得到二值化文本图像;Acquiring a text image, and performing a preprocessing operation on the text image to obtain a binarized text image;
通过迭代算法检测所述二值化文本图像中偏斜的文本,得到偏斜文本图像,并对所述偏斜文本图像进行裁剪,得到二值拷贝图像;Detecting skewed text in the binary text image by an iterative algorithm to obtain a skewed text image, and crop the skewed text image to obtain a binary copy image;
对所述二值拷贝图像进行递进旋转,将递进旋转后的所述二值拷贝图像转换为频数投影直方图,根据所述二值拷贝图像的递进旋转的角度,得到所述二值拷贝图像的频数投影直方图集;Perform progressive rotation on the binary copy image, convert the progressively rotated binary copy image into a frequency projection histogram, and obtain the binary copy image according to the progressive rotation angle of the binary copy image The frequency projection histogram set of the copied image;
计算所述频数投影直方图集的峰顶点与峰谷点的标准差,得到标准差集,将所述标准差集中最大标准差作为所述文本图像的纠偏角度,从而完成对所述文本图像的角度纠偏。Calculate the standard deviation of the peak vertices and peak valley points of the frequency projection histogram set to obtain a standard deviation set, and use the maximum standard deviation in the standard deviation set as the correction angle of the text image to complete the correction of the text image Angle correction.
此外,为实现上述目的,本申请还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有文本图像角度纠偏程序,所述文本图像角度纠偏程序可被一个或者多个处理器执行,以实现如上所述的文本图像角度纠偏方法的步骤。In addition, in order to achieve the above-mentioned object, the present application also provides a computer-readable storage medium having a text image angle correction program stored on the computer-readable storage medium, and the text image angle correction program can be used by one or more processors. Execute to realize the steps of the method for correcting the angle of the text image as described above.
本申请提出的文本图像角度纠偏方法、装置及计算机可读存储介质,在用户进行文本图像角度纠偏时,对获取的文本图像进行预处理操作,并将文本图像中的倾斜文本图像进行分析处理,得到其频数投影直方图集,计算所述频数投影直方图集的峰顶点与峰谷点的标准差,将其最大标准差作为所述文本图像的纠偏角度,从而可以给用户呈现出精准的文本图像角度纠偏结果。The text image angle correction method, device and computer readable storage medium proposed in this application perform preprocessing operations on the acquired text image when the user performs the text image angle correction, and analyze and process the oblique text image in the text image, Obtain the frequency projection histogram set, calculate the standard deviation of the peak apex and peak valley point of the frequency projection histogram set, and use the maximum standard deviation as the correction angle of the text image, so that accurate text can be presented to the user The result of image angle correction.
附图说明Description of the drawings
图1为本申请一实施例提供的文本图像角度纠偏方法的流程示意图;FIG. 1 is a schematic flowchart of a method for correcting the angle of a text image according to an embodiment of the application;
图2为本申请一实施例提供的文本图像角度纠偏装置的内部结构示意图;2 is a schematic diagram of the internal structure of a text image angle correction device provided by an embodiment of the application;
图3为本申请一实施例提供的文本图像角度纠偏装置中文本图像角度纠 偏程序的模块示意图。Fig. 3 is a schematic diagram of modules of a text image angle correction program in a text image angle correction device provided by an embodiment of the application.
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization, functional characteristics, and advantages of the purpose of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings.
具体实施方式detailed description
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。It should be understood that the specific embodiments described here are only used to explain the application, and not used to limit the application.
本申请提供一种文本图像角度纠偏方法。参照图1所示,为本申请一实施例提供的文本图像角度纠偏方法的流程示意图。该方法可以由一个装置执行,该装置可以由软件和/或硬件实现。This application provides a method for correcting the angle of a text image. Referring to FIG. 1, it is a schematic flowchart of a method for correcting the angle of a text image according to an embodiment of this application. The method can be executed by a device, and the device can be implemented by software and/or hardware.
在本实施例中,文本图像角度纠偏方法包括:In this embodiment, the method for correcting the angle of the text image includes:
S1、获取文本图像,对所述文本图像进行预处理操作,得到二值化文本图像。S1. Acquire a text image, and perform a preprocessing operation on the text image to obtain a binary text image.
本申请较佳实施例中,所述文本图像可以为证件、发票等图像数据。所述预处理操作为:通过自适应图像降噪滤波器对所述文本图像进行降噪,利用对比度拉伸方式对降噪后的所述文本图像进行对比度增强,根据OTSU算法将对比度增强后的所述文本图像进行阈值化操作,得到所述二值化文本图像。详细地,所述预处理操作具体实施步骤如下所示:In a preferred embodiment of the present application, the text image may be image data such as certificates and invoices. The preprocessing operation is: denoising the text image through an adaptive image denoising filter, using a contrast stretching method to enhance the contrast of the denoised text image, and using the OTSU algorithm to increase the contrast of the text image. Thresholding is performed on the text image to obtain the binarized text image. In detail, the specific implementation steps of the preprocessing operation are as follows:
a.降噪:a. Noise reduction:
本申请通过自适应图像降噪滤波器对所述文本图像进行降噪,用于滤除所述文本图像的椒盐噪声,并可以很大程度的保护所述文本图像的细节。其中,所述椒盐噪声是图像中一种随机出现的白点或黑点,所述自适应图像降噪滤波器是信号抽取器,用于从被噪声污染的信号中抽取原来的信号。This application uses an adaptive image noise reduction filter to reduce the noise of the text image, which is used to filter out the salt and pepper noise of the text image, and can protect the details of the text image to a large extent. Wherein, the salt and pepper noise is a white point or black point that randomly appears in the image, and the adaptive image noise reduction filter is a signal extractor, which is used to extract the original signal from the signal contaminated by noise.
本申请较佳实施例通过预设所述文本图像为f(x,y),在退化函数H的作用下,由于受到椒盐噪声η(x,y)的影响,得到一个退化图像g(x,y)。于是,得到图像退化公式:g(x,y)=η(x,y)+f(x,y),并利用Adaptive Filter方法对所述文本图像进行降噪,其中,所述降噪的计算公式为:In the preferred embodiment of the present application, the text image is preset to be f(x, y). Under the action of the degradation function H, due to the influence of the salt and pepper noise η(x, y), a degraded image g(x, y) is obtained. y). Therefore, the image degradation formula is obtained: g(x,y)=η(x,y)+f(x,y), and the Adaptive Filter method is used to reduce the noise of the text image, wherein the calculation of the noise reduction The formula is:
Figure PCTCN2019116549-appb-000001
Figure PCTCN2019116549-appb-000001
其中,
Figure PCTCN2019116549-appb-000002
是文本图像的噪声方差,
Figure PCTCN2019116549-appb-000003
是点(x,y)附近的一个窗口内的像素灰度均值,
Figure PCTCN2019116549-appb-000004
是点(x,y)附近一个窗口内的像素灰度的方差。
among them,
Figure PCTCN2019116549-appb-000002
Is the noise variance of the text image,
Figure PCTCN2019116549-appb-000003
Is the average gray value of pixels in a window near the point (x, y),
Figure PCTCN2019116549-appb-000004
It is the variance of the gray level of pixels in a window near the point (x, y).
b.对比度增强:b. Contrast enhancement:
所述对比度指的是成像系统中亮度最大值与最小值之间的对比,其中,对比度低会使图像处理难度增大。本申请较佳实施例中采用的是对比度拉伸方法,利用提高灰度级动态范围的方式,达到文本图像对比度增强的目的。所述对比度拉伸也叫作灰度拉伸。The contrast refers to the contrast between the maximum value and the minimum value of the brightness in the imaging system, where low contrast makes image processing more difficult. In the preferred embodiment of the present application, a contrast stretching method is adopted, which uses a method of increasing the dynamic range of gray levels to achieve the purpose of enhancing the contrast of the text image. The contrast stretching is also called gray scale stretching.
进一步地,本申请根据所述对比度拉伸方法中的分段线性变换函数对特定区域进行灰度拉伸,进一步提高输出图像的对比度。当进行对比度拉伸时,本质上是实现灰度值变换。本申请通过线性拉伸实现灰度值变换,所述线性拉伸指的是输入与输出的灰度值之间为线性关系的像素级运算,灰度变换公式如下所示:Further, the present application performs gray scale stretching on a specific area according to the piecewise linear transformation function in the contrast stretching method, so as to further improve the contrast of the output image. When performing contrast stretching, it essentially realizes gray value conversion. This application implements the gray value transformation through linear stretching. The linear stretching refers to a pixel-level operation with a linear relationship between the input and output gray values. The gray conversion formula is as follows:
D b=f(D a)=a*D a+b D b =f(D a )=a*D a +b
其中a为线性斜率,b为在Y轴上的截距。当a>1时,此时输出的图像对比度相比原图像是增强的。当a<1时,此时输出的图像对比度相比原图像是削弱的,其中D a代表输入图像灰度值,D b代表输出图像灰度值。 Where a is the linear slope and b is the intercept on the Y axis. When a>1, the contrast of the output image at this time is enhanced compared to the original image. When a<1, the contrast of the output image is weaker than the original image, where D a represents the gray value of the input image, and D b represents the gray value of the output image.
c.图像阈值化操作:c. Image thresholding operation:
本申请通过OTSU算法将对比度增强后的所述文本图像进行二值化的高效算法,得到二值化图像。进一步地,本申请较佳实施例预设灰度t为对比度增强后的所述文本图像的前景与背景的分割阈值,并预设前景点数占对比度增强后的所述文本图像比例为w 0,平均灰度为u 0;背景点数占对比度增强后的所述文本图像比例为w 1,平均灰度为u 1,则对比度增强后的所述文本图像的总平均灰度为: This application uses the OTSU algorithm to perform an efficient algorithm for binarizing the contrast-enhanced text image to obtain a binarized image. Further, in a preferred embodiment of the present application, the gray level t is preset to be the segmentation threshold of the foreground and background of the text image after contrast enhancement, and the ratio of the number of front sights to the text image after contrast enhancement is preset to be w 0 , The average gray level is u 0 ; the proportion of the number of background points in the contrast-enhanced text image is w 1 , and the average gray level is u 1 , so the total average gray level of the text image after the contrast-enhancement is:
u=w 0*u 0+w 1*u 1u=w 0 *u 0 +w 1 *u 1 ,
其中,对比度增强后的所述文本图像的前景和背景图象的方差为:Wherein, the variance of the foreground and background image of the text image after contrast enhancement is:
g=w 0*(u 0-u)*(u 0-u)+w 1*(u 1-u)*(u 1-u)=w 0*w 1*(u 0-u 1)*(u 0-u 1), g=w 0 *(u 0 -u)*(u 0 -u)+w 1 *(u 1 -u)*(u 1 -u)=w 0 *w 1 *(u 0 -u 1 )* (u 0 -u 1 ),
其中,当方差g最大时,则此时前景和背景差异最大,此时的灰度t为最佳阈值,并将对比度增强后的所述文本图像中大于所述灰度t的灰度值设置为255,小于所述灰度t的灰度值设置为0,得到对比度增强后的所述文本图像的二值化文本图像。Wherein, when the variance g is the largest, then the difference between the foreground and the background is the largest at this time, the gray level t at this time is the optimal threshold, and the gray level value greater than the gray level t in the text image after the contrast enhancement is set Is 255, the gray value smaller than the gray t is set to 0, and the binary text image of the text image after contrast enhancement is obtained.
进一步地,本申请所述预处理操作还可以包括通过主成分分析法对所述二值化文本图像进行降维,使所述二值化文本图像能够被更高效处理。其中, 所述主成分分析法是一种通过正交变换将一组可能存在相关性的变量为一组线性不相关变量的方法。Further, the preprocessing operation described in the present application may further include reducing the dimension of the binarized text image through a principal component analysis method, so that the binarized text image can be processed more efficiently. Wherein, the principal component analysis method is a method of transforming a group of potentially correlated variables into a group of linearly uncorrelated variables through orthogonal transformation.
S2、通过迭代算法检测所述二值化文本图像中偏斜的文本,得到偏斜文本图像,并对所述偏斜文本图像进行提取,得到二值拷贝图像。S2. Detect skewed text in the binary text image by an iterative algorithm to obtain a skewed text image, and extract the skewed text image to obtain a binary copy image.
本申请较佳实施例通过AdaBoost迭代算法检测所述二值化文本图像中偏斜的文本,到偏斜文本图像。所述AdaBoost迭代算法是一种检测算法,其核心是迭代,其针对不同的训练集构造出的一个弱分类器,并将每一个基弱分类器组合到一起,形成一个最终的强分类器。所述AdaBoost迭代算法的实现是通过调整数据分布,其依据判断每一次训练集当中每一个样本分类的正确性,以及上次样本总体分类的准确率,来设置每一个样本的权值。而新得到的权值将作为下层分类器训练的数据集,然后将每一次训练出的分类器组合起来,形成最终的决策分类器。The preferred embodiment of the present application detects the skewed text in the binarized text image to the skewed text image through the AdaBoost iterative algorithm. The AdaBoost iterative algorithm is a detection algorithm whose core is iteration. It constructs a weak classifier for different training sets, and combines each base weak classifier to form a final strong classifier. The implementation of the AdaBoost iterative algorithm is to adjust the data distribution, and set the weight of each sample based on judging the correctness of the classification of each sample in each training set and the accuracy of the overall classification of the last sample. The newly obtained weights will be used as the data set for the training of the lower classifier, and then the classifiers trained each time will be combined to form the final decision classifier.
本申请将所述二值化文本图像中不同区域进行划分,得到训练样本(x 1,y 1),(x 2,y 2),…(x n,y n),其中,负样本(背景)用y i=0来表示,正样本(前景,即包含偏斜文本)用y i=1来表示。优选地,本申请构建的弱分类器为: This application divides the different regions in the binarized text image to obtain training samples (x 1 , y 1 ), (x 2 , y 2 ), ... (x n , y n ), where the negative sample (background ) Is represented by y i =0, and positive samples (foreground, that is, containing skewed text) are represented by y i =1. Preferably, the weak classifier constructed in this application is:
Figure PCTCN2019116549-appb-000005
Figure PCTCN2019116549-appb-000005
其中,f为特征,θ为阈值,p指示不等号的方向,x表示一个检测子窗口。通过对所述构建的弱分类器进行集合,并对所述构建的弱分类器中分类最小错误率ε t的最佳弱分类器h t(x)进行选取,所述ε t的计算公式为: Among them, f is the feature, θ is the threshold, p indicates the direction of the inequality sign, and x indicates a detection sub-window. By collecting the constructed weak classifiers, and selecting the best weak classifier h t (x) with the smallest classification error rate ε t among the constructed weak classifiers, the calculation formula of ε t is :
ε t=min f,p,θi(w i/∑w i)|h(x,f,p,θ)-y i|, ε t =min f,p,θi (w i /∑w i )|h(x,f,p,θ)-y i |,
其中,w为特征权值,得到最终的强分类器:Among them, w is the feature weight, and the final strong classifier is obtained:
Figure PCTCN2019116549-appb-000006
Figure PCTCN2019116549-appb-000006
β t=ε t/(1-ε t)。 β tt /(1-ε t ).
进一步地,本申请通过级联分类器的方式检测出所述二值化文本图像中偏斜的文本。所述级联分类器就是将所述训练得到的强分类器通过级联的方式组成一个文本检测级联分类器,所述级联分类器是一个退化的决策树。在级联分类器中,第2层分类器分类是由第1层分类得到的正样本触发的,第3 层分类器分类是由第2层分类得到的正样本触发的,依次类推。最终检测到一般环境下所述二值化文本图像中的所有偏斜文本图像,并对所述偏斜文本图像进行裁剪,得到所述二值拷贝图像。Further, the present application detects the skewed text in the binarized text image by means of cascaded classifiers. The cascade classifier is to form a text detection cascade classifier by cascading the strong classifiers obtained by the training, and the cascade classifier is a degraded decision tree. In the cascade classifier, the classification of the second-level classifier is triggered by the positive samples obtained from the first-level classification, the classification of the third-level classifier is triggered by the positive samples obtained from the second-level classification, and so on. Finally, all the skewed text images in the binarized text image in the general environment are detected, and the skewed text images are cropped to obtain the binary copy image.
S3、对所述二值拷贝图像进行递进旋转,将递进旋转后的所述二值拷贝图像转换为频数投影直方图,根据所述二值拷贝图像的递进旋转的角度,得到所述二值拷贝图像的频数投影直方图集。S3. Perform progressive rotation on the binary copy image, convert the binary copy image after the progressive rotation into a frequency projection histogram, and obtain the binary copy image according to the progressive rotation angle of the binary copy image The frequency projection histogram set of the binary copy image.
本申请较佳实施例按照预设的角度对二值拷贝图进行递进旋转,优选地,本申请将在-45°至45°之间以2°为单位对上述二值拷贝图进行递进旋转,并在每一次递进旋转后计算所述二值拷贝图像中长和宽像素点的个数。The preferred embodiment of this application progressively rotates the binary copy image according to a preset angle. Preferably, this application will progressively rotate the binary copy image between -45° and 45° in units of 2°. Rotate, and calculate the number of long and wide pixels in the binary copy image after each progressive rotation.
进一步地,本申请通过傅里叶变换算法将递进旋转后的所述二值拷贝图像转换为频数投影直方图。详细的,所述傅里叶变换的方法包括:Further, the present application converts the progressively rotated binary copy image into a frequency projection histogram through a Fourier transform algorithm. Specifically, the Fourier transform method includes:
Figure PCTCN2019116549-appb-000007
Figure PCTCN2019116549-appb-000007
对其进行变换为:Transform it into:
Figure PCTCN2019116549-appb-000008
Figure PCTCN2019116549-appb-000008
其中,u=0,1,2,3…M-1;v=0,1,2,3…N-1;x=0,1,2,3…M-1;y=0,1,2,3…N-1;M、N分别为所述二值拷贝图像中长和宽像素点个数,x、y为空间坐标点,f(x,y)为所述二值拷贝图像空间域采样值,F(u,v)为所述二值拷贝图像傅里叶变换域采样值,u、v为变换域坐标点。其中,当所述二值拷贝图像真列为方阵时,则M=N。F(u,v)称为所述二值拷贝图像信号f(x,y)的频谱,并分别计算出所述进行傅里叶变换后的二值拷贝图像幅度谱和相位谱:Among them, u=0,1,2,3...M-1; v=0,1,2,3...N-1; x=0,1,2,3...M-1; y=0,1, 2,3...N-1; M and N are the number of long and wide pixels in the binary copy image respectively, x and y are the space coordinate points, and f(x,y) is the binary copy image space Domain sampling value, F(u, v) is the Fourier transform domain sampling value of the binary copy image, u and v are the transform domain coordinate points. Wherein, when the true array of the binary copy image is a square matrix, then M=N. F(u,v) is called the frequency spectrum of the binary copy image signal f(x,y), and the amplitude spectrum and phase spectrum of the binary copy image after Fourier transform are calculated respectively:
Figure PCTCN2019116549-appb-000009
Figure PCTCN2019116549-appb-000009
其中,F(u,v)=R(u,v)+jI(u,v)=|F(u,v)|e jφ(u,v),|F(u,v)|表示所述二值拷贝图像幅度谱,φ(u,v)表示所述二值拷贝图像相位谱。 Among them, F(u,v)=R(u,v)+jI(u,v)=|F(u,v)|e jφ(u,v) , |F(u,v)| means the The amplitude spectrum of the binary copy image, φ(u, v) represents the phase spectrum of the binary copy image.
进一步地,本申请根据所述计算的二值拷贝图像的幅度谱和相位谱,构建频数投影直方图,并根据所述二值拷贝图像递进旋转的角度不同,可以得到不同的频数投影直方图,即所述二值拷贝图像的频数投影直方图集。Further, the present application constructs a frequency projection histogram according to the calculated amplitude spectrum and phase spectrum of the binary copy image, and according to different angles of progressive rotation of the binary copy image, different frequency projection histograms can be obtained , That is, the frequency projection histogram set of the binary copy image.
S4、计算所述频数投影直方图集中的峰顶点与峰谷点的标准差,得到标 准差集,将所述标准差集中最大标准差作为所述文本图像的纠偏角度,完成所述文本图像的角度纠偏。S4. Calculate the standard deviations of the peak vertices and peak valley points in the frequency projection histogram to obtain a standard deviation set, and use the maximum standard deviation in the standard deviation set as the correction angle of the text image to complete the correction of the text image Angle correction.
本申请较佳实施例中,计算所述频数投影直方图集中的峰顶点与峰谷点的标准差的方法为:In a preferred embodiment of the present application, the method for calculating the standard deviation of the peak vertices and the peak valley points in the frequency projection histogram set is:
Figure PCTCN2019116549-appb-000010
Figure PCTCN2019116549-appb-000010
其中,σ表示频数投影直方图的标准差,x i表示频数投影直方图中第i个峰顶点,n表示频数投影直方图中峰顶点的数量,y j表示频数投影直方图中第i个峰谷点,m表示频数投影直方图中峰谷点的数量,μ为所有峰顶点和峰谷点的均值。所求标准差反映了峰谷点和峰顶点之间的离散程度。 Among them, σ represents the standard deviation of the frequency projection histogram, xi represents the i-th peak vertex in the frequency projection histogram, n represents the number of peak vertices in the frequency projection histogram, and y j represents the i-th peak in the frequency projection histogram. Valley point, m represents the number of peak and valley points in the frequency projection histogram, and μ is the mean value of all peak vertices and peak valley points. The required standard deviation reflects the degree of dispersion between the peak valley point and the peak apex.
进一步地,本申请计算出所述频数投影直方图集中所有直方图的标准差,得到标准差集,并根据文本图像的结构特点,得到当标准差最大时即为所述文本图像纠正后的最佳方位,得到所述文本图像纠偏角度,并按照所述纠偏角度对原始图像进行旋转矫正。Further, the present application calculates the standard deviations of all histograms in the frequency projection histogram set to obtain the standard deviation set, and according to the structural characteristics of the text image, it is obtained that when the standard deviation is the largest, it is the highest corrected text image. In the best orientation, the correction angle of the text image is obtained, and the original image is rotated and corrected according to the correction angle.
发明还提供一种文本图像角度纠偏装置。参照图2所示,为本申请一实施例提供的文本图像角度纠偏装置的内部结构示意图。The invention also provides a text image angle correction device. Referring to FIG. 2, it is a schematic diagram of the internal structure of a text image angle correction device provided by an embodiment of this application.
在本实施例中,所述文本图像角度纠偏装置1可以是PC(Personal Computer,个人电脑),或者是智能手机、平板电脑、便携计算机等终端设备,也可以是一种服务器等。该文本图像角度纠偏装置1至少包括存储器11、处理器12,通信总线13,以及网络接口14。In this embodiment, the text image angle correction device 1 may be a PC (Personal Computer, personal computer), or a terminal device such as a smart phone, a tablet computer, or a portable computer, or a server. The text image angle correction device 1 at least includes a memory 11, a processor 12, a communication bus 13, and a network interface 14.
其中,存储器11至少包括一种类型的可读存储介质,所述可读存储介质包括闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、磁性存储器、磁盘、光盘等。存储器11在一些实施例中可以是文本图像角度纠偏装置1的内部存储单元,例如该文本图像角度纠偏装置1的硬盘。存储器11在另一些实施例中也可以是文本图像角度纠偏装置1的外部存储设备,例如文本图像角度纠偏装置1上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,存储器11还可以既包括文本图像角度纠偏装置1的内部存储单元也包括外部存储设备。存储器11不仅可以用于存储安装于文本图像角度纠偏 装置1的应用软件及各类数据,例如文本图像角度纠偏程序01的代码等,还可以用于暂时地存储已经输出或者将要输出的数据。The memory 11 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), magnetic memory, magnetic disk, optical disk, and the like. In some embodiments, the memory 11 may be an internal storage unit of the text image angle correction device 1, for example, a hard disk of the text image angle correction device 1. In other embodiments, the memory 11 may also be an external storage device of the text image angle correction device 1, such as a plug-in hard disk equipped on the text image angle correction device 1, a smart media card (SMC), and a secure digital (Secure Digital, SD) card, flash card (Flash Card), etc. Further, the memory 11 may also include both an internal storage unit of the text image angle correction device 1 and an external storage device. The memory 11 can be used not only to store application software and various data installed in the text image angle correction device 1, such as the code of the text image angle correction program 01, etc., but also to temporarily store data that has been output or will be output.
处理器12在一些实施例中可以是一中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器或其他数据处理芯片,用于运行存储器11中存储的程序代码或处理数据,例如执行文本图像角度纠偏程序01等。In some embodiments, the processor 12 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chip, for running program codes or processing stored in the memory 11 Data, such as the execution of the text image angle correction program 01 and so on.
通信总线13用于实现这些组件之间的连接通信。The communication bus 13 is used to realize the connection and communication between these components.
网络接口14可选的可以包括标准的有线接口、无线接口(如WI-FI接口),通常用于在该装置1与其他电子设备之间建立通信连接。The network interface 14 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface), and is usually used to establish a communication connection between the apparatus 1 and other electronic devices.
可选地,该装置1还可以包括用户接口,用户接口可以包括显示器(Display)、输入单元比如键盘(Keyboard),可选的用户接口还可以包括标准的有线接口、无线接口。可选地,在一些实施例中,显示器可以是LED显示器、液晶显示器、触控式液晶显示器以及OLED(Organic Light-Emitting Diode,有机发光二极管)触摸器等。其中,显示器也可以适当的称为显示屏或显示单元,用于显示在文本图像角度纠偏装置1中处理的信息以及用于显示可视化的用户界面。Optionally, the device 1 may also include a user interface. The user interface may include a display (Display) and an input unit such as a keyboard (Keyboard). The optional user interface may also include a standard wired interface and a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode, organic light-emitting diode) touch device, etc. Among them, the display can also be appropriately called a display screen or a display unit, which is used to display the information processed in the text image angle correction device 1 and to display a visualized user interface.
图2仅示出了具有组件11-14以及文本图像角度纠偏程序01的文本图像角度纠偏装置1,本领域技术人员可以理解的是,图1示出的结构并不构成对文本图像角度纠偏装置1的限定,可以包括比图示更少或者更多的部件,或者组合某些部件,或者不同的部件布置。Figure 2 only shows the text image angle correction device 1 with components 11-14 and the text image angle correction program 01. Those skilled in the art can understand that the structure shown in Figure 1 does not constitute a text image angle correction device The definition of 1 may include fewer or more components than shown, or a combination of certain components, or different component arrangements.
在图2所示的装置1实施例中,存储器11中存储有文本图像角度纠偏程序01;处理器12执行存储器11中存储的文本图像角度纠偏程序01时实现如下步骤:In the embodiment of the apparatus 1 shown in FIG. 2, the memory 11 stores a text image angle correction program 01; when the processor 12 executes the text image angle correction program 01 stored in the memory 11, the following steps are implemented:
步骤一、获取文本图像,对所述文本图像进行预处理操作,得到二值化文本图像。Step 1: Obtain a text image, and perform a preprocessing operation on the text image to obtain a binary text image.
本申请较佳实施例中,所述文本图像可以为证件、发票等图像数据。所述预处理操作为:通过自适应图像降噪滤波器对所述文本图像进行降噪,利用对比度拉伸方式对降噪后的所述文本图像进行对比度增强,根据OTSU算法将对比度增强后的所述文本图像进行阈值化操作,得到所述二值化文本图像。详细地,所述预处理操作具体实施步骤如下所示:In a preferred embodiment of the present application, the text image may be image data such as certificates and invoices. The preprocessing operation is: denoising the text image through an adaptive image denoising filter, using a contrast stretching method to enhance the contrast of the denoised text image, and using the OTSU algorithm to increase the contrast of the text image. Thresholding is performed on the text image to obtain the binarized text image. In detail, the specific implementation steps of the preprocessing operation are as follows:
d.降噪:d. Noise reduction:
本申请通过自适应图像降噪滤波器对所述文本图像进行降噪,用于滤除所述文本图像的椒盐噪声,并可以很大程度的保护所述文本图像的细节。其中,所述椒盐噪声是图像中一种随机出现的白点或黑点,所述自适应图像降噪滤波器是信号抽取器,用于从被噪声污染的信号中抽取原来的信号。This application uses an adaptive image noise reduction filter to reduce the noise of the text image, which is used to filter out the salt and pepper noise of the text image, and can protect the details of the text image to a large extent. Wherein, the salt and pepper noise is a white point or black point that randomly appears in the image, and the adaptive image noise reduction filter is a signal extractor, which is used to extract the original signal from the signal contaminated by noise.
本申请较佳实施例通过预设所述文本图像为f(x,y),在退化函数H的作用下,由于受到椒盐噪声η(x,y)的影响,得到一个退化图像g(x,y)。于是,得到图像退化公式:g(x,y)=η(x,y)+f(x,y),并利用Adaptive Filter方法对所述文本图像进行降噪,其中,所述降噪的计算公式为:In the preferred embodiment of the present application, the text image is preset to be f(x, y). Under the action of the degradation function H, due to the influence of the salt and pepper noise η(x, y), a degraded image g(x, y) is obtained. y). Therefore, the image degradation formula is obtained: g(x,y)=η(x,y)+f(x,y), and the Adaptive Filter method is used to reduce the noise of the text image, wherein the calculation of the noise reduction The formula is:
Figure PCTCN2019116549-appb-000011
Figure PCTCN2019116549-appb-000011
其中,
Figure PCTCN2019116549-appb-000012
是文本图像的噪声方差,
Figure PCTCN2019116549-appb-000013
是点(x,y)附近的一个窗口内的像素灰度均值,
Figure PCTCN2019116549-appb-000014
是点(x,y)附近一个窗口内的像素灰度的方差。
among them,
Figure PCTCN2019116549-appb-000012
Is the noise variance of the text image,
Figure PCTCN2019116549-appb-000013
Is the average gray value of pixels in a window near the point (x, y),
Figure PCTCN2019116549-appb-000014
It is the variance of the gray level of pixels in a window near the point (x, y).
e.对比度增强:e. Contrast enhancement:
所述对比度指的是成像系统中亮度最大值与最小值之间的对比,其中,对比度低会使图像处理难度增大。本申请较佳实施例中采用的是对比度拉伸方法,利用提高灰度级动态范围的方式,达到文本图像对比度增强的目的。所述对比度拉伸也叫作灰度拉伸。The contrast refers to the contrast between the maximum value and the minimum value of the brightness in the imaging system, where low contrast makes image processing more difficult. In the preferred embodiment of the present application, a contrast stretching method is adopted, which uses a method of increasing the dynamic range of gray levels to achieve the purpose of enhancing the contrast of the text image. The contrast stretching is also called gray scale stretching.
进一步地,本申请根据所述对比度拉伸方法中的分段线性变换函数对特定区域进行灰度拉伸,进一步提高输出图像的对比度。当进行对比度拉伸时,本质上是实现灰度值变换。本申请通过线性拉伸实现灰度值变换,所述线性拉伸指的是输入与输出的灰度值之间为线性关系的像素级运算,灰度变换公式如下所示:Further, the present application performs gray scale stretching on a specific area according to the piecewise linear transformation function in the contrast stretching method, so as to further improve the contrast of the output image. When performing contrast stretching, it essentially realizes gray value conversion. This application implements the gray value transformation through linear stretching. The linear stretching refers to a pixel-level operation with a linear relationship between the input and output gray values. The gray conversion formula is as follows:
D b=f(D a)=a*D a+b D b =f(D a )=a*D a +b
其中a为线性斜率,b为在Y轴上的截距。当a>1时,此时输出的图像对比度相比原图像是增强的。当a<1时,此时输出的图像对比度相比原图像是削弱的,其中D a代表输入图像灰度值,D b代表输出图像灰度值。 Where a is the linear slope and b is the intercept on the Y axis. When a>1, the contrast of the output image at this time is enhanced compared to the original image. When a<1, the contrast of the output image is weaker than the original image, where D a represents the gray value of the input image, and D b represents the gray value of the output image.
f.图像阈值化操作:f. Image thresholding operation:
本申请通过OTSU算法将对比度增强后的所述文本图像进行二值化的高效算法,得到二值化图像。进一步地,本申请较佳实施例预设灰度t为对比度增强后的所述文本图像的前景与背景的分割阈值,并预设前景点数占对比度增强后的所述文本图像比例为w 0,平均灰度为u 0;背景点数占对比度增强后 的所述文本图像比例为w 1,平均灰度为u 1,则对比度增强后的所述文本图像的总平均灰度为: This application uses the OTSU algorithm to perform an efficient algorithm for binarizing the contrast-enhanced text image to obtain a binarized image. Further, the preferred embodiment of the present application presets the gray level t to be the segmentation threshold of the foreground and background of the text image after contrast enhancement, and presets the ratio of the number of front sights to the text image after contrast enhancement as w 0 , The average gray level is u 0 ; the proportion of the number of background points in the contrast-enhanced text image is w 1 , and the average gray level is u 1 , so the total average gray level of the text image after the contrast-enhancement is:
u=w 0*u 0+w 1*u 1u=w 0 *u 0 +w 1 *u 1 ,
其中,对比度增强后的所述文本图像的前景和背景图象的方差为:Wherein, the variance of the foreground and background image of the text image after contrast enhancement is:
g=w 0*(u 0-u)*(u 0-u)+w 1*(u 1-u)*(u 1-u)=w 0*w 1*(u 0-u 1)*(u 0-u 1), g=w 0 *(u 0 -u)*(u 0 -u)+w 1 *(u 1 -u)*(u 1 -u)=w 0 *w 1 *(u 0 -u 1 )* (u 0 -u 1 ),
其中,当方差g最大时,则此时前景和背景差异最大,此时的灰度t为最佳阈值,并将对比度增强后的所述文本图像中大于所述灰度t的灰度值设置为255,小于所述灰度t的灰度值设置为0,得到对比度增强后的所述文本图像的二值化文本图像。Wherein, when the variance g is the largest, then the difference between the foreground and the background is the largest at this time, the gray level t at this time is the optimal threshold, and the gray level value greater than the gray level t in the text image after the contrast enhancement is set Is 255, the gray value smaller than the gray t is set to 0, and the binary text image of the text image after contrast enhancement is obtained.
进一步地,本申请所述预处理操作还可以包括通过主成分分析法对所述二值化文本图像进行降维,使所述二值化文本图像能够被更高效处理。其中,所述主成分分析法是一种通过正交变换将一组可能存在相关性的变量为一组线性不相关变量的方法。Further, the preprocessing operation described in the present application may further include reducing the dimension of the binarized text image through a principal component analysis method, so that the binarized text image can be processed more efficiently. Wherein, the principal component analysis method is a method of transforming a group of potentially correlated variables into a group of linearly uncorrelated variables through orthogonal transformation.
步骤二、通过迭代算法检测所述二值化文本图像中偏斜的文本,得到偏斜文本图像,并对所述偏斜文本图像进行提取,得到二值拷贝图像。Step 2: Detect skewed text in the binarized text image by an iterative algorithm to obtain a skewed text image, and extract the skewed text image to obtain a binary copy image.
本申请较佳实施例通过AdaBoost迭代算法检测所述二值化文本图像中偏斜的文本,到偏斜文本图像。所述AdaBoost迭代算法是一种检测算法,其核心是迭代,其针对不同的训练集构造出的一个弱分类器,并将每一个基弱分类器组合到一起,形成一个最终的强分类器。所述AdaBoost迭代算法的实现是通过调整数据分布,其依据判断每一次训练集当中每一个样本分类的正确性,以及上次样本总体分类的准确率,来设置每一个样本的权值。而新得到的权值将作为下层分类器训练的数据集,然后将每一次训练出的分类器组合起来,形成最终的决策分类器。The preferred embodiment of the present application detects the skewed text in the binarized text image to the skewed text image through the AdaBoost iterative algorithm. The AdaBoost iterative algorithm is a detection algorithm whose core is iteration. It constructs a weak classifier for different training sets, and combines each base weak classifier to form a final strong classifier. The implementation of the AdaBoost iterative algorithm is to adjust the data distribution, and set the weight of each sample based on judging the correctness of the classification of each sample in each training set and the accuracy of the overall classification of the last sample. The newly obtained weights will be used as the data set for the training of the lower classifier, and then the classifiers trained each time will be combined to form the final decision classifier.
本申请将所述二值化文本图像中不同区域进行划分,得到训练样本(x 1,y 1),(x 2,y 2),…(x n,y n),其中,负样本(背景)用y i=0来表示,正样本(前景,即包含偏斜文本)用y i=1来表示。优选地,本申请构建的弱分类器为: This application divides the different regions in the binarized text image to obtain training samples (x 1 , y 1 ), (x 2 , y 2 ), ... (x n , y n ), where the negative sample (background ) Is represented by y i =0, and positive samples (foreground, that is, containing skewed text) are represented by y i =1. Preferably, the weak classifier constructed in this application is:
Figure PCTCN2019116549-appb-000015
Figure PCTCN2019116549-appb-000015
其中,f为特征,θ为阈值,p指示不等号的方向,x表示一个检测子窗口。通过对所述构建的弱分类器进行集合,并对所述构建的弱分类器中分类 最小错误率ε t的最佳弱分类器h t(x)进行选取,所述ε t的计算公式为: Among them, f is the feature, θ is the threshold, p indicates the direction of the inequality sign, and x indicates a detection sub-window. By collecting the constructed weak classifiers, and selecting the best weak classifier h t (x) with the smallest classification error rate ε t among the constructed weak classifiers, the calculation formula of ε t is :
ε t=min f,p,θi(w i/∑w i)|h(x,f,p,θ)-y i|, ε t =min f,p,θi (w i /∑w i )|h(x,f,p,θ)-y i |,
其中,w为特征权值,得到最终的强分类器:Among them, w is the feature weight, and the final strong classifier is obtained:
Figure PCTCN2019116549-appb-000016
Figure PCTCN2019116549-appb-000016
β t=ε t/(1-ε t)。 β tt /(1-ε t ).
进一步地,本申请通过级联分类器的方式检测出所述二值化文本图像中偏斜的文本。所述级联分类器就是将所述训练得到的强分类器通过级联的方式组成一个文本检测级联分类器,所述级联分类器是一个退化的决策树。在级联分类器中,第2层分类器分类是由第1层分类得到的正样本触发的,第3层分类器分类是由第2层分类得到的正样本触发的,依次类推。最终检测到一般环境下所述二值化文本图像中的所有偏斜文本图像,并对所述偏斜文本图像进行裁剪,得到所述二值拷贝图像。Further, the present application detects the skewed text in the binarized text image by means of cascaded classifiers. The cascade classifier is to form a text detection cascade classifier by cascading the strong classifiers obtained by the training, and the cascade classifier is a degraded decision tree. In the cascade classifier, the classification of the second-level classifier is triggered by the positive samples obtained from the first-level classification, the classification of the third-level classifier is triggered by the positive samples obtained from the second-level classification, and so on. Finally, all the skewed text images in the binarized text image in the general environment are detected, and the skewed text images are cropped to obtain the binary copy image.
步骤三、对所述二值拷贝图像进行递进旋转,将递进旋转后的所述二值拷贝图像转换为频数投影直方图,根据所述二值拷贝图像的递进旋转的角度,得到所述二值拷贝图像的频数投影直方图集。Step 3: Perform progressive rotation on the binary copy image, convert the binary copy image after the progressive rotation into a frequency projection histogram, and obtain the result according to the progressive rotation angle of the binary copy image The frequency projection histogram set of the binary copy image.
本申请较佳实施例按照预设的角度对二值拷贝图进行递进旋转,优选地,本申请将在-45°至45°之间以2°为单位对上述二值拷贝图进行递进旋转,并在每一次递进旋转后计算所述二值拷贝图像中长和宽像素点的个数。The preferred embodiment of this application progressively rotates the binary copy image according to a preset angle. Preferably, this application will progressively rotate the binary copy image between -45° and 45° in units of 2°. Rotate, and calculate the number of long and wide pixels in the binary copy image after each progressive rotation.
进一步地,本申请通过傅里叶变换算法将递进旋转后的所述二值拷贝图像转换为频数投影直方图。详细的,所述傅里叶变换的方法包括:Further, the present application converts the progressively rotated binary copy image into a frequency projection histogram through a Fourier transform algorithm. Specifically, the Fourier transform method includes:
Figure PCTCN2019116549-appb-000017
Figure PCTCN2019116549-appb-000017
对其进行变换为:Transform it into:
Figure PCTCN2019116549-appb-000018
Figure PCTCN2019116549-appb-000018
其中,u=0,1,2,3…M-1;v=0,1,2,3…N-1;x=0,1,2,3…M-1;y=0,1,2,3…N-1;M、N分别为所述二值拷贝图像中长和宽像素点个数,x、y为空间坐标点,f(x,y)为所述二值拷贝图像空间域采样值,F(u,v)为所述二值拷贝图像傅里叶变换域采样值,u、v为变换域坐标点。其中,当所述二值拷 贝图像真列为方阵时,则M=N。F(u,v)称为所述二值拷贝图像信号f(x,y)的频谱,并分别计算出所述进行傅里叶变换后的二值拷贝图像幅度谱和相位谱:Among them, u=0,1,2,3...M-1; v=0,1,2,3...N-1; x=0,1,2,3...M-1; y=0,1, 2,3...N-1; M and N are the number of long and wide pixels in the binary copy image respectively, x and y are the space coordinate points, and f(x,y) is the binary copy image space Domain sampling value, F(u, v) is the Fourier transform domain sampling value of the binary copy image, u and v are the transform domain coordinate points. Wherein, when the binary copy image is a square matrix, then M=N. F(u,v) is called the frequency spectrum of the binary copy image signal f(x,y), and the amplitude spectrum and phase spectrum of the binary copy image after Fourier transform are calculated respectively:
Figure PCTCN2019116549-appb-000019
Figure PCTCN2019116549-appb-000019
其中,F(u,v)=R(u,v)+jI(u,v)=|F(u,v)|e jφ(u,v),|F(u,v)|表示所述二值拷贝图像幅度谱,φ(u,v)表示所述二值拷贝图像相位谱。 Among them, F(u,v)=R(u,v)+jI(u,v)=|F(u,v)|e jφ(u,v) , |F(u,v)| means the The amplitude spectrum of the binary copy image, φ(u, v) represents the phase spectrum of the binary copy image.
进一步地,本申请根据所述计算的二值拷贝图像的幅度谱和相位谱,构建频数投影直方图,并根据所述二值拷贝图像递进旋转的角度不同,可以得到不同的频数投影直方图,即所述二值拷贝图像的频数投影直方图集。Further, the present application constructs a frequency projection histogram according to the calculated amplitude spectrum and phase spectrum of the binary copy image, and according to different angles of progressive rotation of the binary copy image, different frequency projection histograms can be obtained , That is, the frequency projection histogram set of the binary copy image.
步骤四、计算所述频数投影直方图集中的峰顶点与峰谷点的标准差,得到标准差集,将所述标准差集中最大标准差作为所述文本图像的纠偏角度,完成所述文本图像的角度纠偏。Step 4. Calculate the standard deviations of the peak vertices and peak valley points in the frequency projection histogram set to obtain a standard deviation set, and use the maximum standard deviation in the standard deviation set as the correction angle of the text image to complete the text image The angle correction.
本申请较佳实施例中,计算所述频数投影直方图集中的峰顶点与峰谷点的标准差的方法为:In a preferred embodiment of the present application, the method for calculating the standard deviation of the peak vertices and the peak valley points in the frequency projection histogram set is:
Figure PCTCN2019116549-appb-000020
Figure PCTCN2019116549-appb-000020
其中,σ表示频数投影直方图的标准差,x i表示频数投影直方图中第i个峰顶点,n表示频数投影直方图中峰顶点的数量,y j表示频数投影直方图中第i个峰谷点,m表示频数投影直方图中峰谷点的数量,μ为所有峰顶点和峰谷点的均值。所求标准差反映了峰谷点和峰顶点之间的离散程度。 Among them, σ represents the standard deviation of the frequency projection histogram, xi represents the i-th peak vertex in the frequency projection histogram, n represents the number of peak vertices in the frequency projection histogram, and y j represents the i-th peak in the frequency projection histogram. Valley point, m represents the number of peak and valley points in the frequency projection histogram, and μ is the mean value of all peak vertices and peak valley points. The required standard deviation reflects the degree of dispersion between the peak valley point and the peak apex.
进一步地,本申请计算出所述频数投影直方图集中所有直方图的标准差,得到标准差集,并根据文本图像的结构特点,得到当标准差最大时即为所述文本图像纠正后的最佳方位,得到所述文本图像纠偏角度,并按照所述纠偏角度对原始图像进行旋转矫正。Further, the present application calculates the standard deviations of all histograms in the frequency projection histogram set to obtain the standard deviation set, and according to the structural characteristics of the text image, it is obtained that when the standard deviation is the largest, it is the highest corrected text image. In the best orientation, the correction angle of the text image is obtained, and the original image is rotated and corrected according to the correction angle.
可选地,在其他实施例中,文本图像角度纠偏程序还可以被分割为一个或者多个模块,一个或者多个模块被存储于存储器11中,并由一个或多个处理器(本实施例为处理器12)所执行以完成本申请,本申请所称的模块是指能够完成特定功能的一系列计算机程序指令段,用于描述文本图像角度纠偏 程序在文本图像角度纠偏装置中的执行过程。Optionally, in other embodiments, the text image angle correction program can also be divided into one or more modules, and the one or more modules are stored in the memory 11 and run by one or more processors (in this embodiment). It is executed by the processor 12) to complete this application. The module referred to in this application refers to a series of computer program instruction segments that can complete specific functions, and is used to describe the execution process of the text image angle correction program in the text image angle correction device .
例如,参照图3所示,为本申请文本图像角度纠偏装置一实施例中的文本图像角度纠偏程序的程序模块示意图,该实施例中,所述文本图像角度纠偏程序可以被分割为文本图像预处理模块10、文本图像检测模块20、图像转换模块30以及计算模块40,示例性地:For example, referring to FIG. 3, a schematic diagram of the program module of the text image angle correction program in an embodiment of the text image angle correction device of this application. In this embodiment, the text image angle correction program can be divided into a text image preview. The processing module 10, the text image detection module 20, the image conversion module 30, and the calculation module 40 are exemplarily:
所述文本图像预处理模块10用于:获取文本图像,对所述文本图像进行预处理操作,得到二值化文本图像。The text image preprocessing module 10 is used to obtain a text image, and perform a preprocessing operation on the text image to obtain a binary text image.
所述文本图像检测模块20用于:通过迭代算法检测所述二值化文本图像中偏斜的文本,得到偏斜文本图像,并对所述偏斜文本图像进行裁剪,得到二值拷贝图像。The text image detection module 20 is configured to detect skewed text in the binarized text image by an iterative algorithm to obtain a skewed text image, and crop the skewed text image to obtain a binary copy image.
所述图像转换模块30用于:对所述二值拷贝图像进行递进旋转,将递进旋转后的所述二值拷贝图像转换为频数投影直方图,根据所述二值拷贝图像的递进旋转的角度,得到所述二值拷贝图像的频数投影直方图集。The image conversion module 30 is configured to: perform a progressive rotation on the binary copy image, convert the binary copy image after the progressive rotation into a frequency projection histogram, according to the progressive rotation of the binary copy image The angle of rotation is used to obtain the frequency projection histogram set of the binary copy image.
所述计算模块40用于:计算所述频数投影直方图集的峰顶点与峰谷点的标准差,得到标准差集,将所述标准差集中最大标准差作为所述文本图像的纠偏角度,从而完成对所述文本图像的角度纠偏。The calculation module 40 is configured to: calculate the standard deviation of the peak apex and the peak valley point of the frequency projection histogram set to obtain a standard deviation set, and use the maximum standard deviation in the standard deviation set as the correction angle of the text image, Thus, the angle correction of the text image is completed.
上述文本图像预处理模块10、文本图像检测模块20、图像转换模块30以及计算模块40等程序模块被执行时所实现的功能或操作步骤与上述实施例大体相同,在此不再赘述。The functions or operation steps implemented by the program modules such as the text image preprocessing module 10, the text image detection module 20, the image conversion module 30, and the calculation module 40 when executed are substantially the same as those in the foregoing embodiment, and will not be repeated here.
此外,本申请实施例还提出一种计算机可读存储介质,所述计算机可读存储介质上存储有文本图像角度纠偏程序,所述文本图像角度纠偏程序可被一个或多个处理器执行,以实现如下操作:In addition, an embodiment of the present application also proposes a computer-readable storage medium that stores a text image angle correction program, and the text image angle correction program can be executed by one or more processors to To achieve the following operations:
获取文本图像,对所述文本图像进行预处理操作,得到二值化文本图像;Acquiring a text image, and performing a preprocessing operation on the text image to obtain a binarized text image;
通过迭代算法检测所述二值化文本图像中偏斜的文本,得到偏斜文本图像,并对所述偏斜文本图像进行裁剪,得到二值拷贝图像;Detecting skewed text in the binary text image by an iterative algorithm to obtain a skewed text image, and crop the skewed text image to obtain a binary copy image;
对所述二值拷贝图像进行递进旋转,将递进旋转后的所述二值拷贝图像转换为频数投影直方图,根据所述二值拷贝图像的递进旋转的角度,得到所述二值拷贝图像的频数投影直方图集;Perform progressive rotation on the binary copy image, convert the progressively rotated binary copy image into a frequency projection histogram, and obtain the binary copy image according to the progressive rotation angle of the binary copy image The frequency projection histogram set of the copied image;
计算所述频数投影直方图集的峰顶点与峰谷点的标准差,得到标准差集, 将所述标准差集中最大标准差作为所述文本图像的纠偏角度,从而完成对所述文本图像的角度纠偏。Calculate the standard deviation of the peak apex and peak valley point of the frequency projection histogram set to obtain a standard deviation set, and use the maximum standard deviation in the standard deviation set as the correction angle of the text image, thereby completing the text image Angle correction.
本申请计算机可读存储介质具体实施方式与上述文本图像角度纠偏装置和方法各实施例基本相同,在此不作累述。The specific implementation of the computer-readable storage medium of the present application is basically the same as the foregoing embodiments of the text image angle correction device and method, and will not be repeated here.
需要说明的是,上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。并且本文中的术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、装置、物品或者方法不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、装置、物品或者方法所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、装置、物品或者方法中还存在另外的相同要素。It should be noted that the serial numbers of the foregoing embodiments of the present application are only for description, and do not represent the advantages and disadvantages of the embodiments. And the terms "include", "include" or any other variants thereof in this article are intended to cover non-exclusive inclusion, so that a process, device, article or method including a series of elements not only includes those elements, but also includes those elements that are not explicitly included. The other elements listed may also include elements inherent to the process, device, article, or method. If there are no more restrictions, the element defined by the sentence "including a..." does not exclude the existence of other identical elements in the process, device, article, or method that includes the element.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本申请各个实施例所述的方法。Through the description of the above implementation manners, those skilled in the art can clearly understand that the above-mentioned embodiment method can be implemented by means of software plus the necessary general hardware platform, of course, it can also be implemented by hardware, but in many cases the former is better.的实施方式。 Based on this understanding, the technical solution of this application essentially or the part that contributes to the existing technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium (such as ROM/RAM) as described above. , Magnetic disk, optical disk), including a number of instructions to make a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) execute the method described in each embodiment of the present application.
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。The above are only the preferred embodiments of the application, and do not limit the scope of the patent for this application. Any equivalent structure or equivalent process transformation made using the content of the description and drawings of the application, or directly or indirectly applied to other related technical fields , The same reason is included in the scope of patent protection of this application.

Claims (20)

  1. 一种文本图像角度纠偏方法,其特征在于,所述方法包括:A method for correcting the angle of a text image, characterized in that the method includes:
    获取文本图像,对所述文本图像进行预处理操作,得到二值化文本图像;Acquiring a text image, and performing a preprocessing operation on the text image to obtain a binarized text image;
    通过迭代算法检测所述二值化文本图像中偏斜的文本,得到偏斜文本图像,并对所述偏斜文本图像进行裁剪,得到二值拷贝图像;Detecting skewed text in the binary text image by an iterative algorithm to obtain a skewed text image, and crop the skewed text image to obtain a binary copy image;
    对所述二值拷贝图像进行递进旋转,将递进旋转后的所述二值拷贝图像转换为频数投影直方图,根据所述二值拷贝图像的递进旋转的角度,得到所述二值拷贝图像的频数投影直方图集;Perform progressive rotation on the binary copy image, convert the progressively rotated binary copy image into a frequency projection histogram, and obtain the binary copy image according to the progressive rotation angle of the binary copy image The frequency projection histogram set of the copied image;
    计算所述频数投影直方图集的峰顶点与峰谷点的标准差,得到标准差集,将所述标准差集中最大标准差作为所述文本图像的纠偏角度,从而完成对所述文本图像的角度纠偏。Calculate the standard deviation of the peak vertices and peak valley points of the frequency projection histogram set to obtain a standard deviation set, and use the maximum standard deviation in the standard deviation set as the correction angle of the text image to complete the correction of the text image Angle correction.
  2. 如权利要求1所述的文本图像角度纠偏方法,其特征在于,所述对所述文本图像进行预处理操作,得到二值化文本图像,包括:The method for correcting the angle of a text image according to claim 1, wherein the preprocessing operation on the text image to obtain a binary text image comprises:
    通过自适应图像降噪滤波器对所述文本图像进行降噪,利用对比度拉伸方式对降噪后的所述文本图像进行对比度增强,根据OTSU算法将对比度增强后的所述文本图像进行阈值化操作,得到所述二值化文本图像。The text image is denoised through an adaptive image denoising filter, the denoised text image is contrast-enhanced using a contrast stretching method, and the contrast-enhanced text image is thresholded according to the OTSU algorithm Operation to obtain the binarized text image.
  3. 如权利要求1所述的文本图像角度纠偏方法,其特征在于,所述将递进旋转后的所述二值拷贝图像转换为频数投影直方图,包括:The method for correcting the angle of a text image according to claim 1, wherein the converting the binary copy image after the progressive rotation into a frequency projection histogram comprises:
    对递进旋转后的所述二值拷贝图像进行傅里叶变换;Performing Fourier transform on the binary copy image after progressive rotation;
    计算出进行傅里叶变换后的所述二值拷贝图像的幅度谱和相位谱;Calculating the amplitude spectrum and the phase spectrum of the binary copy image after Fourier transform;
    根据所述幅度谱和相位谱,构建所述频数投影直方图。According to the amplitude spectrum and the phase spectrum, the frequency projection histogram is constructed.
  4. 如权利要求3所述的文本图像角度纠偏方法,其特征在于,所述傅里叶变换的方法包括:The method for correcting the angle of a text image according to claim 3, wherein the Fourier transform method comprises:
    Figure PCTCN2019116549-appb-100001
    Figure PCTCN2019116549-appb-100001
    对其进行变换为:Transform it into:
    Figure PCTCN2019116549-appb-100002
    Figure PCTCN2019116549-appb-100002
    其中,u=0,1,2,3…M-1;v=0,1,2,3…N-1;x=0,1,2,3…M-1;y= 0,1,2,3…N-1;M、N分别为所述二值拷贝图像中长和宽像素点个数,x、y为空间坐标点,f(x,y)为所述二值拷贝图像空间域采样值,F(u,v)为所述二值拷贝图像傅里叶变换域采样值,u、v为变换域坐标点。Among them, u=0,1,2,3...M-1; v=0,1,2,3...N-1; x=0,1,2,3...M-1; y=0,1, 2,3...N-1; M and N are the number of long and wide pixels in the binary copy image respectively, x and y are the space coordinate points, and f(x,y) is the binary copy image space Domain sampling value, F(u, v) is the Fourier transform domain sampling value of the binary copy image, u and v are the transform domain coordinate points.
  5. 如权利要求4所述的文本图像角度纠偏方法,其特征在于,分别计算出所述进行傅里叶变换后的二值拷贝图像幅度谱和相位谱,根据所述计算的二值拷贝图像的幅度谱和相位谱,构建频数投影直方图:The method for correcting the angle of a text image according to claim 4, wherein the amplitude spectrum and the phase spectrum of the binary copy image after Fourier transform are calculated respectively, and the amplitude spectrum and the phase spectrum of the binary copy image are calculated according to the calculated amplitude of the binary copy image. Spectrum and phase spectrum, construct frequency projection histogram:
    Figure PCTCN2019116549-appb-100003
    Figure PCTCN2019116549-appb-100003
    Figure PCTCN2019116549-appb-100004
    Figure PCTCN2019116549-appb-100004
    其中,F(u,v)=R(u,v)+jI(u,v)=|F(u,v)|e jφ(u,v),|F(u,v)|表示所述二值拷贝图像幅度谱,φ(u,v)表示所述二值拷贝图像相位谱。 Among them, F(u,v)=R(u,v)+jI(u,v)=|F(u,v)|e jφ(u,v) , |F(u,v)| means the The amplitude spectrum of the binary copy image, φ(u, v) represents the phase spectrum of the binary copy image.
  6. 如权利要求1-5中任一项所述的文本图像角度纠偏方法,其特征在于,所述计算所述频数投影直方图集中的峰顶点与峰谷点的标准差的方法包括:The method for correcting the angle deviation of a text image according to any one of claims 1 to 5, wherein the method of calculating the standard deviation of the peak vertices and the peak valley points in the frequency projection histogram set comprises:
    Figure PCTCN2019116549-appb-100005
    Figure PCTCN2019116549-appb-100005
    其中,σ表示频数投影直方图的标准差,x i表示频数投影直方图中第i个峰顶点,n表示频数投影直方图中峰顶点的数量,y j表示频数投影直方图中第i个峰谷点,m表示频数投影直方图中峰谷点的数量,μ为所有峰顶点和峰谷点的均值。 Among them, σ represents the standard deviation of the frequency projection histogram, xi represents the i-th peak vertex in the frequency projection histogram, n represents the number of peak vertices in the frequency projection histogram, and y j represents the i-th peak in the frequency projection histogram. Valley point, m represents the number of peak and valley points in the frequency projection histogram, and μ is the mean value of all peak vertices and peak valley points.
  7. 如权利要求2所述的文本图像角度纠偏方法,其特征在于,所述对比度拉伸为灰度值的变换,所述灰度值的计算公式为:The method for correcting the angle deviation of a text image according to claim 2, wherein the contrast stretching is a conversion of a gray value, and the calculation formula of the gray value is:
    D b=f(D a)=a*D a+b D b =f(D a )=a*D a +b
    其中a为线性斜率,b为在Y轴上的截距,当a>1时,此时输出的图像对比度相比原图像是增强的,当a<1时,此时输出的图像对比度相比原图像是削弱的,其中D a代表输入图像灰度值,D b代表输出图像灰度值。 Where a is the linear slope and b is the intercept on the Y axis. When a>1, the output image contrast is enhanced compared to the original image. When a<1, the output image contrast is compared with The original image is weakened, where D a represents the gray value of the input image, and D b represents the gray value of the output image.
  8. 一种文本图像角度纠偏装置,其特征在于,所述装置包括存储器和处理器,所述存储器上存储有可在所述处理器上运行的文本图像角度纠偏程序,所述文本图像角度纠偏程序被所述处理器执行时实现如下步骤:A text image angle correction device, characterized in that the device includes a memory and a processor, the memory stores a text image angle correction program that can be run on the processor, and the text image angle correction program is When the processor executes, the following steps are implemented:
    获取文本图像,对所述文本图像进行预处理操作,得到二值化文本图像;Acquiring a text image, and performing a preprocessing operation on the text image to obtain a binarized text image;
    通过迭代算法检测所述二值化文本图像中偏斜的文本,得到偏斜文本图像,并对所述偏斜文本图像进行裁剪,得到二值拷贝图像;Detecting skewed text in the binary text image by an iterative algorithm to obtain a skewed text image, and crop the skewed text image to obtain a binary copy image;
    对所述二值拷贝图像进行递进旋转,将递进旋转后的所述二值拷贝图像转换为频数投影直方图,根据所述二值拷贝图像的递进旋转的角度,得到所述二值拷贝图像的频数投影直方图集;Perform progressive rotation on the binary copy image, convert the progressively rotated binary copy image into a frequency projection histogram, and obtain the binary copy image according to the progressive rotation angle of the binary copy image The frequency projection histogram set of the copied image;
    计算所述频数投影直方图集的峰顶点与峰谷点的标准差,得到标准差集,将所述标准差集中最大标准差作为所述文本图像的纠偏角度,从而完成对所述文本图像的角度纠偏。Calculate the standard deviation of the peak vertices and peak valley points of the frequency projection histogram set to obtain a standard deviation set, and use the maximum standard deviation in the standard deviation set as the correction angle of the text image to complete the correction of the text image Angle correction.
  9. 如权利要求8所述的文本图像角度纠偏装置,其特征在于,所述对所述文本图像进行预处理操作,得到二值化文本图像,包括:8. The text image angle correction device according to claim 8, wherein the preprocessing operation on the text image to obtain a binary text image comprises:
    通过自适应图像降噪滤波器对所述文本图像进行降噪,利用对比度拉伸方式对降噪后的所述文本图像进行对比度增强,根据OTSU算法将对比度增强后的所述文本图像进行阈值化操作,得到所述二值化文本图像。The text image is denoised through an adaptive image denoising filter, the denoised text image is contrast-enhanced using a contrast stretching method, and the contrast-enhanced text image is thresholded according to the OTSU algorithm Operation to obtain the binarized text image.
  10. 如权利要求8所述的文本图像角度纠偏装置,其特征在于,所述将递进旋转后的所述二值拷贝图像转换为频数投影直方图,包括:8. The text image angle correction device according to claim 8, wherein said converting the progressively rotated binary copy image into a frequency projection histogram comprises:
    对递进旋转后的所述二值拷贝图像进行傅里叶变换;Performing Fourier transform on the binary copy image after progressive rotation;
    计算出进行傅里叶变换后的所述二值拷贝图像的幅度谱和相位谱;Calculating the amplitude spectrum and the phase spectrum of the binary copy image after Fourier transform;
    根据所述幅度谱和相位谱,构建所述频数投影直方图。According to the amplitude spectrum and the phase spectrum, the frequency projection histogram is constructed.
  11. 如权利要求10所述的文本图像角度纠偏装置,其特征在于,所述傅里叶变换的方法包括:10. The text image angle correction device according to claim 10, wherein the Fourier transform method comprises:
    Figure PCTCN2019116549-appb-100006
    Figure PCTCN2019116549-appb-100006
    对其进行变换为:Transform it into:
    Figure PCTCN2019116549-appb-100007
    Figure PCTCN2019116549-appb-100007
    其中,u=0,1,2,3…M-1;v=0,1,2,3…N-1;x=0,1,2,3…M-1;y=0,1,2,3…N-1;M、N分别为所述二值拷贝图像中长和宽像素点个数,x、y为空间坐标点,f(x,y)为所述二值拷贝图像空间域采样值,F(u,v)为所述二值拷贝图像傅里叶变换域采样值,u、v为变换域坐标点。Among them, u=0,1,2,3...M-1; v=0,1,2,3...N-1; x=0,1,2,3...M-1; y=0,1, 2,3...N-1; M and N are the number of long and wide pixels in the binary copy image respectively, x and y are the space coordinate points, and f(x,y) is the binary copy image space Domain sampling value, F(u, v) is the Fourier transform domain sampling value of the binary copy image, u and v are the transform domain coordinate points.
  12. 如权利要求11所述的文本图像角度纠偏装置,其特征在于,分别计算出所述进行傅里叶变换后的二值拷贝图像幅度谱和相位谱,根据所述计算的二值拷贝图像的幅度谱和相位谱,构建频数投影直方图:The text image angle correction device according to claim 11, wherein the amplitude spectrum and the phase spectrum of the binary copy image after Fourier transform are respectively calculated, and the amplitude spectrum and the phase spectrum of the binary copy image are calculated according to the calculated amplitude Spectrum and phase spectrum, construct frequency projection histogram:
    Figure PCTCN2019116549-appb-100008
    Figure PCTCN2019116549-appb-100008
    Figure PCTCN2019116549-appb-100009
    Figure PCTCN2019116549-appb-100009
    其中,F(u,v)=R(u,v)+jI(u,v)=|F(u,v)|e jφ(u,v),|F(u,v)|表示所述二值拷贝图像幅度谱,φ(u,v)表示所述二值拷贝图像相位谱。 Among them, F(u,v)=R(u,v)+jI(u,v)=|F(u,v)|e jφ(u,v) , |F(u,v)| means the The amplitude spectrum of the binary copy image, φ(u, v) represents the phase spectrum of the binary copy image.
  13. 如权利要求8-12中任一项所述的文本图像角度纠偏装置,其特征在于,所述计算所述频数投影直方图集中的峰顶点与峰谷点的标准差的方法包括:The text image angle correction device according to any one of claims 8-12, wherein the method of calculating the standard deviation of the peak vertices and the peak valley points in the frequency projection histogram set comprises:
    Figure PCTCN2019116549-appb-100010
    Figure PCTCN2019116549-appb-100010
    其中,σ表示频数投影直方图的标准差,x i表示频数投影直方图中第i个峰顶点,n表示频数投影直方图中峰顶点的数量,y i表示频数投影直方图中第i个峰谷点,m表示频数投影直方图中峰谷点的数量,μ为所有峰顶点和峰谷点的均值。 Among them, σ represents the standard deviation of the frequency projection histogram, xi represents the i-th peak apex in the frequency projection histogram, n represents the number of peak vertices in the frequency projection histogram, and y i represents the i-th peak in the frequency projection histogram. Valley point, m represents the number of peak and valley points in the frequency projection histogram, and μ is the mean value of all peak vertices and peak valley points.
  14. 如权利要求9所述的文本图像角度纠偏装置,其特征在于,所述对比度拉伸为灰度值的变换,所述灰度值的计算公式为:9. The text image angle correction device according to claim 9, wherein the contrast stretching is a conversion of a gray value, and the calculation formula of the gray value is:
    D b=f(D a)=a*D a+b D b =f(D a )=a*D a +b
    其中a为线性斜率,b为在Y轴上的截距,当a>1时,此时输出的图像对比度相比原图像是增强的,当a<1时,此时输出的图像对比度相比原图像是削弱的,其中D a代表输入图像灰度值,D b代表输出图像灰度值。 Where a is the linear slope and b is the intercept on the Y axis. When a>1, the output image contrast is enhanced compared to the original image. When a<1, the output image contrast is compared with The original image is weakened, where D a represents the gray value of the input image, and D b represents the gray value of the output image.
  15. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有文本图像角度纠偏程序,所述文本图像角度纠偏程序可被一个或者多个处理器执行,以实现如权利要求1至5中任一项所述的文本图像角度纠偏方法的步骤:A computer-readable storage medium, characterized in that a text image angle correction program is stored on the computer readable storage medium, and the text image angle correction program can be executed by one or more processors to realize The steps of the method for correcting the angle of a text image according to any one of 1 to 5:
    获取文本图像,对所述文本图像进行预处理操作,得到二值化文本图像;Acquiring a text image, and performing a preprocessing operation on the text image to obtain a binarized text image;
    通过迭代算法检测所述二值化文本图像中偏斜的文本,得到偏斜文本图像,并对所述偏斜文本图像进行裁剪,得到二值拷贝图像;Detecting skewed text in the binary text image by an iterative algorithm to obtain a skewed text image, and crop the skewed text image to obtain a binary copy image;
    对所述二值拷贝图像进行递进旋转,将递进旋转后的所述二值拷贝图像转换为频数投影直方图,根据所述二值拷贝图像的递进旋转的角度,得到所述二值拷贝图像的频数投影直方图集;Perform progressive rotation on the binary copy image, convert the progressively rotated binary copy image into a frequency projection histogram, and obtain the binary copy image according to the progressive rotation angle of the binary copy image The frequency projection histogram set of the copied image;
    计算所述频数投影直方图集的峰顶点与峰谷点的标准差,得到标准差集, 将所述标准差集中最大标准差作为所述文本图像的纠偏角度,从而完成对所述文本图像的角度纠偏。Calculate the standard deviation of the peak apex and peak valley point of the frequency projection histogram set to obtain a standard deviation set, and use the maximum standard deviation in the standard deviation set as the correction angle of the text image, thereby completing the text image Angle correction.
  16. 如权利要求15所述的计算机可读存储介质,其特征在于,所述对所述文本图像进行预处理操作,得到二值化文本图像,包括:15. The computer-readable storage medium of claim 15, wherein the preprocessing operation on the text image to obtain a binarized text image comprises:
    通过自适应图像降噪滤波器对所述文本图像进行降噪,利用对比度拉伸方式对降噪后的所述文本图像进行对比度增强,根据OTSU算法将对比度增强后的所述文本图像进行阈值化操作,得到所述二值化文本图像。The text image is denoised through an adaptive image denoising filter, the denoised text image is contrast-enhanced using a contrast stretching method, and the contrast-enhanced text image is thresholded according to the OTSU algorithm Operation to obtain the binarized text image.
  17. 如权利要求15所述的计算机可读存储介质,其特征在于,所述将递进旋转后的所述二值拷贝图像转换为频数投影直方图,包括:15. The computer-readable storage medium according to claim 15, wherein the converting the binary copy image after the progressive rotation into a frequency projection histogram comprises:
    对递进旋转后的所述二值拷贝图像进行傅里叶变换;Performing Fourier transform on the binary copy image after progressive rotation;
    计算出进行傅里叶变换后的所述二值拷贝图像的幅度谱和相位谱;Calculating the amplitude spectrum and the phase spectrum of the binary copy image after Fourier transform;
    根据所述幅度谱和相位谱,构建所述频数投影直方图。According to the amplitude spectrum and the phase spectrum, the frequency projection histogram is constructed.
  18. 如权利要求17所述的计算机可读存储介质,其特征在于,所述傅里叶变换的方法包括:17. The computer-readable storage medium of claim 17, wherein the Fourier transform method comprises:
    Figure PCTCN2019116549-appb-100011
    Figure PCTCN2019116549-appb-100011
    对其进行变换为:Transform it into:
    Figure PCTCN2019116549-appb-100012
    Figure PCTCN2019116549-appb-100012
    其中,u=0,1,2,3…M-1;v=0,1,2,3…N-1;x=0,1,2,3…M-1;y=0,1,2,3…N-1;M、N分别为所述二值拷贝图像中长和宽像素点个数,x、y为空间坐标点,f(x,y)为所述二值拷贝图像空间域采样值,F(u,v)为所述二值拷贝图像傅里叶变换域采样值,u、v为变换域坐标点。Among them, u=0,1,2,3...M-1; v=0,1,2,3...N-1; x=0,1,2,3...M-1; y=0,1, 2,3...N-1; M and N are the number of long and wide pixels in the binary copy image respectively, x and y are the space coordinate points, and f(x,y) is the binary copy image space Domain sampling value, F(u, v) is the Fourier transform domain sampling value of the binary copy image, u and v are the transform domain coordinate points.
  19. 如权利要求18所述的计算机可读存储介质,其特征在于,分别计算出所述进行傅里叶变换后的二值拷贝图像幅度谱和相位谱,根据所述计算的二值拷贝图像的幅度谱和相位谱,构建频数投影直方图:The computer-readable storage medium according to claim 18, wherein the Fourier transform of the binary copy image amplitude spectrum and the phase spectrum are respectively calculated, and the calculated amplitude spectrum of the binary copy image is Spectrum and phase spectrum, construct frequency projection histogram:
    Figure PCTCN2019116549-appb-100013
    Figure PCTCN2019116549-appb-100013
    Figure PCTCN2019116549-appb-100014
    Figure PCTCN2019116549-appb-100014
    其中,F(u,v)=R(u,v)+jI(u,v)=|F(u,v)|e jφ(u,v),|F(u,v)|表示所述二值拷贝图像幅度谱,φ(u,v)表示所述二值拷贝图像相位谱。 Among them, F(u,v)=R(u,v)+jI(u,v)=|F(u,v)|e jφ(u,v) , |F(u,v)| means the The amplitude spectrum of the binary copy image, φ(u, v) represents the phase spectrum of the binary copy image.
  20. 如权利要求19所述的计算机可读存储介质,其特征在于,所述计算所述频数投影直方图集中的峰顶点与峰谷点的标准差的方法包括:The computer-readable storage medium of claim 19, wherein the method of calculating the standard deviation of the peak apex and the peak valley point in the frequency projection histogram set comprises:
    Figure PCTCN2019116549-appb-100015
    Figure PCTCN2019116549-appb-100015
    其中,σ表示频数投影直方图的标准差,x i表示频数投影直方图中第i个峰顶点,n表示频数投影直方图中峰顶点的数量,y j表示频数投影直方图中第i个峰谷点,m表示频数投影直方图中峰谷点的数量,μ为所有峰顶点和峰谷点的均值。 Among them, σ represents the standard deviation of the frequency projection histogram, xi represents the i-th peak vertex in the frequency projection histogram, n represents the number of peak vertices in the frequency projection histogram, and y j represents the i-th peak in the frequency projection histogram. Valley point, m represents the number of peak and valley points in the frequency projection histogram, and μ is the mean value of all peak vertices and peak valley points.
PCT/CN2019/116549 2019-09-06 2019-11-08 Method and apparatus for rectifying deflection of angle of text image, and computer-readable storage medium WO2021042509A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910846892.XA CN110705546B (en) 2019-09-06 2019-09-06 Text image angle deviation correcting method and device and computer readable storage medium
CN201910846892.X 2019-09-06

Publications (1)

Publication Number Publication Date
WO2021042509A1 true WO2021042509A1 (en) 2021-03-11

Family

ID=69196126

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/116549 WO2021042509A1 (en) 2019-09-06 2019-11-08 Method and apparatus for rectifying deflection of angle of text image, and computer-readable storage medium

Country Status (2)

Country Link
CN (1) CN110705546B (en)
WO (1) WO2021042509A1 (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4817176A (en) * 1986-02-14 1989-03-28 William F. McWhortor Method and apparatus for pattern recognition
US20100067826A1 (en) * 2008-09-18 2010-03-18 Certifi Media Inc. Method for Image Skew Detection
CN103761700A (en) * 2013-12-23 2014-04-30 南京信息工程大学 Watermark method capable of resisting printing scanning attack and based on character refinement
CN107480728A (en) * 2017-08-28 2017-12-15 南京大学 A kind of discrimination method of the mimeograph documents based on Fourier's residual values
CN107992869A (en) * 2016-10-26 2018-05-04 深圳超多维科技有限公司 For tilting the method, apparatus and electronic equipment of word correction
CN108121983A (en) * 2016-11-29 2018-06-05 蓝盾信息安全技术有限公司 A kind of text image method for correcting error based on Fourier transformation
CN109409356A (en) * 2018-08-23 2019-03-01 浙江理工大学 A kind of multi-direction Chinese print hand writing detection method based on SWT

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101566196B1 (en) * 2009-03-02 2015-11-05 삼성전자주식회사 Method and apparatus for classifying an image using histogram analysis and method and apparatus for recognizing text image using thereof
JP2011215828A (en) * 2010-03-31 2011-10-27 Canon Inc Image correction apparatus, and method of controlling the same
US9621761B1 (en) * 2015-10-08 2017-04-11 International Business Machines Corporation Automatic correction of skewing of digital images
WO2019056346A1 (en) * 2017-09-25 2019-03-28 深圳传音通讯有限公司 Method and device for correcting tilted text image using expansion method

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4817176A (en) * 1986-02-14 1989-03-28 William F. McWhortor Method and apparatus for pattern recognition
US20100067826A1 (en) * 2008-09-18 2010-03-18 Certifi Media Inc. Method for Image Skew Detection
CN103761700A (en) * 2013-12-23 2014-04-30 南京信息工程大学 Watermark method capable of resisting printing scanning attack and based on character refinement
CN107992869A (en) * 2016-10-26 2018-05-04 深圳超多维科技有限公司 For tilting the method, apparatus and electronic equipment of word correction
CN108121983A (en) * 2016-11-29 2018-06-05 蓝盾信息安全技术有限公司 A kind of text image method for correcting error based on Fourier transformation
CN107480728A (en) * 2017-08-28 2017-12-15 南京大学 A kind of discrimination method of the mimeograph documents based on Fourier's residual values
CN109409356A (en) * 2018-08-23 2019-03-01 浙江理工大学 A kind of multi-direction Chinese print hand writing detection method based on SWT

Also Published As

Publication number Publication date
CN110705546B (en) 2023-12-19
CN110705546A (en) 2020-01-17

Similar Documents

Publication Publication Date Title
US9754164B2 (en) Systems and methods for classifying objects in digital images captured using mobile devices
CN110717497B (en) Image similarity matching method, device and computer readable storage medium
US8644561B2 (en) License plate optical character recognition method and system
US8867828B2 (en) Text region detection system and method
US11663817B2 (en) Automated signature extraction and verification
US8538164B2 (en) Image patch descriptors
US9076056B2 (en) Text detection in natural images
Ebrahimi et al. SUSurE: Speeded up surround extrema feature detector and descriptor for realtime applications
WO2020143325A1 (en) Electronic document generation method and device
WO2021218183A1 (en) Certificate edge detection method and apparatus, and device and medium
Fraz et al. Exploiting colour information for better scene text detection and recognition
WO2021159843A1 (en) Object recognition method and apparatus, and electronic device and storage medium
JP6341059B2 (en) Character recognition device, character recognition method, and program
Krupiński et al. Binarization of degraded document images with generalized Gaussian distribution
WO2021042509A1 (en) Method and apparatus for rectifying deflection of angle of text image, and computer-readable storage medium
CN115063826A (en) Mobile terminal driver license identification method and system based on deep learning
Singh et al. Efficient binarization technique for severely degraded document images
Madan Kumar et al. Text extraction from business cards and classification of extracted text into predefined classes
Salagar et al. Analysis of PCA usage to detect and correct skew in document images
CN111652148A (en) Face recognition method and device and electronic equipment
Zhong et al. Image patches analysis for text block identification
Panwar et al. Handwritten text documents binarization and skew normalization approaches
Felhi et al. A robust skew detection method based on Maximum Gradient Difference and R-signature
CN111539406B (en) Certificate copy information identification method, server and storage medium
Kumar et al. Intellectual Curve Scene Text Detection from Natural Images Using MSER Descriptor Based Region Segmentation Approach

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19944423

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19944423

Country of ref document: EP

Kind code of ref document: A1