System and method for correcting an image

A method for correcting an image of a physical object first captures images of a circle and a rectangle set of a calibration plate placed on a measurement machine, and determines correction data using the images of the circle and the rectangle. The method further corrects the image of the physical object captured by the measurement machine according to the correction data, and displays a corrected image of the physical object.

BACKGROUND

1. Technical Field

Embodiments of the present disclosure generally relate to data correction technique, and more particularly, to a system and method for correcting an image captured by a measurement machine.

2. Description of Related Art

In the precision measurement field, a charge coupled device (CCD) installed in a measurement machine can capture an image of a physical object through focusing on the physical object by a lens. The measurement machine determines precision of the physical object via measuring the image of the physical object. However, due to some factors, for example, deviation caused by the CCD and the lens, the image of the physical object may be distorted.

DETAILED DESCRIPTION

All of the processes described below may be embodied in, and fully automated via, function code modules executed by one or more general purpose computers or processors. The code modules may be stored in any type of computer-readable medium or other computer storage device. Some or all of the methods may alternatively be embodied in specialized computer hardware.

FIG. 1is a block diagram of one embodiment of a system100for correcting an image captured by a measurement machine2. In one embodiment, the system100includes a computer100and the measurement machine2. A calibration plate6is placed on a work plane of the measurement machine2. The measurement machine2has a coordinate system7. A charge coupled device (CCD)3coupled with a lens4is installed on Z-axis of the measurement machine2for capturing images of the calibration plate6and physical objects, such as a physical object8. Furthermore, a light source5is installed on the Z-axis of the measurement machine2to provide light source when capturing the images of the calibration plate6and the physical object8.

The computer100is connected to the measurement machine2. In one embodiment, the computer100includes an image acquiring card10and a storage device11. The image acquiring card10is connected to the CCD3electronically, and receives captured images transferred from the CCD3. The captured images can be displayed on a monitor (not shown) of the computer1.

The storage device11may be a hard disk drive, a floppy disk drive, and so on, which stores at least one operational program used to control and implement one or more systems and methods of the present disclosure. In one embodiment, the operational program is an image correction program110for correcting the captured image of the physical object8.

It may be understood that, one or more specialized or general purpose processors, such as a processor12, in the computer1, may be used to execute one or more computerized instructions for the function modules of the image correction program110.

FIG. 2illustrates the calibration plate6. The calibration plate6includes one or more rectangles sets61and one or more circles62with different sizes. Each of the rectangles sets61includes a plurality of rectangles having the same size, which is illustrated inFIG. 3. The horizontal space or the vertical space between any two adjacent rectangles in each rectangle set61is uniform.

FIG. 4is a block diagram of one embodiment of function modules of the image correction program110inFIG. 1. In one embodiment, the image correction program110includes a coordinate system transforming module111, a controlling module112, a scaling computing module113, a correction data computing module114, a storing module115, an image correcting module116, and a displaying module117.

The coordinate system transforming module111is operable to transform the coordinate system7of the measurement machine2to a new coordinate system whose origin is the center of a preset circle62selected from the calibration plate6. All operations described below are executed using the new coordinate system.

The controlling module112is operable to control movement of the Z-axis of the measurement machine2, to focus the lens4on one of the rectangle sets61, one of the circles62, or the physical object8, and enable the CCD3to capture an image of the rectangle set61, the circle62, or the physical object8. Furthermore, the controlling module112is operable to control the light source5to emit light with a predetermined intensity (brightness) when capturing the image of the rectangle set61, the circle62, or the physical object8by the lens4.

The scaling computing module113is operable to determine a scaling of the lens4. It may be understood that, the scaling of the lens4is the ratio of a size of an object (e.g., the circle62or the physical object8) to a size of an image of the object captured by the lens4and the CCD3.

The correction data computing module114is operable to determine correction data for correcting the image of the physical object8according to the scaling of the lens4using the calibration plate6. Further details of how to determine the correction data will be explain below.

The storing module115is operable to store the correction data into the storage device11of the computer1.

The image correcting module116is operable to correct the image of the physical object8using the correction data.

The displaying module117is operable to display a corrected image of the physical object8through the monitor of the computer1.

FIG. 5is a flowchart illustrating one embodiment of a method for determining the correction data. Depending on the embodiment, additional blocks in the flow ofFIG. 5may be added, others removed, and the ordering of the blocks may be changed.

In block S10, the calibration plate6is disposed on the work plane of the measurement machine2, and one circle62is selected (hereinafter referred to as “the selected circle”) from the calibration plate6.

In block S11, the coordinate system transforming module111transforms the coordinate system7of the measurement machine2to a new coordinate system whose origin is the center of the selected circle62of the calibration plate6. All operations described below are executed using the new coordinate system.

In block S12, the controlling module112controls the Z-axis of the measurement machine2to move, thereby, focusing the lens4on the selected circle62, and enabling the CCD3to capture an image of the selected circle62.

In block S13, the controlling module112further adjusts the light source5of the measurement machine2to emit light with suitable brightness when focusing on the selected circle62.

In block S14, the scaling computing module113determines an original scaling of the lens4. The method detailing block S14is described inFIG. 6below.

In block S15, the correction data computing module114determines first correction data and second correction data according to the original scaling of the lens4using the calibration plate6. The method detailing block S11is described inFIG. 7below.

In block S16, the correction data computing module114further determines third correction data using the first correction data and the second correction data. The method detailing block S16is described inFIG. 8below.

In block S17, the scaling computing module113determines an accurate scaling of the lens4according to the first correction data, the second correction data, and the third correction data. The method detailing block S17is described inFIG. 9below.

In block S18, the storing module115stores the correction data and the accurate scaling of the lens4into the storage device11of the computer1. The correction data includes the first correction data, the second correction data, and the third correction data.

FIG. 6is a flowchart illustrating one embodiment of a method detailing block S14ofFIG. 5. Depending on the embodiment, additional blocks in the flow ofFIG. 6may be added, others removed, and the ordering of the blocks may be changed.

In block S140, the lens4focuses on the selected circle62of the calibration plate6, and the CCD3captures a first image of the selected circle62. It may be understood that, the first image of the selected circle62includes an image circle.

In block S141, the scaling computing module113determines boundary points of the image circle in the first image of the selected circle62according to gray values of points in the first image, and fits the boundary points to form a first fitting circle. In one embodiment, in order to determine the boundary points, the scaling computing module113creates a straight line on the first image of the selected circle62, compares gray values of points of the straight line, and selects one or more points whose gray value is distinctly different from their adjacent point's gray value. For example, if the gray values of the points of the straight line are respectively: P0=0, P2=0, P3=1, P4=0, P5=2, P6=3, P7=240, P8=245, P9=255, P10=255, P11=254, P12=254, P13=253, P14=250, P15=2, then point “P7” and point “P15” are determined as boundary points. It may be understood that, the scaling computing module113creates a plurality of straight lines to determine a plurality of boundary points.

In block S142, the scaling computing module113determines the original scaling by computing the ratio between a diameter of the first fitting circle and an actual/real diameter of the selected circle62of the calibration plate6.

FIG. 7is a flowchart illustrating one embodiment of a method detailing block S15ofFIG. 5. Depending on the embodiment, additional blocks in the flow ofFIG. 7may be added, others removed, and the ordering of the blocks may be changed.

In block S150, the controlling module112controls the Z-axis of the measurement machine2to move for enabling the lens4to focus on a selected rectangle set61, and enabling the CCD3to capture a first image of the selected rectangle set61. It may be understood that, the first image of the selected rectangle set61includes an image rectangle set, and the image rectangle set includes a plurality of image rectangle.

In block S151, the correction data computing module114determines boundary points of each image rectangle in the first image of the selected rectangle set61. The method of determining boundary points of each image rectangle is illustrated as follows, which refers toFIG. 11.

The correction data computing module114firstly obtains a center “P” of the first image of the selected rectangle set61, and obtains an image rectangle which is nearest to the point “P” (hereinafter referred to as “the nearest rectangle”) from the first image of the selected rectangle set61. The correction data computing module114further determines a center of the nearest rectangle by fitting a circle, and creates orthogonal/perpendicular lines intersecting the center of the nearest rectangle figure. The correction data computing module114then determines boundary points in each line according to gray values. The boundary points may include P1_top, P2_top, P1_bottom, P2_bottom, P1_left, P2_left, P1_right, and P2_right. Furthermore, the correction data computing module114computes a length and a width of the image rectangle according to the P1_top, P1_bottom, P1_left, and P1_right. In addition, the correction data computing module114computes a horizontal space and a vertical space between two adjacent image rectangles in the first image of the selected rectangle set61according to P1_top, P2_top, and P1_left, P2_left. Moreover, the correction data computing module114computes a center of each image rectangle in the first image of the selected rectangle set61according to the center of the nearest rectangle, the length and the width of the image rectangle, and the horizontal space and the vertical space. Finally, the correction data computing module114creates orthogonal perpendicular lines intersecting the center of each image rectangle, and determines boundary points of each image rectangle from the lines according to gray values. The boundary point in each line may be presented as Pn_top, Pn_bottom, Pn_left, or Pn_right.

In block S152, the correction data computing module114determines a center of each image rectangle in the first image of the selected rectangle set61anew according to the boundary points Pn_top, Pn_bottom, Pn_left, and Pn_right.

In block S153, the correction data computing module114computes a coordinate value of the center of each image rectangle in the first image of the selected rectangle set61according to the coordinate values of the boundary points Pn_top, Pn_bottom, Pn_left, and Pn_right. The coordinate value of the center of each image rectangle in the first image of the selected rectangle set61is the first correction data.

In block S154, the correction data computing module114determines a center of the image rectangle set according to the center of each image rectangle in the first image of the selected rectangle set61, and the lens4focuses on the selected rectangle set61again according to the center of the image rectangle set and the original scaling.

In block S155, the CCD3captures a second image of the selected rectangle set61, and determines boundary points of each image rectangle in the second image of the selected rectangle set61. The method of determining boundary points of each image rectangle has been described above.

In block S156, the correction data computing module114determines a center of each image rectangle in the second image of the selected rectangle set61according to the boundary points.

In block S157, the correction data computing module114computes a coordinate value of the center of each image rectangle in the second image of the selected rectangle set61according to the coordinate values of the boundary points. The coordinate values of the center of each image rectangle in the second image of the selected rectangle set61is the second correction data.

FIG. 8is a flowchart illustrating one embodiment of a method detailing block S16ofFIG. 5. Depending on the embodiment, additional blocks in the flow ofFIG. 8may be added, others removed, and the ordering of the blocks may be changed.

In block S160, the correction data computing module114obtains a center of the second image of the selected rectangle set61, and obtains an original coordinate value of the center of the second image of the selected rectangle set61.

In block S161, the correction data computing module114obtains four image rectangles adjacent to the center of the second image of the selected rectangle set61.

In block S162, the correction data computing module114takes coordinate values (ax1, ay1), (ax2, ay2), (ax3, ay3), and (ax4, ay4) of the centers of the four image rectangles in the second image from the second correction data as first data.

In block S163, the correction data computing module114takes coordinate values (bx1, ay1), (bx2, ay2), (bx3, by3), and (bx4, by4) of the centers of corresponding four image rectangles in the first image from the first correction data as second data.

In block S164, the correction data computing module114corrects the original coordinate value of the center of the second image of the selected rectangle set61according the first data, the second data, and a correcting formula for obtaining a corrected coordinate value of the center of the second image of the selected rectangle set61. In one embodiment, the correcting formula is a bilinear transformation formula as follows:

According to the above correcting formula, by replacing (x′,y′) with the first data, and replacing (x,y) with the second data, the parameters C1˜C8can be solved. Finally, by introducing the parameters C1˜C8and the original coordinate value of the center of the second image of the selected rectangle set61into the correcting formula:

{x′=C⁢⁢1⁢x+C⁢⁢2⁢y+C⁢⁢3⁢xy+C⁢⁢4y′=C⁢⁢5⁢x+C⁢⁢6⁢y+C⁢⁢7⁢xy+C⁢⁢8,
the corrected coordinate value (x′,y′) of the center of the second image of the selected rectangle set61can be solved.

In block S165, the correction data computing module114determines the third correction data by computing a difference between the original coordinate value and the corrected coordinate value of the center of the second image of the selected rectangle set61.

FIG. 9is a flowchart illustrating one embodiment of a method detailing block S17ofFIG. 5. Depending on the embodiment, additional blocks in the flow ofFIG. 9may be added, others removed, and the ordering of the blocks may be changed.

In block S170, the scaling computing module113obtains an original coordinate value of the center of the image circle in the first image of the selected circle62, and computes an corrected coordinate value of the center of the image circle in the first image of the selected circle62according to the original coordinate value, the first correction data, the second correction data, the third correction data, and the correcting formula. The process of computing the corrected coordinate value of the center of the image circle in the first image of the selected circle62is similar to the process ofFIG. 8described above.

In block S171, the lens4focuses on the selected circle62again according to the original scaling and the corrected coordinate value of the center of the image circle in the first image of the selected circle62.

In block S172, the CCD3captures a second image of the selected circle62. It may be understood that, the second image of the selected circle62includes an image circle.

In block S173, the scaling computing module113determines boundary points of the image circle in the second image of the selected circle62according to gray values, and fits the boundary points to form a second fitting circle.

In block S174, the scaling computing module113determines the accurate scaling of the lens4by computing the ratio of a diameter of the second fitting circle and a diameter of the selected circle62.

FIG. 10is a flowchart illustrating one embodiment of a method for correcting an image using the correction data computed inFIG. 5. Depending on the embodiment, additional blocks in the flow ofFIG. 10may be added, others removed, and the ordering of the blocks may be changed.

In block S20, the lens4focuses on the physical object8placed on the measurement machine2according to the accurate scaling, and the CCD3captures an image of the physical object8.

In block S21, the image correcting module116selects a point “A” from the image of the physical object8.

In block S22, the image correcting module116obtains an original coordinate value of the point “A.”

In block S23, the image correcting module116compares the original coordinate value of the point “A” with the first correction data, so as to obtain four coordinate values from the first correction data that are adjacent to the original coordinate value of the point “A”. For example, if the original coordinate value of the point “A” is (5,5), and the first correction data includes (4,4), (4,5), (4,6), (5,4), (5,6), (6,4), (6,5), and (6,6), the coordinate values that are adjacent to the original coordinate value (5,5) are (4,5), (5,4), (6,5), and (5,6).

In block S24, the image correcting module116compares the original coordinate value of the point “A” with the second correction data, so as to obtain four coordinate values from the second correction data that are adjacent to the original coordinate value of the point “A.”

In block S25, the image correcting module116corrects the original coordinate value of the point “A” according to the original coordinate value, the four coordinate values obtained from the first correction data and the four coordinate values obtained from the second correction data using the bilinear transformation formula for obtaining a corrected coordinate value of the point “A.”

In block S26, the image correcting module116computes an accurate coordinate value of the point “A” by adding the third correction data to the corrected coordinate value of the point “A.”

In block S27, the image correcting module116judges if any other points to be corrected exists in the image of the physical object8. If exist, the flow returns to block S21described above. Otherwise, if none exists, the flow moves to block S28described below.

In block S28, the displaying module117displays a corrected image of the physical object8through the monitor of the computer1.