Method for three-dimensional measurement based on positive and inverse code color encoding stripes
Technical field
The invention belongs to the technical field of three-dimensional information reconstruct, by the testee surface being throwed successively two groups of coloud coding stripeds of radix-minus-one complement each other, in conjunction with four width of cloth phase-shift methods, realized the accurate three-dimensional of object with coloured surface is measured and the method for reconstruct, related in particular to a kind of method for three-dimensional measurement based on positive and inverse code color encoding stripes.
Background technology
In recent years, the color image processing development is rapid, and the application in the three-dimensional measurement technology is also increasingly extensive and ripe.Chromatic grating technology in the structured light method is the importance that Color Image Processing is used in the three-dimensional measurement.Using color fringe coding is that the purpose of projection chromatic grating is, the color fringe pattern of arranging according to certain rule by the some width of cloth of projection on testee, and use the colored CCD images acquired, and analysis obtains information such as the phase place, height of object.The advantage of coloud coding striped is to utilize the striped color to write down the phase information of more testee, reaches the purpose that reduces image acquisition quantity, improves the phase method real-time.But the coloud coding striped is also easier to be subjected to the influence of testee surface color and to cause the erroneous judgement of color, has brought bigger challenge to the deviser.How seeking balance between efficiency of measurement and quality is obtained gratifying measurement result, is one of the focus of current research and important directions.
Three-D profile detects and reconfiguration technique is a branch of computer image processing technology, be that computer vision and computer graphic image are handled a research direction that combines, it all has a wide range of applications in fields such as the production automation, robot vision, CAD, virtual reality and the diagnosis of medical science reflection.
The optical grating projection method has the complete noncontact of testing process, data space resolution height, disposable moment projection and realizes that directly the three dimensions body form detects and obtain the characteristics of three-dimensional information.Have multiple advantages such as low, with low cost to environmental requirement, that use is easy to operate in actual applications.
In grating fringe figure, add known or unknown Chang Xiangwei by giving the field of behaviour to be asked, obtain new bar graph, promptly increase solving condition.Thisly increase some constant phase and obtain several bar graphs, be called phase-shift method in order to find the solution the method for the field of behaviour by the bar graph field of behaviour being carried out phase shift.Phase-shift method can provide than the more high-precision result of additive method, the more important thing is, it does not have the phase symbol ambiguity problem.This is because several phase shifts figure provides more information than single width figure.The phase value that obtains by said method is (wrapped) that folds in the scope of-π~π, in order to obtain the unique phase value of the whole audience, before from PHASE DISTRIBUTION, deriving measured parameter, must go out 2 unknown π multiple transition to all pixel identification, thus the phase decoding that obtains restoring.This process is called a phase demodulation (phase unwrapping) or restore mutually the position.
In the three-dimensional measurement process, color images is a very important link.Color images is the identification on each striped color of colored strip encoding and border in the coloud coding stripe pattern that colored CCD is collected, and its quality quality directly affects the decoding rate and the decode precision of coloud coding striped, finally influences the precision of three-dimensional measurement.
Color image segmentation method commonly used is carrying out under the RGB color space He under the HSI color space usually.Color image segmentation method under the RGB color space comprise to R, G, three components of B carry out respectively iteration threshold cut apart, based on the cutting apart of color yearning between lovers coefficient, cut apart etc. based on the adaptive threshold in zone, the color image segmentation method under the HSI color space comprises that it serves as according to carrying out many Threshold Segmentation etc. that H, S, three components of I are regularly carried out associating two dimension or 3-D histogram that iteration threshold cuts apart, forms with H, S, three components of I respectively.Wherein based on the cutting apart of color yearning between lovers coefficient, cut apart the dividing method that is based on the zone, all the other several belonging to based on histogrammic dividing method based on the adaptive threshold in zone.In the dividing method based on the zone, the differentiation of each pixel color of image depends on the color of adjacent pixels on its spatial relationship or the color after the differentiation, is easy to cause the excessive transmission of noise, phenomenons such as backguy occur, and is also not accurate enough to the judgement of color.In histogrammic dividing method, the differentiation of each pixel color of image only depends on the histogram of each component under the employed color space, and promptly the statistical distribution of each component value does not have direct relation and be adjacent color of pixel, has reduced the transmission of noise.But for testee with coloured surface, the color that projects its surperficial coloud coding striped can be subjected to the influence of object color and change, make that the color statistical distribution also changes in the image that collects, cause the threshold value that obtains according to each histogram of component inaccurate, cut apart the generation gross differences.In addition, the purpose of color images is the color that identification projects the coloud coding striped on testee surface in the three-dimensional measurement, and ignore the color of testee, realized cutting apart accurately based on histogrammic color image segmentation method even use, what obtain also is color after changing, if the testee color coloud coding striped color distinction surperficial with it is bigger, color after the variation and coloud coding striped color distinction also can be bigger, still can cause serious erroneous judgement.
In sum, the color images in the three-dimensional measurement mainly needs to solve the problem of three aspects: one, should make and cut apart based on single pixel, i.e. the judgement of each pixel color and other color of pixel are irrelevant, can avoid the transmission of noise like this; Two, it is more accurate each color of pixel to be judged; Three, uneven illumination in the three-dimensional measurement process and testee surface color are the factors that should ignore in color images, can be considered noise, should avoid the interference of these factors to segmentation result when cutting apart as far as possible.
Summary of the invention
Technical matters:, the object of the present invention is to provide a kind of method for three-dimensional measurement based on positive and inverse code color encoding stripes at existing in prior technology shortcoming and restriction.
Technical scheme: the present invention designs a kind of by the testee surface with coloured surface being throwed successively two groups of coloud coding stripeds of radix-minus-one complement each other, in conjunction with four width of cloth phase-shift methods, make color images not be subjected to the influence of testee surface color and illumination, color and border accuracy of judgement to striped among the main color strip encoding figure, and then improved the accuracy of decoding, realized the accurate three-dimensional of object with coloured surface is measured and the method for reconstruct, the method is selected two width of cloth for use, and coloud coding bar graph and 90 ° of phase shift stripeds of four width of cloth bands of radix-minus-one complement are projected in the testee surface with coloured surface successively each other, and with two width of cloth each other the width of cloth in the coloud coding bar graph of radix-minus-one complement as the main color strip encoding, after gathering these images successively, size order according to fringe projection same components in testee these two kinds of colors of when surface of two kinds of colors of hypothesis is constant, judge each color of pixel among the main color strip encoding figure, obtain the wrapped phase figure that the cycle changes by 90 ° of phase shift figure of four width of cloth bands then, and with the cycle boundary of wrapped phase border as each striped among the color images figure, figure further handles to color images, improve the precision of color images, then decode, obtain the periodicity of wrapped phase correspondence, figure realizes phase unwrapping in conjunction with wrapped phase, is obtained the three-dimensional data and the three-dimensionalreconstruction design sketch of testee by trigonometry.The present invention adopts following technical scheme:
Step 1: select the main color strip encoding: select only to comprise the coloud coding striped of some kinds of pure colors as the main color strip encoding, described pure color adopts three component red R of 24 rgb images, green G, blue B assignment respectively realizes, the R of 24 rgb images, G, the B component is respectively 8,256 GTGs are arranged, each component is only got 0 and 255 two value, and be 1 during with GTG 255, be 0 during GTG 0, R like this, G, the value of B component is respectively 0 or 1, these three components have 8 kinds of combinations and represent eight kinds of pure colors respectively, they are black 000, blue 001, green 010, cyan 011, red 100, product look 101, yellow 110, white 111
Step 2: the radix-minus-one complement of trying to achieve the main color strip encoding: establish that (x, y) value of the pixel K component of position is K in the main color strip encoding
1(x, y), (x, y) value of the pixel K component of position is K in the radix-minus-one complement
2(x, y), then
0<x<wilth wherein, 0<y<height, wilth are the pixel counts of coloud coding width of fringe direction, height is the pixel count of coloud coding striped short transverse, K=R, G or B,
Step 3: have the testee surface projection and the images acquired of coloured surface: radix-minus-one complement and four 90 ° of phase shift stripeds of main color strip encoding, main color strip encoding are projected in the testee surface with coloured surface successively, use the colored CCD images acquired simultaneously
Step 4: carry out color images according to hypothesis: hypothesis is proposed, the fringe projection of two kinds of colors during to the testee surface in these two kinds of colors the size order of same components constant,
If the value of the pixel K ' component of (x ', y ') position is K ' among the main color strip encoding figure that collects
1(x ', y '), the value of the pixel K ' component of (x ', y ') position is K ' in the radix-minus-one complement
2(x ', y '), the value of the pixel K ' component of (x ', y ') position is K ' (x ', y ') among the figure that obtains after the color images, then
0<x '<wilth ' wherein, 0<y '<height ', wilth ' they are the pixel counts that collects the picture traverse direction, height ' is the pixel count that collects the picture altitude direction, K=R, G or B,
Step 5: four 90 ° of phase shift diagrams of the width of cloth band phase places that collect are obtained wrapped phase: the 90 ° of phase shift figure of four width of cloth bands that collect handle as gray-scale map, make phase differential α among 90 ° of phase shift figure of four width of cloth bands
1=0, α
2=pi/2, α
3=π, α
4=3 pi/2s, each figure can be expressed as
Wherein, I
i(x ', y ') is the gray-scale value of i width of cloth phase shift figure (x ', y ') position pixel, I
0(x ', y ') is the background value of phase shift bar graph, γ (x ', y ') be the modulate intensity function,
Be the field of behaviour to be asked, 0<x '<wilty ', 0<y '<height ', with ' are the pixel counts that collects the picture traverse direction, and height ' is the pixel count that collects the picture altitude direction; Four width of cloth phase shifted images are gathered in same light field, and background gray levels is identical, the phase place main value expression formula of (x ', y ') the position pixel of deriving according to triangle formula and can get:
Try to achieve the phase place main value of each pixel correspondence according to above-mentioned formula, form value, from left to right increase progressively in cycle inside at-wrapped phase that pi/2~pi/2 scope intercycle changes,
The span of wrapped phase is adjusted into 0~2 π:
Then the value of wrapped phase changes at 0~2 π scope intercycle, from left to right increase progressively in cycle inside,
Step 6: determine each striped border according to wrapped phase: wrapped phase is lined by line scan, and the gray-scale value minimum point is the striped border,
Step 7: the noise in the image after the color images is removed on the striped border that obtains according to step 6 line by line: mark in the image after the color images corresponding to the pixel that is obtained the border by wrapped phase; Image after the color images is lined by line scan; Belong to same color fringe with the pixel between per two adjacent boundaries of delegation; The number of each colored pixels in the statistics one's own profession between per two adjacent boundaries; Be the maximum color of number of pixels that counts with the whole assignment of these pixels
Step 8: the picture decoding that step 7 is obtained according to the coding/decoding method of main color strip encoding: the color of each striped is identical with the main color strip encoding in the image that step 7 obtains, if the numbering of each color fringe from left to right is followed successively by 1 in the main color strip encoding, 2, j,, n, the reference numeral of each color fringe is n in the image that obtains according to the unique determining step 7 of main color strip encoding corresponding decoding method
0, n
0+ 1 ..., j ..., n
1, n wherein
0〉=1, n
1≤ n, these numberings are corresponding one by one with the wrapped phase cycle that step 5 obtains,
Step 9: the numbering that wrapped phase that obtains according to step 5 and step 8 obtain is carried out phase unwrapping: establish
The corresponding j that is numbered, then
Wherein
Be the expansion phase value that has complete testee surface elevation information of each image of collecting (x ', y ') position pixel correspondence, obtain the expansion phase value at each pixel place,
Step 10: obtain testee surface elevation information with trigonometry.
Beneficial effect: the present invention mainly is to provide a kind of method for three-dimensional measurement based on positive and inverse code color encoding stripes that can make phase method effectively measure the object dimensional information with coloured surface.
In the three-dimensional measurement process, because coloured image comprises more information than gray level image, use the comparable use black-white grating of chromatic grating to obtain measuring speed faster, an available width of cloth coloud coding striped replaces seven width of cloth two minutes black and white strip progressively, but, coloud coding contrast of fringes black and white strip is more vulnerable to the influence of testee surface color and variable color takes place, what CCD collected is background, the testee color, the new color that the stack of projected fringe color forms, if only at one group of coloud coding striped of the testee surface projection with coloured surface, then can't obtain the information of enough backgrounds and testee color, color image segmentation method commonly used all can only determine the new color of various factors stack formation and be subjected to noise effect easily and noise transfer takes place, and can't satisfy simultaneously based on single pixel, to coloud coding striped color accuracy of judgement, avoid the requirement of noise and isolate the color of the required coloud coding striped of three-dimensional measurement.
At above situation, we have designed a kind of method for three-dimensional measurement based on positive and inverse code color encoding stripes, throw main color strip encoding and radix-minus-one complement thereof successively on testee surface with coloured surface, in conjunction with four width of cloth phase-shift methods, make color images not be subjected to the influence of testee surface color and illumination, color and border accuracy of judgement to striped among the main color strip encoding figure, and then the accuracy of raising decoding, realization is measured and reconstruct the accurate three-dimensional of object with coloured surface, the method is by the auxiliary striped of radix-minus-one complement conduct of main color strip encoding, the constant hypothesis of size order of same components in these two kinds of colors during to the testee surface according to the fringe projection of two kinds of colors, the design color image segmentation method, accurately judge each color of pixel among the main color strip encoding figure, obtain the wrapped phase figure that the cycle changes by 90 ° of phase shift figure of four width of cloth bands then, and with the cycle boundary of wrapped phase border as each striped among the color images figure, figure further handles to color images, remove noise effect, improve the precision of color images, and then the raising decode precision, the precision of raising three-dimensional measurement.
Description of drawings
Fig. 1 is based on the process flow diagram of the method for three-dimensional measurement of positive and inverse code color encoding stripes.
Embodiment
Show below in conjunction with accompanying drawing the specific embodiment of the present invention is further described.According to said method, in Windows operating system, realized operation with C++ programming based on the striped coloud coding method of the grating fringe image of Gray code principle by the VC++6.0 platform.
Three-dimensional measurement is a pair of contradiction to the requirement of real-time and validity, coloured image comprises more information than gray level image, use the comparable use black-white grating of chromatic grating to obtain measuring speed faster, in order to improve the real-time of three-dimensional measurement, an available width of cloth coloud coding striped replaces seven width of cloth two minutes black and white strip progressively, but, coloud coding contrast of fringes black and white strip is more vulnerable to the influence of testee surface color and variable color takes place, what CCD collected is background, the testee color, the new color that the stack of projected fringe color forms, if only at one group of coloud coding striped of the testee surface projection with coloured surface, then can't obtain the information of enough backgrounds and testee color, color image segmentation method commonly used all can only determine the new color of various factors stack formation and be subjected to noise effect easily and noise transfer takes place, can't satisfy simultaneously based on single pixel, to coloud coding striped color accuracy of judgement, avoid the requirement of noise and isolate the color of the required coloud coding striped of three-dimensional measurement, make the validity of three-dimensional measurement be subjected to very big influence.For of the requirement of balance three-dimensional measurement to real-time and validity, the coloud coding striped of selecting one group of better performances and only comprising some kinds of pure colors is as the main color strip encoding, and try to achieve its radix-minus-one complement as auxiliary striped, the constant hypothesis of size order of same components in these two kinds of colors during to the testee surface according to the fringe projection of two kinds of colors, the design color image segmentation method, accurately judge each color of pixel among the main color strip encoding figure, obtain the wrapped phase figure that the cycle changes by 90 ° of phase shift figure of four width of cloth bands then, and with the cycle boundary of wrapped phase border as each striped among the color images figure, figure further handles to color images, remove noise effect, improve the precision of color images, and then the raising decode precision, the precision of raising three-dimensional measurement.
Process flow diagram of the present invention as shown in Figure 1, the specific implementation step is as follows:
Step 1: select the main color strip encoding: the coloud coding striped of selecting a kind of better performances and only comprising some kinds of pure colors is as the main color strip encoding, described pure color adopts three components R of 24 rgb images, G, B assignment respectively realizes, the R of 24 rgb images, G, the B component is respectively 8,256 GTGs are arranged, each component is only got 0 and 255 two value, and be 1 during with GTG 255, be 0 during GTG 0, R like this, G, the value of B component is respectively 0 or 1, these three components have 8 kinds of combinations and represent eight kinds of pure colors respectively, they are black 000, blue 001, green 010, cyan 011, red 100, product look 101, yellow 110, white 111, these pure color discriminations are bigger, help in color images, being distinguished smoothly, and they are at R, G, all have only two kinds of values on each component of B, binaryzation when helping color images
Step 2: the radix-minus-one complement of trying to achieve the main color strip encoding: establish that (x, y) value of the pixel K component of position is K in the main color strip encoding
1(x, y), (x, y) value of the pixel K component of position is K in the radix-minus-one complement
2(x, y), then
0<x<wilth wherein, 0<y<height, wilth are the pixel counts of coloud coding width of fringe direction, height is the pixel count of coloud coding striped short transverse, K=R, G or B,
Step 3: have the testee surface projection and the images acquired of coloured surface: radix-minus-one complement and four 90 ° of phase shift stripeds of main color strip encoding, main color strip encoding are projected in the testee surface with coloured surface successively, use the colored CCD images acquired simultaneously
Step 4: carry out color images according to hypothesis: hypothesis is proposed, the fringe projection of two kinds of colors during to the testee surface in these two kinds of colors the size order of same components constant,
If the value of the pixel K ' component of (x ', y ') position is K ' among the main color strip encoding figure that collects
1(x ', y '), the value of the pixel K ' component of (x ', y ') position is K ' in the radix-minus-one complement
2(x ', y '), color images
After among the figure that obtains the value of the pixel K ' component of (x ', y ') position be K ' (x ', y '), then
0<x '<wilth ' wherein, 0<y '<height ', wilth ' they are the pixel counts that collects the picture traverse direction, height ' is the pixel count that collects the picture altitude direction, K=R, G or B,
Step 5: four 90 ° of phase shift diagrams of the width of cloth band phase places that collect are obtained wrapped phase: the 90 ° of phase shift figure of four width of cloth bands that collect should become gray-scale map to handle, and make phase differential α among 90 ° of phase shift figure of four width of cloth bands
1=0, α
2=pi/2, α
3=π, α
4=3 pi/2s, each figure can be expressed as
Wherein, I
i(x ', y ') is the gray-scale value of i width of cloth phase shift figure (x ', y ') position pixel, I
0(x ', y ') is the background value of phase shift bar graph, γ (x ', y ') be the modulate intensity function,
Be the field of behaviour to be asked, 0<x '<wilth ', 0<y '<height ', wilth ' are the pixel counts that collects the picture traverse direction, and height ' is the pixel count that collects the picture altitude direction.Four width of cloth phase shifted images are gathered in same light field, and background gray levels is identical, according to triangle formula
With I
i(x ', y ') substitution following formula gets
To following formula negate tan, just obtained the main value field of behaviour:
Try to achieve the phase place main value of each pixel correspondence according to above-mentioned formula, form value, from left to right increase progressively in cycle inside at-wrapped phase that pi/2~pi/2 scope intercycle changes,
The span of wrapped phase is adjusted into 0~2 π:
Then the value of wrapped phase changes at 0~2 π scope intercycle, from left to right increase progressively in cycle inside,
Step 6: determine each striped border according to wrapped phase: wrapped phase is lined by line scan, and the gray-scale value minimum point is the striped border,
Step 7: the noise in the image after the color images is removed on the striped border that obtains according to step 6 line by line: because the borderline phase of corresponding striped is same in 90 ° of phase shift stripeds of coloud coding striped and four width of cloth bands, therefore the borderline phase of corresponding striped is same among the 90 ° of phase shift figure of coloud coding bar graph and four width of cloth bands that collect, hence one can see that, the coloud coding striped border of identifying after the color images should be same with the borderline phase that is obtained by wrapped phase, image after the color images is lined by line scan, belong to same color fringe with the pixel between per two adjacent boundaries of delegation, the number of each colored pixels in the statistics one's own profession between per two adjacent boundaries, with the whole assignment of these pixels is the maximum color of number of pixels that counts
Step 8: the picture decoding that step 7 is obtained according to the coding/decoding method of main color strip encoding: the color of each striped is identical with the main color strip encoding in the image that step 7 obtains, if the numbering of each color fringe from left to right is followed successively by 1 in the main color strip encoding, 2, j,, n, the reference numeral of each color fringe is n in the image that obtains according to the unique determining step 7 of main color strip encoding corresponding decoding method
0, n
0+ 1 ..., j ..., n
1, n wherein
0〉=1, n
1≤ n, these numberings are corresponding one by one with the wrapped phase cycle that step 5 obtains,
Step 9: the numbering that wrapped phase that obtains according to step 5 and step 8 obtain is carried out phase unwrapping: establish
The corresponding j that is numbered, then
Wherein
Be the expansion phase value that has complete testee surface elevation information of each image of collecting (x ', y ') position pixel correspondence, obtain the expansion phase value at each pixel place,
Step 10: obtain testee surface elevation information with trigonometry.