Summary of the invention
The technical problem to be solved in the present invention provides a kind of method and system that generates stereo-picture, can obtain having with source figure more than a width of cloth or the width of cloth image of parallax more simply and easily.
For solving the problems of the technologies described above, the invention provides a kind of generation stereo-picture method, comprising:
The object that intercepts the image of reception more than a width of cloth is positioned over the object of described intercepting in the background image, obtains first plane picture;
Receive the convex-concave parameter of character pixel in first plane picture, according to the convex-concave parameter of each pixel correspondence on this first plane picture of convex-concave calculation of parameter of this character pixel;
The convex-concave parameter of each pixel correspondence on first plane picture is converted into offset parameter, each pixel on first plane picture is offset, obtain second plane picture.
Further, obtain described second plane picture after, described method also comprises: merge described first plane picture and second plane picture, generate stereo-picture, perhaps merge above second plane picture of two width of cloth, generate stereo-picture.
Further, obtain described second plane picture after, described method also comprises: the blank pixel in described second plane picture is repaired filling.
Further, the convex-concave parameter of character pixel in described reception first plane picture comprises according to the step of the convex-concave parameter of each pixel correspondence on this first plane picture of convex-concave calculation of parameter of this character pixel:
Obtain the convex-concave parameter of described first pixel according to the convex-concave calculation of parameter of the distance of each character pixel to this object of first pixel on the object and each character pixel; Repeat the convex-concave parameter that this step obtains all pixels on the described object;
All objects on first plane picture are carried out above-mentioned behaviour's step, obtain the convex-concave parameter of each pixel correspondence on first plane picture.
Further, described distance and the convex-concave calculation of parameter of each character pixel step that obtains the convex-concave parameter of described first pixel according to each character pixel to this object of first pixel on the object comprises:
The convex-concave parameter of described first pixel equals weight coefficient, distance parameter and the convex-concave parameter three sum of products of each character pixel, wherein, described distance parameter is the distance and described first pixel ratio apart from sum to all character pixels of described first pixel to this character pixel.
Further, described offset parameter comprises offset direction and offset distance;
Described convex-concave parameter with each pixel correspondence on first plane picture is converted into offset parameter, and each pixel on first plane picture is offset, and the step that obtains second plane picture comprises:
The convex-concave parameter of each pixel correspondence on first plane picture is converted into first offset parameter, each pixel on first plane picture is carried out the skew first time, obtain first second plane picture;
The convex-concave parameter of each pixel correspondence on first plane picture is converted into second offset parameter, offset distance in wherein said second offset parameter equals the product of offset distance in current skew number of times, offset coefficient and first offset parameter, each pixel on first plane picture is carried out the skew second time, obtain second second plane picture;
The convex-concave parameter of each pixel correspondence on first plane picture is converted into the 3rd offset parameter, offset distance in wherein said the 3rd offset parameter equals the product of offset distance in current skew number of times, offset coefficient and first offset parameter, each pixel on first plane picture is offset for the third time, obtains the 3rd second plane picture;
By that analogy, obtain several second plane pictures.
Further, described offset parameter comprises offset direction and offset distance;
The step that described convex-concave parameter with each pixel correspondence on first plane picture is converted into offset parameter comprises:
The convex-concave parameter of the second pixel correspondence on first plane picture positive and negative is converted into the offset direction in the offset parameter of the described second pixel correspondence, the absolute value of the convex-concave parameter of the second pixel correspondence is converted into the offset distance in the offset parameter of the described second pixel correspondence.
For solving the problems of the technologies described above, the present invention also provides a kind of generation stereo vision system, comprises the first plane picture generating apparatus, convex-concave parameter calculation apparatus, the second plane picture generating apparatus, wherein:
The described first plane picture generating apparatus, it is used for receiving the object that intercepts from the image more than the width of cloth, and the object of described intercepting is positioned in the background image, obtains first plane picture;
Described convex-concave parameter calculation apparatus, it is used for receiving the convex-concave parameter of the first plane picture character pixel, according to the convex-concave parameter of each pixel correspondence on this first plane picture of convex-concave calculation of parameter of this character pixel;
The described second plane picture generating apparatus, it is used for the convex-concave parameter of each pixel correspondence on first plane picture is converted into offset parameter, and each pixel on first plane picture is offset, and obtains second plane picture.
Further, described system also comprises stereoscopic image generation device, and it is used for after obtaining described second plane picture, merge described first plane picture and second plane picture, generate stereo-picture, perhaps merge above second plane picture of two width of cloth, generate stereo-picture.
Further, described system also comprises prosthetic device, and it is used for the blank pixel of described second plane picture is repaired filling.
Further, described convex-concave parameter calculation apparatus is used for receiving in the following ways the convex-concave parameter of the first plane picture character pixel, according to the convex-concave parameter of each pixel correspondence on this first plane picture of convex-concave calculation of parameter of this character pixel:
Described convex-concave parameter calculation apparatus is used to repeat the convex-concave parameter that following steps obtain all pixels on the described object: the convex-concave parameter that obtains described first pixel according to the convex-concave calculation of parameter of the distance of each character pixel to this object of first pixel on the object and each character pixel.
Further, described convex-concave parameter calculation apparatus is used in the following ways obtaining according to the convex-concave calculation of parameter of the distance of each character pixel to this object of first pixel on the object and each character pixel the convex-concave parameter of described first pixel:
The convex-concave parameter of described first pixel equals weight coefficient, distance parameter and the convex-concave parameter three sum of products of each character pixel, wherein, described distance parameter is the distance and described first pixel ratio apart from sum to all character pixels of described first pixel to this character pixel.
Further, described offset parameter comprises offset direction and offset distance;
The described second plane picture generating apparatus is used in the following ways described convex-concave parameter with each pixel correspondence on first plane picture being converted into offset parameter, and each pixel on first plane picture is offset, and obtains second plane picture:
The convex-concave parameter of each pixel correspondence on first plane picture is converted into first offset parameter, each pixel on first plane picture is carried out the skew first time, obtain first second plane picture;
The convex-concave parameter of each pixel correspondence on first plane picture is converted into second offset parameter, offset distance in wherein said second offset parameter equals the product of offset distance in current skew number of times, offset coefficient and first offset parameter, each pixel on first plane picture is carried out the skew second time, obtain second second plane picture;
The convex-concave parameter of each pixel correspondence on first plane picture is converted into the 3rd offset parameter, offset distance in wherein said the 3rd offset parameter equals the product of offset distance in current skew number of times, offset coefficient and first offset parameter, each pixel on first plane picture is offset for the third time, obtains the 3rd second plane picture;
By that analogy, obtain several second plane pictures.
Further, described offset parameter comprises offset direction and offset distance;
The described second plane picture generating apparatus is used in the following ways the convex-concave parameter of each pixel correspondence on first plane picture is converted into offset parameter:
The convex-concave parameter of the second pixel correspondence on first plane picture positive and negative is converted into the offset direction in the offset parameter of the described second pixel correspondence, the absolute value of the convex-concave parameter of the second pixel correspondence is converted into the offset distance in the offset parameter of the described second pixel correspondence.
The embodiment of the invention is by cutting apart arbitrary image, obtain the subject on the image, the position of these one or more subject is set on background then, generate two width of cloth or several images by the image shift algorithm at last with parallax with parallax, thereby substituted the method for the complexity of existing acquisition 3-D view, operate simplyr, and need not expensive expense.
Embodiment
The present invention obtains the pending three-dimensional object of handling by original image is cut apart, and the hierarchical position of those objects is set, and by the image shift algorithm, obtains the image that a width of cloth or several and former figure have parallax.The following scheme of concrete employing:
The object that intercepts the image of reception more than a width of cloth is positioned over the object of described intercepting in the background image, obtains first plane picture;
Receive the convex-concave parameter of character pixel in first plane picture, according to the convex-concave parameter of each pixel correspondence on this first plane picture of convex-concave calculation of parameter of this character pixel;
The convex-concave parameter of each pixel correspondence on first plane picture is converted into offset parameter, each pixel on first plane picture is offset, obtain second plane picture.
Preferably, obtain described second plane picture after, merge described first plane picture and second plane picture, generate stereo-picture, perhaps merge above second plane picture of two width of cloth, generate stereo-picture.
Above-mentioned object may be that an object also may be a panel region.For example can be a cup, building or a slice sky etc.
The above-mentioned background image can be the former figure at object place, perhaps also can be that a width of cloth is newly schemed.
Particularly, the convex-concave parameter of character pixel in described reception first plane picture comprises according to the step of the convex-concave parameter of each pixel correspondence on this first plane picture of convex-concave calculation of parameter of this character pixel: the convex-concave parameter that obtains described first pixel according to the convex-concave calculation of parameter of the distance of each character pixel to this object of first pixel on the object and each character pixel; Repeat the convex-concave parameter that this step obtains all pixels on the described object; All objects on first plane picture are carried out above-mentioned behaviour's step, obtain the convex-concave parameter of each pixel correspondence on first plane picture.
Particularly, described distance and the convex-concave calculation of parameter of each character pixel step that obtains the convex-concave parameter of described first pixel according to each character pixel to this object of first pixel on the object comprises:
The convex-concave parameter of described first pixel equals weight coefficient, distance parameter and the convex-concave parameter three sum of products of each character pixel, wherein, described distance parameter is the distance and described first pixel ratio apart from sum to all character pixels of described first pixel to this character pixel.
Particularly, described offset parameter comprises offset direction and offset distance; Described convex-concave parameter with each pixel correspondence on first plane picture is converted into offset parameter, and each pixel on first plane picture is offset, and the step that obtains second plane picture comprises:
The convex-concave parameter of each pixel correspondence on first plane picture is converted into first offset parameter, each pixel on first plane picture is carried out the skew first time, obtain first second plane picture;
The convex-concave parameter of each pixel correspondence on first plane picture is converted into second offset parameter, offset distance in wherein said second offset parameter equals the product of offset distance in current skew number of times, offset coefficient and first offset parameter, each pixel on first plane picture is carried out the skew second time, obtain second second plane picture;
The convex-concave parameter of each pixel correspondence on first plane picture is converted into the 3rd offset parameter, offset distance in wherein said the 3rd offset parameter equals the product of offset distance in current skew number of times, offset coefficient and first offset parameter, each pixel on first plane picture is offset for the third time, obtains the 3rd second plane picture;
By that analogy, obtain several second plane pictures.
Realize system for carrying out said process as shown in Figure 1, comprise the first plane picture generating apparatus, convex-concave parameter calculation apparatus, the second plane picture generating apparatus, wherein:
The described first plane picture generating apparatus, it is used for receiving the object that intercepts from the image more than the width of cloth, and the object of described intercepting is positioned in the background image, obtains first plane picture;
Described convex-concave parameter calculation apparatus, it is used for receiving the convex-concave parameter of the first plane picture character pixel, according to the convex-concave parameter of each pixel correspondence on this first plane picture of convex-concave calculation of parameter of this character pixel;
The described second plane picture generating apparatus, it is used for the convex-concave parameter of each pixel correspondence on first plane picture is converted into offset parameter, and each pixel on first plane picture is offset, and obtains second plane picture.
Preferably, described system also comprises stereoscopic image generation device, and it is used for after obtaining described second plane picture, merge described first plane picture and second plane picture, generate stereo-picture, perhaps merge above second plane picture of two width of cloth, generate stereo-picture.
Preferably, described system also comprises prosthetic device, and it is used for the blank pixel of described second plane picture is repaired filling.
Preferably, described convex-concave parameter calculation apparatus is used for receiving in the following ways the convex-concave parameter of the first plane picture character pixel, and according to the convex-concave parameter of each pixel correspondence on this first plane picture of convex-concave calculation of parameter of this character pixel: described convex-concave parameter calculation apparatus is used to repeat the convex-concave parameter that following steps obtain all pixels on the described object: the convex-concave parameter that obtains described first pixel according to the convex-concave calculation of parameter of the distance of each character pixel to this object of first pixel on the object and each character pixel.
Preferably, described convex-concave parameter calculation apparatus is used in the following ways obtaining according to the convex-concave calculation of parameter of the distance of each character pixel to this object of first pixel on the object and each character pixel the convex-concave parameter of described first pixel: the convex-concave parameter of described first pixel equals weight coefficient, distance parameter and the convex-concave parameter three sum of products of each character pixel, wherein, described distance parameter is the distance and described first pixel ratio apart from sum to all character pixels of described first pixel to this character pixel.
Preferably, described offset parameter comprises offset direction and offset distance.
Preferably, the described second plane picture generating apparatus is used in the following ways described convex-concave parameter with each pixel correspondence on first plane picture being converted into offset parameter, and each pixel on first plane picture is offset, and obtains second plane picture:
The convex-concave parameter of each pixel correspondence on first plane picture is converted into first offset parameter, each pixel on first plane picture is carried out the skew first time, obtain first second plane picture;
The convex-concave parameter of each pixel correspondence on first plane picture is converted into second offset parameter, offset distance in wherein said second offset parameter equals the product of offset distance in current skew number of times, offset coefficient and first offset parameter, each pixel on first plane picture is carried out the skew second time, obtain second second plane picture;
The convex-concave parameter of each pixel correspondence on first plane picture is converted into the 3rd offset parameter, offset distance in wherein said the 3rd offset parameter equals the product of offset distance in current skew number of times, offset coefficient and first offset parameter, each pixel on first plane picture is offset for the third time, obtains the 3rd second plane picture;
By that analogy, obtain several second plane pictures.
Preferably, the described second plane picture generating apparatus is used in the following ways the convex-concave parameter of each pixel correspondence on first plane picture is converted into offset parameter:
The convex-concave parameter of the second pixel correspondence on first plane picture positive and negative is converted into the offset direction in the offset parameter of the described second pixel correspondence, the absolute value of the convex-concave parameter of the second pixel correspondence is converted into the offset distance in the offset parameter of the described second pixel correspondence.
Hereinafter will be elaborated to embodiments of the invention in conjunction with the accompanying drawings.Need to prove that under the situation of not conflicting, embodiment among the application and the feature among the embodiment be combination in any mutually.
Embodiment 1
It is that example describes that present embodiment all obtains from a width of cloth original image with all objects.As shown in Figure 2, may further comprise the steps:
The first step: load original image, obtain the essential information of original image;
The essential information of original image comprises: size of images (long and wide), each color of pixel value (rgb value) in the image.
Second step: according to the object that the user selects, original image is cut apart, one or more object that the user selects is separated from this original image, and storage separately;
The preferred image segmentation algorithm (or claiming to scratch nomography) that adopts is cut apart original image.The mode of specifically cutting apart is a lot, for example can adopt specific shape to cut apart, such as: rectangle, circle etc.; Also can adopt some algorithms to carry out cutting apart of intelligence, as average drifting algorithm, minimal cut/max-flow algorithm etc.
Separate a plurality of objects if desired, once cut apart an object usually,, isolate a plurality of objects by operation image partitioning algorithm repeatedly.Carried out for the 3rd step again after all objects that will separate are all split.
The 3rd step: receive the object that from original image, intercepts, those objects are positioned in the background image, obtain first plane picture;
The position relation of placing also can exert an influence to the degree of depth level (the convex-concave level during three-dimensional display) of follow-up stereo display.The object that is positioned at the upper strata is positioned at the object of lower floor from visually protruding more.
Each color of pixel value is according to the color value of each color of pixel value, background image on the object that is intercepted in first plane picture, and the placement of object relation decides, from the common color value of forming first plane picture of the color value of visible object of viewpoint and/or background.
The above-mentioned background image can be the new image of a width of cloth, perhaps can be original image, can also be the image that obtains through after three-dimensional the processing.
In this step, when being positioned over object in the background image, it is the setting of position that the positional information of the object that can be provided with according to the user is placed.Adopt this kind mode, the placement of each object relation was given the bigger degree of freedom of user, better user experience when the user can be provided with three-dimensional display voluntarily.
The 4th step: receive the convex-concave parameter of character pixel in first plane picture, according to the convex-concave parameter of each pixel correspondence on this first plane picture of convex-concave calculation of parameter of this character pixel;
Character pixel is meant the pixel that can embody object shapes or architectural feature, for example: the point of protrusion, recessed point etc.To liking a cuboid, character pixel then comprises the pixel of this each visual vertex position of cuboid at least so.
This convex-concave parameter is used to represent the visual convex-concave degree of corresponding pixel points, and the scope of convex-concave parameter is: [1,1], wherein-1 represent the most recessed screen, 0 is illustrated on the current screen, and screen is protruded in 1 expression most.Software can be set to the user by double-clicking character pixel, the convex-concave parameter of input respective pixel.Avoided making up in the prior art the complicated drawback of threedimensional model scheme by directly each object on the image to be generated being provided with the convex-concave parameter.
The step of calculating the convex-concave parameter of each pixel correspondence on the image to be generated comprises:
1, first convex-concave parameter according to each pixel correspondence of this object of convex-concave calculation of parameter of all character pixel correspondences on a certain object of user's setting:
1) establishing the point of establishing the convex-concave parameter is: P1, P2, P3.....PN, corresponding convex-concave parameter value is: V1, V2, V3, ... .VN, for other any 1 PX on this object, calculate its distance to the point of establishing the convex-concave parameter (distance herein is meant the distance on the two dimensional surface), be made as: D1, D2, D3, ... .DN, wherein D1 is the distance that PX is ordered to P1, and D2 is the distance that PX is ordered to P2, by that analogy;
2) calculate the convex-concave V parameter X that PX is ordered by the linear weighted function method:
VX=a
1* (D1/D) * V1+a
2* (D2/D) * V2+a
3* (D3/D) * V3+...+a
N* (DN/D) * VN (formula 1)
Wherein, D=D1+D2+D3+.....+DN; A is a weight coefficient, a>0.For the sake of simplicity, preferably, a=1.
Repeat above-mentioned steps 1), 2) calculate the convex-concave parameter of all pixel correspondences on this object.
2, repeat above-mentioned steps 1 and respectively each object on first plane picture is calculated, obtain the convex-concave parameter of each pixel correspondence on first plane picture.
If background image as seen, then can adopt said method to be provided with and to calculate the convex-concave parameter of background parts with the background exposed as an object.
Preferably, after calculating the convex-concave parameter of each pixel correspondence on first plane picture, can also carry out optimization processes such as denoising to the convex-concave parameter that obtains, can adopt optimization process scheme of the prior art, this paper repeats no more.
The 5th step: the convex-concave parameter of each pixel correspondence on first plane picture is converted into offset parameter, each pixel on first plane picture is offset, obtain second plane picture;
Particularly:
Step 1 according to the value of convex-concave parameter, is converted into one or more offset parameters of this pixel correspondence with the convex-concave parameter of each pixel on first plane picture, and this offset parameter comprises offset direction and offset distance;
In a plurality of offset parameters of same pixel correspondence, the offset direction in each offset parameter is identical, the offset distance difference.
The convex-concave parameter of the second pixel correspondence on first plane picture positive and negative is converted into the offset direction in the offset parameter of the second pixel correspondence, the absolute value of the convex-concave parameter of the second pixel correspondence is converted into the offset distance in the offset parameter of the second pixel correspondence.For example: for the convex-concave parameter is 1 pixel, and its offset parameter is for being offset N pixel left; For the convex-concave parameter is-1 pixel, and its offset parameter is for being offset N pixel to the right.The pixel value that other convex-concave parameter value can obtain being offset by interpolation.
Step 2 is offset each pixel according to offset parameter, obtains one second plane picture;
If generate several second plane pictures, then repeat above-mentioned steps 1 and step 2, at this moment, for same pixel, the offset parameter of second second plane picture is different with the offset parameter of first second plane picture, offset parameter can increase along with the number difference of image, for example: be 1 pixel for the convex-concave parameter, the distance of skew is N for the first time, and when calculating second second plane picture, its offset distance is 2*K*N, when calculating the 3rd second plane picture, its offset distance is 3*K*N, by that analogy, can obtain several second plane pictures, wherein, 2 and 3 are respectively current skew number of times, and the K value can be set by the user, perhaps the default value that provides for system.
For the blank pixel of image, use the mode of image repair to fill.
Adopt above-mentioned image shift algorithm that pixel is offset, finally be offset out second plane picture that or many and first plane picture have parallax.Can obtain stereo-picture after several second plane pictures are synthetic, perhaps with first plane picture and second plane picture as about figure also can obtain stereo-picture after synthetic.
Preferably, after obtaining a width of cloth or several and second plane picture of parallax being arranged, utilize the image compensation algorithm, the empty pixel that compensation produces because of the skew of image with first plane picture.Can adopt image to repair to retouch (Inpainting) technology or adjustment (Resize) technology compensates image automatically as the image compensation algorithm.
Describe to adopt the inpainting technology to fill up: according to the partial pixel on blank pixel next door, at the enterprising line search of entire image, when some pixel on this part pixel and the entire image reaches certain coupling, just can fill up empty pixel with this part pixel adjacent pixels.Particularly, select a model to be matched earlier at empty pixel edge place, 5*5 pixel for example arranged, if it is known that 13 pixels are wherein arranged, it is empty pixels that 12 pixels are arranged, and utilizes these 13 known pixels to mate on entire image, and 13 known pixels in model to be matched are identical with 13 pixels in a certain zone, should the zone be Matching Model then, other 12 known pixels in the Matching Model be used for filling up 12 blank pixel of model to be matched.
One of ordinary skill in the art will appreciate that all or part of step in the said method can instruct related hardware to finish by program, described program can be stored in the computer-readable recording medium, as read-only memory, disk or CD etc.Alternatively, all or part of step of the foregoing description also can use one or more integrated circuits to realize.Correspondingly, each the module/unit in the foregoing description can adopt the form of hardware to realize, also can adopt the form of software function module to realize.The present invention is not restricted to the combination of the hardware and software of any particular form.
Certainly; the present invention also can have other various embodiments; under the situation that does not deviate from spirit of the present invention and essence thereof; those of ordinary skill in the art work as can make various corresponding changes and distortion according to the present invention, but these corresponding changes and distortion all should belong to the protection range of the appended claim of the present invention.