CN108171669A - A kind of image correction method based on OpenCV algorithms - Google Patents
A kind of image correction method based on OpenCV algorithms Download PDFInfo
- Publication number
- CN108171669A CN108171669A CN201711490245.7A CN201711490245A CN108171669A CN 108171669 A CN108171669 A CN 108171669A CN 201711490245 A CN201711490245 A CN 201711490245A CN 108171669 A CN108171669 A CN 108171669A
- Authority
- CN
- China
- Prior art keywords
- image
- correction method
- opencv
- algorithms
- opencv algorithms
- 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
- 238000000034 method Methods 0.000 title claims abstract description 30
- 238000003702 image correction Methods 0.000 title claims abstract description 21
- 238000001514 detection method Methods 0.000 claims description 16
- 239000011159 matrix material Substances 0.000 claims description 12
- 230000009466 transformation Effects 0.000 claims description 10
- 230000002708 enhancing effect Effects 0.000 claims description 4
- 238000001914 filtration Methods 0.000 claims description 4
- 238000012216 screening Methods 0.000 claims description 4
- 238000006243 chemical reaction Methods 0.000 claims description 3
- 238000000605 extraction Methods 0.000 claims description 3
- 238000012937 correction Methods 0.000 abstract description 12
- 241000251468 Actinopterygii Species 0.000 abstract description 4
- 230000006870 function Effects 0.000 description 25
- 239000011521 glass Substances 0.000 description 20
- 238000012545 processing Methods 0.000 description 4
- 230000007547 defect Effects 0.000 description 2
- 235000013399 edible fruits Nutrition 0.000 description 2
- 230000002787 reinforcement Effects 0.000 description 2
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000002474 experimental method Methods 0.000 description 1
- 238000007689 inspection Methods 0.000 description 1
- 230000035807 sensation Effects 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
- 238000005303 weighing Methods 0.000 description 1
Classifications
-
- G06T5/80—
-
- G06T5/90—
Abstract
The present invention relates to a kind of image correction methods based on OpenCV algorithms, include the following steps, load image;The image loaded is pre-processed;Image border is determined using function;Position fix is determined according to identified image border;Using identified position fix as input, image is corrected by OpenCV algorithms.A kind of image correction method of base OpenCV algorithms provided by the present invention, it, which is specifically included, pre-processes image, different compensation ways is set according to the colour temperature of light during shooting, the image bias colour so as to ensure that, it avoids since subtle colour cast causes to generate error in correction, and then improve the accuracy of correction, and pass through function check image border, image border according to being detected determines position fix, picture is corrected using OpenCV algorithms using identified position fix as input, so as to eliminate the anamorphose caused by the deviation of lens location and fish eye lens, improve the quality of picture.
Description
Technical field
The present invention relates to image correction method fields, and in particular to a kind of image correction method based on OpenCV algorithms.
Background technology
When carrying out photograph taking using camera, wanted by photographer it is difficult to ensure that the camera lens of camera is right against completely
The object of shooting, thus it is captured go out photo and the photo that is actually subjected to expression there is certain deformation;Even if it can ensure camera lens
With the complete face of the object to be shot, since short-focus lens are typically all spherical camera lens, it is captured go out photo still
There are certain fish eye lens.
Invention content
For above-mentioned technical problem, the present invention provides a kind of image correction method based on OpenCV algorithms, this method
The deformation of picture is corrected using OpenCV algorithms, so as to improve the quality of picture.
To achieve the above object, the present invention provides a kind of image correction method based on OpenCV algorithms, including as follows
Step,
S001, load image;
S002, the image loaded is pre-processed;
S003, image border is determined using function;
S004, position fix is determined according to identified image border;
S005, using identified position fix as input, image is corrected by OpenCV algorithms.
Preferably, the step S002 includes carrying out image white balance, contrast and brightness to image into
Row is adjusted.
Preferably, the S003 includes the following steps,
S003a, binary conversion treatment is carried out to image and obtains binary map;
S003b, it detects the binary map using canny operators and obtains image C;
S003c, using all straight lines in HoughLinesP function check described images C and image D is obtained;
S003d, edge frame is drawn according to image D.
Preferably, the S004 includes the following steps,
Intersection point between the detected straight line of S004a, extraction, and the intersection point extracted is screened;
S004b, it finds out in filtered out point apart from two points of lie farthest away, is made using the two points as diagonal
One rectangle, using made rectangular area as the size of correcting image;
S004c, four vertex for obtaining made rectangle are simultaneously marked one of vertex, with what is marked
Vertex is as azimuthal point.
Preferably, the S005 includes the following steps,
S005a, matrixing is carried out using findHomography function pairs image, obtains transformation matrix;
S005b, using the transformation matrix as input, using warpPerspective function pairs image correct
To correcting image;
S005c, using filter2D function pairs correcting image carry out enhancing filtering obtain final image.
Preferably, image is put down in vain using gray world automatic white balance algorithm in the step S002a
Weighing apparatus.
Preferably, all lines in canny operator detection images are utilized in the S003b.
Preferably, it is utilized detected by HoughLinesP function screening steps S003b in the S003c
Straight line in lines.
A kind of image correction method based on OpenCV algorithms that above-mentioned technical proposal is provided, specifically includes to image
It is pre-processed, different compensation ways is set according to the colour temperature of light during shooting, the image bias colour so as to ensure that is kept away
Exempt from since subtle colour cast causes to generate error in correction and then improves the accuracy of correction, and pass through function check figure
As edge, position fix is determined according to the image border detected, OpenCV is utilized using identified position fix as input
Algorithm corrects picture, so as to eliminate anamorphose caused by the deviation of lens location and fish eye lens, carry
The high quality of picture.
Description of the drawings
Fig. 1 is a kind of flow chart of the image correction method based on OpenCV algorithms of the present invention.
Specific embodiment
With reference to the accompanying drawings and examples, the specific embodiment of the present invention is described in further detail.Implement below
Example is used to illustrate the present invention, but be not limited to the scope of the present invention.
It is as shown in Figure 1 a kind of image correction method based on OpenCV algorithms provided by the present invention, including walking as follows
Suddenly,
S001, load image, the image loaded in this step is the original image (src) that carry out image flame detection.
S002, the image loaded is pre-processed;
Its specific steps includes, and the step S002 includes carrying out white balance, contrast and brightness to image to image
It is adjusted.In the present embodiment, white balance is carried out to image using gray world automatic white balance algorithm, by capillary glass
White balance is carried out to the image in camera lens before the shooting of glass pipe, different compensation ways is set according to the colour temperature of light during shooting,
So as to ensure that image bias colour, avoid since subtle colour cast causes to generate error in correction and then improves correction knot
The accuracy of fruit.
S003, image border is determined using function;
Its specific steps includes, and S003a, binary conversion treatment is carried out to image and obtains binary map, i.e., by the picture on image
The gray value of vegetarian refreshments is set as 0 or 255, that is, whole image is showed apparent black and white effect;S003b, canny is utilized
Operator detects the binary map and obtains image C, that is, utilizes all lines in canny operator detection images;S003c, utilization
All straight lines in HoughLinesP function check described images C simultaneously obtain image D, i.e. profit HoughLinesP functions screening step
Straight line in rapid S003b in detected lines;S003d, edge frame is drawn according to image D, i.e., by drawing a side
The straight line filtered out in step S003c is all enclosed in edge frame by rim frame, wherein the four edges of edge frame by
The straight line filtered out in step S003c outermost point in four orientation of edge frame determines.
S004, position fix is determined according to identified image border;
Its specific steps includes, the intersection point between the detected straight line of S004a, extraction, and the intersection point to being extracted into
Row screening;S004b, it finds out in filtered out point apart from two points of lie farthest away, is made using the two points as diagonal
One rectangle, using made rectangular area as the size of correcting image;S004c, four tops for obtaining made rectangle
Point is simultaneously simultaneously marked one of vertex, using the vertex that is marked as azimuthal point.
S005, using identified position fix as input, image is corrected by OpenCV algorithms.
Its specific steps includes, and S005a, carries out matrixing using findHomography function pairs image, is become
Change matrix;S005b, using the transformation matrix as input, corrected to obtain using warpPerspective function pair images
Correcting image;S005c, using filter2D function pairs correcting image carry out enhancing filtering obtain final image.The tool of this step
Body process is, using rectangle size determined by obtained in S004c four vertex as the size of the image after correction
(dst.size), Mat is utilized::Zero function creations one open the new picture (dst) of blank, by original image (src) and new picture
(dst) findHomography functions are transmitted to as input parameter, transformation matrix is obtained after processing.By original image (src), newly
The transformation matrix that the size (dst.size) and step S005a of image after picture (dst), correction obtain is passed as input
WarpPerspective functions are given, correcting image is obtained after processing;The obtained correcting images of step S005b are passed to
Filter2D functions obtain final image (result) after reinforcement.Photo is corrected by above-mentioned steps, avoids and is clapped
The error that the photo taken the photograph is generated due to deformation.
A kind of image correction method based on OpenCV algorithms provided by the present invention can be used in some precision equipments
Detection field, for example, currently for glass tube Quality Detection used by method it is varied, wherein, be using more
The method directly detected using human eye, but due to light, human eye detection glass tube is being adopted there are the defects of vision blind spot
When being detected with human eye to the quality of glass tube, human eye must specific angle can be just recognized on glass tube the defects of,
The lower human eye that works long hours is easily tired, and using human eye detection can not accurately detect bubble in glass tube and foreign matter,
So as to which testing result reliability is not high.In addition, the method for human eye detection can only be directed to large glass pipe and common quality requirements
Glass tube, and the high standard glass capillary of Bioexperiment, Experiments of Optics can not be detected.
Below for a kind of image correction method based on OpenCV algorithms provided by the present invention in glass capillary product
The application in quality detection field is introduced.When carrying out Quality Detection to glass capillary using visible sensation method, need first to shoot
Go out the integral photograph of glass capillary, then to captured photo binaryzation, and by the result and preset value of image binaryzation
It is compared, so as to judge whether the glass capillary is qualified.But due to the deviation and fish eye lens of the position of camera lens, institute
The photo shot is also typically present deformation, if therefore do not carry out image flame detection to captured photo, and directly to photo into
Row Quality Detection will influence the accuracy of detection.
Specific steps of the method provided by the present invention in glass capillary Quality Detection are briefly introduced below,
It is specifically included,
S001, load image, the image loaded in this step are the original image (src) of captured glass capillary.
S002, the image loaded is pre-processed;
Its specific steps includes, and the step S002 includes carrying out white balance, contrast and brightness to image to image
It is adjusted.In the present embodiment, white balance is carried out to image using gray world automatic white balance algorithm, by capillary glass
White balance is carried out to the image in camera lens before the shooting of glass pipe, different compensation ways is set according to the colour temperature of light during shooting,
So as to ensure that image bias colour, avoid since subtle colour cast causes to generate error in correction and then improves correction knot
The accuracy of fruit.
S003, image border is determined using function;
S004, position fix is determined according to identified image border;
S005, using identified position fix as input, image is corrected by OpenCV algorithms.
Its specific steps includes, and S005a, carries out matrixing using findHomography function pairs image, is become
Change matrix;S005b, using the transformation matrix as input, corrected to obtain using warpPerspective function pair images
Correcting image;S005c, using filter2D function pairs correcting image carry out enhancing filtering obtain final image.The tool of this step
Body process is, using rectangle size determined by obtained in S004c four vertex as the size of the image after correction
(dst.size), Mat is utilized::Zero function creations one open the new picture (dst) of blank, by original image (src) and new picture
(dst) findHomography functions are transmitted to as input parameter, transformation matrix is obtained after processing.By original image (src), newly
The transformation matrix that the size (dst.size) and step S005a of image after picture (dst), correction obtain is passed as input
WarpPerspective functions are given, correcting image is obtained after processing;The obtained correcting images of step S005b are passed to
Filter2D functions obtain final image (result) after reinforcement.By above-mentioned steps before photo three is formed to captured
Photo one and photo two carry out image flame detection, avoid captured photo due to deformation, cause to glass capillary quality
The error of inspection, and then, improve captured photo and the consistency for the glass capillary being detected.
Claims (8)
1. a kind of image correction method based on OpenCV algorithms, which is characterized in that include the following steps,
S001, load image;
S002, the image loaded is pre-processed;
S003, image border is determined using function;
S004, position fix is determined according to identified image border;
S005, using identified position fix as input, image is corrected by OpenCV algorithms.
2. the image correction method according to claim 1 based on OpenCV algorithms, which is characterized in that the step S002
Including carrying out white balance to image, the contrast and brightness of image are adjusted.
3. the image correction method according to claim 1 based on OpenCV algorithms, which is characterized in that the S003 includes
Following steps,
S003a, binary conversion treatment is carried out to image and obtains binary map;
S003b, it detects the binary map using canny operators and obtains image C;
S003c, using all straight lines in HoughLinesP function check described images C and image D is obtained;
S003d, edge frame is drawn according to image D.
4. the image correction method according to claim 1 based on OpenCV algorithms, which is characterized in that the S004 includes
Following steps,
Intersection point between the detected straight line of S004a, extraction, and the intersection point extracted is screened;
S004b, it finds out in filtered out point apart from two points of lie farthest away, one is made using the two points as diagonal
Rectangle, using made rectangular area as the size of correcting image;
S004c, four vertex for obtaining made rectangle are simultaneously marked one of vertex, with the vertex marked
As azimuthal point.
5. the image correction method according to claim 1 based on OpenCV algorithms, which is characterized in that the S005 includes
Following steps,
S005a, matrixing is carried out using findHomography function pairs image, obtains transformation matrix;
S005b, using the transformation matrix as input, corrected and rectified using warpPerspective function pair images
Positive image;
S005c, using filter2D function pairs correcting image carry out enhancing filtering obtain final image.
6. the image correction method according to claim 1 based on OpenCV algorithms, which is characterized in that the step
White balance is carried out to image using gray world automatic white balance algorithm in S002a.
7. the image correction method according to claim 3 based on OpenCV algorithms, which is characterized in that in the S003b
Utilize all lines in canny operator detection images.
8. the image correction method according to claim 7 based on OpenCV algorithms, which is characterized in that in the S003c
Utilize the straight line in lines detected in HoughLinesP function screening steps S003b.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711490245.7A CN108171669A (en) | 2017-12-29 | 2017-12-29 | A kind of image correction method based on OpenCV algorithms |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711490245.7A CN108171669A (en) | 2017-12-29 | 2017-12-29 | A kind of image correction method based on OpenCV algorithms |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108171669A true CN108171669A (en) | 2018-06-15 |
Family
ID=62516910
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201711490245.7A Pending CN108171669A (en) | 2017-12-29 | 2017-12-29 | A kind of image correction method based on OpenCV algorithms |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108171669A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110516531A (en) * | 2019-07-11 | 2019-11-29 | 广东工业大学 | A kind of recognition methods of the dangerous mark based on template matching |
CN110674815A (en) * | 2019-09-29 | 2020-01-10 | 四川长虹电器股份有限公司 | Invoice image distortion correction method based on deep learning key point detection |
CN112067253A (en) * | 2020-06-03 | 2020-12-11 | 翔升(上海)电子技术有限公司 | Camera calibration method based on machine vision |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103279924A (en) * | 2013-05-24 | 2013-09-04 | 中南大学 | Correction method for patent certificate image with any inclination angle |
US20130242054A1 (en) * | 2012-03-15 | 2013-09-19 | Fuji Xerox Co., Ltd. | Generating hi-res dewarped book images |
CN103745221A (en) * | 2014-01-08 | 2014-04-23 | 杭州晟元芯片技术有限公司 | Two-dimensional code image correction method |
CN105279787A (en) * | 2015-04-03 | 2016-01-27 | 北京明兰网络科技有限公司 | Method for generating three-dimensional (3D) building model based on photographed house type image identification |
CN106407983A (en) * | 2016-09-12 | 2017-02-15 | 南京理工大学 | Image body identification, correction and registration method |
-
2017
- 2017-12-29 CN CN201711490245.7A patent/CN108171669A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20130242054A1 (en) * | 2012-03-15 | 2013-09-19 | Fuji Xerox Co., Ltd. | Generating hi-res dewarped book images |
CN103279924A (en) * | 2013-05-24 | 2013-09-04 | 中南大学 | Correction method for patent certificate image with any inclination angle |
CN103745221A (en) * | 2014-01-08 | 2014-04-23 | 杭州晟元芯片技术有限公司 | Two-dimensional code image correction method |
CN105279787A (en) * | 2015-04-03 | 2016-01-27 | 北京明兰网络科技有限公司 | Method for generating three-dimensional (3D) building model based on photographed house type image identification |
CN106407983A (en) * | 2016-09-12 | 2017-02-15 | 南京理工大学 | Image body identification, correction and registration method |
Non-Patent Citations (2)
Title |
---|
H.B.MITCHELL: "《图像融合——理论、技术与应用》", 31 May 2016, 国防工业出版社 * |
刘瑞祯等: "《OpenCV教程——基础篇》", 30 June 2007, 北京航空航天大学出版社 * |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110516531A (en) * | 2019-07-11 | 2019-11-29 | 广东工业大学 | A kind of recognition methods of the dangerous mark based on template matching |
CN110516531B (en) * | 2019-07-11 | 2023-04-11 | 广东工业大学 | Identification method of dangerous goods mark based on template matching |
CN110674815A (en) * | 2019-09-29 | 2020-01-10 | 四川长虹电器股份有限公司 | Invoice image distortion correction method based on deep learning key point detection |
CN112067253A (en) * | 2020-06-03 | 2020-12-11 | 翔升(上海)电子技术有限公司 | Camera calibration method based on machine vision |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106600644B (en) | Parameter correction method and device for panoramic camera | |
CN109919933B (en) | VR device, picture detection method and device thereof, and computer-readable storage medium | |
CN112669394B (en) | Automatic calibration method for vision detection system | |
CN110838149B (en) | Camera light source automatic configuration method and system | |
CN108171669A (en) | A kind of image correction method based on OpenCV algorithms | |
US20100225666A1 (en) | Digital optical comparator | |
CN104361580B (en) | Projected image real-time correction method based on planar screen | |
JP4436810B2 (en) | Display multi-angle measuring system and method | |
CN106488202B (en) | Image processing device and image processing method for red, green, blue and infrared light sensor | |
CN110261069B (en) | Detection method for optical lens | |
CN109660736A (en) | Method for correcting flat field and device, image authentication method and device | |
CN111062961A (en) | Contact lens edge defect detection method based on deep learning | |
CN109509148A (en) | A kind of panoramic looking-around image mosaic fusion method and device | |
CN111028187A (en) | Light ray self-adaptive airborne double-light image reconnaissance device and method | |
CN108508022B (en) | Multi-camera splicing imaging detection method | |
CN116721039B (en) | Image preprocessing method applied to automatic optical defect detection | |
CN108965749A (en) | Defect pixel detection and means for correcting and method based on texture recognition | |
JP2012165147A5 (en) | Image processing apparatus, control method therefor, and imaging apparatus | |
TWI598655B (en) | Automatic focusing method and automatic focusing system | |
CN109561292A (en) | A kind of white balancing treatment method and device for camera system | |
TWI416433B (en) | Method of detecting red eye image and apparatus thereof | |
CN108012133A (en) | Image processing method, device, computer-readable recording medium and computer equipment | |
JP5163940B2 (en) | Image quality inspection apparatus and image quality inspection method | |
TW201820856A (en) | Inspection system for inspecting projected image definition of projector and inspection method thereof enabling user to learn about definition level of projected image for adjusting focal length of projector in real time | |
JP6561479B2 (en) | Imaging device capable of color shading correction |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
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: 20180615 |
|
RJ01 | Rejection of invention patent application after publication |