CN107045729B - A kind of image rendering method and device - Google Patents

A kind of image rendering method and device Download PDF

Info

Publication number
CN107045729B
CN107045729B CN201710312950.1A CN201710312950A CN107045729B CN 107045729 B CN107045729 B CN 107045729B CN 201710312950 A CN201710312950 A CN 201710312950A CN 107045729 B CN107045729 B CN 107045729B
Authority
CN
China
Prior art keywords
profile
stroke
vertex
target object
rendering
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710312950.1A
Other languages
Chinese (zh)
Other versions
CN107045729A (en
Inventor
刘皓
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201710312950.1A priority Critical patent/CN107045729B/en
Publication of CN107045729A publication Critical patent/CN107045729A/en
Application granted granted Critical
Publication of CN107045729B publication Critical patent/CN107045729B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/02Non-photorealistic rendering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/005General purpose rendering architectures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/04Texture mapping
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/50Lighting effects
    • G06T15/506Illumination models

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Graphics (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Generation (AREA)

Abstract

The present invention provides a kind of image rendering method and devices, wherein the method includes:Obtain the first profile of target object;From the vertex of the target object, the profile vertex in the first profile is selected;Second profile of the target object that obtains that treated through presetting light source and default illumination model;According to the location information on the profile vertex, in the corresponding color of second configuration sampling, and according to the color sampled, the stroke width of the profile vertex correspondence is determined;According to the stroke width of the profile vertex correspondence, the stroke on the profile vertex of connecting is generated, and the stroke is rendered according to predetermined rendering mode, the profile texture after being rendered.The present invention is based on the colors of illumination profile to carry out profile rendering so that the profile after rendering can reflect Lighting information, improve rendering effect.In addition, the present invention can be realized by programmable pipeline in the image processor, rendering efficiency is improved.

Description

A kind of image rendering method and device
Technical field
The present invention relates to technical field of image processing, and in particular to a kind of image rendering method and device.
Background technology
In technical field of image processing, photo live stage can be used often and renders (PR, Photorealistic Rendering) and non-photograph live stage renders (NPR, Non-Photorealistic Rendering) technology.Wherein, PR is Refer to through the research to actual physical shadow, makes the rendering effect of real world;NPR refers to passing through paintbrush by studying artist The abstract artistic conception sketched the contours of is made and the rendering effect that be abstracted artistic conception similar.NPR is one kind of computer graphics, mainly For simulating artistic type drawing style, it is also used for developing new drafting style.
Different with traditional computer graphics of the pursuit sense of reality, NPR is by oil painting, sketch, technical drawing and moves The influence for drawing cartoon, develop in the field it is more and more ripe general related with western paintings, such as sketch images, pen Picture, carbon pencil picture, watercolor, cartoon etc..Currently, NPR also begins to carry out related rendering using the style of writing of Chinese ink painting.
Invention content
An embodiment of the present invention provides a kind of image rendering method and devices, realize a kind of image wheel based on Lighting information Exterior feature renders.
In a first aspect, an embodiment of the present invention provides a kind of image rendering methods, including:
Obtain the first profile of target object;
From the vertex of the target object, the profile vertex in the first profile is selected;
Second profile of the target object that obtains that treated through presetting light source and default illumination model;
According to the location information on the profile vertex, in the corresponding color of second configuration sampling, and according to sampling Color, determine the stroke width of the profile vertex correspondence;
According to the stroke width of the profile vertex correspondence, the stroke on the profile vertex of connecting is generated, and according to predetermined Rendering mode renders the stroke, the profile texture after being rendered.
Second aspect, the embodiment of the present invention additionally provide a kind of image rendering device, including:
First acquisition module, the first profile for obtaining target object;
Selecting module, for from the vertex of the target object, selecting the profile vertex in the first profile;
Second acquisition module, for obtaining the through default light source and default illumination model treated the target object Two profiles;
Stroke module, it is corresponding in second configuration sampling for the location information according to the profile vertex Color, and according to the color sampled, determine the stroke width of the profile vertex correspondence;
Stroke generation module generates the profile vertex of connecting for the stroke width according to the profile vertex correspondence Stroke, and render the stroke according to predetermined rendering mode, the profile texture after being rendered.
Image rendering method and device provided in an embodiment of the present invention, at least have the advantages that:
The image rendering method and device of the embodiment of the present invention, the color based on illumination profile carry out profile rendering so that Profile after rendering can reflect Lighting information, improve rendering effect.In addition, the method and apparatus of the embodiment of the present invention, It can be realized by programmable pipeline in image processor (GPU), improve rendering efficiency.
Description of the drawings
In order to illustrate the technical solution of the embodiments of the present invention more clearly, below by institute in the description to the embodiment of the present invention Attached drawing to be used is needed to be briefly described, it should be apparent that, the accompanying drawings in the following description is only some implementations of the present invention Example, for those of ordinary skill in the art, without having to pay creative labor, can also be according to these attached drawings Obtain other attached drawings.
Fig. 1 is a kind of application scenarios schematic diagram of image rendering method provided in an embodiment of the present invention;
Fig. 2 is a kind of flow diagram of image rendering method provided in an embodiment of the present invention;
Fig. 3 is a schematic diagram of the depth texture image of target object in the embodiment of the present invention;
Fig. 4 is the schematic diagram of the profile of depth texture image shown in Fig. 3;
Fig. 5 is the exemplary plot on the vertex of target object in the embodiment of the present invention;
Fig. 6 is the exemplary plot on the profile vertex of target object in the embodiment of the present invention;
Fig. 7 is the style of writing texture schematic diagram for a variety of different-styles that may be used in the embodiment of the present invention;
Fig. 8 is a kind of style of writing texture schematic diagram used in the embodiment of the present invention;
Fig. 9 is a kind of schematic diagram of the profile texture rendered in the embodiment of the present invention;
Figure 10 is another flow diagram of image rendering method provided in an embodiment of the present invention;
Figure 11 is the another flow diagram of image rendering method provided in an embodiment of the present invention;
Figure 12 is an exemplary plot of the depth texture image of target object in the embodiment of the present invention;
Figure 13 is a kind of schematic diagram of the light source position used in the embodiment of the present invention;
Figure 14 is the outline drawing that the target object in the embodiment of the present invention for Figure 13 obtains;
Figure 15 is the exemplary plot for removing the second profile of sampling in the embodiment of the present invention according to profile vertex;
Figure 16 is the schematic diagram based on the obtained stroke width of color sampled in the embodiment of the present invention;
Figure 17 is another style of writing texture schematic diagram used in the embodiment of the present invention;
Figure 18 is a kind of stroke schematic diagram of profile in the embodiment of the present invention;
Figure 19 is the schematic diagram of another profile texture rendered in the embodiment of the present invention;
Figure 20 is a kind of structural schematic diagram of image rendering device provided in an embodiment of the present invention;
Figure 21 is the structural schematic diagram of another image rendering device provided in an embodiment of the present invention;
Figure 22 is the structural schematic diagram of another image rendering device provided in an embodiment of the present invention;
Figure 23 is the structural schematic diagram of another image rendering device provided in an embodiment of the present invention;
The structural schematic diagram of Figure 24 electronic equipments provided in an embodiment of the present invention.
Specific implementation mode
Exemplary embodiment of the present invention is more fully described below with reference to accompanying drawings.Although showing the present invention in attached drawing Exemplary embodiment, it being understood, however, that may be realized in various forms the present invention without should be by embodiments set forth here It is limited.It is to be able to be best understood from the present invention on the contrary, providing these embodiments, and can be by the scope of the present invention Completely it is communicated to those skilled in the art.
An embodiment of the present invention provides a kind of image rendering methods, and the wash with watercolours of image outline can be realized based on Lighting information Dye so that the profile after rendering can reflect Lighting information, improve rendering effect.In the present embodiment, above-mentioned object Rendering intent can be applied in the scene as shown in Figure 1 being made of server 102 and terminal 104.As shown in Figure 1, clothes Business device 102 is communicated by network with terminal 104, and above-mentioned network includes but not limited to:Wide area network, Metropolitan Area Network (MAN) or LAN, Terminal 104 is not limited to PC (PC), mobile phone, tablet computer etc..The image rendering method of the embodiment of the present invention can be with It is executed, can also be executed by terminal 104 by server 102, can also be and executed jointly by server 102 and terminal 104. Wherein, the image rendering method that terminal 104 executes the embodiment of the present invention can also be to be executed by client mounted thereto.
To help to understand the scheme of the embodiment of the present invention, introduce first below present document relates to image processing field Several concepts:
Profile (Contour):
Profile refers to the object bounds in image.A kind of essential characteristic of the profile as image, is the basis of image procossing. Provided in a kind of embodiment it is a kind of based on the contours extract algorithm differentiated, can be by smoothly filtering out making an uproar in image Then sound carries out first differential or second-order differential operation, acquires maximum of gradients or the zero crossing of second dervative, finally choose suitable When threshold value extract boundary, obtain the profile of image.
Vertex (Vertex):
In image procossing, what three-dimension object can be regarded as being made of triangular mesh, each triangle is by space In three points constitute.In image rendering, the figure being displayed on the screen is drawn by triangle one by one It arrives, these vertexs of a triangle are vertex as described herein.Vertex is the basic data of image rendering, generally includes position It sets, the information such as normal direction, color, texture coordinate, vertex weights.
Fig. 2, image rendering method provided in an embodiment of the present invention are please referred to, this method can be applied to a graphics processor (GPU) in, as shown in Fig. 2, this method includes:
Step 21, the first profile of target object is obtained.
The embodiment of the present invention can carry out Image Acquisition to target object in advance, and acquisition carries the two of pixel depth information Dimension image can directly render the target object in step 21, obtain the depth texture image of the target object.Here, mesh Mark object can be the feature that personage, animal, object, environment etc. are embodied.In practical applications, which may include Said one or multiple features.Fig. 3 gives a schematic diagram of the depth texture image for rendering obtained target object, the figure In 3, target object is the ellipsoid objects 31 positioned at 30 center of screen;Then each pixel in the depth texture image is calculated Change in depth value, the change in depth value is used to indicate the change in depth degree between multiple adjacent pixels of the pixel, into And determine that the change in depth value exceeds multiple pixels of predetermined threshold value, obtains the first profile of the target object, Fig. 4 gives The schematic diagram of the profile 32 of depth texture image shown in Fig. 3 is gone out.
In the embodiment of the present invention, filter may be used, processing is filtered to the depth texture image, identify mesh The first profile for marking object, specifically includes:It obtains first filter and the first filtering is carried out to multiple adjacent pixels of current pixel Handle obtained the first change in depth value, wherein the first change in depth value is for indicating between the multiple adjacent pixel the Change in depth degree on one direction;It obtains second filter and what the second filtration treatment obtained is carried out to the multiple adjacent pixel Second change in depth value, wherein the second change in depth value is used to indicate between the multiple adjacent pixel in a second direction Change in depth degree, second direction are different from first direction;Worked as according to the first change in depth value and the determination of the second change in depth value The change in depth value of preceding pixel.
Here, first filter can carry out the first filtration treatment according to the first formula, and the first formula is multiple for calculating The sum of the first depth parameter of pixel adjacent in a first direction in adjacent pixel, the first depth parameter are in a first direction The product of the depth value of adjacent pixel and corresponding impact factor.Second filter can carry out the second mistake according to the second formula Filter handle, the second formula be used for calculate pixel adjacent in a second direction in multiple adjacent pixels the second depth parameter it With the product that, the second depth parameter is the depth value of adjacent pixel and corresponding impact factor in a second direction.
For current pixel, 8 pixels that are adjacent thereto and being centered around around current pixel are generally comprised, it can be with Current pixel is denoted as S11, then the pixel in its upper left corner is S00, the pixel of surface is S01, and the pixel in the upper right corner is The pixel of S11, directly to the left are S10, and the pixel of directly to the right is S12, and the pixel in the lower left corner is S20, and the pixel of underface is S21, The pixel in the lower right corner is S22.
Above-mentioned first direction can be longitudinal, and as a kind of realization method, the first formula can be SobelX=S00+ 2*S10+S20-S02-2*S12-S22, SobelX indicate that the first change in depth value, S00, S10, S20, S02, S12, S22 are pair The depth value of the pixel of position is answered, 1,2,1, -1, -2, -1 is respectively the impact factor of respective pixel in a first direction.It is above-mentioned Second direction can be laterally, the second formula be SobelY=S00+2*S01+S02-S20-2*S21-S22, SobelY indicate Second change in depth value, S00, S01, S02, S20, S21, S22 be corresponding position pixel depth value, 1,2,1, -1, -2, -1 The respectively impact factor of respective pixel in a second direction.The first change in depth value SobelX and the change of the second depth is being determined It, can be according to following formula after change value SobelY:EdgeSqr=(SobelX*SobelX+SobelY*SobelY), calculates To the change in depth value edgeSqr of current pixel.
Step 22, from the vertex of the target object, the profile vertex in the first profile is selected.
Here it is possible to obtain all vertex of target object by graphics processor (GPU), that is, it is used to render the target The vertex of object, and judge whether each vertex is located in the first profile, if so, using the vertex as profile vertex, So as to obtain one or more profile vertex.The profile vertex refers to the vertex being located on profile.For example, Fig. 5 is provided All vertex of target object, such as vertex 33, vertex 34 can be acquired by GPU, then therefrom selected positioned at wheel Vertex on exterior feature, such as vertex 33, and then obtain profile vertex as shown in FIG. 6.
Step 23, the second profile of the target object that obtains that treated through presetting light source and default illumination model.
In step 23, coloring treatment can be carried out to target object, obtained according to default light source and default illumination model Target object after coloring treatment;Then, the second profile of the target object after the coloring treatment is obtained.Second profile obtains It can be by the way of similar to the change in depth value for calculating pixel in step 21, if the change in depth of some pixel to take mode Value exceeds predetermined threshold value, then it is assumed that the pixel belongs to the second profile.Here it is possible to using existing illumination model, such as Lambert Model, Phong models, Blinn-Phong models, Cook-Torrance models etc. carry out coloring treatment to target object, specifically Colouring process can be realized by the vertex shader and/or fragment shader of graphics processor.
It should be noted that having no stringent execution ordinal relation, Ke Yixian between above-mentioned steps 21~22 and step 23 Step 21~22 are executed, then execute step 23, step 23 can also be first carried out, then execute step 21~22, or even can also be incited somebody to action Step 21~22 and step 23 are performed simultaneously.After step 21~22 and step 23 are performed both by, 24 are entered step.
Step 24, according to the location information on the profile vertex, in the corresponding color of second configuration sampling, and according to The color sampled determines the stroke width of the profile vertex correspondence.
Here, it according to the location information on the profile vertex, is sampled in second profile, obtains second wheel The color of wide corresponding position, and then determine according to the color stroke width of profile vertex correspondence.It is adopted specifically, can obtain The brightness value for the color that sample arrives;Then, it according to the correspondence between preset brightness value and stroke width, determines described bright The corresponding stroke width of angle value, the stroke width as the profile vertex correspondence.
As a kind of realization method, stroke width and brightness value positive correlation namely the corresponding stroke of larger brightness value are wide Degree is greater than or equal to the smaller corresponding stroke width of brightness value.For example, can determine profile vertex x's according to following formula Stroke width Wx:Wx=Wmax*Bx/Bmax, here, WmaxIndicate the maximum value of preset stroke width, BmaxIndicate the upper of brightness value Limit, BxIndicate the brightness value of profile vertex x.It should be pointed out that above formula, which is only the embodiment of the present invention, determines stroke width A kind of example, the embodiment of the present invention can also determine stroke width using other modes.
Step 25, according to the stroke width of the profile vertex correspondence, the stroke on the profile vertex of connecting is generated, and is pressed The stroke is rendered according to predetermined rendering mode, the profile texture after being rendered.
Here it is possible to obtain adjacent profile by interpolation calculation according to the adjacent corresponding stroke width in profile vertex Stroke width between vertex;Then, according to the stroke width between obtained adjacent profile vertex, the profile top of connecting is generated The stroke of point., can be as needed after generating stroke, using the corresponding style of writing texture rendering stroke of predetermined rendering mode, Profile texture is obtained to render.Specifically, the predetermined rendering mode include sketch images, pen-and-ink drawing, crayon drawing, watercolor, Cartoon and ink and wash etc., Fig. 7 give the style of writing texture schematic diagram of a variety of different-styles.For example, applying mechanically as shown in Figure 8 The corresponding style of writing texture of ink and wash, can obtain the profile texture after rendering as shown in Figure 9.
By above step, the embodiment of the present invention carries out coloring treatment, and then basis using illumination model to target object The color of illumination model treated profile apex, to be rendered to profile so that the profile after rendering can reflect Lighting information enriches the picture material after rendering, improves rendering to realize the profile rendering for being based on illumination (light source) Effect.In addition, the above step of the embodiment of the present invention, can be executed, GPU is to be exclusively used in figure by graphics processor (GPU) The processor of shape processing, can be by hardware-accelerated mode speed up processing, therefore the embodiment of the present invention can be by GPU It is programmed, the flow processing of above-mentioned all steps is realized using programmable pipeline, the data between CPU and GPU can be saved Interactive process improves treatment effeciency.
Non-photograph live stage (NPR) rendering, certainly, the embodiment of the present invention may be implemented in the above method of the embodiment of the present invention It can also be not limited to NPR.
The above step of the embodiment of the present invention can also be executed by CPU and GPU respectively.For example, can be according to CPU and GPU Respective processing capacity and/or current loads determine the executive agent of above each step.For example, 21~22 He of above-mentioned steps Stringent execution ordinal relation is had no between step 23, therefore can step 21~22 be executed by CPU, and step 23 is executed by GPU (can also step 23 be executed by CPU, step 21~22 are executed by GPU), to improve treatment effeciency using parallel processing manner.
In an embodiment of the present invention, can also be to used light source be adjusted when coloring treatment in step 23, example Quantity and/or the position for such as adjusting light source change the color of the second profile to obtain different direction of illuminations, to obtain dynamic The rendering effect of light source.At this point, as shown in Figure 10, the image rendering method of the embodiment of the present invention is after above-mentioned steps 25, also It may comprise steps of:
Step 26, quantity and/or the position of the default light source, return to step 23 are adjusted.
Here it is possible to according to the needs of simulated scenario, quantity of light source is increased or decreased, some or certain light can also be adjusted The position in source to simulate the scene of dynamic light source, and obtains the original target image under the scene to change direction of illumination The second profile, to being updated to the second profile.Step 24-25 subsequently is continued to execute, is being updated based on profile vertex The color in the second profile afterwards updates the stroke width of profile vertex correspondence, generates the stroke on the profile vertex of connecting, and The stroke is rendered according to predetermined rendering mode, obtains updated profile texture.
By above step, the embodiment of the present invention can make profile texture support dynamic light source, further improve wash with watercolours Contaminate effect.
Next a specific example is combined, the above step of the embodiment of the present invention is described in more detail.
It please refers to shown in Figure 11, image rendering method provided in an embodiment of the present invention, including:
Step 111, it obtains and the two dimensional image that Image Acquisition obtains is carried out to target object.
Here, collected two dimensional image can be the two dimensional image for the depth value for carrying pixel, to which the present invention is implemented Example can direct post-processing object object, obtain the depth texture image of target object, Figure 11 gives the one of depth texture image A example.
Step 112, according to the two dimensional image, render obtain include depth value information depth texture image, utilize Filter is filtered the depth texture image, obtains the profile of the target object, i.e. the first profile.
Here it is possible to draw frame (such as rectangle frame) identical with screen size, then depth texture image is sampled, Obtain the first profile.Specifically, can as follows be handled in PixelShader.
Depth texture image pixel by pixel is filtered using horizontal and vertical filter, table 1 gives implementation of the present invention A kind of matrix that may be used when transversal filters are filtered depth texture in example, table 2 give in the embodiment of the present invention A kind of matrix that may be used when vertical filter is filtered depth texture, table 3 give current pixel and adjacent pixel Position relationship and pixel depth value, the wherein position of the table where the depth value i.e. position of the pixel, S11 in table 3 Indicate that the depth value of current pixel, current pixel have 8 pixels adjacent thereto.
Actual transversal filters can be obtained for filtering by executing matrix multiple with the matrix of table 3 using the matrix of table 1 The first formula S obelX=S00+2*S10+S20-S02-2*S12-S22, SobelX indicates the first change in depth value, S00, S10, S20, S02, S12, S22 are the depth value of the pixel of corresponding position;Utilize the matrix shown in table 2 and the matrix shown in table 3 Execute matrix multiple can obtain actual vertical filter for filtering the second formula S obelY=S00+2*S01+S02- S20-2*S21-S22, SobelY indicate that the second change in depth value, S00, S01, S02, S20, S21, S22 are the picture of corresponding position The depth value of element.
It, can be according to following public affairs after the first change in depth value SobelX and the second change in depth value SobelY is determined Formula determines the change in depth value edgeSqr of current pixel point.
EdgeSqr=(SobelX*SobelX+SobelY*SobelY).
EdgeSqr indicates the variation degree of the value of current pixel surrounding pixel, if edgeSqr is more than a threshold value n (example Such as, n can also can suitably be finely tuned with value for 0.005), then illustrate that the depth value variation of the pixel around current pixel is fierce, Then illustrate that current pixel is the profile of object, to which current pixel to be judged as to the pixel on profile;If edgeSqr is less than threshold Value n, then it is the profile of object to illustrate current pixel not.It may finally obtain the first profile of target object.
Step 113, the profile vertex of target object is drawn.
It can be inquired by image processor (GPU) and obtain the vertex of target object, by all vertex in a manner of drawing a little It is drawn, by reading the first profile of target object, vertex is judged one by one, if the vertex is located at the first profile On, then the vertex is profile vertex, and is drawn out;If the vertex not in the first profile, is not drawn in the vertex, It is hereby achieved that profile vertex texture.
Step 114, according to default light source and default illumination model, coloring treatment is carried out to target object, obtains new depth Texture image is spent, the second profile of target object described in new depth texture image is generated;
In the embodiment of the present invention, corresponding light source and illumination model can be used to carry out target object as needed Color obtains new depth texture image.Figure 13 gives using two light sources 131, according to general diffusing reflection illumination model, to mesh The schematic diagram that object is coloured is marked, light source 131 is located above and below target object in Figure 13.Then, sharp It is filtered with the filter depth texture image new to this, obtains target object by the second profile of illumination, specific filtering Mode can refer to step 112, and which is not described herein again.The schematic diagram of the profile of the target object in Figure 13 is given in Figure 14.
Step 115, according to the location information on the profile vertex, in the corresponding color of second configuration sampling, and root According to the color sampled, the stroke width of the profile vertex correspondence is determined.
Here, according to the location information on the profile vertex obtained in step 113, corresponding position picture in the second profile is sampled The color of element, the brightness value being specifically as follows in the pixel color determine the pen of the profile vertex correspondence according to the brightness value Draw width.Figure 15 gives the example that the second profile of sampling is removed according to profile vertex.
Step 116, according to the stroke width of the profile vertex correspondence, the stroke on the profile vertex of connecting is generated, and The stroke is rendered according to predetermined rendering mode, the profile texture after being rendered.
After the stroke width for obtaining profile vertex correspondence, interpolation algorithm can be utilized, is calculated between adjacent profile vertex Stroke width, if for example, two adjacent corresponding stroke widths of profile vertex a and b are respectively WaAnd Wb, then, the wheel The corresponding stroke widths of pixel x between wide vertex can be:Wa+Lx*Wd/ L, wherein LxIndicate pixel x and vertex a between away from From L indicates the distance between vertex b and vertex a, Wd=Wb-Wa.Certainly, the above citing is that the embodiment of the present invention may be used A kind of linear interpolation algorithm, the embodiment of the present invention can also use other various interpolation algorithms, no longer illustrate one by one here It is bright.After stroke width is determined according to interpolation algorithm, adjacent profile vertex can be connected, line segment is obtained, then according to institute The line segment, is extended to the stroke of corresponding width by determining stroke width, and Figure 16 gives based on obtained by the color sampled The schematic diagram of the stroke width arrived.By applying mechanically specific style of writing texture to above-mentioned stroke, can render to obtain profile texture.
When rendering profile corresponds to stroke, the embodiment of the present invention can draw the rectangle frame with screen same size, then Scheduled style of writing texture is applied mechanically, rendering obtains profile texture.Figure 19 gives using style of writing texture shown in Figure 17, to being obtained in Figure 18 The example for the profile texture that profile stroke is rendered.For part of the original target image in addition to profile, the present invention Embodiment can carry out rendering or not rendering as needed, if not rendering, only obtain the texture image of profile at this time.
It, can be at image processor (GPU) from above step as can be seen that above-mentioned all steps of the embodiment of the present invention Middle realization eliminates CPU and GPU data exchange process, and can realize above-mentioned flow processing by the programmable pipeline of GPU, Improve rendering efficiency.In addition, the color based on illumination profile carries out profile rendering in the embodiment of the present invention so that after rendering Profile can reflect Lighting information, improve rendering effect.In addition, the embodiment of the present invention can also be supported to be based on dynamic light source Profile render, improve rendering effect.
Figure 20 is please referred to, the embodiment of the present invention additionally provides a kind of image rendering device, which can set It sets at individual terminal devices (such as smart mobile phone, PC, PAD) or server, as shown in figure 20, image rendering dress Set including:
First acquisition module 201, the first profile for obtaining target object;
Selecting module 202, for from the vertex of the target object, selecting the profile top in the first profile Point;
Second acquisition module 203, for the target object that obtains that treated through presetting light source and default illumination model The second profile;
Stroke module 204 is corresponded to for the location information according to the profile vertex in second configuration sampling Color, and according to the color sampled, determine the stroke width of the profile vertex correspondence;
Stroke rendering module 205 generates the profile top of connecting for the stroke width according to the profile vertex correspondence The stroke of point, and the stroke is rendered according to predetermined rendering mode, the profile texture after being rendered.
By the way that with upper module, color of the embodiment of the present invention based on illumination profile carries out profile rendering so that after rendering Profile can reflect Lighting information, improve rendering effect.In some embodiments, all moulds of above-mentioned image rendering device Block can be realized in GPU, at this point, above-mentioned image rendering device can be set in GPU, it is real in the programmable pipeline of GPU Existing above-mentioned module can utilize the dedicated image processing functions of GPU, improve rendering efficiency.
As shown in figure 21, in some embodiments, second acquisition module 203 includes:
Staining module 2031, for according to default light source and default illumination model, carrying out coloring treatment to target object, obtaining Target object after to coloring treatment;
Profile filtering module 2032, the second profile for obtaining the target object after the coloring treatment.
The stroke module 204 includes:
Luminance acquisition module 2041, the brightness value for obtaining the color sampled;
Stroke width determining module 2042 is used for according to the correspondence between preset brightness value and stroke width, really The corresponding stroke width of the brightness value is made, the stroke width as the profile vertex correspondence.
As a kind of realization method, in the correspondence, stroke width and brightness value positive correlation.
As shown in figure 22, in some embodiments, the stroke rendering module 205 includes:
Interpolating module 2051, for being obtained by interpolation calculation according to the adjacent corresponding stroke width in profile vertex Stroke width between adjacent profile vertex;
Serial module structure 2052, for according to the stroke width between obtained adjacent profile vertex, generating the wheel of connecting The stroke on wide vertex.
Drafting module 2053, for using style of writing texture corresponding with the predetermined rendering mode to paint the stroke System, wherein the predetermined rendering mode includes sketch images, pen-and-ink drawing, crayon drawing, watercolor, cartoon and ink and wash.
As shown in figure 23, in some embodiments, described image rendering device further includes:
Light source update module 206 adjusts institute after the profile texture after the stroke rendering module is rendered Quantity and/or the position of default light source are stated, and triggers second acquisition module.
By the way that with upper module, the embodiment of the present invention can support the profile of dynamic light source to render.
Figure 24 is please referred to, Figure 24 is the structure chart of a kind of electronic equipment provided in an embodiment of the present invention, which can To be PC, smart mobile phone, server etc..As shown in figure 24, which includes:At least one processor 2401, Memory 2402, at least one network interface 2404 and user interface 2403.Various components in electronic equipment pass through total linear system System 2405 is coupled.It is understood that bus system 2405 is for realizing the connection communication between these components.Bus system 2405 in addition to including data/address bus, further includes power bus, controlling bus and status signal bus in addition.But for clear explanation For the sake of, various buses are all designated as bus system 2405 in fig. 24.
Wherein, user interface 2403 may include display, keyboard or pointing device (for example, mouse, trace ball (track ball), touch-sensitive plate or touch screen etc..
It is appreciated that the memory 2402 in the embodiment of the present invention can be volatile memory or non-volatile memories Both device, or may include volatile and non-volatile memory.Wherein, nonvolatile memory can be read-only memory (Read-Only Memory, ROM), programmable read only memory (Programmable ROM, PROM), erasable programmable are only Read memory (Erasable P ROM, EPROM), electrically erasable programmable read-only memory (Electrically EP ROM, ) or flash memory EEPROM.Volatile memory can be random access memory (Random Access Memory, RAM), use Make External Cache.By exemplary but be not restricted explanation, the RAM of many forms is available, such as static random-access Memory (Static RAM, SRAM), dynamic random access memory (Dynamic RAM, DRAM), synchronous dynamic random-access Memory (Synchronous D RAM, SDRAM), double data speed synchronous dynamic RAM (Double Data Rate SD RAM, DDRSDRAM), enhanced Synchronous Dynamic Random Access Memory (Enhanced SD RAM, ESDRAM), synchronized links dynamic random access memory (Synch link D RAM, SLDRAM) and direct rambus are random Access memory (Direct Rambus RAM, DRRAM).The memory 2402 of system and method described herein is intended to But it is not limited to the memory of these and any other suitable type.
In some embodiments, memory 2402 stores following element, executable modules or data structures, or Their subset of person or their superset:Operating system 24021 and application program 24022.
Wherein, operating system 24021, including various system programs, such as ccf layer, core library layer, driving layer etc., are used for Realize various basic businesses and the hardware based task of processing.Application program 24022, including various application programs, such as matchmaker Body player (Media Player), browser (Browser) etc., for realizing various applied business.Realize that the present invention is implemented The program of example method may be embodied in application program 24022.
In embodiments of the present invention, by the program for calling memory 2402 to store or instruction, specifically, can be application The program stored in program 24022 or instruction, processor 2401 are used for:Obtain the first profile of target object;From the target In the vertex of object, the profile vertex in the first profile is selected;It obtains through presetting light source and the processing of default illumination model Second profile of the target object afterwards;According to the location information on the profile vertex, corresponded in second configuration sampling Color, and according to the color sampled, determine the stroke width of the profile vertex correspondence;According to the profile vertex correspondence Stroke width, generate the stroke on the profile vertex of connecting, and the stroke is rendered according to predetermined rendering mode, rendered Profile texture afterwards.
Optionally, processor 2401 is additionally operable to:According to default light source and default illumination model, target object is coloured Processing, obtains the target object after coloring treatment;Obtain the second profile of the target object after the coloring treatment.
Optionally, processor 2401 is additionally operable to obtain the brightness value of the color sampled;According to preset brightness value and pen The correspondence between width is drawn, determines the corresponding stroke width of the brightness value, the pen as the profile vertex correspondence Draw width.
Optionally, processor 2401 is additionally operable to, according to the adjacent corresponding stroke width in profile vertex, pass through interpolation meter It calculates, obtains the stroke width between adjacent profile vertex;According to the stroke width between obtained adjacent profile vertex, series connection is generated The stroke on the profile vertex, and, the stroke is painted using style of writing texture corresponding with the predetermined rendering mode System, wherein the predetermined rendering mode includes sketch images, pen-and-ink drawing, crayon drawing, watercolor, cartoon and ink and wash.
Optionally, processor 2401 is additionally operable to adjust the quantity of used light source when the default illumination model processing And/or position, return to the second profile of the target object that obtains that treated through presetting light source and default illumination model The step of.
The above electronic equipment of the embodiment of the present invention, the color based on illumination profile carry out profile rendering so that after rendering Profile can reflect Lighting information, improve rendering effect.In addition, the method and apparatus of the embodiment of the present invention, Ke Yi It is realized by programmable pipeline in image processor (GPU), improves rendering efficiency.Also, above-mentioned electronic equipment can also prop up The profile for holding dynamic light source renders, and further improves rendering effect.
The embodiment of the present invention also provides a kind of computer readable storage medium, is stored thereon with computer program, the meter Calculation machine program realizes the step in the image rendering method in any one above-mentioned embodiment of the method when being executed by processor.
Those of ordinary skill in the art may realize that lists described in conjunction with the examples disclosed in the embodiments of the present disclosure Member and algorithm steps can be realized with the combination of electronic hardware or computer software and electronic hardware.These functions are actually It is implemented in hardware or software, depends on the specific application and design constraint of technical solution.Professional technician Each specific application can be used different methods to achieve the described function, but this realization is it is not considered that exceed The scope of the present invention.
It is apparent to those skilled in the art that for convenience and simplicity of description, the system of foregoing description, The specific work process of device and unit, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
In embodiment provided herein, it should be understood that disclosed device and method can pass through others Mode is realized.For example, the apparatus embodiments described above are merely exemplary, for example, the division of the unit, only A kind of division of logic function, formula that in actual implementation, there may be another division manner, such as multiple units or component can combine or Person is desirably integrated into another system, or some features can be ignored or not executed.Another point, shown or discussed is mutual Between coupling, direct-coupling or communication connection can be INDIRECT COUPLING or communication link by some interfaces, device or unit It connects, can be electrical, machinery or other forms.
The unit illustrated as separating component may or may not be physically separated, aobvious as unit The component shown may or may not be physical unit, you can be located at a place, or may be distributed over multiple In network element.Some or all of unit therein can be selected according to the actual needs to realize the embodiment of the present invention Purpose.
In addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, it can also It is that each unit physically exists alone, it can also be during two or more units be integrated in one unit.
It, can be with if the function is realized in the form of SFU software functional unit and when sold or used as an independent product It is stored in a computer read/write memory medium.Based on this understanding, technical scheme of the present invention is substantially in other words The part of the part that contributes to existing technology or the technical solution can be expressed in the form of software products, the meter Calculation machine software product is stored in a storage medium, including some instructions are used so that a computer equipment (can be People's computer, server or network equipment etc.) it performs all or part of the steps of the method described in the various embodiments of the present invention. And storage medium above-mentioned includes:USB flash disk, mobile hard disk, ROM, RAM, magnetic disc or CD etc. are various can to store program code Medium.
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any Those familiar with the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, and should all contain Lid is within protection scope of the present invention.Therefore, protection scope of the present invention should be subject to the protection scope in claims.

Claims (12)

1. a kind of image rendering method, which is characterized in that including:
Obtain the first profile of target object;
From the vertex of the target object, the profile vertex in the first profile is selected;
Second profile of the target object that obtains that treated through presetting light source and default illumination model;
According to the location information on the profile vertex, in the corresponding color of second configuration sampling, and according to the face sampled Color determines the stroke width of the profile vertex correspondence;
According to the stroke width of the profile vertex correspondence, the stroke on the profile vertex of connecting is generated, and according to predetermined rendering Mode renders the stroke, the profile texture after being rendered;
Wherein, the color that the basis samples, the step of determining the stroke width of the profile vertex correspondence, including:
Obtain the brightness value of the color sampled;
According to the correspondence between preset brightness value and stroke width, the corresponding stroke width of the brightness value is determined, Stroke width as the profile vertex correspondence.
2. according to the method described in claim 1, it is characterized in that, the acquisition is through presetting light source and the processing of default illumination model The step of second profile of the target object afterwards, including:
According to default light source and default illumination model, coloring treatment is carried out to target object, obtains the target pair after coloring treatment As;
Obtain the second profile of the target object after the coloring treatment.
3. according to the method described in claim 1, it is characterized in that, in the correspondence, stroke width and brightness value positive It closes.
4. according to the method described in claim 1, it is characterized in that, the stroke width according to the profile vertex correspondence, The step of generating the stroke on the profile vertex of connecting, including:
The stroke between adjacent profile vertex is obtained by interpolation calculation according to the adjacent corresponding stroke width in profile vertex Width;
According to the stroke width between obtained adjacent profile vertex, the stroke on the profile vertex of connecting is generated.
5. according to the method described in claim 1, it is characterized in that, described render the stroke according to predetermined rendering mode, obtain The step of profile texture after to rendering, including:
The stroke is drawn using style of writing texture corresponding with the predetermined rendering mode, wherein the predetermined rendering Mode includes sketch images, pen-and-ink drawing, crayon drawing, watercolor, cartoon and ink and wash.
6. according to the method described in claim 1, it is characterized in that, render the stroke according to predetermined rendering mode described, After the step of profile texture after being rendered, the method further includes:
Quantity and/or the position of the default light source are adjusted, returns to the acquisition through presetting light source and the processing of default illumination model The step of second profile of the target object afterwards.
7. a kind of image rendering device, which is characterized in that including:
First acquisition module, the first profile for obtaining target object;
Selecting module, for from the vertex of the target object, selecting the profile vertex in the first profile;
Second acquisition module the second of the target object is taken turns for obtaining that treated through presetting light source and default illumination model It is wide;
Stroke module, for according to the location information on the profile vertex, in the corresponding color of second configuration sampling, And according to the color sampled, determine the stroke width of the profile vertex correspondence;
Stroke rendering module generates the pen on the profile vertex of connecting for the stroke width according to the profile vertex correspondence It draws, and the stroke is rendered according to predetermined rendering mode, the profile texture after being rendered;
Wherein, the stroke module includes:
Luminance acquisition module, the brightness value for obtaining the color sampled;
Stroke width determining module, it is described for according to the correspondence between preset brightness value and stroke width, determining The corresponding stroke width of brightness value, the stroke width as the profile vertex correspondence.
8. image rendering device according to claim 7, which is characterized in that second acquisition module includes:
Staining module, for according to default light source and default illumination model, carrying out coloring treatment to target object, obtaining at coloring Target object after reason;
Profile filtering module, the second profile for obtaining the target object after the coloring treatment.
9. image rendering device according to claim 7, which is characterized in that in the correspondence, stroke width with it is bright Angle value positive correlation.
10. image rendering device according to claim 7, which is characterized in that the stroke rendering module includes:
Interpolating module, for obtaining adjacent profile by interpolation calculation according to the adjacent corresponding stroke width in profile vertex Stroke width between vertex;
Serial module structure, for according to the stroke width between obtained adjacent profile vertex, generating the profile vertex of connecting Stroke.
11. image rendering device according to claim 7, which is characterized in that the stroke rendering module includes:
Drafting module, for using style of writing texture corresponding with the predetermined rendering mode to draw the stroke, wherein The predetermined rendering mode includes sketch images, pen-and-ink drawing, crayon drawing, watercolor, cartoon and ink and wash.
12. image rendering device according to claim 7, which is characterized in that further include:
Light source update module adjusts described default after the profile texture after the stroke rendering module is rendered The quantity of light source and/or position, and trigger second acquisition module.
CN201710312950.1A 2017-05-05 2017-05-05 A kind of image rendering method and device Active CN107045729B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710312950.1A CN107045729B (en) 2017-05-05 2017-05-05 A kind of image rendering method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710312950.1A CN107045729B (en) 2017-05-05 2017-05-05 A kind of image rendering method and device

Publications (2)

Publication Number Publication Date
CN107045729A CN107045729A (en) 2017-08-15
CN107045729B true CN107045729B (en) 2018-09-18

Family

ID=59546181

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710312950.1A Active CN107045729B (en) 2017-05-05 2017-05-05 A kind of image rendering method and device

Country Status (1)

Country Link
CN (1) CN107045729B (en)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108022286B (en) * 2017-11-30 2019-08-13 腾讯科技(深圳)有限公司 Picture rendering method, device and storage medium
CN109993760A (en) * 2017-12-29 2019-07-09 北京京东尚科信息技术有限公司 A kind of edge detection method and device of picture
CN110473280B (en) * 2018-05-09 2024-02-23 网易(杭州)网络有限公司 Multi-light source picture rendering method and device, storage medium, processor and terminal
CN110070555A (en) * 2018-10-19 2019-07-30 北京微播视界科技有限公司 Image processing method, device, hardware device
US11195308B2 (en) * 2018-12-05 2021-12-07 Sony Group Corporation Patcher tool
CN109993822B (en) * 2019-04-10 2023-02-21 创新先进技术有限公司 Ink and wash style rendering method and device
CN110298786B (en) * 2019-07-02 2023-12-08 北京字节跳动网络技术有限公司 Image rendering method, device, equipment and storage medium
CN110969568B (en) * 2019-11-29 2023-06-13 广联达科技股份有限公司 BIM model double-sided display accelerated rendering method, system, product and storage medium
CN111402381B (en) * 2020-03-17 2023-11-21 网易(杭州)网络有限公司 Model rendering method and device, and readable storage medium
CN111932980A (en) * 2020-09-14 2020-11-13 苏州探寻文化科技有限公司 Digital traditional Chinese painting simulation method and equipment
CN112233215B (en) * 2020-10-15 2023-08-22 网易(杭州)网络有限公司 Contour rendering method, device, equipment and storage medium
CN114419238A (en) * 2022-01-24 2022-04-29 脸萌有限公司 Special effect image processing method and device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101038675A (en) * 2006-03-16 2007-09-19 腾讯科技(深圳)有限公司 Method and apparatus for implementing wash painting style
CN101127127A (en) * 2007-09-29 2008-02-20 腾讯科技(深圳)有限公司 Shade drafting method and rendering device
CN104966312A (en) * 2014-06-10 2015-10-07 腾讯科技(深圳)有限公司 Method for rendering 3D model, apparatus for rendering 3D model and terminal equipment
CN105869203A (en) * 2016-03-28 2016-08-17 南京大学 Pencil style processing method of 3D scene

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8249365B1 (en) * 2009-09-04 2012-08-21 Adobe Systems Incorporated Methods and apparatus for directional texture generation using sample-based texture synthesis

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101038675A (en) * 2006-03-16 2007-09-19 腾讯科技(深圳)有限公司 Method and apparatus for implementing wash painting style
CN101127127A (en) * 2007-09-29 2008-02-20 腾讯科技(深圳)有限公司 Shade drafting method and rendering device
CN104966312A (en) * 2014-06-10 2015-10-07 腾讯科技(深圳)有限公司 Method for rendering 3D model, apparatus for rendering 3D model and terminal equipment
CN105869203A (en) * 2016-03-28 2016-08-17 南京大学 Pencil style processing method of 3D scene

Also Published As

Publication number Publication date
CN107045729A (en) 2017-08-15

Similar Documents

Publication Publication Date Title
CN107045729B (en) A kind of image rendering method and device
CN109427088B (en) Rendering method for simulating illumination and terminal
JP7370527B2 (en) Method and computer program for generating three-dimensional model data of clothing
CN105374007B (en) Merge the pencil drawing generation method and device of skeleton stroke and textural characteristics
Chu et al. Detail-preserving paint modeling for 3D brushes
Jimenez et al. Separable subsurface scattering
CN100463003C (en) Method and apparatus for implementing wash painting style
US20150310305A1 (en) Learning painting styles for painterly rendering
CN108090945A (en) Object rendering intent and device, storage medium and electronic device
Way et al. The synthesis of trees in Chinese landscape painting using silhoutte and texture strokes
CN110223372A (en) Method, apparatus, equipment and the storage medium of model rendering
CN113240783B (en) Stylized rendering method and device, readable storage medium and electronic equipment
US10922852B2 (en) Oil painting stroke simulation using neural network
US8847963B1 (en) Systems and methods for generating skin and volume details for animated characters
CN109712226A (en) The see-through model rendering method and device of virtual reality
CA2957493C (en) System and method for colorimetric and geometric parameterization of procedural textures on an object
US9202291B1 (en) Volumetric cloth shader
Haller et al. A loose and sketchy approach in a mediated reality environment
Montesdeoca et al. Edge-and substrate-based effects for watercolor stylization
Kerber et al. Real-time generation of digital bas-reliefs
Seo et al. Interactive painterly rendering with artistic error correction
Burgess et al. A system for real-time watercolour rendering
Güssefeld et al. Are reflectance field renderings appropriate for optical flow evaluation?
Madono et al. Data‐Driven Ink Painting Brushstroke Rendering
Zheng et al. [Retracted] Visual Sensing Technology for Digital Image‐Oriented Public Art Design

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant