WO2021042509A1 - 文本图像角度纠偏方法、装置及计算机可读存储介质 - Google Patents

文本图像角度纠偏方法、装置及计算机可读存储介质 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
English (en)
French (fr)
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/zh

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

本申请涉及一种人工智能技术,揭露了一种文本图像角度纠偏方法,包括获取文本图像,对所述文本图像进行预处理操作,得到二值化文本图像;通过迭代算法检测所述二值化文本图像中偏斜的文本,得到偏斜文本图像,并对所述偏斜文本图像进行裁剪,得到二值拷贝图像;对所述二值拷贝图像进行递进旋转,将递进旋转后的所述二值拷贝图像转换为频数投影直方图集;计算所述频数投影直方图集的峰顶点与峰谷点的标准差,得到标准差集,将所述标准差集中最大标准差作为所述文本图像的纠偏角度,从而完成对所述文本图像的角度纠偏。本申请还提出一种文本图像角度纠偏装置以及一种计算机可读存储介质。本申请实现了文本图像角度的精准纠偏。

Description

文本图像角度纠偏方法、装置及计算机可读存储介质
本申请要求于2019年09月06日提交中国专利局、申请号为201910846892.X、发明名称为“文本图像角度纠偏方法、装置及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在申请中。
技术领域
本申请涉及人工智能技术领域,尤其涉及一种基于投影的文本图像角度纠偏方法、装置及计算机可读存储介质。
背景技术
光学字符识别技术在当前社会已有极其广泛的应用场景。所述光学字符识别(Optical Character Recognition,OCR)是指通过图像处理和模式识别技术对图片中的光学字符进行识别,并将光学字符翻译成计算机文字的过程,其主要过程为输入图像并进行预处理、二值化处理、去噪、字符切割和字符识别,现今大部分OCR算法基于决策树和支持向量机(Support Vector Machine,SVM)实现的,其识别的精度对于字符的偏转非常敏感,然而文本图像的采集很难做到零偏转,如需精确的计算出纠偏角度也存在一定难度。
发明内容
本申请提供一种文本图像角度纠偏方法、装置及计算机可读存储介质,其主要目的在于当用户在知识库中进行文本图像角度纠偏时,给用户呈现出精准的纠偏结果。
为实现上述目的,本申请提供的一种文本图像角度纠偏方法,包括:
获取文本图像,对所述文本图像进行预处理操作,得到二值化文本图像;
通过迭代算法检测所述二值化文本图像中偏斜的文本,得到偏斜文本图像,并对所述偏斜文本图像进行裁剪,得到二值拷贝图像;
对所述二值拷贝图像进行递进旋转,将递进旋转后的所述二值拷贝图像转换为频数投影直方图,根据所述二值拷贝图像的递进旋转的角度,得到所述二值拷贝图像的频数投影直方图集;
计算所述频数投影直方图集的峰顶点与峰谷点的标准差,得到标准差集,将所述标准差集中最大标准差作为所述文本图像的纠偏角度,从而完成对所述文本图像的角度纠偏。
此外,为实现上述目的,本申请还提供一种文本图像角度纠偏装置,该装置包括存储器和处理器,所述存储器中存储有可在所述处理器上运行的文本图像角度纠偏程序,所述文本图像角度纠偏程序被所述处理器执行时实现如下步骤:
获取文本图像,对所述文本图像进行预处理操作,得到二值化文本图像;
通过迭代算法检测所述二值化文本图像中偏斜的文本,得到偏斜文本图像,并对所述偏斜文本图像进行裁剪,得到二值拷贝图像;
对所述二值拷贝图像进行递进旋转,将递进旋转后的所述二值拷贝图像转换为频数投影直方图,根据所述二值拷贝图像的递进旋转的角度,得到所述二值拷贝图像的频数投影直方图集;
计算所述频数投影直方图集的峰顶点与峰谷点的标准差,得到标准差集,将所述标准差集中最大标准差作为所述文本图像的纠偏角度,从而完成对所述文本图像的角度纠偏。
此外,为实现上述目的,本申请还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有文本图像角度纠偏程序,所述文本图像角度纠偏程序可被一个或者多个处理器执行,以实现如上所述的文本图像角度纠偏方法的步骤。
本申请提出的文本图像角度纠偏方法、装置及计算机可读存储介质,在用户进行文本图像角度纠偏时,对获取的文本图像进行预处理操作,并将文本图像中的倾斜文本图像进行分析处理,得到其频数投影直方图集,计算所述频数投影直方图集的峰顶点与峰谷点的标准差,将其最大标准差作为所述文本图像的纠偏角度,从而可以给用户呈现出精准的文本图像角度纠偏结果。
附图说明
图1为本申请一实施例提供的文本图像角度纠偏方法的流程示意图;
图2为本申请一实施例提供的文本图像角度纠偏装置的内部结构示意图;
图3为本申请一实施例提供的文本图像角度纠偏装置中文本图像角度纠 偏程序的模块示意图。
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
具体实施方式
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
本申请提供一种文本图像角度纠偏方法。参照图1所示,为本申请一实施例提供的文本图像角度纠偏方法的流程示意图。该方法可以由一个装置执行,该装置可以由软件和/或硬件实现。
在本实施例中,文本图像角度纠偏方法包括:
S1、获取文本图像,对所述文本图像进行预处理操作,得到二值化文本图像。
本申请较佳实施例中,所述文本图像可以为证件、***等图像数据。所述预处理操作为:通过自适应图像降噪滤波器对所述文本图像进行降噪,利用对比度拉伸方式对降噪后的所述文本图像进行对比度增强,根据OTSU算法将对比度增强后的所述文本图像进行阈值化操作,得到所述二值化文本图像。详细地,所述预处理操作具体实施步骤如下所示:
a.降噪:
本申请通过自适应图像降噪滤波器对所述文本图像进行降噪,用于滤除所述文本图像的椒盐噪声,并可以很大程度的保护所述文本图像的细节。其中,所述椒盐噪声是图像中一种随机出现的白点或黑点,所述自适应图像降噪滤波器是信号抽取器,用于从被噪声污染的信号中抽取原来的信号。
本申请较佳实施例通过预设所述文本图像为f(x,y),在退化函数H的作用下,由于受到椒盐噪声η(x,y)的影响,得到一个退化图像g(x,y)。于是,得到图像退化公式:g(x,y)=η(x,y)+f(x,y),并利用Adaptive Filter方法对所述文本图像进行降噪,其中,所述降噪的计算公式为:
Figure PCTCN2019116549-appb-000001
其中,
Figure PCTCN2019116549-appb-000002
是文本图像的噪声方差,
Figure PCTCN2019116549-appb-000003
是点(x,y)附近的一个窗口内的像素灰度均值,
Figure PCTCN2019116549-appb-000004
是点(x,y)附近一个窗口内的像素灰度的方差。
b.对比度增强:
所述对比度指的是成像***中亮度最大值与最小值之间的对比,其中,对比度低会使图像处理难度增大。本申请较佳实施例中采用的是对比度拉伸方法,利用提高灰度级动态范围的方式,达到文本图像对比度增强的目的。所述对比度拉伸也叫作灰度拉伸。
进一步地,本申请根据所述对比度拉伸方法中的分段线性变换函数对特定区域进行灰度拉伸,进一步提高输出图像的对比度。当进行对比度拉伸时,本质上是实现灰度值变换。本申请通过线性拉伸实现灰度值变换,所述线性拉伸指的是输入与输出的灰度值之间为线性关系的像素级运算,灰度变换公式如下所示:
D b=f(D a)=a*D a+b
其中a为线性斜率,b为在Y轴上的截距。当a>1时,此时输出的图像对比度相比原图像是增强的。当a<1时,此时输出的图像对比度相比原图像是削弱的,其中D a代表输入图像灰度值,D b代表输出图像灰度值。
c.图像阈值化操作:
本申请通过OTSU算法将对比度增强后的所述文本图像进行二值化的高效算法,得到二值化图像。进一步地,本申请较佳实施例预设灰度t为对比度增强后的所述文本图像的前景与背景的分割阈值,并预设前景点数占对比度增强后的所述文本图像比例为w 0,平均灰度为u 0;背景点数占对比度增强后的所述文本图像比例为w 1,平均灰度为u 1,则对比度增强后的所述文本图像的总平均灰度为:
u=w 0*u 0+w 1*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,得到对比度增强后的所述文本图像的二值化文本图像。
进一步地,本申请所述预处理操作还可以包括通过主成分分析法对所述二值化文本图像进行降维,使所述二值化文本图像能够被更高效处理。其中, 所述主成分分析法是一种通过正交变换将一组可能存在相关性的变量为一组线性不相关变量的方法。
S2、通过迭代算法检测所述二值化文本图像中偏斜的文本,得到偏斜文本图像,并对所述偏斜文本图像进行提取,得到二值拷贝图像。
本申请较佳实施例通过AdaBoost迭代算法检测所述二值化文本图像中偏斜的文本,到偏斜文本图像。所述AdaBoost迭代算法是一种检测算法,其核心是迭代,其针对不同的训练集构造出的一个弱分类器,并将每一个基弱分类器组合到一起,形成一个最终的强分类器。所述AdaBoost迭代算法的实现是通过调整数据分布,其依据判断每一次训练集当中每一个样本分类的正确性,以及上次样本总体分类的准确率,来设置每一个样本的权值。而新得到的权值将作为下层分类器训练的数据集,然后将每一次训练出的分类器组合起来,形成最终的决策分类器。
本申请将所述二值化文本图像中不同区域进行划分,得到训练样本(x 1,y 1),(x 2,y 2),…(x n,y n),其中,负样本(背景)用y i=0来表示,正样本(前景,即包含偏斜文本)用y i=1来表示。优选地,本申请构建的弱分类器为:
Figure PCTCN2019116549-appb-000005
其中,f为特征,θ为阈值,p指示不等号的方向,x表示一个检测子窗口。通过对所述构建的弱分类器进行集合,并对所述构建的弱分类器中分类最小错误率ε t的最佳弱分类器h t(x)进行选取,所述ε t的计算公式为:
ε t=min f,p,θi(w i/∑w i)|h(x,f,p,θ)-y i|,
其中,w为特征权值,得到最终的强分类器:
Figure PCTCN2019116549-appb-000006
β t=ε t/(1-ε t)。
进一步地,本申请通过级联分类器的方式检测出所述二值化文本图像中偏斜的文本。所述级联分类器就是将所述训练得到的强分类器通过级联的方式组成一个文本检测级联分类器,所述级联分类器是一个退化的决策树。在级联分类器中,第2层分类器分类是由第1层分类得到的正样本触发的,第3 层分类器分类是由第2层分类得到的正样本触发的,依次类推。最终检测到一般环境下所述二值化文本图像中的所有偏斜文本图像,并对所述偏斜文本图像进行裁剪,得到所述二值拷贝图像。
S3、对所述二值拷贝图像进行递进旋转,将递进旋转后的所述二值拷贝图像转换为频数投影直方图,根据所述二值拷贝图像的递进旋转的角度,得到所述二值拷贝图像的频数投影直方图集。
本申请较佳实施例按照预设的角度对二值拷贝图进行递进旋转,优选地,本申请将在-45°至45°之间以2°为单位对上述二值拷贝图进行递进旋转,并在每一次递进旋转后计算所述二值拷贝图像中长和宽像素点的个数。
进一步地,本申请通过傅里叶变换算法将递进旋转后的所述二值拷贝图像转换为频数投影直方图。详细的,所述傅里叶变换的方法包括:
Figure PCTCN2019116549-appb-000007
对其进行变换为:
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)的频谱,并分别计算出所述进行傅里叶变换后的二值拷贝图像幅度谱和相位谱:
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)表示所述二值拷贝图像相位谱。
进一步地,本申请根据所述计算的二值拷贝图像的幅度谱和相位谱,构建频数投影直方图,并根据所述二值拷贝图像递进旋转的角度不同,可以得到不同的频数投影直方图,即所述二值拷贝图像的频数投影直方图集。
S4、计算所述频数投影直方图集中的峰顶点与峰谷点的标准差,得到标 准差集,将所述标准差集中最大标准差作为所述文本图像的纠偏角度,完成所述文本图像的角度纠偏。
本申请较佳实施例中,计算所述频数投影直方图集中的峰顶点与峰谷点的标准差的方法为:
Figure PCTCN2019116549-appb-000010
其中,σ表示频数投影直方图的标准差,x i表示频数投影直方图中第i个峰顶点,n表示频数投影直方图中峰顶点的数量,y j表示频数投影直方图中第i个峰谷点,m表示频数投影直方图中峰谷点的数量,μ为所有峰顶点和峰谷点的均值。所求标准差反映了峰谷点和峰顶点之间的离散程度。
进一步地,本申请计算出所述频数投影直方图集中所有直方图的标准差,得到标准差集,并根据文本图像的结构特点,得到当标准差最大时即为所述文本图像纠正后的最佳方位,得到所述文本图像纠偏角度,并按照所述纠偏角度对原始图像进行旋转矫正。
发明还提供一种文本图像角度纠偏装置。参照图2所示,为本申请一实施例提供的文本图像角度纠偏装置的内部结构示意图。
在本实施例中,所述文本图像角度纠偏装置1可以是PC(Personal Computer,个人电脑),或者是智能手机、平板电脑、便携计算机等终端设备,也可以是一种服务器等。该文本图像角度纠偏装置1至少包括存储器11、处理器12,通信总线13,以及网络接口14。
其中,存储器11至少包括一种类型的可读存储介质,所述可读存储介质包括闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、磁性存储器、磁盘、光盘等。存储器11在一些实施例中可以是文本图像角度纠偏装置1的内部存储单元,例如该文本图像角度纠偏装置1的硬盘。存储器11在另一些实施例中也可以是文本图像角度纠偏装置1的外部存储设备,例如文本图像角度纠偏装置1上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,存储器11还可以既包括文本图像角度纠偏装置1的内部存储单元也包括外部存储设备。存储器11不仅可以用于存储安装于文本图像角度纠偏 装置1的应用软件及各类数据,例如文本图像角度纠偏程序01的代码等,还可以用于暂时地存储已经输出或者将要输出的数据。
处理器12在一些实施例中可以是一中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器或其他数据处理芯片,用于运行存储器11中存储的程序代码或处理数据,例如执行文本图像角度纠偏程序01等。
通信总线13用于实现这些组件之间的连接通信。
网络接口14可选的可以包括标准的有线接口、无线接口(如WI-FI接口),通常用于在该装置1与其他电子设备之间建立通信连接。
可选地,该装置1还可以包括用户接口,用户接口可以包括显示器(Display)、输入单元比如键盘(Keyboard),可选的用户接口还可以包括标准的有线接口、无线接口。可选地,在一些实施例中,显示器可以是LED显示器、液晶显示器、触控式液晶显示器以及OLED(Organic Light-Emitting Diode,有机发光二极管)触摸器等。其中,显示器也可以适当的称为显示屏或显示单元,用于显示在文本图像角度纠偏装置1中处理的信息以及用于显示可视化的用户界面。
图2仅示出了具有组件11-14以及文本图像角度纠偏程序01的文本图像角度纠偏装置1,本领域技术人员可以理解的是,图1示出的结构并不构成对文本图像角度纠偏装置1的限定,可以包括比图示更少或者更多的部件,或者组合某些部件,或者不同的部件布置。
在图2所示的装置1实施例中,存储器11中存储有文本图像角度纠偏程序01;处理器12执行存储器11中存储的文本图像角度纠偏程序01时实现如下步骤:
步骤一、获取文本图像,对所述文本图像进行预处理操作,得到二值化文本图像。
本申请较佳实施例中,所述文本图像可以为证件、***等图像数据。所述预处理操作为:通过自适应图像降噪滤波器对所述文本图像进行降噪,利用对比度拉伸方式对降噪后的所述文本图像进行对比度增强,根据OTSU算法将对比度增强后的所述文本图像进行阈值化操作,得到所述二值化文本图像。详细地,所述预处理操作具体实施步骤如下所示:
d.降噪:
本申请通过自适应图像降噪滤波器对所述文本图像进行降噪,用于滤除所述文本图像的椒盐噪声,并可以很大程度的保护所述文本图像的细节。其中,所述椒盐噪声是图像中一种随机出现的白点或黑点,所述自适应图像降噪滤波器是信号抽取器,用于从被噪声污染的信号中抽取原来的信号。
本申请较佳实施例通过预设所述文本图像为f(x,y),在退化函数H的作用下,由于受到椒盐噪声η(x,y)的影响,得到一个退化图像g(x,y)。于是,得到图像退化公式:g(x,y)=η(x,y)+f(x,y),并利用Adaptive Filter方法对所述文本图像进行降噪,其中,所述降噪的计算公式为:
Figure PCTCN2019116549-appb-000011
其中,
Figure PCTCN2019116549-appb-000012
是文本图像的噪声方差,
Figure PCTCN2019116549-appb-000013
是点(x,y)附近的一个窗口内的像素灰度均值,
Figure PCTCN2019116549-appb-000014
是点(x,y)附近一个窗口内的像素灰度的方差。
e.对比度增强:
所述对比度指的是成像***中亮度最大值与最小值之间的对比,其中,对比度低会使图像处理难度增大。本申请较佳实施例中采用的是对比度拉伸方法,利用提高灰度级动态范围的方式,达到文本图像对比度增强的目的。所述对比度拉伸也叫作灰度拉伸。
进一步地,本申请根据所述对比度拉伸方法中的分段线性变换函数对特定区域进行灰度拉伸,进一步提高输出图像的对比度。当进行对比度拉伸时,本质上是实现灰度值变换。本申请通过线性拉伸实现灰度值变换,所述线性拉伸指的是输入与输出的灰度值之间为线性关系的像素级运算,灰度变换公式如下所示:
D b=f(D a)=a*D a+b
其中a为线性斜率,b为在Y轴上的截距。当a>1时,此时输出的图像对比度相比原图像是增强的。当a<1时,此时输出的图像对比度相比原图像是削弱的,其中D a代表输入图像灰度值,D b代表输出图像灰度值。
f.图像阈值化操作:
本申请通过OTSU算法将对比度增强后的所述文本图像进行二值化的高效算法,得到二值化图像。进一步地,本申请较佳实施例预设灰度t为对比度增强后的所述文本图像的前景与背景的分割阈值,并预设前景点数占对比度增强后的所述文本图像比例为w 0,平均灰度为u 0;背景点数占对比度增强后 的所述文本图像比例为w 1,平均灰度为u 1,则对比度增强后的所述文本图像的总平均灰度为:
u=w 0*u 0+w 1*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,得到对比度增强后的所述文本图像的二值化文本图像。
进一步地,本申请所述预处理操作还可以包括通过主成分分析法对所述二值化文本图像进行降维,使所述二值化文本图像能够被更高效处理。其中,所述主成分分析法是一种通过正交变换将一组可能存在相关性的变量为一组线性不相关变量的方法。
步骤二、通过迭代算法检测所述二值化文本图像中偏斜的文本,得到偏斜文本图像,并对所述偏斜文本图像进行提取,得到二值拷贝图像。
本申请较佳实施例通过AdaBoost迭代算法检测所述二值化文本图像中偏斜的文本,到偏斜文本图像。所述AdaBoost迭代算法是一种检测算法,其核心是迭代,其针对不同的训练集构造出的一个弱分类器,并将每一个基弱分类器组合到一起,形成一个最终的强分类器。所述AdaBoost迭代算法的实现是通过调整数据分布,其依据判断每一次训练集当中每一个样本分类的正确性,以及上次样本总体分类的准确率,来设置每一个样本的权值。而新得到的权值将作为下层分类器训练的数据集,然后将每一次训练出的分类器组合起来,形成最终的决策分类器。
本申请将所述二值化文本图像中不同区域进行划分,得到训练样本(x 1,y 1),(x 2,y 2),…(x n,y n),其中,负样本(背景)用y i=0来表示,正样本(前景,即包含偏斜文本)用y i=1来表示。优选地,本申请构建的弱分类器为:
Figure PCTCN2019116549-appb-000015
其中,f为特征,θ为阈值,p指示不等号的方向,x表示一个检测子窗口。通过对所述构建的弱分类器进行集合,并对所述构建的弱分类器中分类 最小错误率ε t的最佳弱分类器h t(x)进行选取,所述ε t的计算公式为:
ε t=min f,p,θi(w i/∑w i)|h(x,f,p,θ)-y i|,
其中,w为特征权值,得到最终的强分类器:
Figure PCTCN2019116549-appb-000016
β t=ε t/(1-ε t)。
进一步地,本申请通过级联分类器的方式检测出所述二值化文本图像中偏斜的文本。所述级联分类器就是将所述训练得到的强分类器通过级联的方式组成一个文本检测级联分类器,所述级联分类器是一个退化的决策树。在级联分类器中,第2层分类器分类是由第1层分类得到的正样本触发的,第3层分类器分类是由第2层分类得到的正样本触发的,依次类推。最终检测到一般环境下所述二值化文本图像中的所有偏斜文本图像,并对所述偏斜文本图像进行裁剪,得到所述二值拷贝图像。
步骤三、对所述二值拷贝图像进行递进旋转,将递进旋转后的所述二值拷贝图像转换为频数投影直方图,根据所述二值拷贝图像的递进旋转的角度,得到所述二值拷贝图像的频数投影直方图集。
本申请较佳实施例按照预设的角度对二值拷贝图进行递进旋转,优选地,本申请将在-45°至45°之间以2°为单位对上述二值拷贝图进行递进旋转,并在每一次递进旋转后计算所述二值拷贝图像中长和宽像素点的个数。
进一步地,本申请通过傅里叶变换算法将递进旋转后的所述二值拷贝图像转换为频数投影直方图。详细的,所述傅里叶变换的方法包括:
Figure PCTCN2019116549-appb-000017
对其进行变换为:
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)的频谱,并分别计算出所述进行傅里叶变换后的二值拷贝图像幅度谱和相位谱:
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)表示所述二值拷贝图像相位谱。
进一步地,本申请根据所述计算的二值拷贝图像的幅度谱和相位谱,构建频数投影直方图,并根据所述二值拷贝图像递进旋转的角度不同,可以得到不同的频数投影直方图,即所述二值拷贝图像的频数投影直方图集。
步骤四、计算所述频数投影直方图集中的峰顶点与峰谷点的标准差,得到标准差集,将所述标准差集中最大标准差作为所述文本图像的纠偏角度,完成所述文本图像的角度纠偏。
本申请较佳实施例中,计算所述频数投影直方图集中的峰顶点与峰谷点的标准差的方法为:
Figure PCTCN2019116549-appb-000020
其中,σ表示频数投影直方图的标准差,x i表示频数投影直方图中第i个峰顶点,n表示频数投影直方图中峰顶点的数量,y j表示频数投影直方图中第i个峰谷点,m表示频数投影直方图中峰谷点的数量,μ为所有峰顶点和峰谷点的均值。所求标准差反映了峰谷点和峰顶点之间的离散程度。
进一步地,本申请计算出所述频数投影直方图集中所有直方图的标准差,得到标准差集,并根据文本图像的结构特点,得到当标准差最大时即为所述文本图像纠正后的最佳方位,得到所述文本图像纠偏角度,并按照所述纠偏角度对原始图像进行旋转矫正。
可选地,在其他实施例中,文本图像角度纠偏程序还可以被分割为一个或者多个模块,一个或者多个模块被存储于存储器11中,并由一个或多个处理器(本实施例为处理器12)所执行以完成本申请,本申请所称的模块是指能够完成特定功能的一系列计算机程序指令段,用于描述文本图像角度纠偏 程序在文本图像角度纠偏装置中的执行过程。
例如,参照图3所示,为本申请文本图像角度纠偏装置一实施例中的文本图像角度纠偏程序的程序模块示意图,该实施例中,所述文本图像角度纠偏程序可以被分割为文本图像预处理模块10、文本图像检测模块20、图像转换模块30以及计算模块40,示例性地:
所述文本图像预处理模块10用于:获取文本图像,对所述文本图像进行预处理操作,得到二值化文本图像。
所述文本图像检测模块20用于:通过迭代算法检测所述二值化文本图像中偏斜的文本,得到偏斜文本图像,并对所述偏斜文本图像进行裁剪,得到二值拷贝图像。
所述图像转换模块30用于:对所述二值拷贝图像进行递进旋转,将递进旋转后的所述二值拷贝图像转换为频数投影直方图,根据所述二值拷贝图像的递进旋转的角度,得到所述二值拷贝图像的频数投影直方图集。
所述计算模块40用于:计算所述频数投影直方图集的峰顶点与峰谷点的标准差,得到标准差集,将所述标准差集中最大标准差作为所述文本图像的纠偏角度,从而完成对所述文本图像的角度纠偏。
上述文本图像预处理模块10、文本图像检测模块20、图像转换模块30以及计算模块40等程序模块被执行时所实现的功能或操作步骤与上述实施例大体相同,在此不再赘述。
此外,本申请实施例还提出一种计算机可读存储介质,所述计算机可读存储介质上存储有文本图像角度纠偏程序,所述文本图像角度纠偏程序可被一个或多个处理器执行,以实现如下操作:
获取文本图像,对所述文本图像进行预处理操作,得到二值化文本图像;
通过迭代算法检测所述二值化文本图像中偏斜的文本,得到偏斜文本图像,并对所述偏斜文本图像进行裁剪,得到二值拷贝图像;
对所述二值拷贝图像进行递进旋转,将递进旋转后的所述二值拷贝图像转换为频数投影直方图,根据所述二值拷贝图像的递进旋转的角度,得到所述二值拷贝图像的频数投影直方图集;
计算所述频数投影直方图集的峰顶点与峰谷点的标准差,得到标准差集, 将所述标准差集中最大标准差作为所述文本图像的纠偏角度,从而完成对所述文本图像的角度纠偏。
本申请计算机可读存储介质具体实施方式与上述文本图像角度纠偏装置和方法各实施例基本相同,在此不作累述。
需要说明的是,上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。并且本文中的术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、装置、物品或者方法不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、装置、物品或者方法所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、装置、物品或者方法中还存在另外的相同要素。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本申请各个实施例所述的方法。
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。

Claims (20)

  1. 一种文本图像角度纠偏方法,其特征在于,所述方法包括:
    获取文本图像,对所述文本图像进行预处理操作,得到二值化文本图像;
    通过迭代算法检测所述二值化文本图像中偏斜的文本,得到偏斜文本图像,并对所述偏斜文本图像进行裁剪,得到二值拷贝图像;
    对所述二值拷贝图像进行递进旋转,将递进旋转后的所述二值拷贝图像转换为频数投影直方图,根据所述二值拷贝图像的递进旋转的角度,得到所述二值拷贝图像的频数投影直方图集;
    计算所述频数投影直方图集的峰顶点与峰谷点的标准差,得到标准差集,将所述标准差集中最大标准差作为所述文本图像的纠偏角度,从而完成对所述文本图像的角度纠偏。
  2. 如权利要求1所述的文本图像角度纠偏方法,其特征在于,所述对所述文本图像进行预处理操作,得到二值化文本图像,包括:
    通过自适应图像降噪滤波器对所述文本图像进行降噪,利用对比度拉伸方式对降噪后的所述文本图像进行对比度增强,根据OTSU算法将对比度增强后的所述文本图像进行阈值化操作,得到所述二值化文本图像。
  3. 如权利要求1所述的文本图像角度纠偏方法,其特征在于,所述将递进旋转后的所述二值拷贝图像转换为频数投影直方图,包括:
    对递进旋转后的所述二值拷贝图像进行傅里叶变换;
    计算出进行傅里叶变换后的所述二值拷贝图像的幅度谱和相位谱;
    根据所述幅度谱和相位谱,构建所述频数投影直方图。
  4. 如权利要求3所述的文本图像角度纠偏方法,其特征在于,所述傅里叶变换的方法包括:
    Figure PCTCN2019116549-appb-100001
    对其进行变换为:
    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为变换域坐标点。
  5. 如权利要求4所述的文本图像角度纠偏方法,其特征在于,分别计算出所述进行傅里叶变换后的二值拷贝图像幅度谱和相位谱,根据所述计算的二值拷贝图像的幅度谱和相位谱,构建频数投影直方图:
    Figure PCTCN2019116549-appb-100003
    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)表示所述二值拷贝图像相位谱。
  6. 如权利要求1-5中任一项所述的文本图像角度纠偏方法,其特征在于,所述计算所述频数投影直方图集中的峰顶点与峰谷点的标准差的方法包括:
    Figure PCTCN2019116549-appb-100005
    其中,σ表示频数投影直方图的标准差,x i表示频数投影直方图中第i个峰顶点,n表示频数投影直方图中峰顶点的数量,y j表示频数投影直方图中第i个峰谷点,m表示频数投影直方图中峰谷点的数量,μ为所有峰顶点和峰谷点的均值。
  7. 如权利要求2所述的文本图像角度纠偏方法,其特征在于,所述对比度拉伸为灰度值的变换,所述灰度值的计算公式为:
    D b=f(D a)=a*D a+b
    其中a为线性斜率,b为在Y轴上的截距,当a>1时,此时输出的图像对比度相比原图像是增强的,当a<1时,此时输出的图像对比度相比原图像是削弱的,其中D a代表输入图像灰度值,D b代表输出图像灰度值。
  8. 一种文本图像角度纠偏装置,其特征在于,所述装置包括存储器和处理器,所述存储器上存储有可在所述处理器上运行的文本图像角度纠偏程序,所述文本图像角度纠偏程序被所述处理器执行时实现如下步骤:
    获取文本图像,对所述文本图像进行预处理操作,得到二值化文本图像;
    通过迭代算法检测所述二值化文本图像中偏斜的文本,得到偏斜文本图像,并对所述偏斜文本图像进行裁剪,得到二值拷贝图像;
    对所述二值拷贝图像进行递进旋转,将递进旋转后的所述二值拷贝图像转换为频数投影直方图,根据所述二值拷贝图像的递进旋转的角度,得到所述二值拷贝图像的频数投影直方图集;
    计算所述频数投影直方图集的峰顶点与峰谷点的标准差,得到标准差集,将所述标准差集中最大标准差作为所述文本图像的纠偏角度,从而完成对所述文本图像的角度纠偏。
  9. 如权利要求8所述的文本图像角度纠偏装置,其特征在于,所述对所述文本图像进行预处理操作,得到二值化文本图像,包括:
    通过自适应图像降噪滤波器对所述文本图像进行降噪,利用对比度拉伸方式对降噪后的所述文本图像进行对比度增强,根据OTSU算法将对比度增强后的所述文本图像进行阈值化操作,得到所述二值化文本图像。
  10. 如权利要求8所述的文本图像角度纠偏装置,其特征在于,所述将递进旋转后的所述二值拷贝图像转换为频数投影直方图,包括:
    对递进旋转后的所述二值拷贝图像进行傅里叶变换;
    计算出进行傅里叶变换后的所述二值拷贝图像的幅度谱和相位谱;
    根据所述幅度谱和相位谱,构建所述频数投影直方图。
  11. 如权利要求10所述的文本图像角度纠偏装置,其特征在于,所述傅里叶变换的方法包括:
    Figure PCTCN2019116549-appb-100006
    对其进行变换为:
    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为变换域坐标点。
  12. 如权利要求11所述的文本图像角度纠偏装置,其特征在于,分别计算出所述进行傅里叶变换后的二值拷贝图像幅度谱和相位谱,根据所述计算的二值拷贝图像的幅度谱和相位谱,构建频数投影直方图:
    Figure PCTCN2019116549-appb-100008
    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)表示所述二值拷贝图像相位谱。
  13. 如权利要求8-12中任一项所述的文本图像角度纠偏装置,其特征在于,所述计算所述频数投影直方图集中的峰顶点与峰谷点的标准差的方法包括:
    Figure PCTCN2019116549-appb-100010
    其中,σ表示频数投影直方图的标准差,x i表示频数投影直方图中第i个峰顶点,n表示频数投影直方图中峰顶点的数量,y i表示频数投影直方图中第i个峰谷点,m表示频数投影直方图中峰谷点的数量,μ为所有峰顶点和峰谷点的均值。
  14. 如权利要求9所述的文本图像角度纠偏装置,其特征在于,所述对比度拉伸为灰度值的变换,所述灰度值的计算公式为:
    D b=f(D a)=a*D a+b
    其中a为线性斜率,b为在Y轴上的截距,当a>1时,此时输出的图像对比度相比原图像是增强的,当a<1时,此时输出的图像对比度相比原图像是削弱的,其中D a代表输入图像灰度值,D b代表输出图像灰度值。
  15. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有文本图像角度纠偏程序,所述文本图像角度纠偏程序可被一个或者多个处理器执行,以实现如权利要求1至5中任一项所述的文本图像角度纠偏方法的步骤:
    获取文本图像,对所述文本图像进行预处理操作,得到二值化文本图像;
    通过迭代算法检测所述二值化文本图像中偏斜的文本,得到偏斜文本图像,并对所述偏斜文本图像进行裁剪,得到二值拷贝图像;
    对所述二值拷贝图像进行递进旋转,将递进旋转后的所述二值拷贝图像转换为频数投影直方图,根据所述二值拷贝图像的递进旋转的角度,得到所述二值拷贝图像的频数投影直方图集;
    计算所述频数投影直方图集的峰顶点与峰谷点的标准差,得到标准差集, 将所述标准差集中最大标准差作为所述文本图像的纠偏角度,从而完成对所述文本图像的角度纠偏。
  16. 如权利要求15所述的计算机可读存储介质,其特征在于,所述对所述文本图像进行预处理操作,得到二值化文本图像,包括:
    通过自适应图像降噪滤波器对所述文本图像进行降噪,利用对比度拉伸方式对降噪后的所述文本图像进行对比度增强,根据OTSU算法将对比度增强后的所述文本图像进行阈值化操作,得到所述二值化文本图像。
  17. 如权利要求15所述的计算机可读存储介质,其特征在于,所述将递进旋转后的所述二值拷贝图像转换为频数投影直方图,包括:
    对递进旋转后的所述二值拷贝图像进行傅里叶变换;
    计算出进行傅里叶变换后的所述二值拷贝图像的幅度谱和相位谱;
    根据所述幅度谱和相位谱,构建所述频数投影直方图。
  18. 如权利要求17所述的计算机可读存储介质,其特征在于,所述傅里叶变换的方法包括:
    Figure PCTCN2019116549-appb-100011
    对其进行变换为:
    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为变换域坐标点。
  19. 如权利要求18所述的计算机可读存储介质,其特征在于,分别计算出所述进行傅里叶变换后的二值拷贝图像幅度谱和相位谱,根据所述计算的二值拷贝图像的幅度谱和相位谱,构建频数投影直方图:
    Figure PCTCN2019116549-appb-100013
    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)表示所述二值拷贝图像相位谱。
  20. 如权利要求19所述的计算机可读存储介质,其特征在于,所述计算所述频数投影直方图集中的峰顶点与峰谷点的标准差的方法包括:
    Figure PCTCN2019116549-appb-100015
    其中,σ表示频数投影直方图的标准差,x i表示频数投影直方图中第i个峰顶点,n表示频数投影直方图中峰顶点的数量,y j表示频数投影直方图中第i个峰谷点,m表示频数投影直方图中峰谷点的数量,μ为所有峰顶点和峰谷点的均值。
PCT/CN2019/116549 2019-09-06 2019-11-08 文本图像角度纠偏方法、装置及计算机可读存储介质 WO2021042509A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910846892.XA CN110705546B (zh) 2019-09-06 2019-09-06 文本图像角度纠偏方法、装置及计算机可读存储介质
CN201910846892.X 2019-09-06

Publications (1)

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

Family

ID=69196126

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/116549 WO2021042509A1 (zh) 2019-09-06 2019-11-08 文本图像角度纠偏方法、装置及计算机可读存储介质

Country Status (2)

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

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 (zh) * 2013-12-23 2014-04-30 南京信息工程大学 一种基于字符细化的可抵抗打印扫描攻击的水印方法
CN107480728A (zh) * 2017-08-28 2017-12-15 南京大学 一种基于傅里叶残差值的打印文件的鉴别方法
CN107992869A (zh) * 2016-10-26 2018-05-04 深圳超多维科技有限公司 用于倾斜文字校正的方法、装置及电子设备
CN108121983A (zh) * 2016-11-29 2018-06-05 蓝盾信息安全技术有限公司 一种基于傅里叶变换的文本图像纠偏方法
CN109409356A (zh) * 2018-08-23 2019-03-01 浙江理工大学 一种基于swt的多方向中文印刷体文字检测方法

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101566196B1 (ko) * 2009-03-02 2015-11-05 삼성전자주식회사 히스토그램 분석을 이용한 영상 분류 방법 및 장치, 이를 이용한 문자 인식 방법 및 장치
JP2011215828A (ja) * 2010-03-31 2011-10-27 Canon Inc 画像補正装置およびその制御方法
US9621761B1 (en) * 2015-10-08 2017-04-11 International Business Machines Corporation Automatic correction of skewing of digital images
WO2019056346A1 (zh) * 2017-09-25 2019-03-28 深圳传音通讯有限公司 一种利用膨胀法校正文本图像倾斜的方法及装置

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 (zh) * 2013-12-23 2014-04-30 南京信息工程大学 一种基于字符细化的可抵抗打印扫描攻击的水印方法
CN107992869A (zh) * 2016-10-26 2018-05-04 深圳超多维科技有限公司 用于倾斜文字校正的方法、装置及电子设备
CN108121983A (zh) * 2016-11-29 2018-06-05 蓝盾信息安全技术有限公司 一种基于傅里叶变换的文本图像纠偏方法
CN107480728A (zh) * 2017-08-28 2017-12-15 南京大学 一种基于傅里叶残差值的打印文件的鉴别方法
CN109409356A (zh) * 2018-08-23 2019-03-01 浙江理工大学 一种基于swt的多方向中文印刷体文字检测方法

Also Published As

Publication number Publication date
CN110705546B (zh) 2023-12-19
CN110705546A (zh) 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 (zh) 图像相似度匹配方法、装置及计算机可读存储介质
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 (zh) 一种电子文档的生成方法及设备
WO2021218183A1 (zh) 证件边沿检测方法、装置、设备及介质
KR20210113620A (ko) 객체 인식 방법과 장치, 전자기기, 저장매체
Fraz et al. Exploiting colour information for better scene text detection and recognition
JP6341059B2 (ja) 文字認識装置、文字認識方法、およびプログラム
Krupiński et al. Binarization of degraded document images with generalized Gaussian distribution
WO2021042509A1 (zh) 文本图像角度纠偏方法、装置及计算机可读存储介质
CN115063826A (zh) 一种基于深度学习的移动端驾驶证识别方法和***
CN111652148B (zh) 人脸识别方法、装置与电子设备
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
Zhong et al. Image patches analysis for text block identification
Felhi et al. A robust skew detection method based on Maximum Gradient Difference and R-signature
CN111539406B (zh) 证件复印件信息识别方法、服务器及存储介质
Kumar et al. Intellectual Curve Scene Text Detection from Natural Images Using MSER Descriptor Based Region Segmentation Approach
Nguyen et al. Recognizing text in low resolution born-digital images

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