[go: up one dir, main page]

CN103714327B - Method and system for correcting image direction - Google Patents

Method and system for correcting image direction Download PDF

Info

Publication number
CN103714327B
CN103714327B CN201310746613.5A CN201310746613A CN103714327B CN 103714327 B CN103714327 B CN 103714327B CN 201310746613 A CN201310746613 A CN 201310746613A CN 103714327 B CN103714327 B CN 103714327B
Authority
CN
China
Prior art keywords
image
rotation angle
angle
bar code
module
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.)
Active
Application number
CN201310746613.5A
Other languages
Chinese (zh)
Other versions
CN103714327A (en
Inventor
郭丰俊
罗希平
王晓立
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Hehe Information Technology Development Co Ltd
Original Assignee
Shanghai Hehe Information Technology Development Co Ltd
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 Shanghai Hehe Information Technology Development Co Ltd filed Critical Shanghai Hehe Information Technology Development Co Ltd
Priority to CN201310746613.5A priority Critical patent/CN103714327B/en
Publication of CN103714327A publication Critical patent/CN103714327A/en
Application granted granted Critical
Publication of CN103714327B publication Critical patent/CN103714327B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Image Processing (AREA)
  • Editing Of Facsimile Originals (AREA)
  • Character Input (AREA)

Abstract

The invention provides a method and system for correcting the image direction. The method comprises the steps that whether a bar code can be detected or not in an image is judged, and if it is detected that at least one bar code exists, the image is rotated every other rotation angle within the rotation angle range with the direction angle of each bar code as the center angle; whether characters exist in the image formed after each time of rotation of the rotation angle or not is detected, if yes, the characters in the image are recognized, and after each time of rotation of the rotation angle, the corresponding character confidence coefficients are calculated and obtained; whether character confidence coefficients larger than the preset threshold value exist in the corresponding character confidence coefficients generated after each time of rotation of the rotation angle or not is judged, if yes, the image rotation angle corresponding to the highest character confidence coefficient is selected as the image correction angle, and if not, the direction angle of any bar code is selected as the image correction angle, and the image direction is corrected according to the image correction angle. The method and system can reduce the image rotation misjudgment possibility and can fast and accurately judge the correction image angle.

Description

Image direction correction method and system
Technical Field
The invention belongs to the technical field of image processing, relates to a correction method and a correction system, and particularly relates to an image direction correction method and an image direction correction system.
Background
The 21 st century is an information-filled era, and images serve as visual bases for human perception of the world and are important means for human to acquire information, express information and transmit information. With the wide application of images to human beings, digital image processing technology also comes along, and the digital image processing is the behavior of processing image information by using a computer to meet the visual psychology of the human beings or the application requirements. Is essentially a piece of digital code that can be restored by a computer for display and output as an image.
In recent years, the applications related to images are increasing, and there are common demands for information preservation in an image form, image indexing, image classification, extraction of meaningful information in images, and the like. Since digital imaging devices such as digital cameras and scanners are applied more and more widely, the digital cameras provided by the users become standard configurations of mobile devices such as mobile phones. These digital imaging devices are often used to scan or take various pictures including text images, images of persons, and photographs of landscapes. Due to the differences of the usage habits, the shooting angles, the viewing requirements, the saving directions and the like of the scanning or shooting persons, during the browsing or the post-processing, the scanned or shot digital images are often rotated by 90 degrees, 180 degrees or 270 degrees, the scanned or shot text images are more likely to be rotated by any angle between 0 degree and 360 degrees, and the user needs to use an image browsing tool such as acdSee, photoshop and the like to correct the image directions when browsing such digital images. In daily life, people need to check images in the correct direction; in business, the identification and archiving of various documents also requires image orientation correction. During research work, OCR recognition and the like also require correct image orientation correction. The text information can more effectively understand the image content, so the text information is an important clue for better understanding the deep semantics of the image content.
The current picture contains not only text images but also bar codes, and the bar codes (especially two-dimensional bar codes) refer to track lines formed by black and white modules which are arranged in a straight line and staggered with each other. The function of the orbit line is to correct the entire image by obtaining the image coordinates of the centers of the respective modules.
However, in the prior art, a method for cross-verifying the image rotation direction through bar code credibility information and character credibility information, avoiding misjudgment of the rotation method and outputting an image in the correct direction does not exist.
Disclosure of Invention
In view of the above-mentioned shortcomings of the prior art, an object of the present invention is to provide an image direction correction method and system, which are used to solve the problems in the prior art that when the image direction is incorrect, the image direction cannot be corrected quickly and accurately, and the rotation direction is misjudged in the process of correcting the image direction.
To achieve the above and other related objects, an aspect of the present invention provides an image orientation correction method, including: preprocessing the read original image data; judging whether a bar code is detected in the preprocessed image, if so, rotating the image once every other preset rotation angle within a rotation angle range by taking the direction angle of the bar code as a central angle, detecting whether characters exist in the rotated image, if so, identifying the characters, calculating the corresponding character confidence coefficient after rotating the rotation angle every time, judging whether the character confidence coefficient larger than a preset threshold exists, if not, the image direction does not need to be corrected, if so, selecting the image rotation angle corresponding to the highest confidence coefficient, and correcting the image direction according to the image rotation angle; if not, selecting the direction angle of the bar code, and correcting the image direction according to the direction angle of the bar code; if not, rotating the image every other preset rotation angle within the omnibearing range once, detecting whether characters exist, if so, identifying the characters, calculating the character confidence coefficient corresponding to another rotation angle after each rotation, judging whether the character confidence coefficient larger than a preset threshold exists, if not, the image direction does not need to be corrected, if so, selecting the image rotation angle corresponding to the highest confidence coefficient, and correcting the image direction according to the image rotation angle; if not, the image direction does not need to be corrected.
Preferably, whether a bar code is detected in the preprocessed image is judged, whether the bar code is detected in the preprocessed image is judged, if not, the [0 degrees and 360 degrees ] is set into a plurality of subintervals, another rotation angle is selected in each subinterval, the preprocessed image is rotated at every other rotation angle, whether characters exist in the rotated image is detected, if yes, the characters are identified, the confidence coefficient of the characters corresponding to the rotated another rotation angle is calculated, whether the confidence coefficient of the characters larger than a preset threshold exists is judged, if not, the image direction does not need to be corrected, if yes, the image rotation angle corresponding to the highest confidence coefficient is selected, and the image direction is corrected according to the image direction; if not, the image direction does not need to be corrected.
Preferably, the image direction correction method further includes determining whether only one barcode exists in the preprocessed image, if so, rotating the image every other preset rotation angle within a rotation angle range by taking a direction angle of the barcode as a center angle, detecting whether characters exist in the rotated image, if so, recognizing the characters, calculating a character confidence coefficient corresponding to each rotation angle, and determining whether a character confidence coefficient larger than a preset threshold exists, if not, the image direction does not need to be corrected, if so, selecting an image rotation angle corresponding to the highest confidence coefficient, and correcting the image direction according to the image rotation angle; if not, selecting the direction angle of the bar code, and correcting the image direction according to the direction angle of the bar code; if not, respectively taking the direction angle of each bar code as a central angle, respectively rotating the image every other preset rotation angle within a rotation angle range corresponding to each bar code, detecting whether characters exist in the rotated image, if so, identifying the characters, calculating the corresponding character confidence coefficient after each rotation of the rotation angle, judging whether a character confidence coefficient larger than a preset threshold exists, if not, the image direction does not need to be corrected, if so, selecting the image rotation angle corresponding to the highest confidence coefficient, and correcting the image direction according to the image rotation angle; if not, selecting the direction angle of any bar code, and correcting the image direction according to the direction angle of the bar code.
Preferably, the rotation angle range is [ central angle-i, central angle + i ], wherein i is greater than 0 degree and less than or equal to 10 degrees; the rotation angle is greater than 0 degree and less than 10 degrees.
Preferably, the step of determining whether a barcode is detected in the preprocessed image comprises: scanning any pixel row in the preprocessed image; performing pixel statistics on the pixel rows, performing statistics on continuous black and white pixels in the pixel rows, and calculating a proportion sequence of the pixel rows; comparing the calculated proportional sequence with the positioning symbols of various pre-stored bar codes, and if the proportions are the same, indicating that the corresponding bar codes are detected; if the proportions are different, the bar code is not detected, and the next step is continuously executed; and rotating the image, and returning to the scanning step to continue detection.
Another aspect of the present invention further provides an image orientation correction system, including: the bar code detection module is used for detecting whether a bar code exists in the preprocessed image; the bar code direction angle determining module is connected with the bar code detecting module and is used for acquiring the direction angle of the bar code detected by the bar code detecting module, and setting a rotation angle range corresponding to the bar code by taking the direction angle as a central angle after acquiring the direction angle of the bar code; the bar code direction angle determining module prestores a rotation angle; the rotating module is connected with the bar code direction angle determining module and is used for rotating the image once every other preset rotating angle within the rotating angle range when the bar code is detected to exist; the rotation module is further used for rotating the image once every other preset rotation angle within the all-round 360-degree range when the bar code is not detected. The character detection module is connected with the rotation module and used for detecting whether characters exist in the image after the image is rotated by the rotation angle every time; the character recognition module is connected with the character detection module and used for recognizing characters in the image rotated by the rotation angle degree every time when the character detection module detects that the characters exist in the image rotated by the rotation angle degree every time; the operation module is connected with the character recognition module and used for calculating and acquiring character confidence corresponding to each rotation angle; the comparison module is connected with the operation module and used for judging whether the character confidence corresponding to each rotation angle is higher than a preset threshold value, if not, the comparison module indicates that the character confidence corresponding to each rotation angle is not high, and the image direction does not need to be corrected; if yes, selecting the image rotation angle corresponding to the highest character confidence coefficient, and correcting the image direction according to the image rotation angle.
Preferably, the correction system further comprises an image correction module, connected to the comparison module, for correcting the image direction according to the image correction angle.
Preferably, the rotation module is further configured to store another rotation angle and another rotation angle in advance, and is configured to rotate the preprocessed image every other rotation angle within an omnidirectional 360-degree range when the barcode detection module does not detect a barcode in the preprocessed image, where the another rotation angle is greater than 10 degrees and less than 30 degrees; or [0 degrees, 360 degrees ] is set into a plurality of subintervals, and a rotation angle is adopted in each subinterval, and the preprocessed image is rotated every other rotation angle.
Preferably, the correction system further comprises an image reading module for reading original image data, and a pre-processing image module for pre-processing the image data.
Preferably, the barcode detection module includes: the scanning unit is used for scanning any pixel row in the preprocessed image; the operation unit is connected with the scanning unit and used for counting the pixel rows, counting continuous black and white pixels in the pixel rows and calculating a proportion sequence of the pixel rows; the comparison unit is connected with the operation unit and used for comparing the calculated proportional sequence with the locators of various bar codes stored in advance, and if the proportions are the same, the comparison unit indicates that the corresponding bar codes are detected; if the proportions are different, the bar code is not detected; and the rotating unit is connected with the comparing unit. And when the scanning unit does not detect the bar code, rotating the image and recalling the scanning unit to continue scanning any pixel row in the image.
As described above, the image direction correction method and system of the present invention have the following advantages:
1. the image direction correcting method and the system of the invention determine the range of the image rotation direction by utilizing the bar code direction, and determine the image correction angle by detecting and identifying characters in the range, thereby reducing the possibility of misjudgment of image rotation, and simultaneously rapidly and accurately judging and correcting the image direction,
2. the image direction correction method and the image direction correction system provide convenience for browsing and other post-image processing operations of the user in daily life, business work, research work and the like.
Drawings
FIG. 1 is a flowchart illustrating an image direction correction method according to the present invention.
Fig. 2 is a schematic flow chart illustrating step 2 of the image direction correction method according to the present invention.
Fig. 3 is a schematic flow chart illustrating step 3 of the image direction correction method according to the present invention.
FIG. 4 is a schematic diagram of an image orientation correction system according to the present invention.
FIG. 5 is a schematic diagram of an image pre-processing module in the image direction correction system according to the present invention.
FIG. 6 is a schematic diagram of a barcode detection module in the image direction correction system according to the present invention.
Description of the element reference numerals
1 image orientation correction system
10 image reading module
20 image preprocessing module
30 bar code detection module
40 bar code direction angle determining module
50 rotating module
60 characters detection module
70 character recognition module
80 operation module
90 comparison module
100 correction module
201 image graying unit
202 image denoising unit
203 image binarization unit
301 scanning unit
302 arithmetic unit
303 comparison unit
304 rotating unit
S1-S23
Detailed Description
The embodiments of the present invention are described below with reference to specific embodiments, and other advantages and effects of the present invention will be easily understood by those skilled in the art from the disclosure of the present specification. The invention is capable of other and different embodiments and of being practiced or of being carried out in various ways, and its several details are capable of modification in various respects, all without departing from the spirit and scope of the present invention. It is to be noted that the features in the following embodiments and examples may be combined with each other without conflict.
It should be noted that the drawings provided in the following embodiments are only for illustrating the basic idea of the present invention, and the components related to the present invention are only shown in the drawings rather than drawn according to the number, shape and size of the components in actual implementation, and the type, quantity and proportion of the components in actual implementation may be changed freely, and the layout of the components may be more complicated.
The invention firstly detects the direction of the bar code in the image, detects and identifies the characters according to the possible direction range of the bar code, and corrects the direction of the image by combining the angle and the confidence coefficient of the direction of the characters and the bar code. In the present embodiment, the rotation direction may be a clockwise direction unless otherwise stated, but the scope of the present invention is not limited thereto.
Example one
Before saving image data or displaying the image data for a user to browse, or opening an image file which is saved, reading the image data, and before displaying the read image data for the user to browse, automatically detecting the rotation angle and automatically correcting the rotation of the image data, thereby ensuring that the image which is viewed when the user browses the image is corrected by rotation, and reducing the trouble that the user has to manually correct the rotation by using an image browsing tool.
The present embodiment provides an image direction correction method, please refer to fig. 1, which shows a flow of the image direction correction method, where the image direction correction method includes:
s1, the original image data is read. The raw image data read may be: shooting the obtained image data by using a digital camera; or image data obtained by scanning with a scanner; or opening a pre-existing file containing image data, reading the data in the file, and decompressing according to a standard algorithm to obtain the image data.
S2, the read raw image data is preprocessed. Referring to FIG. 2, a pre-processing flow is shown, the pre-processing comprising:
s201, graying the original image data; since most of the original image read is a color image, and the color image storage takes more space than the grayscale image, it is much longer to process than the grayscale image. Meanwhile, the barcode existing in the image is printed in a black-and-white manner, so that in the process of identifying the barcode, the color information component in the actually shot barcode image has no effect on the identification of the barcode, and the color image needs to be converted into a gray image so as to reduce the operation time of subsequent operation. The color of each pixel in the color image is determined by R, G, B three components, and the gray image is a special color image with R, G, B three components being the same, wherein the variation range of one pixel point is 0-255.
S202, continuing denoising processing on the image data. Since the read image generally contains noise due to interference of the surrounding environment, the read image is subjected to denoising processing. In this embodiment, the denoising method employs median filtering. Median filtering is a non-linear processing method of constant noise, the basic principle of which is to replace the value of a point in a digital image or digital sequence by the median of the values of points in a domain of the point.
And S203, continuing binarization processing on the image data. The purpose of image binarization is to remove background, preserve bar code symbols as much as possible and reduce noise and magazines in the symbols, and provide a basic guarantee for correctly identifying position detection patterns and correctly reading bar code words in subsequent bar code detection. Read grey scale value access L in image datalowAnd LhightThe pixels in between constitute the transition region. The basic idea of the image segmentation method for transition region extraction is to extract the pixels of the transition region and then binarize the image by using the gray average value of the pixels of the transition region as the segmentation threshold.
S3, judging whether the preprocessed image has the bar code detected, if so, continuing to execute the step S4; if no barcode is detected, the process continues to step S18. In this embodiment, the barcode is a one-dimensional barcode or a two-dimensional barcode. Referring to fig. 3, a process for detecting a barcode is shown, wherein the barcode detection specifically includes the following steps:
s301, scanning any pixel row in the preprocessed image; since each row in the image corresponds to a pixel row of black and white pixel values. In this embodiment, in order to avoid the influence of the environmental noise, the pixel rows in the image are scanned multiple times in step S31.
S302, performing pixel statistics on the pixel rows, performing statistics on continuous black and white pixels in the pixel rows, and calculating a proportion sequence of the pixel rows; since each barcode corresponds to a locator, the locator is a sequence of black and white bars corresponding to a certain proportion.
S303, comparing the calculated proportional sequence with the positioning symbols of various pre-stored bar codes, if the proportions are the same, indicating that the corresponding bar code is detected, and executing the step S4; if the proportions are different, the bar code is not detected, and the next step is continuously executed.
S304, rotating the image by omega degrees, returning to the step S301, continuously scanning any pixel row in the image, performing pixel statistics on the row, performing statistics on continuous black and white pixels of the row, calculating a proportion sequence of the row,
s4, judging whether only one bar code exists in the preprocessed image, if only one bar code exists, executing the step S5; if there are a plurality of barcodes, step S12 is executed.
S5, a bar code exists, and the direction angle j of the bar code is obtained by utilizing a bar code scanning line algorithm. Setting a rotation angle theta within the rotation angle range of [ j-i, j + i ] by taking the direction angle j of the bar code as a central angle, and rotating the image once every other rotation angle theta. In the embodiment, the angle i is set to be 5 degrees and the angle θ is set to be 1 degree, the direction angle j of the barcode is obtained through a barcode scanning line algorithm, and the preprocessed image is rotated every 1 degree within the rotation angle range of [ j-5, j +5] with the direction angle j as a central angle.
S6, detecting whether characters exist in the image after each rotation of theta degrees, if so, executing the step S7; if no text exists, step S11 is executed.
S7, recognizing characters in the image rotated by theta degrees every time, calculating the similarity between character data corresponding to the image rotated by theta degrees every time and character template data in a preset correct direction, and acquiring character confidence corresponding to the image rotated by theta degrees every time;
s8, judging whether the character confidence corresponding to each theta degree rotation has a character confidence greater than a preset threshold, if not, indicating that the character confidence corresponding to each theta degree rotation is not high, and the image rotation angle is not trusted from j-i + theta, j-i +2 theta, … … to j-i + n theta, then executing the step S9; if there is a text confidence greater than the preset threshold, step S10 is executed.
S9, the image correction angle is set to 0 degrees, the image does not need to be rotated, and the image direction does not need to be corrected.
And S10, comparing the character confidence degrees corresponding to different image rotation angles which are larger than the preset threshold value. And selecting the image rotation angle corresponding to the highest character confidence coefficient, setting the image rotation angle as an image correction angle, correcting the image direction according to the image correction angle, and outputting a corrected image. In this embodiment, for example, if i is equal to 5 degrees and θ is equal to 1 degree, if the image is rotated 10 times and 10 θ, that is, 10 degrees within the rotation angle range, the corresponding character confidence is the highest, then the intersection of the rotation of the image corresponding to the highest character confidence is j-5+10, which is j +5 degrees, and the image correction angle is j +5 degrees.
S11, selecting the direction angle of the bar code as an image correction angle, correcting the image direction according to the image correction angle, outputting the corrected image, and ending the process.
S12, a plurality of bar codes exist, direction angles alpha, beta, gamma and the like of the bar codes are obtained by utilizing the bar code scanning line algorithm, another rotation angle theta is set in rotation angle ranges of [ alpha-i, alpha + i ], [ beta-i, beta + i ], [ gamma-i, gamma + i ] and the like by respectively taking the direction angles alpha, beta, gamma and the like of each bar code as central angles, and the image is rotated once every other rotation angle theta. In the embodiment, the angle i is set to be 5 degrees and the angle θ is set to be 1 degree, the direction angles α, β, γ, etc. of the plurality of barcodes are obtained through a barcode scanning line algorithm, and the preprocessed image is rotated once every 1 degree within the rotation angle ranges of [ α -i, α + i ], [ β -i, β + i ], [ γ -i, γ + i ], etc. by taking the direction angles α, β, γ, etc. of each barcode as central angles.
S13, detecting whether characters exist in the image after each rotation of theta degrees, if so, executing the step S14; if no text exists, step S17 is executed.
S14, recognizing the characters in the image rotated by theta degrees every time, calculating the similarity between the character data corresponding to the rotated theta degrees every time and the preset character template data in the correct direction, and acquiring the character confidence corresponding to the rotated theta degrees every time;
s15, judging whether the character confidence corresponding to each theta degree rotation exists a character confidence greater than a preset threshold value, if not, indicating that the character confidence corresponding to each theta degree rotation is not high, and if the image rotation angle is not reliable from alpha-i + theta/beta-i + theta/gamma-i + theta … …, alpha-i +2 theta/beta-i +2 theta/gamma-i +2 theta … …, … … to alpha-i + n theta/beta-i + n theta/gamma-i + n theta … …, executing S9; if there is a text confidence greater than the preset threshold, step S16 is executed.
And S16, comparing the character confidence degrees corresponding to different image rotation angles which are larger than the preset threshold value. And selecting the image rotation angle with the highest character confidence coefficient, setting the image rotation angle as an image correction angle, correcting the image direction according to the image correction angle, and outputting a corrected image. In the embodiment, the cross validation image rotation method is performed by using the direction of the bar code and the confidence information of the character recognition in the corresponding rotation range, so that the misjudgment of the image rotation method is avoided. In this embodiment, for example, if the intersection α of the directions of a barcode is the central angle, and if i is equal to 5 degrees and θ is equal to 1 degree in the rotation angle range [ α -i, α + i ], if the confidence of the corresponding characters is highest after the image is rotated 12 times and 12 θ, that is, 12 degrees, within the rotation angle range, the intersection α -5+12 of the image rotation corresponding to the highest confidence of the characters is α +7 degrees, so the image correction angle is α +7 degrees.
S17, selecting the direction angle of any one of the plurality of barcodes as an image correction angle, correcting the image direction according to the image correction angle, outputting the corrected image, and ending the process.
S18, if no bar code is detected in the image, a rotation angle is set within 360 degreesEvery other rotation angleRotating the preprocessed image, wherein the angle of rotationGreater than 10 degrees and less than 30 degrees; the step can also be carried out at the angle of [0 DEG, 360 DEG ]]Set to n sub-intervals, selecting another rotation angle in each sub-intervalAnd rotating the preprocessed image.
S19, detecting whether there is a character in the rotated image, and if so, executing step S20; if the characters are not detected, the image is not rotated, and the process is ended;
s20, recognizing each rotationDegree orThe characters in the image after the degree are calculated and each rotationDegree orThe similarity degree of the corresponding character data after the degree and the preset character template data in the correct direction is obtained, and each rotation is obtainedDegree orThe corresponding character confidence after the degree;
s21, judging each rotationOrWhether the corresponding character confidence coefficient after the degree is greater than a preset threshold character confidence coefficient exists or not, if not, the character confidence coefficient indicates that each rotation is carried outDegree orThe confidence degrees of the corresponding characters are not high, and the image rotation angle is fromIs not trusted, then step S22 is executed; if there is a text confidence greater than the preset threshold, step S23 is executed.
S22, the image correction angle is set to 0 degrees, the image does not need to be rotated, and the image direction does not need to be corrected.
And S23, comparing the character confidence degrees corresponding to different image rotation angles which are larger than the preset threshold value, selecting the image rotation angle with the highest character confidence degree, setting the image rotation angle as an image correction angle, correcting the image direction according to the image correction angle, and outputting the corrected image.
In this embodiment, if the image includes a human face, the step S7 detects whether the image has a human face after each rotation angle, calculates a human face reliability index, and corrects the image direction according to the calculated human face reliability index.
Example two
The present embodiment provides an image orientation correction system 1, please refer to fig. 4, which shows a structure of the image orientation correction system, the correction system includes: the image processing device comprises an image reading module 10, an image preprocessing module 20, a bar code detection module 30, a bar code direction and angle determination module 40, a rotation module 50, a character detection module 60, a character recognition module 70, an operation module 80, a comparison module 90 and a correction module 100.
The image reading module 10 is configured to read original image data.
The image preprocessing module 20 is configured to preprocess the original image data. Referring to fig. 5, the structure of the image preprocessing module 20 is shown, where the image preprocessing module 20 includes: an image graying unit 201, an image denoising unit 202, and an image binarization unit 203. Wherein,
the image graying unit 201 is used for graying the original image data, and since most of the read original image is a color image, the color image storage occupies more space than the grayscale image, and the processing is much longer than the grayscale image. While the bar code present in the image is printed in black and white, soSo that the color information component in the actually photographed barcode image has no effect on the recognition of the barcode in the process of recognizing the barcode, and thus the color image needs to be converted into a gray image in order to reduce the operation time of the subsequent operation. The color of each pixel in the color image is determined by R, G, B three components, and the gray image is a special color image with R, G, B three components being the same, wherein the variation range of one pixel point is 0-255. The image denoising unit 202 is configured to denoise the image data. Since the read image generally contains noise due to interference of the surrounding environment, the read image is subjected to denoising processing. In this embodiment, the denoising method employs median filtering. Median filtering is a non-linear processing method of constant noise, the basic principle of which is to replace the value of a point in a digital image or digital sequence by the median of the values of points in a domain of the point. The image binarization unit 203 is configured to continue binarization processing on the image data. The purpose of image binarization is to remove background, preserve bar code symbols as much as possible and reduce noise and magazines in the symbols, and provide a basic guarantee for correctly identifying position detection patterns and correctly reading bar code words in subsequent bar code detection. Read grey scale value access L in image datalowAnd LhightThe pixels in between constitute the transition region. The basic idea of the image segmentation method for transition region extraction is to extract the pixels of the transition region and then binarize the image by using the gray average value of the pixels of the transition region as the segmentation threshold.
The barcode detection module 30 is connected to the image preprocessing unit 20, and is configured to detect whether at least one barcode exists in the preprocessed image. Referring to fig. 6, a structure of a barcode detection module is shown, in which the barcode detection module 30 includes a scanning unit 301, an operation unit 302, a comparison unit 303, and a rotation unit 304. In this embodiment, the barcode is a one-dimensional barcode or a two-dimensional barcode.
The scanning unit 301 is configured to scan any pixel row in the pre-processed image; since each row in the image corresponds to a pixel row of black and white pixel values. In the embodiment, in order to avoid the influence of environmental noise, the scanning unit is called multiple times to scan the pixel rows in the image.
The arithmetic unit 302 connected to the scanning unit 301 is configured to count the pixel rows, count consecutive black and white pixels in the pixel rows, and calculate a proportional sequence of the pixel rows. Since each barcode corresponds to a locator, the locator is a sequence of black and white bars corresponding to a certain proportion.
The comparison unit 303 connected to the operation unit 302 compares the calculated proportional sequence with the locators of various barcodes stored in advance, and if the proportions are the same, it indicates that the corresponding barcode is detected; if the ratios are different, it is indicated that no barcode is detected.
The rotation unit 304 connected to the comparison unit 303 is configured to rotate the image according to a predetermined rotation angle ω when the scanning unit 301 does not detect a barcode, recall any pixel row in the image scanned by the scanning unit 301, perform pixel statistics on the row, perform statistics on continuous black and white pixels of the row, and calculate a proportional sequence of the row.
The barcode detection module 30 is further configured to detect the number of barcodes in the preprocessed image, where the number of barcodes in the preprocessed image at least includes one barcode.
The barcode direction angle determining module 40 connected to the barcode detecting module 30 is configured to obtain direction angles j, α, β, γ, and the like of all barcodes detected by the barcode detecting module 30, after the barcode direction angle determining module 40 obtains the direction angles of all barcodes, intersecting each other with the direction angles as a center, and setting rotation angle ranges [ j-i, j + i ], [ α -i, α + i ], [ β -i, β + i ], [ γ -i, γ + i ], and the like corresponding to each barcode one by one, where a rotation angle θ is stored in the module in advance.
The rotation module 50 connected to the bar code direction angle determination unit 40 is used for respectively centering on the direction angles j, α, β, gamma, etc. of the respective bar codes at [ j-i, j + i ]]、[α-i,α+i]、[β-i,β+i]、[γ-i,γ+i]And rotating the bar codes once every other rotation angle theta within the rotation angle range, wherein the direction angles j, α, β, gamma and the like of the bar codes are more than 0 degree and less than 360 degrees, the angle i is more than 0 degree and less than or equal to 10 degrees, the rotation angle theta is more than 0 degree and less than or equal to 10 degrees, in the embodiment, the angle i is set to be 5 degrees, the rotation angle theta is set to be 1 degree, the direction angle j of the bar codes is acquired through a bar code scanning line algorithm, and the central angles of the direction angles j, α, β, gamma and the like are set to be [ j-5, j +5]]、[α-5,α+5]、[β-5,β+5]、[γ-5,γ+5]And rotating the preprocessed image every 1 degree within the rotation range. The rotation module 50 stores another rotation angle therein in advanceAnd yet another angle of rotationFor every other rotation angle within 360 degrees of the whole range when the barcode detection module 30 does not detect the barcode in the preprocessed imageAnd rotating the preprocessed image. Wherein the angle of rotationGreater than 10 degrees and less than 30 degrees; or the rotation module 50 can also rotate [0 °, 360 ° ]]Set to n sub-intervals, with another rotation angle in each sub-intervalRotating the preprocessed image
The character detection module 6 connected with the rotation module 500 is used for detecting whether characters exist in the image after each rotation of theta degrees. The text detection module 60 may also be a face detection module 60' configured to detect whether a face exists in the image after each rotation of θ degrees. The operation module 80 'is used for calculating the face reliability index, and the correction module 100' is used for correcting the image direction according to the calculated face reliability index. The text detection module 60 is further configured to detect a barcode in the preprocessed image at every other rotation angle when the barcode detection module 30 does not detect the barcode in the preprocessed imageDetecting each rotation after rotating the imageAnd whether characters exist in the image after the degree determination.
The character recognition module 70 connected to the character detection module 60 is configured to recognize characters existing in the image rotated by θ degrees each time when the character detection module 60 detects that characters exist in the image rotated by θ degrees each time. The text recognition module 70 is further configured to detect each rotation when the text detection module 60 detects each rotationRecognizing each rotation when there is a character in the image after the rotationAnd the characters exist in the image after the measurement.
The operation module 80 connected to the character recognition module 70 is configured to calculate a similarity between the character data corresponding to each rotation of θ degrees and the preset character template data in the correct direction, and obtain a corresponding character confidence after each rotation of θ degrees; the calculation module 80 is further configured to calculate each rotationCharacter data corresponding to degree and advanceSetting the similarity of the character template data in the right direction and obtaining each rotationAnd the corresponding character confidence after the degree is reached.
The comparing module 90 connected to the computing module 80 is configured to determine whether a text confidence corresponding to each theta degree rotation is greater than a preset threshold, if not, the text confidence corresponding to each theta degree rotation is not high, and the image rotation angle is determined to be untrustworthy from j-i + θ/α -i + θ/β -i + θ/γ -i + θ … …, j-i +2 θ/α -i +2 θ/β -i- +2 θ/γ -i +2 θ … …, … … to j-i + n θ/α -i + n θ/β -i + n θ/γ -i + n θ … …, and if the text confidence is greater than the preset threshold, the image rotation angle with the highest text confidence is selected and set as the image rotation angle, in this embodiment, the image rotation method for determining the cross-bar code recognition information by using the comparison range of the bar code rotation, and the image rotation method for avoiding erroneous determinationDegree orWhether the corresponding character confidence coefficient after the degree is greater than a preset threshold exists or not, if not, the character confidence coefficient indicates that each rotation is carried outDegree orThe confidence degrees of the corresponding characters are not high, and the image rotation angle is from Are all not trusted, the image does not need to be corrected; if the character confidence coefficient greater than the preset threshold exists, comparing the character confidence coefficients greater than the preset threshold and corresponding to different image rotation angles, selecting the image rotation angle with the highest character confidence coefficient, and setting the image rotation angle as the image correction angle.
The correction module 100 connected to the comparison module 90 is configured to obtain an image correction angle, correct an image direction according to the image correction angle, and output a corrected image.
Aiming at the image containing characters and/or bar codes, the image direction correcting method and the image direction correcting system automatically detect the positive direction of the image according to the angle of the characters and/or the bar codes and confidence information, firstly, the bar codes are utilized to determine the range of the image rotating direction, and the image correcting angle is determined by detecting and identifying the characters in the range, so that the possibility of image rotating misjudgment can be reduced, meanwhile, the image direction can be quickly and accurately judged and corrected, and convenience is provided for browsing and other post image processing operations of a user in daily life, business work, research work and the like. The invention is also convenient to be installed in intelligent equipment such as computers, mobile phones, tablet computers and the like.
Therefore, the invention effectively overcomes various defects in the prior art and has high industrial utilization value.
The foregoing embodiments are merely illustrative of the principles and utilities of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or change the above-mentioned embodiments without departing from the spirit and scope of the present invention. Accordingly, it is intended that all equivalent modifications or changes which can be made by those skilled in the art without departing from the spirit and technical spirit of the present invention be covered by the claims of the present invention.

Claims (10)

1. An image orientation correction method, comprising:
preprocessing the read original image data;
judging whether the bar code is detected in the preprocessed image,
if so, rotating the image every other preset rotation angle within a rotation angle range by taking the direction angle of the bar code as a central angle, detecting whether characters exist in the rotated image, if so, identifying the characters, calculating the corresponding character confidence coefficient after each rotation angle, judging whether the character confidence coefficient larger than a preset threshold exists, if not, the image direction does not need to be corrected, if so, selecting the image rotation angle corresponding to the highest confidence coefficient, and correcting the image direction according to the image rotation angle; if not, selecting the direction angle of the bar code, and correcting the image direction according to the direction angle of the bar code;
if not, rotating the image every other preset rotation angle within the omnibearing range once, detecting whether characters exist, if so, identifying the characters, calculating the character confidence coefficient corresponding to another rotation angle after each rotation, judging whether the character confidence coefficient larger than a preset threshold exists, if not, the image direction does not need to be corrected, if so, selecting the image rotation angle corresponding to the highest confidence coefficient, and correcting the image direction according to the image rotation angle; if not, the image direction does not need to be corrected.
2. The image orientation correction method according to claim 1, characterized in that: judging whether a bar code is detected in the preprocessed image, if not, setting [0 degrees and 360 degrees ] into a plurality of subintervals, selecting another rotation angle in each subinterval, rotating the preprocessed image every other rotation angle, detecting whether characters exist in the rotated image, if so, identifying the characters, calculating the character confidence coefficient corresponding to the rotation angle of another rotation angle every time, and judging whether the character confidence coefficient larger than a preset threshold exists, if not, the image direction does not need to be corrected, if so, selecting the image rotation angle corresponding to the highest confidence coefficient, and correcting the image direction according to the character confidence coefficient; if not, the image direction does not need to be corrected.
3. The image orientation correction method according to claim 1, characterized in that: the image orientation correction method further includes determining whether only one barcode exists in the preprocessed image,
if so, rotating the image every other preset rotation angle within a rotation angle range by taking the direction angle of the bar code as a central angle, detecting whether characters exist in the rotated image, if so, identifying the characters, calculating the corresponding character confidence coefficient after each rotation angle, judging whether the character confidence coefficient larger than a preset threshold exists, if not, the image direction does not need to be corrected, if so, selecting the image rotation angle corresponding to the highest confidence coefficient, and correcting the image direction according to the image rotation angle; if not, selecting the direction angle of the bar code, and correcting the image direction according to the direction angle of the bar code;
if not, respectively taking the direction angle of each bar code as a central angle, respectively rotating the image every other preset rotation angle within a rotation angle range corresponding to each bar code, detecting whether characters exist in the rotated image, if so, identifying the characters, calculating the corresponding character confidence coefficient after each rotation of the rotation angle, judging whether a character confidence coefficient larger than a preset threshold exists, if not, the image direction does not need to be corrected, if so, selecting the image rotation angle corresponding to the highest confidence coefficient, and correcting the image direction according to the image rotation angle; if not, selecting the direction angle of any bar code, and correcting the image direction according to the direction angle of the bar code.
4. The image orientation correction method according to claim 1, characterized in that: the rotation angle range is [ central angle-i, central angle + i ], wherein i is greater than 0 degree and less than or equal to 10 degrees; the rotation angle is greater than 0 degree and less than 10 degrees.
5. The image orientation correction method according to claim 1, characterized in that: the step of judging whether the bar code is detected in the preprocessed image comprises the following steps:
scanning any pixel row in the preprocessed image;
performing pixel statistics on the pixel rows, performing statistics on continuous black and white pixels in the pixel rows, and calculating a proportion sequence of the pixel rows;
comparing the calculated proportional sequence with the positioning symbols of various pre-stored bar codes, and if the proportions are the same, indicating that the corresponding bar codes are detected; if the proportions are different, the bar code is not detected, and the next step is continuously executed;
and rotating the image, and returning to the scanning step to continue detection.
6. An image orientation correction system, comprising:
the bar code detection module is used for detecting whether a bar code exists in the preprocessed image;
the bar code direction angle determining module is connected with the bar code detecting module and is used for acquiring the direction angle of the bar code detected by the bar code detecting module, and setting a rotation angle range corresponding to the bar code by taking the direction angle as a central angle after acquiring the direction angle of the bar code; the bar code direction angle determining module prestores a rotation angle;
the rotating module is connected with the bar code direction angle determining module and is used for rotating the image once every other preset rotating angle within the rotating angle range when the bar code is detected to exist; the rotation module is further used for rotating the image once every other preset rotation angle within the all-round 360-degree range when the bar code is not detected;
the character detection module is connected with the rotation module and used for detecting whether characters exist in the image after the image is rotated by the rotation angle every time;
the character recognition module is connected with the character detection module and used for recognizing characters in the image rotated by the rotation angle degree every time when the character detection module detects that the characters exist in the image rotated by the rotation angle degree every time;
the operation module is connected with the character recognition module and used for calculating and acquiring character confidence corresponding to each rotation angle;
the comparison module is connected with the operation module and used for judging whether the character confidence corresponding to each rotation angle is higher than a preset threshold value, if not, the comparison module indicates that the character confidence corresponding to each rotation angle is not high, and the image direction does not need to be corrected; if yes, selecting the image rotation angle corresponding to the highest character confidence coefficient, and correcting the image direction according to the image rotation angle.
7. The image orientation correction system according to claim 6, characterized in that: the correction system also comprises an image correction module, wherein the image correction module is connected with the comparison module and is used for correcting the image direction according to the image correction angle.
8. The image orientation correction system according to claim 6, characterized in that: the rotation module is further configured to pre-store another rotation angle and another rotation angle, and is configured to rotate the preprocessed image every other another rotation angle within an omnidirectional 360-degree range when the barcode detection module does not detect a barcode in the preprocessed image, where the another rotation angle is greater than 10 degrees and smaller than 30 degrees; or [0 degrees, 360 degrees ] is set into a plurality of subintervals, and a rotation angle is adopted in each subinterval, and the preprocessed image is rotated every other rotation angle.
9. The image orientation correction system according to claim 6, characterized in that: the correction system further includes an image reading module for reading original image data, and a pre-processing image module for pre-processing the image data.
10. The image orientation correction system according to claim 6, characterized in that: the barcode detection module includes:
the scanning unit is used for scanning any pixel row in the preprocessed image;
the operation unit is connected with the scanning unit and used for counting the pixel rows, counting continuous black and white pixels in the pixel rows and calculating a proportion sequence of the pixel rows;
the comparison unit is connected with the operation unit and used for comparing the calculated proportional sequence with the locators of various bar codes stored in advance, and if the proportions are the same, the comparison unit indicates that the corresponding bar codes are detected; if the proportions are different, the bar code is not detected;
and the rotating unit is connected with the comparing unit and used for rotating the image and recalling the scanning unit to continuously scan any pixel row in the image when the comparing unit does not detect the bar code.
CN201310746613.5A 2013-12-30 2013-12-30 Method and system for correcting image direction Active CN103714327B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310746613.5A CN103714327B (en) 2013-12-30 2013-12-30 Method and system for correcting image direction

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310746613.5A CN103714327B (en) 2013-12-30 2013-12-30 Method and system for correcting image direction

Publications (2)

Publication Number Publication Date
CN103714327A CN103714327A (en) 2014-04-09
CN103714327B true CN103714327B (en) 2017-02-01

Family

ID=50407287

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310746613.5A Active CN103714327B (en) 2013-12-30 2013-12-30 Method and system for correcting image direction

Country Status (1)

Country Link
CN (1) CN103714327B (en)

Families Citing this family (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104537609A (en) * 2014-11-28 2015-04-22 上海理工大学 Rotated image correction method
CN104820968A (en) * 2015-04-22 2015-08-05 上海理工大学 Text draft angle correction method
WO2017049507A1 (en) * 2015-09-23 2017-03-30 深圳还是威健康科技有限公司 Barcode recognition method and smart wristband
CN105426887B (en) * 2015-10-30 2019-04-12 北京奇艺世纪科技有限公司 A kind of method and device of text image correction
CN105631396A (en) * 2015-11-13 2016-06-01 东莞酷派软件技术有限公司 A method and device for obtaining electronic files of documents
CN107038440B (en) * 2016-02-04 2020-04-28 株式会社理光 Image tilt correction device, image processing system, and image tilt correction method
CN106056156A (en) * 2016-05-31 2016-10-26 武汉明德生物科技股份有限公司 System and method of recognizing and detecting reagent card
CN108171098B (en) * 2016-12-07 2021-01-22 杭州海康威视数字技术股份有限公司 Bar code detection method and equipment
CN106874845B (en) * 2016-12-30 2021-03-26 东软集团股份有限公司 Image recognition method and device
GB2562529B (en) * 2017-05-18 2019-12-11 Samsung Electronics Co Ltd Method and apparatus for stabilising 360 degree video
CN107608604B (en) * 2017-09-26 2019-06-07 维沃移动通信有限公司 A kind of image display method and mobile terminal
CN110298879B (en) * 2018-03-21 2021-08-27 北京猎户星空科技有限公司 Method and device for determining pose of object to be grabbed and electronic equipment
CN108573473A (en) * 2018-04-27 2018-09-25 平安科技(深圳)有限公司 Picture rotation method, apparatus, computer equipment and storage medium
CN109886058B (en) * 2019-01-03 2021-07-13 青岛海信移动通信技术股份有限公司 Method and equipment for detecting image
CN109784331B (en) * 2019-01-08 2023-07-07 河北科技大学 Bar end face marking scheme based on mark points and character image correction method
CN110399872B (en) * 2019-06-20 2023-04-28 创新先进技术有限公司 Image processing method and device
CN111291753B (en) * 2020-01-22 2024-05-28 平安科技(深圳)有限公司 Text recognition method and device based on image and storage medium
CN111860027B (en) * 2020-06-11 2024-06-18 贝壳技术有限公司 Two-dimensional code identification method and device
CN112651401B (en) * 2020-12-30 2024-04-02 凌云光技术股份有限公司 Automatic correction method and system for code spraying character
CN113903038A (en) * 2021-10-13 2022-01-07 广东金赋科技股份有限公司 A method and system for text correction based on bounding box

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1073001A2 (en) * 1999-07-30 2001-01-31 Fujitsu Limited Document image correcting device and correcting method
CN1677441A (en) * 2004-03-31 2005-10-05 富士胶片株式会社 Image display control apparatus and method, and program for controlling image display control apparatus
CN101639933A (en) * 2009-07-16 2010-02-03 上海合合信息科技发展有限公司 Image rotation correction method and system and electronic device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1073001A2 (en) * 1999-07-30 2001-01-31 Fujitsu Limited Document image correcting device and correcting method
CN1677441A (en) * 2004-03-31 2005-10-05 富士胶片株式会社 Image display control apparatus and method, and program for controlling image display control apparatus
CN101639933A (en) * 2009-07-16 2010-02-03 上海合合信息科技发展有限公司 Image rotation correction method and system and electronic device

Also Published As

Publication number Publication date
CN103714327A (en) 2014-04-09

Similar Documents

Publication Publication Date Title
CN103714327B (en) Method and system for correcting image direction
CN110046529B (en) Two-dimensional code identification method, device and equipment
CN103400099B (en) Terminal and two-dimensional code identification method
US8240571B2 (en) Barcode image recognition system and associated method for hand-held device
Tian et al. Rectification and 3D reconstruction of curved document images
US8712188B2 (en) System and method for document orientation detection
WO2014160433A2 (en) Systems and methods for classifying objects in digital images captured using mobile devices
US9076242B2 (en) Automatic correction of skew in natural images and video
EP2650821A1 (en) Text image trimming method
CN101639933A (en) Image rotation correction method and system and electronic device
US8897565B1 (en) Extracting documents from a natural scene image
US10169629B2 (en) Decoding visual codes
US10303969B2 (en) Pose detection using depth camera
KR101907414B1 (en) Apparus and method for character recognition based on photograph image
CN109948521B (en) Image deviation rectifying method and device, equipment and storage medium
CN112163443A (en) Code scanning method, code scanning device and mobile terminal
KR101842535B1 (en) Method for the optical detection of symbols
US20170061184A1 (en) Portable electronic device and operation method thereof
CN104268512A (en) Method and device for recognizing characters in image on basis of optical character recognition
CN117540762A (en) Bar code identification method, device, equipment and readable storage medium
WO2014020820A1 (en) Mark reading device and mark reading method
Kleber et al. Robust skew estimation of handwritten and printed documents based on grayvalue images
US20210281742A1 (en) Document detections from video images
US20150169973A1 (en) Incomplete patterns
CN117408278A (en) Image processing method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CP01 Change in the name or title of a patent holder

Address after: 200433 room 335, No. 8008-34, National Road, Shanghai, Yangpu District

Patentee after: Shanghai hehe Information Technology Co., Ltd

Address before: 200433 room 335, No. 8008-34, National Road, Shanghai, Yangpu District

Patentee before: INTSIG INFORMATION Co.,Ltd.

CP01 Change in the name or title of a patent holder
CP02 Change in the address of a patent holder

Address after: Room 1105-1123, No. 1256, 1258, Wanrong Road, Jing'an District, Shanghai, 200436

Patentee after: Shanghai hehe Information Technology Co., Ltd

Address before: 200433 room 335, No. 8008-34, National Road, Shanghai, Yangpu District

Patentee before: Shanghai hehe Information Technology Co., Ltd

CP02 Change in the address of a patent holder