A kind of fast phase unwrapping algorithm
Technical field
The invention belongs to optical three-dimensional measurement technical fields, and in particular to a kind of fast phase unwrapping algorithm.
Background technique
Phase- un- wrapping is one of the key link of fringe projection three-dimensional measurement technology, how effectively and rapidly to carry out phase
Position unpacking is the emphasis research topic of this field researcher.By analyzing domestic and international present Research and developments
Research, Phase- un- wrapping technology includes time domain and airspace unwrapping algorithm at present.Airspace unpacks package method and is also easy to produce pixel error
Transmitting is easy failure when measuring complicated face shape, so time phase unpacks package method and more often uses.Time domain unpacking can be compared with
Benefit manages Surfaces of Unusual Shape, but there is the problems such as acquisition image width number is excessive, data volume is big and the processing time is long, and is mostly static survey
Amount.Therefore, the method for how carrying out Phase- un- wrapping with less projected fringe frame number, becomes the breach of this field.
The present invention proposes a kind of fast phase unwrapping algorithm, and the method need to only project N width sine phase shift bar graph, energy
Phase solution and unpacking are carried out, phase recovery effect is suitable with conventional method, but has great advantage in calculating speed, fits
Close the application field for having quick three-dimensional measurement demand.
Summary of the invention
The purpose of the present invention is to provide a kind of fast phase unwrapping algorithm, the method need to only project N width sine phase shift
Bar graph just can be carried out phase solution and unpacking, and phase recovery effect is suitable with conventional method, but has in calculating speed
Great advantage is suitble to the application field for having quick three-dimensional measurement demand.
To achieve the goals above, the invention adopts the following technical scheme: a kind of fast phase unwrapping algorithm, the party
Method includes the following steps: that the N width sine phase shift bar graph that computer generates successively is projected to measured object body surface with projector by (1)
Face is acquired every width projected image with camera;(2) phase shift algorithm is walked using N to collected N width sine phase shift bar graph
Solve wrapped phase;(3) Mask is made using N width sine streak figure;(4) it is asked using wrapped phase and connected component labeling algorithm
Solve fringe order;(5) absolute phase that Phase- un- wrapping acquisition is used for three-dimensional reconstruction is carried out according to fringe order.
Step 1: computer N width sine phase shift bar graph generated is successively projected to measured object body surface with projector
Face is acquired every width projected image with camera, obtains N width by the modulated bar graph of object under test, light distribution is such as
Under:
In formula (1), Ik(x, y) is the light intensity that pixel coordinate is (x, y) in the sinusoidal phase shift bar graph of camera acquisition, I'
(x, y) is average gray, and I " (x, y) is streak amplitude,For object wrapped phase to be asked,For phase shift size;
Step 2: N width sine phase shift bar graph collected to step 1 solves package phase using N step phase shift algorithm
Position, shown in method for solving such as formula (2):
Step 3: production Mask, N width sine phase shift bar graph collected to step 1 camera first are summed, are taken
Average gray is calculated using formula (3) in average value:
Then average gray figure done into binary image processing using formula (4), obtain for divide object phase range,
Eliminate the Mask of background;
Imask(x, y)=im2bw [I'(x, y)] (4)
Step 4: fringe order K is solved, be limited in by the wrapped phase that formula (2) arctan function solves [-
π, π], firstly, we press formula (5) respectively to wrapped phase and formula (6) carries out positive and negative binary conversion treatment twice, respectively obtain
Two opposite binarization resultsWith
Then, by the result after above-mentioned binaryzationWithRespectively with Mask convolution, knot after obtaining convolution
FruitWithAs shown in formula (7) and formula (8):
Then, fringe order is determined using connected component labeling algorithm;We use MATLAB image processing toolbox
Bwlabel function marks respectivelyWithThe connected domain of image, the function are substantially to mark two-dimentional two-value
Connected domain in image;The first step is first marked with bwlabel functionIt can be obtained by first initial connected domain
Mark value Kright(x, y), it corresponds to the right half part of each fringe order, left-half zero, as shown in formula (9):
Second step is equally marked with bwlabel functionIt can be obtained by second initial connected component labeling
Value Kleft(x, y), it corresponds to the left-half of each fringe order, right half part zero, as shown in formula (10):
Obtain the two initial markers values, so that it may using formula (11), by the two values, corresponding be added merges pixel-by-pixel,
Complete fringe order is calculated;
K (x, y)=Kright(x,y)+Kleft(x,y) (11)
Step 5: absolute phase solves, once acquiring fringe order K, the absolute phase Φ (x, y) of object can pass through
Formula (12) acquires:
The invention has the advantages that (1) present invention uses phase shift method, measurement result is rung smaller, strong robustness by environment shadow;
And as a result accurately error propagation directly will not be generated using wrapped phase solution fringe order;(2) present invention only needs N width sinusoidal
Phase shift bar graph just can be carried out phase solution and unpacking, and phase recovery effect is suitable with conventional method;(3) present invention meter
Calculation speed is fast, has potential application prospect and practical value in the quick of dynamic object, real-time three-dimensional measurement.
Detailed description of the invention
Fig. 1 is three-dimension measuring system schematic diagram of the invention.It is made of projector, camera, computer etc..Projector is successively
N width sine phase shift bar graph is projected, camera is shot in other direction by the modulated deforming stripe image of object.Projector and phase
The optical axis of machine intersects at the point of the O in plane, and projector and camera are sustained height, and the distance between they are d, they arrive reference
The distance of plane is L.The height calculation formula of testee are as follows:
Wherein: f is the phase shift fringe frequency in reference planes,It is corresponding for body surface image and reference planes image
The continuous phase potential difference of point.Parameter L, d and f are obtained by calibration.
Fig. 2 is execution flow chart of the invention.
Fig. 3 is in the embodiment of the present invention, with camera acquisition by the modulated sinusoidal phase shift stripe pattern of object, wherein scheming
3 (a) be bar graph I1, Fig. 3 (b) is bar graph I2, Fig. 3 (c) is bar graph I3。
Fig. 4 is the calculated result of step 2 and step 3 in the embodiment of the present invention, and wherein Fig. 4 (a) is what step 2 acquired
Wrapped phase, Fig. 4 (b) are the average gray figure that step 3 acquires, and Fig. 4 (c) is the Mask that step 3 acquires.
Fig. 5 is the calculated result of step 4 and step 5 in the embodiment of the present invention, wherein Fig. 5 (a) and Fig. 5 (b) is respectively
It is acquired for step 4WithFig. 5 (c) and Fig. 5 (d) is respectively the K that step 4 acquiresright(x,y)
And Kleft(x, y), Fig. 5 (e) are the fringe order that step 4 acquires, and Fig. 5 (f) is the object absolute phase that step 5 acquires.
Fig. 6 is the final measurement in the embodiment of the present invention.
Specific embodiment
It is readily appreciated that, technical solution according to the present invention, in the case where not changing connotation of the invention, this field
Those skilled in the art can imagine the present invention be used for three-dimensional measurement numerous embodiments.Therefore, embodiment party in detail below
Formula and attached drawing are only the exemplary illustrations to technical solution of the present invention, and are not to be construed as whole of the invention or are considered as pair
The limitation or restriction of technical solution of the present invention.Example of the invention is described in further detail below in conjunction with Detailed description of the invention, but
This example is not intended to restrict the invention, all using similar structure and its similar variation of the invention, should all be included in the present invention
Protection scope.
In conjunction with Fig. 2 execution flow chart, a kind of fast phase unwrapping algorithm of the present invention, steps are as follows:
Step 1: computer N width sine phase shift bar graph generated is successively projected to measured object body surface with projector
Face is acquired every width projected image with camera, obtains N width by the modulated bar graph of object under test, light distribution is such as
Under:
In formula (1), Ik(x, y) is the light intensity that pixel coordinate is (x, y) in the sinusoidal phase shift bar graph of camera acquisition,
In, I'(x, y) it is average gray, I " (x, y) is streak amplitude,For object wrapped phase to be asked,For phase shift size;
Step 2: N width sine phase shift bar graph collected to step 1 solves package phase using N step phase shift algorithm
Position, shown in method for solving such as formula (2):
Step 3: production Mask, N width sine phase shift bar graph collected to step 1 camera first are summed, are taken
Average gray is calculated using formula (3) in average value:
Then average gray figure done into binary image processing using formula (4), obtain for divide object phase range,
Eliminate the Mask of background;
Imask(x, y)=im2bw [I'(x, y)] (4)
Step 4: fringe order K is solved, be limited in by the wrapped phase that formula (2) arctan function solves [-
π, π], firstly, we press formula (5) respectively to wrapped phase and formula (6) carries out positive and negative binary conversion treatment twice, respectively obtain
Two opposite binarization resultsWith
Then, by the result after above-mentioned binaryzationWithRespectively with Mask convolution, knot after obtaining convolution
FruitWithAs shown in formula (7) and formula (8):
Then, fringe order is determined using connected component labeling algorithm;We use MATLAB image processing toolbox
Bwlabel function marks respectivelyWithThe connected domain of image, the function are substantially to mark two-dimentional two-value
Connected domain in image;The first step is first marked with bwlabel functionIt can be obtained by first initial connected domain
Mark value Kright(x, y), it corresponds to the right half part of each fringe order, left-half zero, as shown in formula (9):
Second step is equally marked with bwlabel functionIt can be obtained by second initial connected component labeling
Value Kleft(x, y), it corresponds to the left-half of each fringe order, right half part zero, as shown in formula (10):
Obtain the two initial markers values, so that it may using formula (11), by the two values, corresponding be added merges pixel-by-pixel,
Complete fringe order is calculated;
K (x, y)=Kright(x,y)+Kleft(x,y) (11)
Step 5: absolute phase solves, once acquiring fringe order K, the absolute phase Φ (x, y) of object can pass through
Formula (12) acquires:
Effect of the present invention can be further illustrated by following instance (as N=3):
Firstly, computer three width sine phase shift bar graph generated is successively projected to measured object body surface using projector
Face, camera are successively acquired by the modulated stripe pattern of object.Wherein, Fig. 3 (a) is bar graph I1, Fig. 3 (b) is bar graph I2,
Fig. 3 (c) is bar graph I3。
Then, it is calculated according to step 2 and step 3, obtains calculated result.Wherein, Fig. 4 (a) acquires for step 2
Wrapped phase, Fig. 4 (b) is the average gray figure that acquires of step 3, and Fig. 4 (c) is the Mask that step 3 acquires.
Finally, being calculated according to step 4 and step 5, calculated result is obtained.Wherein, Fig. 5 (a) and Fig. 5 (b) difference
It is acquired for step 4WithFig. 5 (c) and Fig. 5 (d) is respectively the K that step 4 acquiresright(x, y) and
Kleft(x, y), Fig. 5 (e) are the fringe order that step 4 acquires, and Fig. 5 (f) is the object absolute phase that step 5 acquires.
Fig. 6 is the final measurement in the embodiment of the present invention.