Summary of the invention
The technical problem to be solved in the present invention provides the degree of depth method to set up of object on a kind of plane picture.
In order to address the above problem, the invention provides the degree of depth method to set up of object on a kind of plane picture, comprising:
According to input instruction, be identified for one or more three-dimensional models that certain object degree of depth is provided with;
According to input instruction, the size of described three-dimensional model and/or attitude are adjusted and shown;
According to the reference depth value that is provided with and the size and/or the attitude of described three-dimensional model, for each pixel of described three-dimensional model visible surface is provided with depth value;
According to the depth value of each pixel of described three-dimensional model visible surface, for the corresponding pixel points of described object on plane picture is provided with depth value.
Preferably,
Described three-dimensional model is a solid figure.
Preferably,
Before the size of described three-dimensional model and/or attitude adjusted and show, also comprise:, described three-dimensional model is inserted into the editing interface of the plane picture at described object place according to input instruction.
Preferably,
Described reference depth value comprises the depth value of any two or more positions on the described three-dimensional model; Perhaps, described reference depth value comprises the depth value of any one position on the described three-dimensional model, and the depth value of three-dimensional model unit sizes correspondence.
Preferably,
Described reference depth value comprises the minimum depth value of three-dimensional model closest approach correspondence and the maximum depth value of solstics correspondence;
Described according to the reference depth value that is provided with and the size and the attitude of described three-dimensional model, for each pixel of described three-dimensional model visible surface is provided with depth value, specifically comprise:
According to this minimum depth value and maximum depth value,, utilize interpolation algorithm to calculate the depth value of each pixel of described three-dimensional model visible surface in conjunction with the size and/or the attitude of described three-dimensional model.
Preferably,
Described degree of depth method to set up also comprises:
When the degree of depth being set, from a plurality of objects, select one earlier, finish the degree of depth setting of this reference body as reference body for a plurality of objects of same plane picture;
According to the degree of depth setting of this reference body, determine the corresponding relation of three-dimensional model unit sizes and depth value, based on this corresponding relation other objects are carried out degree of depth setting then.
Preferably,
The depth value of described each pixel according to described three-dimensional model visible surface for the corresponding pixel points of described object on plane picture is provided with depth value, comprising:
According to the border of described object on plane picture of determining, to each pixel in this border, the depth value of this pixel is set to the depth value of this pixel at the pixel of described three-dimensional model visible surface correspondence.
Preferably,
Described degree of depth method to set up also comprises:
Determine the border of described object on plane picture earlier, after the size of described three-dimensional model and/or attitude are adjusted and being shown according to input instruction, check whether described three-dimensional model has covered the border of described object on plane picture fully, if covering or the border of described object on plane picture are not also determined fully, then provide the information of putting again or determining the border earlier.
Preferably,
Described solid figure is the stereoscopic grid figure that comprises a plurality of zones;
According to the reference depth value that is provided with and the size and/or the attitude of described three-dimensional model,, also comprise for each pixel of described three-dimensional model visible surface is provided with before the depth value:
According to input instruction, deformation process is carried out in one or more zones of described stereoscopic grid figure, and automatically smoothing processing is done in the neighboring area.
Correspondingly, the degree of depth of object is provided with system on the plane picture provided by the invention, comprising:
The model determination module is used for according to input instruction, is identified for one or more three-dimensional models that certain object degree of depth is provided with;
Adjust and display module,, the size of described three-dimensional model and/or attitude are adjusted and shown according to input instruction;
First degree of depth is provided with module, is used for according to the reference depth value that is provided with and the size and/or the attitude of described three-dimensional model, for each pixel of described three-dimensional model visible surface is provided with depth value;
Second degree of depth is provided with module, is used for the depth value according to each pixel of described three-dimensional model visible surface, for the corresponding pixel points of described object on plane picture is provided with depth value.
Preferably,
The described degree of depth is provided with system and also comprises:
The image insert module is used for according to input instruction, described three-dimensional model is inserted into the editing interface of the plane picture at described object place.
Preferably,
The described degree of depth is provided with system and also comprises:
3 d model library is used to preserve and safeguard the three-dimensional model of solid figure form;
Described model determination module is used for according to input instruction, is identified for one or more three-dimensional models that certain object degree of depth is provided with from described 3 d model library.
Preferably,
Described first degree of depth is provided with module when the described reference depth value that is provided with comprises the maximum depth value of the minimum depth value of three-dimensional model closest approach correspondence and solstics correspondence, according to this minimum depth value and maximum depth value, in conjunction with the size and/or the attitude of described three-dimensional model, utilize interpolation algorithm to calculate the depth value of each pixel of described three-dimensional model visible surface.
Preferably,
It is a plurality of objects of same plane picture when the degree of depth is set that described first degree of depth is provided with module, selects one earlier as reference body from a plurality of objects, finishes the degree of depth setting of this reference body; According to the degree of depth setting of this reference body, determine the corresponding relation of three-dimensional model unit sizes and depth value again, based on this corresponding relation other objects are carried out degree of depth setting then.
Preferably,
Described second degree of depth is provided with the depth value of module according to each pixel of described three-dimensional model visible surface, for the corresponding pixel points of described object on plane picture is provided with depth value, comprise: according to the border of described object on plane picture of determining, to each pixel in this border, the depth value of this pixel is set to the depth value of this pixel at the pixel of described three-dimensional model visible surface correspondence.
Preferably, the described degree of depth is provided with system and also comprises:
The border determination module is used for determining the border of described object on plane picture;
Check module, be used for after according to input instruction the size of described three-dimensional model and/or attitude being adjusted and being shown, check whether described three-dimensional model has covered the border of described object on plane picture fully, if covering or the border of described object on plane picture are not also determined fully, then provide the information of putting again or determining the border earlier; And/or, know the depth value of setting after, judge that whether the variation of the depth value of the part that described three-dimensional model is related with the object on the described plane picture surpasses setting threshold, as surpass, the depth value of described part is provided with automatically.
Preferably,
Described adjustment and display module also are used for according to input instruction, deformation process is carried out in one or more zones of stereoscopic grid figure, and automatically smoothing processing is done in the neighboring area.
The degree of depth method to set up of object and system have overcome plane picture the limitation of the degree of depth can not be set on the above-mentioned plane picture, and the degree of depth setting of plane picture are become simply, flexibly and accurately.
Embodiment
For making the purpose, technical solutions and advantages of the present invention clearer, 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.
First embodiment
Before the degree of depth being set for the object on the plane picture, can system be set in the degree of depth (can be system independently, also can be the subsystem of big graphic system, below the degree of depth is provided with system abbreviates system as) in set up model bank or utilize other model bank.The effect of model bank provides the three-dimensional model of using when the degree of depth is set.In the present embodiment, the three-dimensional model in the model bank comprises basic solid figures such as ball, cylinder, circular cone, rectangular parallelepiped.These three-dimensional models are adjustable, promptly can be by varying sized and attitudes such as stretching, convergent-divergent and rotations, with plane picture on object be complementary.Simultaneously, as three-dimensional model, also more conveniently object on the plane picture is carried out nested solid figure, be about to whole object and be included in the three-dimensional model.
In other embodiments, if not high to the accuracy requirement of degree of depth setting, model bank also can be only with an adjustable rectangular parallelepiped or an adjustable ball.If higher, then can comprise the complex three-dimensional model that a plurality of solid figures are formed to the accuracy requirement that the degree of depth is provided with.
Utilize basic solid figure as three-dimensional model, the making of model or obtain very simply need not to finish by other instrument, also need not to set up different mock-ups according to objects different on the plane picture, compare with setting up mock-up, be very easy to design and use.
For the object of waiting to be provided with the degree of depth on the plane picture, present embodiment carries out flow process that the degree of depth is provided with as shown in Figure 1, comprising:
Step 110:, from model bank, extract corresponding one or more three-dimensional models according to input instruction;
This input instruction can be user's one or more three-dimensional model that select and object matches.The three-dimensional model of selecting should make the display part of object on plane picture can both correspond to the surface of three-dimensional model as far as possible.Generally speaking, the three-dimensional model of selection is many more, when next step is put just easy more near plane picture on the true form of object, the degree of depth of setting is just accurate more.
Please refer to Fig. 2 a and Fig. 2 b, is an example of present embodiment degree of depth method to set up, and in this example, the object of waiting to be provided with the degree of depth is a desk, and the three-dimensional model that the user selects is 3 right cylinders (only illustrating one among the figure).
Need to prove that the present invention might not need the model bank of using system itself, also can be from other local importings.If only use simple solid figure, when coupling, create also passable again.
Step 120 according to input instruction, is adjusted and is shown the size of described three-dimensional model and/or attitude;
Preferably, system provides the function that three-dimensional model is inserted into the editing interface of object place plane picture as object.Before this step, described three-dimensional model can be inserted into the editing interface of the plane picture at described object place.The user just can directly put three-dimensional model according to the object on the primary plane image like this, and the size that makes three-dimensional module present is consistent as far as possible with size and the attitude that attitude and object present on plane picture, and then has also improved the accuracy that the degree of depth is provided with.
In the above-mentioned example, 3 right cylinders are put respectively, respectively and the position between the desktop of desk, pillar and base and each several part relation be complementary, generally answer the counterpart on the overlay planes image.Preferably, can directly be enclosed within on the plane picture and put.3 cylindrical composite figures after putting are shown in Fig. 3 a.Each right cylinder is then respectively as Fig. 3 b, shown in Fig. 3 c and Fig. 3 d.
In one example, solid figure is the stereoscopic grid figure that comprises a plurality of zones; In this step, can also deformation process be carried out in one or more zones of described stereoscopic grid figure, and automatically smoothing processing is done in the neighboring area according to input instruction.For example, the surface of rectangular parallelepiped can be divided into many zones, these zones can be square, can be circular, also can triangle or the like.When three-dimensional model is adjusted, for make three-dimensional model better with object matches, outside the adjustment of carrying out size and attitude, can also do deformation process.For example, during with a rectangular parallelepiped and petal coupling, can do the concave, convex processing to some zone and make its matching degree better, and these regional neighboring areas can be done smoothing processing automatically.
Step 130: according to the reference depth value that is provided with and the size and/or the attitude of described three-dimensional model, for each pixel of described three-dimensional model visible surface is provided with depth value;
In this step, the reference depth value of setting can be the depth value of any two or more positions on the three-dimensional model, also can be the depth value of any one position on the three-dimensional model and the depth value of three-dimensional model unit sizes correspondence, or the like.Described position be as being the unique points such as closest approach, solstics or central point of this three-dimensional model, also can the user on three-dimensional model appointment more arbitrarily.The reference depth value that is provided with can be represented with distance, also can directly adopt gray-scale value to represent.For a plurality of three-dimensional models of putting simultaneously, only need provide one group of reference depth value and get final product.
Reference depth value with setting is that the minimum depth value of three-dimensional model closest approach correspondence and the maximum depth value of solstics correspondence are example, after this maximum depth value and minimum depth value are determined, in conjunction with three-dimensional model size and/or attitude, utilize simple interpolation just can obtain the depth value of each pixel of three-dimensional model visible surface.So-called visible surface, promptly the part that can see is corresponding with the object on the plane picture.Normally, systematic unity was set when the size of three-dimensional model was the model of creation storehouse, and when three-dimensional model was scaled, the size of three-dimensional model also changed thereupon.
For example, the three-dimensional model shown in Fig. 4 is a cube.D
nBe the depth value of the nearest position (closest approach) of the three-dimensional model relative distance user that is provided with of user, D
fIt is the depth value of the three-dimensional model distance users position (solstics) farthest of user person's setting.The distance that can calculate between this closest approach and the solstics according to the size and the attitude of three-dimensional model is L, and then nearest point is that the depth value of the point of l is: D
l=D
n+ l* (D
f-D
n)/L.D
nAnd D
fCan calculate by user's estimation or with other modes.
Among Fig. 4, P
nBe the nearest position of distance users, i.e. P
n=255; P
fBe distance users position farthest, i.e. P
f=0.P
nAnd P
fCan calculate according to the reference depth value of representing with gray-scale value to obtain, also can obtain according to the reference depth value of representing with distance and apart from calculating with the corresponding relation of gray scale.When the degree of depth being set for a plurality of objects of same plane picture, P
nAnd P
fShould remain unchanged.
When the degree of depth being set, can from a plurality of objects, select one, finish the degree of depth setting of this reference body as reference body for a plurality of objects of same plane picture; According to the degree of depth setting of this reference body, determine the corresponding relation of three-dimensional model unit sizes and depth value, based on this corresponding relation other objects are carried out degree of depth setting then.The degree of depth setting that can guarantee a plurality of objects on the same plane picture like this is consistent.
After depth value was set, system can judge that whether the variation of the depth value of the part that described three-dimensional model is related with the object on the described plane picture surpasses setting threshold, as surpasses, and the depth value of described part is provided with automatically.
Step 140: according to the depth value of each pixel of described three-dimensional model visible surface, for the corresponding pixel points of described object on plane picture is provided with depth value.
This step can be divided into following two sub-steps:
Step 1 is determined the border of described object on plane picture;
Separate described object in the zone that this step can be covered on plane picture based on described three-dimensional model from plane picture.In known algorithm, can realize that the algorithm of this function is a lot, such as: average drifting algorithm, minimal cut/max-flow algorithm (min-cut/max-flow algorithms) etc.
In another embodiment, also can before putting three-dimensional model, determine the border of described object on plane picture earlier.Input instruction when putting described three-dimensional model according to the user, after the size of described three-dimensional model and/or attitude adjusted and show, receive when putting the input instruction of finishing, check earlier whether the described three-dimensional model of putting has covered the border of described object on plane picture fully, if covering or the border of described object on plane picture are not also determined fully, then provide the information of putting again or determining described border earlier.When the three-dimensional model that can avoid like this putting did not cover object fully, the pixel in the border of object on plane picture can not find corresponding pixel on three-dimensional model.When certainly a few pixels point in the border can not find corresponding pixel points, also can get the depth value of its adjacent pixels point or handle by the user.
Step 2, to each pixel in this border, the depth value of this pixel is set to the depth value of this pixel at the pixel of described three-dimensional model visible surface correspondence.
As shown in Figure 5, the zone that is covered by three-dimensional model on the plane picture can be regarded as the projection of three-dimensional model on plane picture, and projection pattern has rectangular projection or perspective projection, is example with rectangular projection among the figure.Equally,, for example put P, can find the corresponding point P ' on the three-dimensional model by projection for each pixel on the plane picture.The degree of depth of P ' point can be made as the degree of depth that P is ordered.
Fig. 6 shows the desk of above-mentioned example and finishes the depth map of being made after the degree of depth is provided with.Among the figure, black is background, and color is white more, and is near more from the user.
The degree of depth of present embodiment is provided with system can realize that as shown in Figure 7, this degree of depth is provided with system and comprises on mobile phone, computer or other have the device of logical operation function:
Model determination module 100 is used for according to input instruction, is identified for one or more three-dimensional models that certain object degree of depth is provided with;
Adjust and display module 200,, the size of described three-dimensional model and/or attitude are adjusted and shown according to input instruction;
First degree of depth is provided with module 300, is used for according to the reference depth value that is provided with and the size and/or the attitude of described three-dimensional model, for each pixel of described three-dimensional model visible surface is provided with depth value;
Second degree of depth is provided with module 400, is used for the depth value according to each pixel of described three-dimensional model visible surface, for the corresponding pixel points of described object on plane picture is provided with depth value.
Described first degree of depth is provided with module when the described reference depth value that is provided with comprises the maximum depth value of the minimum depth value of three-dimensional model closest approach correspondence and solstics correspondence, according to this minimum depth value and maximum depth value, in conjunction with the size and/or the attitude of described three-dimensional model, utilize interpolation algorithm to calculate the depth value of each pixel of described three-dimensional model visible surface.
It is a plurality of objects of same plane picture when the degree of depth is set that described first degree of depth is provided with module, selects one earlier as reference body from a plurality of objects, finishes the degree of depth setting of this reference body; According to the degree of depth setting of this reference body, determine the corresponding relation of three-dimensional model unit sizes and depth value again, based on this corresponding relation other objects are carried out degree of depth setting then.
Described second degree of depth is provided with the depth value of module according to each pixel of described three-dimensional model visible surface, for the corresponding pixel points of described object on plane picture is provided with depth value, comprise: according to the border of described object on plane picture of determining, to each pixel in this border, the depth value of this pixel is set to the depth value of this pixel at the pixel of described three-dimensional model visible surface correspondence.
Described adjustment and display module can also be used for according to input instruction, deformation process is carried out in one or more zones of stereoscopic grid figure, and automatically smoothing processing is done in the neighboring area.
The degree of depth of present embodiment is provided with system can also comprise one or more with in the lower module:
The image insert module is used for according to input instruction, described three-dimensional model being inserted into the editing interface of the plane picture at described object place before the size of described three-dimensional model and/or attitude being adjusted and shown.
3 d model library is used to preserve and safeguard the three-dimensional model of solid figure form; Correspondingly, described model determination module can be identified for one or more three-dimensional models that certain object degree of depth is provided with according to input instruction from described 3 d model library.
The border determination module is used for determining the border of described object on plane picture.
Check module, be used for after according to input instruction the size of described three-dimensional model and/or attitude being adjusted and being shown, check whether described three-dimensional model has covered the border of described object on plane picture fully, if covering or the border of described object on plane picture are not also determined fully, then provide the information of putting again or determining the border earlier; And/or, know the depth value of setting after, judge that whether the variation of the depth value of the part that described three-dimensional model is related with the object on the described plane picture surpasses setting threshold, as surpass, the depth value of described part is provided with automatically.
To sum up, such scheme is by putting three-dimensional model, and three-dimensional model is carried out degree of depth setting and is mapped on the object of plane picture, reached the object on the plane picture is carried out the effect that the degree of depth is provided with.
And said method can also have following lot of advantages.As:
Method is very simple, uses a software to finish and all builds the storehouse, puts, processing such as computing, need be by other software, and user friendly operation.
Use solid figure as three-dimensional model, can carry out nested to object easily.
The depth information of three-dimensional model need not obtain by other three-dimensional animation software, can directly setting obtains to three-dimensional model.
Putting of three-dimensional model, three-dimensional model can be put on the plane picture and put, make both unanimities.
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 ROM (read-only memory), disk or CD etc.Alternatively, all or part of step of the foregoing description also can use one or more integrated circuit 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.
The above is the preferred embodiments of the present invention only, is not limited to the present invention, and for a person skilled in the art, the present invention can have various changes and variation.Within the spirit and principles in the present invention all, any modification of being done, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.