The object picture methods of exhibiting and the system of dynamic fusion background
Technical field
The present invention relates to Flame Image Process, specifically is a kind of object picture methods of exhibiting and system of dynamic fusion background.
Background technology
For the object with transparent characteristic (like liquid, glassware, crystal product; Jade) or the object with transparent component (like glasses; Automobiles etc.), its transparency is not only the important attribute of material, and is its profile and in-built manifestation mode.Under different backgrounds, the design sketch that this type objects demonstrated is diverse.With object picture and background separation; And merge with different background picture and to show its design sketch under different background; Make object picture more lively, be rich in expressive force, help its thingness, profile and internal structure are made more intuitively, are familiar with clearly.
But, transparent substance to be taken pictures, its picture unavoidably is mixed with background information.Therefore present object methods of exhibiting is shot object picture under fixing background perhaps; Can't the dynamic fusion background picture; Perhaps just object picture is processed into the picture of transparent PNG or GIF form, transparent picture is superimposed upon on the background picture simply.This simple superposition on background, its transparent characteristic distortion even forfeiture have a strong impact on bandwagon effect.
In addition, red, green in the color, the light of the corresponding three kinds of different wave lengths of blue three primary colours, the three primary colours transparency of object has been reacted the transmitance of object to these three kinds of different frequency light; In fact, object is not quite similar to the transparency of three kinds of frequency light.The picture of PNG or GIF form adopts an alpha channel to preserve transparency, and each pixel has only a kind of transparency, and is promptly red, green, and the transparency of blue three primary colours is identical numerical value; Therefore, the transparency of transparent picture is taken from the median or the mean value of three primary colours transparency usually, does same treatment like this and has introduced quantization error, reduces the acutance between each primary colours transparency, influences the vividness and the fine and smooth sense of object picture; Under the setting off of background, object tarnishes, and the utmost point is nature not.
Suppose background picture be B (Br, Bg, Bb), object picture be P (Pr, Pg, Pb).Take two kinds of different background pictures of sunglasses and calculate transparency A (Ar according to the method for
patent documentation 1; Ag; Ab) (0 ≤Ar; Ag; Ab=1), the mean square deviation e=
of average transparency Av=(Ar+Ag+Ab)/3 and transparency and average transparency, weigh the deviation between the three primary colours transparency with e.From the result, for bright transparent substance picture, deviation e surpasses 0.1 pixel proportion up to 5%.Maximum deviation reaches 0.45.
Summary of the invention
To the deficiency of prior art, the invention provides a kind of object picture methods of exhibiting and system of dynamic fusion background, can be realistically with object picture and background picture fusion arbitrarily.
Technical matters to be solved by this invention realizes through following technical scheme:
A kind of object methods of exhibiting of dynamic fusion background.Comprise the steps:
Step 1: under object, camera arrangement position and the fixed situation of light, obtain the white background picture and the black background image of the on all four object of Pixel Dimensions;
Step 2: utilization is black, whiteprint separates object picture from background, and further the colouring information picture and the transparence information picture of conversion generation object also deposit system in;
Step 3: adopt the transparent blending algorithm of image, with the background picture fusion of object picture and appointment and pass through system demonstration.
Described step 2 comprises: the color showing of each pixel of white background picture be G1 (G1r, G1g, G1b); The three primary colours color showing of each pixel of black background picture be G2 (G2r, G2g, G2b); The color showing of white background be W (Wr, Wg, Wb); The color showing of black background be B (Br, Bg, Bb); Newly-built two with white, the image of JPEG that the black background dimension of picture is the same or BITMAP form is expressed as PC, PA; Utilize following formula calculate each pixel colouring information C (Cr, Cg, Cb) and transparence information A (Ar, Ag, Ab) (0 ≤Ar, Ag, Ab=1, wherein 0 expression is opaque, and 1 expression is transparent fully);
Ai=(G1i-G2i)/(Wi-Bi) (i=r, g, b) (formula 1)
Ci=(G1i-Ai*Wi)/(1-Ai) (i=r, g, b) (formula 2)
(Ab) multiplication by constants k (getting 128 such as k) and rounding is as the color value of picture PA and the corresponding pixel of background picture for Ar, Ag transparence information A; (Cr, Cg Cb) round, as the color value of picture PC with the corresponding pixel of background picture C; Black, the whiteprint of traversal object finally obtain the colouring information picture PC of corresponding object with it, and transparence information picture PA, deposit the system backstage in.
Described colouring information picture PC and transparence information picture PA are the picture of two JPEG or BITMAP form.
Described step 3 comprises: according to user's selection, system reads the colouring information picture PC and the transparence information picture PA of object from the backstage; The pixel color of supposing the background picture PB that desire merges be B (Br, Bg, Bb); According to user's translation, operations such as scaling are confirmed the relative position of background image and subject image finally to obtain the mapping relations between the two; Color D (Dr, Dg Db) confirm through following formula:
Di=Ai*Bi+ (1-Ai) * Ci (i=r, g, b) (formula 3)
According to mapping relations, (Dr, Dg Db) are set at the color value of the respective pixel of effect picture PD with the color D that calculates.
The transparent blending algorithm of image of the present invention is for adopting formula 3, according to the color of the color calculation effect picture of object color information, transparence information and background picture, rather than simply the transparent picture of object is superimposed upon on the background picture.
Described background picture can be uploaded by user's own, perhaps from the context vault that system provides, selects.
More, if the user specifies the time interval of switching through operating unit, and select to automatically switch, all background pictures that system selects object picture or upload with the user successively automatically according to designated time intervals merge and show.
More, the user can be directly through mouse action mobile object picture on background picture relative position and drag the effect picture, can pass through associative operation scaling background picture.
More, carry out associative operation having merged on the object design sketch of background picture, the user can open new forms; On new forms, the effect picture is with bigger interface display, and effect picture, background picture and object picture can or drag by scaling.
The system that the present invention relates to comprises the object background processing module, is used for black, the white Background of object is processed into colouring information picture and transparence information picture and deposits system in;
The data storage module is used to various types of background pictures of storing object picture and being provided by system.
The foreground display module comprises like lower unit: the background selected cell, show the background picture that desire merges, and uploading perhaps by the user, system provides;
Effect picture display unit, the fusion picture of demonstration object picture and background picture allows user's translation, effect picture, background picture or object picture that scaling merges;
System operation unit: supply user's uploading pictures to use, comprise file selection box and upload button etc.; In addition, provide the user to select background picture amalgamation mode (automatic or manual), switch speed etc. is set;
The historical record unit shows the historical effect picture that merges background.
This system can build based on C/S or B/S framework, if build based on the C/S framework, can on forms, adopt image processing algorithm picture to be handled and directly displaying; If build, then adopt FLASH component Design object picture display unit, and this display unit operates on the browser of client based on the B/S framework.
Can find out from above-mentioned technical scheme,, avoid converting the three primary colours transparency into quantization error that a kind of transparency causes because the transparency of three primary colours is nondestructively preserved on the picture of a JPEG or BITMAP form; And merge the distortion that background has been avoided the thingness that the simple superposition picture is caused on background picture through blending algorithm; And the diversity of background picture be beneficial to the user to thingness do comprehensively, intuitively understanding; Background is switched and user's operation is convenient in the dirigibility of interface operation mode very much.The invention provides the display systems of a nested structureization, included background process and foreground displaying, particularly foreground display module, compact conformation, rationally distributed, perfect in shape and function is for the user provides friendly displaying interface.
Description of drawings
Fig. 1 is the object picture display systems block scheme of dynamic fusion background provided by the invention
Fig. 2 is a background processing module process flow diagram of the present invention
Fig. 3 is that the functional unit of foreground display module is formed block diagram
Fig. 4 is the method flow diagram that merges background
Fig. 5 is the white background picture
Fig. 6 is the black background picture
Fig. 7 is the transparence information picture
Fig. 8 is the colouring information picture
Embodiment
Fig. 1 is the system construction drawing of the object picture display systems of dynamic fusion background.This system comprises background processing module 101, data storage module 102 and foreground display module 103.
Wherein, background processing module 101 is used for the handled object picture, and the picture according to taking good different background utilizes the transparency acquisition algorithm to obtain the transparency and the color of object, and the picture with JPEG or BITMAP form deposits data storage module 102 in respectively.
Data storage module 102 is used for some data that storage system is used, and comprises object transparence information picture and colouring information picture, diversity of settings picture etc.This module can have various ways according to different frameworks, such as database server, and local computing, the remote computer or the webserver etc.;
Foreground display module 103 provides the display platform that merges the picture that generates; According to user's operation, system is with selected object picture and background picture fusion and pass through this modules exhibit to the user, in addition; This module provides the user to carry out the interface of interactive operation; Through these interfaces, the user can select picture, scaling or translation picture; Uploading pictures is transferred historical record etc.
Fig. 2 is the processing flow chart of background processing module.Flow process is following: select white background picture 501, the left button of clicking the mouse in the background area of white background picture is selected white background color 502; Select black background picture 601, the left button of clicking the mouse in the background area of black background picture is selected black background color 602; Two pictures according to above-mentioned selection; Program is by newly-built two pictures of its size; Obtain pixel color black, the white background picture one by one,, multiply by certain coefficient and round the wherein color value of a same pixel of new picture of conduct later on through the transparency of formula 1 this pixel of calculating; Color through formula 2 these pixels of calculating rounds the color value as the same pixel of another new picture; Traversal is black, all pixels of whiteprint, finally obtains the transparence information picture 701 and the colouring information picture 801 of object.Two pictures that generate are saved as the picture of jpeg format or BITMAP form; If system is based on the B/S framework; Then picture is caught the WEB server, and in database other relevant information of typing, if system is C/S framework or stand-alone program; Then deposit in long-range picture or local hard drive, other relevant information of typing in the database.
Another part function of background processing module is the typing 104 of background picture; System selects various types of pictures in advance on the backstage, such as people's head portrait, sunshine; High light; Pictures such as landscape painting also are kept at the backstage, and the selection aim of these background pictures is fully to show the attribute of object, particularly transparent attribute.
The foreground display module comprises object picture display unit 401, background picture display unit 402, and system operation unit 403, effect picture display unit 404, historical record display unit 405,
In object picture display unit 401, system lists all objects picture classification paging of typing.
In background picture 402, system listed input system the background picture of having powerful connections and uploading by user oneself.
The user at first selects the picture A that will show, and selects background picture, and system utilizes blending algorithm that both are merged and displays according to selecting.According to user's operation, can put the translation of combination scaling to object picture and background picture respectively, be true origin with the position, the upper left corner of merging the picture presentation unit; The scaling ratio of supposing object picture is K1; Relatively origin translation=position be (X0, Y0), the scaling ratio of background picture is K2; Relatively the position of origin translation be (X1, Y1);
At first adopt the bilinear interpolation algorithm that background picture is carried out the scaling operation, generate new picture and be kept at Installed System Memory.
Calculate background picture with respect to the displacement of object picture (X1-X0, Y1-Y0).
System merges calculating according to aforesaid operations; If (X Y), reads the color value B (Br of this pixel to the background picture pixel of current calculating; Bg; Bb) ((X+X0-X1)/K2 (Y+Y0-Y1)/K2), judges that whether this pixel is the effective pixel points in the object picture range of size to calculate the pixel of object picture on the other side according to the scaling proportional meter of relative position and background picture.If effective pixel points, from object transparence information picture read transparency A (Ar, Ab, Ag); From the colouring information picture, read color C (Cr, Cg, Cb), according to formula Di=Ai*Bi+ (1-Ai) * Ci (i=r; G, b), with D (Dr; Dg Db) calculates the Fusion of Color of four neighborhoods of this pixel one by one, and adopts the bilinear interpolation algorithm to generate this pixel and color on the syncretizing effect picture according to the color of each neighborhood.Travel through all pixels on the background picture successively, generation syncretizing effect picture also shows on effect picture display unit 404.
If system is based on the B/S framework, effect picture display unit 404 is made based on the FLASH platform, through JAVASCRIPT function call ACTIONSCRIPT function to FLASH component passes picture path, relative position, parameters such as scaling ratio.FLASH utilizes formula 3 to carry out image co-registration according to these parameters and handles and bandwagon effect.Avoid like this carrying out the large amount of complex computing, reduced the server negative terminal at server end.
On effect picture display unit 404, can directly drag object picture or background picture, double-click and then can open new window, in the window of newly opening, the picture of fusion shows with large scale.Make things convenient for the user to observe the detail section of picture, the user still can directly carry out scaling or translation to object picture or background picture through mouse action.
If the user selects to merge automatically and be provided with switching time in system operation unit 403, then system can be automatically successively with the background picture display unit on background picture merge, to user's bandwagon effect picture.The user click this unit amplification, dwindle picture and can carry out scaling the picture of object or background.
In system operation unit 403, the user can select local picture to be uploaded to system and object picture merges, and browses the design sketch of object picture on this background picture.
Fusion historical record before historical record display unit 405 is used to show; If the user selects a certain historical record through mouse action; The effect picture presentation singly can show this history again, is convenient to the user like this design sketch of object on different backgrounds carried out the reference contrast.
Foreground display module display form can change according to page layout, and the foregrounding step is operated thousand changes, ten thousand changes according to the user, as long as the user provides enough parameters, system just can provide the effect picture to supply the user to browse.