Summary of the invention
The technical problem to be solved in the present invention is to provide 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 Depth arranges;
According to input instruction, the size of described three-dimensional model and/or attitude are adjusted and shown;
According to the reference depth value arranging and size and/or the attitude of described three-dimensional model, for each pixel of described three-dimensional model visible surface arranges 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 arranges depth value.
Preferably,
Described three-dimensional model is solid figure.
Preferably,
Before the size of described three-dimensional model and/or attitude are adjusted and shown, also comprise: according to input instruction, described three-dimensional model is inserted into the editing interface of the plane picture at described object place.
Preferably,
Described reference depth value comprises the depth value of any two or more positions on described three-dimensional model; Or described reference depth value comprises the depth value of any one position on described three-dimensional model, and depth value corresponding to three-dimensional model unit sizes.
Preferably,
Described reference depth value comprises maximum depth value corresponding to minimum depth value and solstics that three-dimensional model closest approach is corresponding;
Described according to the reference depth value arranging and size and the attitude of described three-dimensional model, for each pixel of described three-dimensional model visible surface arranges depth value, specifically comprise:
According to this minimum depth value and maximum depth value, in conjunction with 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,
Described degree of depth method to set up also comprises:
While the degree of depth being set for a plurality of objects of same plane image, first from a plurality of objects, select one as reference body, complete 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, then based on this corresponding relation, other objects are carried out to degree of depth setting.
Preferably,
Described 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 arranges depth value, comprising:
Each pixel in ,Dui Gai border, border according to the described object of determining on plane picture, the depth value of this pixel is set to this pixel at the depth value of pixel corresponding to described three-dimensional model visible surface.
Preferably,
Described degree of depth method to set up also comprises:
First determine the border of described object on plane picture, after the size of described three-dimensional model and/or attitude adjusted and being shown according to input instruction, check whether described three-dimensional model has covered the border of described object on plane picture completely, if covering or the border of described object on plane picture are not also determined completely, provide and re-start the information of putting or first determining border.
Preferably,
Described solid figure is the stereoscopic grid figure that comprises a plurality of regions;
According to the reference depth value arranging and size and/or the attitude of described three-dimensional model, for before each pixel of described three-dimensional model visible surface arranges depth value, also comprise:
According to input instruction, deformation process is carried out in one or more regions of described stereoscopic grid figure, and automatically smoothing processing is done in neighboring area.
Correspondingly, on plane picture provided by the invention, the degree of depth of object arranges system, comprising:
Model determination module, for according to input instruction, is identified for one or more three-dimensional models that certain Object Depth arranges;
Adjust and display module, according to input instruction, the size of described three-dimensional model and/or attitude are adjusted and shown;
First degree of depth arranges module, for according to the reference depth value arranging and size and/or the attitude of described three-dimensional model, for each pixel of described three-dimensional model visible surface arranges depth value;
Second degree of depth arranges module, for 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 arranges depth value.
Preferably,
The described degree of depth arranges system and also comprises:
Image insert module, for according to input instruction, is inserted into described three-dimensional model the editing interface of the plane picture at described object place.
Preferably,
The described degree of depth arranges system and also comprises:
3 d model library, for preserving and safeguard the three-dimensional model of solid figure form;
Described model determination module, for according to input instruction, is identified for one or more three-dimensional models that certain Object Depth arranges from described 3 d model library.
Preferably,
Described first degree of depth arranges module when the described reference depth value arranging comprises minimum depth value that three-dimensional model closest approach is corresponding and maximum depth value corresponding to solstics, according to this minimum depth value and maximum depth value, in conjunction with 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 image when the degree of depth is set that described first degree of depth arranges module, first from a plurality of objects, selects one as reference body, completes 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, then based on this corresponding relation, other objects are carried out to degree of depth setting.
Preferably,
Described second degree of depth arranges module 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 arranges depth value, comprise: the border according to the described object of determining on plane picture, to each pixel in this border, the depth value of this pixel is set to this pixel at the depth value of pixel corresponding to described three-dimensional model visible surface.
Preferably, the described degree of depth arranges system and also comprises:
Border determination module, for determining the border of described object on plane picture;
Checking module, for after the size of described three-dimensional model and/or attitude being adjusted according to input instruction and being shown, check whether described three-dimensional model has covered the border of described object on plane picture completely, if covering or the border of described object on plane picture are not also determined completely, provide and re-start the information of putting or first determining border; And/or, know after the depth value of setting, judge that whether the variation of the depth value of the part that described three-dimensional model is associated with object on described plane picture surpasses setting threshold, as surpass, the depth value of described part is carried out to Lookup protocol.
Preferably,
Described adjustment and display module, also, for according to input instruction, carry out deformation process to one or more regions of stereoscopic grid figure, and automatically smoothing processing done in neighboring area.
On above-mentioned plane picture, 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, and the degree of depth setting of plane picture are become simply, flexibly and accurately.
Embodiment
For making the object, technical solutions and advantages of the present invention clearer, hereinafter in connection with accompanying drawing, embodiments of the invention are elaborated.It should be noted that, in the situation that not conflicting, the embodiment in the application and the feature in embodiment be combination in any mutually.
The first embodiment
At the object on plane picture, arrange before the degree of depth, can system be set in the degree of depth (can be system independently, also can be the subsystem of large graphic system, below the degree of depth be arranged to system referred to as system) in set up model bank or utilize other model bank.The effect of model bank is to provide the three-dimensional model of using when the degree of depth is set.In the present embodiment, the three-dimensional model in model bank comprises the basic solid figures such as ball, cylinder, circular cone, rectangular parallelepiped.These three-dimensional models are adjustable, can be by varying sized and attitudes such as stretching, convergent-divergent and rotations, with plane picture on object match.Meanwhile, using solid figure as three-dimensional model, also more conveniently object on plane picture is carried out nested, be about to whole object and be included in three-dimensional model.
In other embodiments, if the accuracy requirement that the degree of depth is arranged is not high, model bank also can be only with an adjustable rectangular parallelepiped or an adjustable ball.If the accuracy requirement that the degree of depth is arranged is higher, can comprise the complex three-dimensional model that a plurality of solid figures form.
Utilize basic solid figure as three-dimensional model, the making of model or obtain very simply, completes without the instrument by other, also without setting up different mock-ups according to objects different on plane picture, compare with setting up mock-up, be very easy to design and use.
For the object of the degree of depth to be arranged on plane picture, the flow process that the present embodiment carries out degree of depth setting as shown in Figure 1, comprising:
Step 110: according to input instruction, extract corresponding one or more three-dimensional model from model bank;
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 section 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 more, just more easily approaches the true form of object on plane picture when next step is put, and the degree of depth of setting is just more accurate.
Please refer to Fig. 2 a and Fig. 2 b, is an example of the present embodiment degree of depth method to set up, and in this example, the object of the degree of depth to be arranged is a desk, and the three-dimensional model that user selects is 3 right cylinders (only illustrating one in figure).
It should be noted that, the present invention might not need the model bank of use system itself, also can be from other local importings.If only use simple solid figure, when coupling, create again also passable.
Step 120, according to input instruction, adjusts and shows the size of described three-dimensional model and/or attitude;
Preferably, system provides the function of the editing interface that is inserted into object place plane picture using three-dimensional model as object.Before this step, described three-dimensional model can be inserted into the editing interface of the plane picture at described object place.User just can directly put three-dimensional model according to the object on primary plane image like this, and size and attitude that size that three-dimensional module presents is presented with object with attitude on plane picture are as far as possible consistent, and then has also improved the accuracy of degree of depth setting.
In above-mentioned example, 3 right cylinders are put respectively, the position relationship respectively and between the desktop of desk, pillar and base and each several part matches, and generally answers the corresponding part on overlay planes image.Preferably, can directly be enclosed within on plane picture and put.3 cylindrical composite figures after putting as shown in Figure 3 a.Each right cylinder is 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 regions; In this step, can also, according to input instruction, deformation process be carried out in one or more regions of described stereoscopic grid figure, and automatically smoothing processing is done in neighboring area.For example, the surface of rectangular parallelepiped can be divided into many regions, these regions can be square, can be circular, also can triangle etc.When three-dimensional model is adjusted, for make three-dimensional model better with object matches, carrying out, outside the adjustment of size and attitude, can also doing deformation process.For example, when a rectangular parallelepiped is mated with petal, can do concave, convex processing to some region and make its matching degree better, and the neighboring area in these regions can be done smoothing processing automatically.
Step 130: according to the reference depth value arranging and size and/or the attitude of described three-dimensional model, for each pixel of described three-dimensional model visible surface arranges depth value;
In this step, the reference depth value of setting can be the depth value of any two or more positions on three-dimensional model, can be also depth value and the depth value corresponding to three-dimensional model unit sizes of any one position on three-dimensional model, etc.Described position be as being the unique points such as closest approach, solstics or central point of this three-dimensional model, any point that also can user's appointment on three-dimensional model.The reference depth value arranging can represent by distance, also can directly adopt gray-scale value to represent.For a plurality of three-dimensional models of putting simultaneously, only need to provide one group of reference depth value.
Take the reference depth value that arranges as maximum depth value corresponding to minimum depth value corresponding to three-dimensional model closest approach and solstics be 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, the part that can see, corresponding with the object on plane picture.Normally, when the size of three-dimensional model is model of creation storehouse, systematic unity is set, and when three-dimensional model is scaled, the size of three-dimensional model also changes thereupon.
For example, the three-dimensional model shown in Fig. 4 is cube.D
nthe depth value of the nearest position (closest approach) of the three-dimensional model relative distance user that arranges of user, D
fit is the depth value of the three-dimensional model distance users that arranges of user person position (solstics) farthest.The distance that can calculate between this closest approach and solstics according to the size of three-dimensional model and attitude is L, and the depth value of the point that nearest point is l is: D
l=D
n+ l* (D
f-D
n)/L.D
nand D
fcan estimate or calculate by other modes by user.
In Fig. 4, P
nthe nearest position of distance users, i.e. P
n=255; P
fdistance users position farthest, i.e. P
f=0.P
nand P
fcan calculate and obtain according to the reference depth value representing with gray-scale value, also can calculate and obtain with the corresponding relation of gray scale according to the reference depth value representing by distance and distance.When the degree of depth being set for a plurality of objects of same plane image, P
nand P
fshould remain unchanged.
While the degree of depth being set for a plurality of objects of same plane image, can from a plurality of objects, select one as reference body, complete 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, then based on this corresponding relation, other objects are carried out to degree of depth setting.The degree of depth setting that can guarantee so a plurality of objects on same plane image is consistent.
After depth value is set, system can judge that whether the variation of the depth value of the part that described three-dimensional model is associated with object on described plane picture surpasses setting threshold, as surpass, and carries out Lookup protocol to the depth value of described part.
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 arranges depth value.
This step can be divided into following two sub-steps:
Step 1, determines the border of described object on plane picture;
Separate described object from plane picture in the region that this step can cover based on described three-dimensional model on plane picture.In known algorithm, the algorithm that can realize this function is a lot, such as: mean shift algorithm, minimal cut/max-flow algorithm (min-cut/max-flow algorithms) etc.
In another embodiment, also can, before putting three-dimensional model, first determine the border of described object on plane picture.Input instruction while putting described three-dimensional model according to user, after the size of described three-dimensional model and/or attitude are adjusted and are shown, while receiving the input instruction of having put, first check whether the described three-dimensional model of putting has covered the border of described object on plane picture completely, if covering or the border of described object on plane picture are not also determined completely, provide and re-start the information of putting or first determining described border.When the three-dimensional model that can avoid like this putting does not cover object completely, the pixel in the border of object on plane picture can not find corresponding pixel on three-dimensional model.When a few pixels point in border can not find corresponding pixel points certainly, also can get the depth value of its adjacent pixels point or be processed by user.
Step 2, to each pixel in this border, the depth value of this pixel is set to this pixel at the depth value of pixel corresponding to described three-dimensional model visible surface.
As shown in Figure 5, the region being covered by three-dimensional model on plane picture, can be regarded as the projection of three-dimensional model on plane picture, and projection pattern has rectangular projection or perspective projection, take rectangular projection as example in figure.Equally, for each pixel on plane picture, for example, put P, can, by projection, find the corresponding point P ' on three-dimensional model.The degree of depth of P ' point can be made as the degree of depth that P is ordered.
The desk that Fig. 6 shows above-mentioned example completes the degree of depth rear made depth map is set.In figure, black is background, and color is whiter, from user more close to.
The degree of depth of the present embodiment arranges system and can on mobile phone, computer or other have the device of logical operation function, realize, and as shown in Figure 7, this degree of depth arranges system and comprises:
Model determination module 100, for according to input instruction, is identified for one or more three-dimensional models that certain Object Depth arranges;
Adjust and display module 200, according to input instruction, the size of described three-dimensional model and/or attitude are adjusted and shown;
First degree of depth arranges module 300, for according to the reference depth value arranging and size and/or the attitude of described three-dimensional model, for each pixel of described three-dimensional model visible surface arranges depth value;
Second degree of depth arranges module 400, for 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 arranges depth value.
Described first degree of depth arranges module when the described reference depth value arranging comprises minimum depth value that three-dimensional model closest approach is corresponding and maximum depth value corresponding to solstics, according to this minimum depth value and maximum depth value, in conjunction with 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 image when the degree of depth is set that described first degree of depth arranges module, first from a plurality of objects, selects one as reference body, completes 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, then based on this corresponding relation, other objects are carried out to degree of depth setting.
Described second degree of depth arranges module 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 arranges depth value, comprise: the border according to the described object of determining on plane picture, to each pixel in this border, the depth value of this pixel is set to this pixel at the depth value of pixel corresponding to described three-dimensional model visible surface.
Described adjustment and display module, can also, for according to input instruction, carry out deformation process to one or more regions of stereoscopic grid figure, and automatically smoothing processing be done in neighboring area.
The degree of depth of the present embodiment arranges system can also comprise one or more with in lower module:
Image insert module, for before the size of described three-dimensional model and/or attitude being adjusted and shown, according to input instruction, is inserted into described three-dimensional model the editing interface of the plane picture at described object place.
3 d model library, for preserving and safeguard the three-dimensional model of solid figure form; Correspondingly, described model determination module can, according to input instruction, be identified for one or more three-dimensional models that certain Object Depth arranges from described 3 d model library.
Border determination module, for determining the border of described object on plane picture.
Checking module, for after the size of described three-dimensional model and/or attitude being adjusted according to input instruction and being shown, check whether described three-dimensional model has covered the border of described object on plane picture completely, if covering or the border of described object on plane picture are not also determined completely, provide and re-start the information of putting or first determining border; And/or, know after the depth value of setting, judge that whether the variation of the depth value of the part that described three-dimensional model is associated with object on described plane picture surpasses setting threshold, as surpass, the depth value of described part is carried out to Lookup protocol.
To sum up, such scheme, by putting three-dimensional model, carries out degree of depth setting and is mapped on the object of plane picture three-dimensional model, has reached the effect of the object on plane picture being carried out to degree of depth setting.
And said method can also have following lot of advantages.As:
Method is very simple, uses a software to complete and all builds storehouse, puts, the processing such as computing, need to be by other software, and user friendly operation.
Use solid figure as three-dimensional model, can to object, carry out nested easily.
The depth information of three-dimensional model need to not obtain by other Three-dimensional Animation Softwares, can directly to three-dimensional model, setting obtains.
Putting of three-dimensional model, three-dimensional model can be put on plane picture and put, make both consistent.
One of ordinary skill in the art will appreciate that all or part of step in said method can come instruction related hardware to complete by program, described program can be stored in computer-readable recording medium, as ROM (read-only memory), disk or CD etc.Alternatively, all or part of step of above-described embodiment also can realize with one or more integrated circuit, and correspondingly, each the module/unit in above-described embodiment can adopt the form of hardware to realize, and 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 foregoing is only the preferred embodiments of the present invention, be not limited to the present invention, for a person skilled in the art, the present invention can have various modifications and variations.Within the spirit and principles in the present invention all, any modification of doing, be equal to replacement, improvement etc., within all should being included in protection scope of the present invention.