Object picture methods of exhibiting and the system of dynamic fusion background
Technical field
The present invention relates to image and process, specifically a kind of object picture methods of exhibiting and system of dynamic fusion background.
Background technology
For have transparent characteristic object (as liquid, glassware, crystal product, jade) or the object with transparent component (as glasses, automobiles etc.), its transparency is not only the important property of material, and is its profile and in-built manifestation mode.Under different backgrounds, the design sketch that this type objects presents is diverse.By object picture and background separation, and show its design sketch under different background from different background picture fusions, make object picture more lively, be rich in expressive force, contribute to its thingness, profile and internal structure to make more intuitively, be familiar with clearly.
But, transparent substance to be taken pictures, its picture is unavoidably mixed with background information.So current object methods of exhibiting or shot object picture under fixing background, cannot dynamic fusion background picture, or the picture that just object picture is processed into transparent PNG or GIF form, is superimposed upon transparent picture on background picture simply.This simple superposition in background, its transparent characteristic distortion is even lost, and has a strong impact on bandwagon effect.
In addition, the light of the corresponding three kinds of different wave lengths of red, green, blue three primary colours in color, 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 only has a kind of transparency, and the transparency of red, green, blue three primary colours is identical numerical value; Therefore, the transparency of transparent picture is taken from median or the mean value of three primary colours transparency conventionally, does like this same treatment and has introduced quantization error, reduces the acutance between each primary colours transparency, affects 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 that background picture is B (Br, Bg, Bb), object picture is P (Pr, Pg, Pb).According to the method for patent documentation 1, take two kinds of different background pictures of sunglasses and calculate transparency A(Ar, 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
, with e, weigh the deviation between three primary colours transparency.From the results of view, for bright transparent substance picture, deviation e surpasses 0.1 pixel proportion up to 5%.Maximum deviation reaches 0.45.
Summary of the invention
For the deficiencies in the prior art, the invention provides a kind of object picture methods of exhibiting and system of dynamic fusion background, can be realistically by object picture and background picture fusion arbitrarily.
Technical matters to be solved by this invention is achieved through the following technical solutions:
A kind of object methods of exhibiting of dynamic fusion background.Comprise the steps:
Step 1: in object, camera arrangement position and the fixed situation of light, obtain white background picture and the black background image of the on all four object of Pixel Dimensions;
Step 2: utilize black, whiteprint that object picture is separated from background, colouring information picture and transparence information picture that further conversion generates object also deposit system in;
Step 3: adopt the transparent blending algorithm of image, the background picture of object picture and appointment is melted to merga pass system demonstration.
Described step 2 comprises: the color table of each pixel of white background picture is shown G1 (G1r, G1g, G1b), the three primary colours color table of each pixel of black background picture is shown G2 (G2r, G2g, G2b), the color table of white background is shown W1 (W1r, W1g, W1b), the color table of black background is shown B1 (B1r, B1g, B1b); Newly-built two with white, the image of the JPEG that black background dimension of picture is the same or BITMAP form, is expressed as PC, PA; Utilize following formula calculate the colouring information C (Cr, Cg, Cb) of each pixel and transparence information A (Ar, Ag, Ab) (0<=Ar, Ag, Ab<=1, wherein 0 represent opaque, 1 represent completely transparent);
Ai=(G1i-G2i)/(W1i-B1i) (i=r, g, b) (formula 1)
Ci=(G1i-Ai*W1i)/(1-Ai) (i=r, g, b) (formula 2)
Transparence information A (Ar, Ag, Ab) multiplication by constants k(such as k gets 128) and round, as the color value of the picture PA pixel corresponding with background picture; C (Cr, Cg, Cb) is rounded to the color value as picture PC with the corresponding pixel of background picture; Black, the whiteprint of traversal object, finally obtain the colouring information picture PC of the object of answering in contrast, and transparence information picture PA, deposits 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 colouring information picture PC and the transparence information picture PA of object from backstage; The pixel color of supposing the background picture PB that wish merges is B (Br, Bg, Bb); According to user's translation, the operations such as scaling, determine and the relative position of background image and subject image finally obtain the mapping relations between the two; Color D(Dr, Dg, Db) by following formula, determine:
Di=Ai*Bi+ (1-Ai) * Ci(i=r, g, b) (formula 3)
According to mapping relations, the color D calculating (Dr, Dg, Db) is set as to the color value of the respective pixel of effect picture PD.
The transparent blending algorithm of image of the present invention, for adopting formula 3, calculates the color of effect picture, rather than simply the transparent picture of object is superimposed upon on background picture according to the color of object color information, transparence information and background picture.
Described background picture can independently be uploaded by user, or selects the context vault providing from system.
More, if user specifies the time interval of switching by operating unit, and select to automatically switch, all background pictures that system was automatically selected object picture or upload with user successively according to the time interval of appointment merge and show.
More, user can be directly by mouse action mobile object picture the relative position on background picture and drag 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, user can open new forms; On new forms, effect picture is with larger interface display, and effect picture, background picture and object picture can or drag by scaling.
The system the present invention relates to comprises object background processing module, for black, the white Background of object is processed into colouring information picture and transparence information picture and deposits system in;
Data storage module, for various types of background pictures of storing object picture and being provided by system.
Foreground display module, comprises as lower unit: background selected cell, show the background picture that wish merges, and by user, uploaded or 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 operating unit: for user's uploading pictures, comprise file selection box and upload button etc.; In addition, provide user to select background picture amalgamation mode (automatic or manual), switch speed etc. is set;
Historical record unit, shows the historical effect picture that merges background.
This system can be built based on C/S or B/S framework, if built based on C/S framework, can on forms, adopt image processing algorithm picture is processed and directly shown; If built based on B/S framework, adopt FLASH component design object picture display unit, and this display unit operates on the browser of client.
From above-mentioned technical scheme, can find out, because the transparency of three primary colours is nondestructively preserved on the picture of a JPEG or BITMAP form, avoid three primary colours transparency to be converted to the quantization error that a kind of transparency causes; And merge by blending algorithm the distortion that background has been avoided the thingness that simple superposition picture causes on background picture; And the diversity of background picture be beneficial to 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 a set of structurized display systems, included background process and foreground displaying, particularly foreground display module, compact conformation, rationally distributed, perfect in shape and function, for user provides friendly displaying interface.
Accompanying drawing explanation
Fig. 1 is the object picture display systems block scheme of dynamic fusion background provided by the invention
Fig. 2 is background processing module process flow diagram of the present invention
Fig. 3 is that the functional unit of foreground display module forms block diagram
Fig. 4 is the method flow diagram that merges background
Fig. 5 is white background picture
Fig. 6 is black background picture
Fig. 7 is transparence information picture
Fig. 8 is 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, for the treatment of object picture, according to the picture of the different background of having taken, utilizes transparency acquisition algorithm to obtain transparency and the color of object, and the picture with JPEG or BITMAP form deposits data storage module 102 in respectively.
Some data that data storage module 102 is used for storage system, comprise object transparence information picture and colouring information picture, diversity of settings picture etc.This module, according to different frameworks, can have various ways, such as database server, and local computing, remote computer or the webserver etc.;
Foreground display module 103 provides the display platform that merges the picture generating; According to user's operation, system is melted this modules exhibit of merga pass to user by selected object picture and background picture, in addition, this module provides user to carry out the interface of interactive operation, by these interfaces, user can select picture, scaling or translation picture, uploading pictures, transfers historical record etc.
Fig. 2 is the processing flow chart of background processing module.Flow process is as follows: select white background picture 501, the left button of clicking the mouse in the background area of white background picture, selects white background color 502; Select black background picture 601, the left button of clicking the mouse in the background area of black background picture, selects black background color 602; According to two pictures of above-mentioned selection, program is by newly-built two pictures of its size, obtain one by one pixel color black, white background picture, by formula 1, calculate the transparency of this pixel, be multiplied by certain coefficient and round the wherein color value of a same pixel of new picture of conduct later, the color of calculating this pixel by formula 2, rounds the color value as the same pixel of another new picture; Travel through all pixels black, whiteprint, finally obtain transparence information picture 701 and the colouring information picture 801 of object.Two pictures that generate are saved as to the picture of jpeg format or BITMAP form, if system is based on B/S framework, picture is caught to WEB server, and in database other relevant information of typing, if system is C/S framework or stand-alone program, picture is deposited in to long-range or local hard drive, other relevant information of typing in database.
Another part function of background processing module is the typing 104 of background picture, system is selected various types of pictures in advance on backstage, head portrait such as people, sunshine, high light, the pictures such as landscape painting are also kept at backstage, and the selection aim of these background pictures is fully to show the attribute, particularly transparent attribute of object.
Foreground display module comprises object picture display unit 401, background picture display unit 402, and system operating unit 403, effect picture display unit 404, historical record display unit 405,
In object picture display unit 401, system is listed all objects picture classification paging of typing.
In background picture 402, system listed input system the background picture of having powerful connections and being uploaded by user oneself.
First user selects the picture A that will show, and selects background picture, and system utilizes blending algorithm both are merged and display according to selecting.According to user's operation, can to object picture and background picture, put in conjunction with scaling translation respectively, take the position, the upper left corner of merging picture presentation unit is true origin, the scaling ratio of supposing object picture is K1, relative origin translation=position is (X0, Y0), the scaling ratio of background picture is K2, the position of origin translation is (X1, Y1) relatively;
First adopt bilinear interpolation algorithm to carry out scaling operation to background picture, generate new picture and be kept at Installed System Memory.
Calculate background picture with respect to the displacement (X1-X0, Y1-Y0) of object picture.
System is carried out fusion calculation according to aforesaid operations, if the background picture pixel (X of current calculating, Y), read the color value B(Br of this pixel, Bg, Bb) according to the scaling ratio of relative position and background picture, calculate the pixel ((X+X0-X1)/K2, (Y+Y0-Y1)/K2) of object picture on the other side, judge whether this pixel is the effective pixel points in object picture range of size.If effective pixel points reads transparency A(Ar, Ab from object transparence information picture, Ag), from colouring information picture, read color C(Cr, Cg, Cb), according to formula Di=Ai*Bi+ (1-Ai) * Ci(i=r, g, b), by D(Dr, Dg, Db) calculate one by one the Fusion of Color of four neighborhoods of this pixel, and adopt bilinear interpolation algorithm to generate this pixel and color on syncretizing effect picture according to the color of each neighborhood.Travel through successively all pixels on background picture, generate syncretizing effect picture and show on effect picture display unit 404.
If system is based on B/S framework, effect picture display unit 404 is made based on FLASH platform, by JAVASCRIPT function call ACTIONSCRIPT function to FLASH component passes picture path, relative position, the parameters such as scaling ratio.FLASH utilizes formula 3 to carry out image co-registration according to these parameters and processes and bandwagon effect.Avoid like this carrying out large amount of complex computing at server end, reduced server negative terminal.
On effect picture display unit 404, can directly drag object picture or background picture, double-click and can open new window, in the window of newly opening, the picture of fusion shows with large scale.Facilitate user to observe the detail section of picture, user still can directly carry out scaling or translation to object picture or background picture by mouse action.
If user selects automatically to merge and be provided with switching time in system operating unit 403, system can be automatically successively with background picture display unit on background picture merge, to user's bandwagon effect picture.User click this unit amplification, dwindle picture and can carry out scaling to the picture of object or background.
In system operating unit 403, user can select local picture uploading to system and object picture to merge, and browses the design sketch of object picture on this background picture.
Historical record display unit 405 is for the fusion historical record before showing, if user selects a certain historical record by mouse action, effect picture presentation list can show this history again, and the design sketch in different backgrounds carries out reference contrast to object to be convenient to like this user.
Foreground display module display form can change according to page layout, and foregrounding step operates thousand change ten thousand changes according to user, as long as user provides enough parameters, system just can provide effect picture to browse for user.