CN111178356A - Paper contour skew correction method - Google Patents
Paper contour skew correction method Download PDFInfo
- Publication number
- CN111178356A CN111178356A CN201911379032.6A CN201911379032A CN111178356A CN 111178356 A CN111178356 A CN 111178356A CN 201911379032 A CN201911379032 A CN 201911379032A CN 111178356 A CN111178356 A CN 111178356A
- Authority
- CN
- China
- Prior art keywords
- image
- paper
- contour
- skew correction
- binary
- Prior art date
- Legal status (The legal status 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 status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/20—Image preprocessing
- G06V10/24—Aligning, centring, orientation detection or correction of the image
- G06V10/242—Aligning, centring, orientation detection or correction of the image by image rotation, e.g. by 90 degrees
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/20—Image preprocessing
- G06V10/28—Quantising the image, e.g. histogram thresholding for discrimination between background and foreground patterns
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/40—Extraction of image or video features
- G06V10/44—Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components
Abstract
The invention discloses a skew correction method for paper contour, which comprises the following steps: s1: acquiring a scanning image of paper; s2: carrying out graying processing on the scanned image to obtain a grayscale image; s3: performing binary conversion on the gray level image to obtain a binary image; s4: extracting the contour of the binary image to obtain the contour of the binary image; s5: calculating the minimum circumscribed rectangle of the extracted outline; s6: and carrying out affine transformation on the scanned image according to the minimum circumscribed rectangle to obtain the corrected image. The minimum external rectangle is used for positioning the paper outline, the influence of incomplete paper and special-shaped paper on the paper outline positioning can be effectively avoided, affine transformation processing is used after the outline is extracted, the scanned image can be simultaneously corrected and cut, the image processing efficiency is improved, and the high-quality and corrected scanned image can be quickly obtained.
Description
Technical Field
The invention relates to the technical field of image processing, in particular to a paper contour skew detection and correction method.
Background
When scanning a sheet using a scanner, a situation in which the sheet profile is skewed often occurs. With the continuous development of digital applications, images scanned by scanners are not only applied to image data storage, but also applied to extended applications such as picture information identification, extraction, modification and the like. The skewed paper image may adversely affect the accuracy and efficiency of the extended application, so we need to perform skew detection and deskew processing on the scanned paper image.
In the traditional solution, a mechanical structure is relied on to ensure the scanning angle of the paper, but the problem of paper skew can only be solved relatively roughly, and the related scheme can not be well solved for the paper skew caused by mechanical failure or pixel-level skew correction with higher precision.
Disclosure of Invention
In order to solve the technical defects, the technical scheme adopted by the invention is to provide a skew correction method for a paper contour, which comprises the following steps:
s1: acquiring a scanning image of paper;
s2: carrying out graying processing on the scanned image to obtain a grayscale image;
s3: performing binary conversion on the gray level image to obtain a binary image;
s4: extracting the contour of the binary image to obtain the contour of the binary image;
s5: calculating the minimum circumscribed rectangle of the extracted outline;
s6: and carrying out affine transformation on the scanned image according to the minimum circumscribed rectangle to obtain the corrected image.
Compared with the prior art, the technical scheme of the invention has the beneficial effects that: the minimum external rectangle is used for positioning the paper outline, the influence of incomplete paper and special-shaped paper on the paper outline positioning can be effectively avoided, affine transformation processing is used after the outline is extracted, the scanned image can be simultaneously corrected and cut, the image processing efficiency is improved, and the high-quality and corrected scanned image can be quickly obtained.
Further, the step S1a is included after the step S1 acquires the scan image: it is judged whether or not the scanned image is a color image, and if so, the process proceeds to step S2, and if not, the process proceeds to step S3.
Further, the graying processing in step S2 includes: the scanning image is a color image, maximum value method gray level processing is carried out on the color image, and each pixel of the obtained gray level image is the maximum value of RGB of the corresponding pixel in the color image.
Further, the binary conversion in step S3 includes: setting a fixed threshold, traversing the gray values of all pixels of the gray image, and when the gray value of a pixel is greater than the fixed threshold, converting the gray value of the pixel to be 255, otherwise, converting the gray value of the pixel to be 0.
Further, the fixed threshold is 30.
Further, the contour extraction in step S4 includes: and accessing pixels from four edges of the binary image to the inside according to rows or columns, and recording the coordinates of the pixels when accessing non-zero pixels 255, wherein the set of all the finally recorded point coordinates is the outline of the binary image.
Further, N pixels are explored inwards every M rows or columns, wherein M and N are integers which are larger than or equal to 1.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a step diagram of a method for correcting skew of a paper profile according to an embodiment of the present invention;
FIG. 2 is a diagram of the skew correction variation of the paper profile according to the embodiment of the present invention.
Detailed Description
The invention is further described with reference to the following figures and specific examples.
Examples
Referring to fig. 1 and 2, the present invention provides a method for correcting skew of a paper contour, including the following steps:
s1: acquiring a scanning image of paper;
in this embodiment, after the step S1 of acquiring the scan image, the method further includes a step S1a of: it is judged whether or not the scanned image is a color image, and if so, the process proceeds to step S2, and if not, the process proceeds to step S3. The judgment logic of the color map can be used as a judgment standard according to the number of channels.
S2: carrying out graying processing on the scanned image to obtain a grayscale image;
in this embodiment, the graying processing in step S2 includes: the scanned image is a color image, maximum value method gray level processing is carried out on the color image, and each pixel of the obtained gray level image is the maximum value of RGB of the corresponding pixel in the color image. In order to more effectively retain image paper information and adapt to color images with lower partial brightness, the scheme uses an RGB maximum value method pix as max (R, max (G, B)), so that the paper information can be retained to the maximum extent.
S3: performing binary conversion on the gray level image to obtain a binary image;
in this embodiment, the binary conversion in step S3 includes: setting a fixed threshold, traversing the gray values of all pixels of the gray image, and when the gray value of a pixel is greater than the fixed threshold, converting the gray value of the pixel to be 255, otherwise, converting the gray value of the pixel to be 0. Preferably, the fixed threshold value in this embodiment may be 30, as close to 0 as possible, so as to better distinguish the black background from the paper pattern.
S4: extracting the contour of the binary image to obtain the contour of the binary image;
in this embodiment, the contour extraction in step S4 includes: and accessing pixels from four edges of the binary image to the inside according to rows or columns, and recording the coordinates of the pixels when accessing non-zero pixels 255, wherein the set of all the finally recorded point coordinates is the outline of the binary image. Specifically, N pixels may be searched in M rows or columns at intervals, where M and N are both integers greater than or equal to 1, and the larger the value is, the higher the algorithm efficiency is, and the lower the accuracy is.
S5: calculating the minimum circumscribed rectangle of the extracted outline; the method for calculating the minimum bounding rectangle may refer to an algorithm minAreaRect in an OpenCV of a third-party image processing library, which is well known to those skilled in the art and will not be described herein again.
S6: and carrying out affine transformation on the scanned image according to the minimum circumscribed rectangle to obtain the corrected image.
The affine transformation is geometrically defined as an affine transformation between two vector spaces or affine mapping consisting of a transformation by a linear function followed by a translation transformation. The affine transformation formula in this step is:
where x 'and y' are pixel coordinate values (x ', y') of the conversion target, respectively, and x and y are coordinate values of the original image. a, b, c, d, m and n are coefficient constants of affine transformation, each original pixel coordinate can be obtained through calculation through the equation set, and the corresponding target pixel coordinate is obtained after transformation, so that the corrected image is obtained.
Specifically, the minimum external rectangle is used for positioning the paper outline, the influence of some incomplete paper and special-shaped paper on the positioning of the paper outline can be effectively avoided, affine transformation processing is used after the outline is extracted, the correction and cutting can be simultaneously carried out on the scanned image, the image processing efficiency is improved, and the high-quality and corrected scanned image can be rapidly obtained.
The above description is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments, and all technical solutions belonging to the idea of the present invention belong to the protection scope of the present invention. It should be noted that modifications and embellishments within the scope of the invention may occur to those skilled in the art without departing from the principle of the invention, and are considered to be within the scope of the invention.
Claims (7)
1. A skew correction method for a paper contour is characterized by comprising the following steps:
s1: acquiring a scanning image of paper;
s2: carrying out graying processing on the scanned image to obtain a grayscale image;
s3: performing binary conversion on the gray level image to obtain a binary image;
s4: extracting the contour of the binary image to obtain the contour of the binary image;
s5: calculating the minimum circumscribed rectangle of the extracted outline;
s6: and carrying out affine transformation on the scanned image according to the minimum circumscribed rectangle to obtain the corrected image.
2. A method of skew correction of a paper profile according to claim 1, further comprising, after acquiring the scanned image at step S1, step S1 a: it is judged whether or not the scanned image is a color image, and if so, the process proceeds to step S2, and if not, the process proceeds to step S3.
3. A method for skew correction of a sheet profile according to claim 1, wherein the ashing process in step S2 includes: the scanning image is a color image, maximum value method gray level processing is carried out on the color image, and each pixel of the obtained gray level image is the maximum value of RGB of the corresponding pixel in the color image.
4. A method for skew correction of a paper profile according to claim 1, wherein the binary conversion in step S3 includes: setting a fixed threshold, traversing the gray values of all pixels of the gray image, and when the gray value of a pixel is greater than the fixed threshold, converting the gray value of the pixel to be 255, otherwise, converting the gray value of the pixel to be 0.
5. A method of skew correction of a paper profile according to claim 4, wherein the fixed threshold is 30.
6. The skew correction method for a paper sheet contour according to claim 1, wherein the contour extraction in step S4 includes: and accessing pixels from four edges of the binary image to the inside according to rows or columns, and recording the coordinates of the pixels when accessing non-zero pixels 255, wherein the set of all the finally recorded point coordinates is the outline of the binary image.
7. A method of skew correction of a paper profile according to claim 6, wherein N pixels are explored inwards per M row or column intervals, wherein M and N are integers greater than or equal to 1.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911379032.6A CN111178356A (en) | 2019-12-27 | 2019-12-27 | Paper contour skew correction method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911379032.6A CN111178356A (en) | 2019-12-27 | 2019-12-27 | Paper contour skew correction method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111178356A true CN111178356A (en) | 2020-05-19 |
Family
ID=70654178
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911379032.6A Pending CN111178356A (en) | 2019-12-27 | 2019-12-27 | Paper contour skew correction method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111178356A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111783801A (en) * | 2020-07-17 | 2020-10-16 | 上海明波通信技术股份有限公司 | Object contour extraction method and system and object contour prediction method and system |
CN112383670A (en) * | 2020-11-10 | 2021-02-19 | 武汉天有科技有限公司 | Test paper scanning automatic centering method and device |
-
2019
- 2019-12-27 CN CN201911379032.6A patent/CN111178356A/en active Pending
Non-Patent Citations (1)
Title |
---|
视觉一只白: "opencv 仿射变换和透视变换", 《HTTPS://BLOG.CSDN.NET/ZHANGJUNP3/ARTICLE/DETAILS/80318533》 * |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111783801A (en) * | 2020-07-17 | 2020-10-16 | 上海明波通信技术股份有限公司 | Object contour extraction method and system and object contour prediction method and system |
CN111783801B (en) * | 2020-07-17 | 2024-04-23 | 上海明波通信技术股份有限公司 | Object contour extraction method and system and object contour prediction method and system |
CN112383670A (en) * | 2020-11-10 | 2021-02-19 | 武汉天有科技有限公司 | Test paper scanning automatic centering method and device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9135489B2 (en) | System for decoding two dimensional code and method thereof | |
JP4219542B2 (en) | Image processing apparatus, image processing method, and recording medium storing image processing program | |
US6956587B1 (en) | Method of automatically cropping and adjusting scanned images | |
US7170647B2 (en) | Document processing apparatus and method | |
CN110298282B (en) | Document image processing method, storage medium and computing device | |
US8107734B2 (en) | Image processing apparatus, and method for performing document matching using extracted feature points of connected image components | |
US20140368891A1 (en) | Method for detecting a document boundary | |
EP2270746B1 (en) | Method for detecting alterations in printed document using image comparison analyses | |
JP2012243307A (en) | Method for detecting strain in input image, device for detecting strain in input image and computer readable medium | |
US8538191B2 (en) | Image correction apparatus and method for eliminating lighting component | |
CN111178356A (en) | Paper contour skew correction method | |
JP5870745B2 (en) | Image processing apparatus, binarization threshold value calculation method, and computer program | |
JP2008092447A (en) | Image processing apparatus, image output device, and image processing method | |
US8243985B2 (en) | Bit pattern design for visible watermarking | |
JP5005732B2 (en) | Image forming apparatus and image processing method | |
CN111445402A (en) | Image denoising method and device | |
JP4208520B2 (en) | Image processing apparatus, image processing method, program, and storage medium | |
US6181437B1 (en) | Image processing apparatus capable of producing images without jaggies at edges | |
US20170032227A1 (en) | Image processing apparatus | |
CN110502950B (en) | Quick self-adaptive binarization method for QR codes with uneven illumination | |
JP2009284190A (en) | Image reading apparatus and image reading system | |
JPH11288453A (en) | Method and system for detecting skew angle and black boundary line of original image in scan environment for reproduction | |
CN109801227B (en) | Book illustration correcting method based on font image | |
JP2019016898A (en) | Image processing system, and computer program | |
JP3260891B2 (en) | Edge extraction method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200519 |
|
RJ01 | Rejection of invention patent application after publication |