Contour rendering method, device, electronic device and computer-readable storage medium
By obtaining and expanding the transparent channel parameter array of the image model, we perform transparent test cropping and depth information rendering, which solves the problem of the selection box and highlighting methods occupying space in the game and affecting rendering, and achieves a better visual experience and rendering efficiency. .
Patent Information
- Application Number
- CN202011524824.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-22
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2040-12-22
AI Technical Summary
In open world 3D games, when irregular objects are highlighted by selecting boxes and highlighting, a large amount of screen space is occupied, resulting in poor game scene display effects. Especially when multiple image models overlap in complex scenes, it affects the user's visual experience and increases the cost. Rendering workload.
By obtaining the transparent channel parameter array of the image model, the representation area is expanded, transparent test cropping is performed to obtain the outer contour, and the outer contour is rendered based on the depth information, avoiding unnecessary space occupation and rendering, and reducing overlapping edge lines.
It achieves outline rendering that does not occupy additional space, reduces rendering workload, improves user visual experience, avoids blocked outer outline rendering, and significantly reduces rendering load.
Smart Images

Figure CN112669433B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a contour rendering method, device, electronic device and computer-readable storage medium. Background Art
[0002] In open-world 3D games, a large number of irregular objects need to be drawn, such as plants and hair. At the same time, it is also a common function to emphasize a certain object in the scene in terms of display effects, such as selecting a target and guiding novices. On mobile devices that need to save energy and have low performance, irregular objects are usually highlighted by using check boxes and highlights. The check box occupies a large amount of extra space on the screen except for the selected object. In addition, in complex scenes, when multiple overlapping image models need to be selected, there is overlap between the check boxes, which affects the normal display effect of the game scene, affects the user's visual experience, and increases the rendering workload. Summary of the invention
[0003] In view of this, an object of the present invention is to provide a contour rendering method, device, electronic device and computer-readable storage medium.
[0004] In order to achieve the above purpose, the technical solution adopted by the embodiment of the present invention is as follows:
[0005] In a first aspect, the present invention provides a contour rendering method, the contour rendering method comprising:
[0006] Drawing is performed according to the image model existing in the scene to obtain the image to be processed;
[0007] Acquire a transparent channel parameter array corresponding to the image to be processed to obtain first image data;
[0008] Expanding outward an array region in the transparent channel parameter array that represents the image model to obtain second image data;
[0009] Using the first image data to perform a transparent test clipping on the second image data to obtain an outer contour;
[0010] Determine depth information corresponding to an outer contour according to the image to be processed, so as to render the outer contour according to the depth information.
[0011] In an optional embodiment, the step of expanding outwardly the array area representing the image model in the transparent channel parameter array comprises:
[0012] Determine, from the transparent channel parameter array, a first element belonging to the image model and a second element not belonging to the image model;
[0013] The transparent channel parameter corresponding to the target element adjacent to the first element in the second element is changed to the transparent channel parameter corresponding to the first element to obtain a new transparent channel parameter array and generate the corresponding second image data.
[0014] In an optional implementation, the outline rendering method further includes:
[0015] A target element adjacent to the first element is obtained from the second element using a cross sampling method.
[0016] In an optional embodiment, the step of expanding outwardly the array area representing the image model in the transparent channel parameter array comprises:
[0017] Acquire first image data corresponding to the transparent channel parameter array;
[0018] Performing edge expansion on an image region representing the image model in the first image data using a Gaussian blur algorithm;
[0019] In an optional implementation, the step of determining the depth information corresponding to the outer contour according to the image to be processed includes:
[0020] Mapping the outer contour onto the image to be processed to obtain a target image region where the image model corresponding to the outer contour appears in the image to be processed;
[0021] Sequentially matching the target pixel points closest to each pixel point on the outer contour in the target image area;
[0022] The depth information of the target pixel point is assigned to the matching pixel point on the outer contour.
[0023] In an optional implementation, the outline rendering method further includes:
[0024] The outer contour is rendered based on the depth information corresponding to the outer contour.
[0025] In an optional implementation, the step of rendering according to the image model existing in the scene includes:
[0026] The image model existing in the scene is drawn using a pre-calculated screen depth algorithm.
[0027] In a second aspect, the present invention provides a contour rendering device, the contour rendering device comprising:
[0028] A drawing module, used for drawing according to the image model existing in the scene to obtain an image to be processed;
[0029] An acquisition module, used for acquiring a transparent channel parameter array corresponding to the image to be processed to obtain first image data;
[0030] An expansion module, used for expanding the array area representing the image model in the transparent channel parameter array outward to obtain second image data;
[0031] A cropping module, used for performing a transparent test cropping on the second image data using the first image data to obtain an outer contour;
[0032] The determination module is used to determine the depth information corresponding to the outer contour according to the image to be processed, so as to render the outer contour according to the depth information.
[0033] In a third aspect, the present invention provides an electronic device, comprising a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor can execute the machine executable instructions to implement any of the methods described in the aforementioned embodiments.
[0034] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements a method as described in any one of the aforementioned embodiments.
[0035] Compared with the prior art, the contour rendering method provided by the embodiment of the present invention obtains the image to be processed by drawing according to the image model existing in the scene, obtains the transparent channel parameter array corresponding to the image to be processed, and obtains the first image data, and then expands the array area representing the image model in the transparent channel parameter array outward to obtain the second image data, and then uses the first image data to perform a transparent test cropping on the second image data to obtain the outer contour. Finally, according to the image to be processed, the depth information corresponding to the outer contour is determined so that the outer contour can be rendered according to the depth information. On the one hand, the outer contour wraps the corresponding image model and does not occupy unnecessary space. On the other hand, the depth information of the determined outer contour can be used to avoid rendering of the obscured outer contour during the rendering process, thereby reducing the rendering workload, avoiding the rendering of unnecessary edge lines, and improving the user's visual experience.
[0036] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0038] Figure 1 A schematic diagram of an electronic device provided by an embodiment of the present invention is shown.
[0039] Figure 2 One of the step flow charts of the outline rendering method provided by an embodiment of the present invention is shown.
[0040] Figure 3 A sub-step flow chart of step S103 provided in an embodiment of the present invention is shown.
[0041] Figure 4 The second step flow chart of the outline rendering method provided by the embodiment of the present invention is shown.
[0042] Figure 5 A schematic diagram of a contour rendering device provided by an embodiment of the present invention is shown.
[0043] Icons: 100 - electronic device; 110 - memory; 120 - processor; 130 - communication module; 300 - contour rendering device; 301 - drawing module; 302 - acquisition module; 303 - expansion module; 304 - clipping module; 305 - determination module. DETAILED DESCRIPTION
[0044] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0045] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present invention.
[0046] It should be noted that relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0047] Please refer to Figure 1 , Figure 1 A block diagram of the electronic device 100 is shown. The electronic device 100 may be, but is not limited to, a personal computer (PC), a server, a distributed computer, and the like. It is understandable that the electronic device 100 is not limited to a physical server, but may also be a virtual machine on a physical server, a virtual machine built on a cloud platform, and the like that can provide a computer having the same functions as the server or virtual machine. The electronic device 100 includes a memory 110, a processor 120, and a communication module 130. The memory 110, the processor 120, and the communication module 130 are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components may be electrically connected to each other via one or more communication buses or signal lines.
[0048] The memory 110 is used to store programs or data. The memory 110 may be, but is not limited to, a random access memory 110 (RAM), a read only memory 110 (ROM), a programmable read-only memory 110 (PROM), an erasable programmable read-only memory 110 (EPROM), an electrically erasable read-only memory 110 (Electric Erasable Programmable Read-Only Memory 110 (EEPROM), etc.
[0049] The processor 120 is used to read / write data or programs stored in the memory 110 and execute corresponding functions.
[0050] The communication module 130 is used to establish a communication connection between the electronic device 100 and other communication terminals through the network, and to send and receive data through the network.
[0051] It should be understood that Figure 1 The structure shown is only a schematic diagram of the structure of the electronic device 100. The electronic device 100 may also include Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown. Figure 1 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0052] Please refer to Figure 2 , Figure 2 FIG. 2 shows a contour rendering method provided by an embodiment of the present invention. Figure 2 As shown, the above outline rendering method may include the following steps:
[0053] Step S101, rendering is performed according to the image model existing in the scene to obtain an image to be processed.
[0054] The above scene may be a scene that needs to be presented to the user by rendering. For example, it may be a game interface scene or a video screen scene. In order to conveniently explain the principle of the contour rendering method provided in the embodiment of the present invention, the game interface scene is mainly used as an example for description.
[0055] In some embodiments, the scene is composed of a background and an image model. The image model is a person or object that appears in the scene, for example, the image model can be a tree, a person, etc. that appears in the game interface scene.
[0056] When the user operates the controlled game character to switch the perspective in the virtual game space, the game interface scene that needs to be rendered on the electronic device 100 will also switch accordingly, and the switching of the game interface scene is accompanied by the change of the image model. When it is necessary to render the game interface scene and identify the image model, the image model existing in the game interface scene under the current perspective can be drawn on a blank drawing board. The above drawing can be a drawing with depth.
[0057] As an implementation method, the image models existing in the scene can be drawn using a pre-calculated screen depth (prez) algorithm. It can be understood that the prez algorithm is a drawing method that uses software instead of hardware. Its principle is similar to the early-z technology and will not be repeated here. The prez algorithm significantly reduces the number of pixels that are repeatedly drawn when drawing multiple times. This technology is used to draw colors on the existing depth buffer during post-effect drawing to obtain the color and depth buffer of the occluded object. In other words, the drawn image to be processed carries the depth information corresponding to each image model.
[0058] In some embodiments, in a complex scene with multiple image models, multiple frames of images to be processed can be drawn in sequence, with an image model drawn in each frame of the image to be processed, and the position of the image model in the image to be processed is consistent with the position of the image model in the scene.
[0059] Step S102, obtaining a transparent channel parameter array corresponding to the image to be processed to obtain first image data.
[0060] It can be understood that each pixel in the image to be processed corresponds to a RED parameter (the value of the R channel), a GREEN parameter (the value of the G channel), a BLUE parameter (the value of the B channel) and an Alpha parameter (that is, the value of the transparent channel). For example, the transparent channel value corresponding to the pixel belonging to the image model can be 1, and the transparent channel value corresponding to the pixel not belonging to the image model can be 0.
[0061] In some embodiments, according to the positional relationship between the pixels, the transparent channel parameters corresponding to the pixels are arranged to obtain a transparent channel parameter array, thereby obtaining first image data presenting transparent information.
[0062] It is understandable that in a complex scene with multiple image models, multiple frames of images to be processed will be obtained. Therefore, multiple frames of first image data can also be obtained in the above manner. Each frame of first image data corresponds to a single image model.
[0063] Step S103: Expand the array region representing the image model in the transparent channel parameter array outward to obtain second image data.
[0064] In some embodiments, the area representing the image model in the second image data obtained by expansion is larger than the area representing the same image model in the corresponding first image data. For example, one pixel point may be added to the periphery of the area representing the same image model in the first image data.
[0065] In some embodiments, Figure 3 As shown, the above step S103 may include:
[0066] Sub-step S103 - 1 , determining a first element belonging to the image model and a second element not belonging to the image model from the transparent channel parameter array.
[0067] In some embodiments, it is very easy to distinguish the area where the image model is located from other areas using transparent channel parameters. It can be understood that the transparent channel parameter array is composed of multiple elements, and each element corresponds to the transparent channel parameter of a pixel in the image to be processed. The arrangement order between the elements is the same as the arrangement order of the corresponding pixels in the image to be processed. The value of the element corresponding to the pixel belonging to the image model (that is, the transparent channel parameter) is different from the value of the element corresponding to the pixel that does not belong to the image model (that is, the transparent channel parameter). For example, the value of the element corresponding to the pixel belonging to the image model is 1, and the value of the element corresponding to the pixel that does not belong to the image model is 0. Therefore, the first element and the second element can be determined from the transparent channel parameter array by the values corresponding to the values of each element.
[0068] Sub-step S103-2, changing the transparent channel parameter corresponding to the target element adjacent to the first element in the second element to the transparent channel parameter corresponding to the first element, so as to obtain a new transparent channel parameter array and generate the corresponding second image data.
[0069] It can be understood that the above-mentioned elements adjacent to a first element are elements in the transparent channel parameter matrix that have no gaps between them and the first element. For example, if the first element is located in the i-th row and j-th column in the transparent channel parameter matrix, then the elements adjacent to the first element may be the elements located in the i+1-th row and j-th column in the transparent channel parameter matrix, the elements located in the i-1-th row and j-th column in the transparent channel parameter matrix, the elements located in the i-th row and j+1-th column in the transparent channel parameter matrix, the elements located in the i-th row and j-1-th column in the transparent channel parameter matrix, the elements located in the i-1-th row and j-1-th column in the transparent channel parameter matrix, and the elements located in the i+1-th row and j+1-th column in the transparent channel parameter matrix.
[0070] In some embodiments, the element that is the second element among the elements adjacent to the first element is determined as the target element, and the value of the target element is changed from the original value of the second element to the value of the first element.
[0071] In some embodiments, in order to reduce the amount of data processing and reduce the load of the processor 120, a cross sampling method can be used to obtain a target element adjacent to the first element from the second element. That is, the cross sampling method is used when determining the elements adjacent to the first element. In this way, for the first element located in the i-th row and j-th column in the transparent channel parameter matrix, the adjacent elements are the elements located in the i+1-th row and j-th column in the transparent channel parameter matrix, the elements located in the i-1-th row and j-th column in the transparent channel parameter matrix, the elements located in the i-th row and j+1-th column in the transparent channel parameter matrix, and the elements located in the i-th row and j-1-th column in the transparent channel parameter matrix. Then, the elements that are the second elements among the elements adjacent to the first element are determined as the target elements. In this way, the bandwidth occupancy of this step can be significantly reduced.
[0072] In some other embodiments, the above step S103 may also be to obtain the first image data corresponding to the transparent channel parameter array. The edge of the image area representing the image model in the first image data is expanded using a Gaussian blur algorithm. It can be understood that the transparent channel parameters of the pixel points corresponding to the expanded edge are consistent with the transparent channel parameters of the pixel points corresponding to the image model. In this way, it can be observed that the point-like contours inside the complex object are significantly reduced, and the performance cost is negligible relative to the entire stroke.
[0073] Step S104: perform transparency test cropping on the second image data using the first image data to obtain an outer contour.
[0074] In some embodiments, the image area representing the image model in the first image data may be used to crop the image area in the second image data representing the image model. Optionally, the transparent channel parameters corresponding to each pixel in the second image data may be obtained and compared with the transparent channel parameters of the pixel at the same position in the first image data. If the transparent channel parameters of the pixel in the second image data represent that the pixel belongs to the image model, and the transparent channel parameters corresponding to the pixel at the same position in the first image data are the same, then the pixel is cropped in the first image data. Optionally, the pixel may be cropped by changing its corresponding transparent channel parameter to be consistent with the pixel that does not belong to the image model.
[0075] In addition, when executing the above step S104, an X-shaped sampling method may be used to sample the depth map, and the depth center is not sampled, which significantly reduces the bandwidth occupancy in this step.
[0076] Step S105: determining depth information corresponding to the outer contour according to the image to be processed.
[0077] In some embodiments, the above step S105 may be:
[0078] (1) Mapping the outer contour onto the image to be processed to obtain the target image region where the image model corresponding to the outer contour appears in the image to be processed. It can be understood that the outer contour is located outside the image model. In addition, the outer contour is also obtained based on the image to be processed. Therefore, after mapping all the pixels of the outer contour onto the pixels at the same position in the image to be processed, the target image region where the image model is located can be displayed in the image to be processed.
[0079] (2) sequentially matching the target pixel points closest to each pixel point on the outer contour in the target image area.
[0080] (3) Assign the depth information of the target pixel to the matching pixel on the outer contour.
[0081] In other embodiments, the depth information corresponding to each pixel point belonging to the image model in the image to be processed may be mapped to the second image data from which the outer contour has been cut out. Then, each pixel point of the outer contour is used as a pixel point to be determined, and then, the target pixel point closest to the pixel point to be determined and having depth information is determined in turn, and the depth information corresponding to the target pixel point is assigned to the pixel point to be determined. In this way, the outer contour with depth information can be obtained.
[0082] It can be understood that the method for determining the outer contour with depth information corresponding to each image model can be implemented according to the above steps S103 to S105.
[0083] After obtaining the outer contour with depth information, in some embodiments, as Figure 4 As shown, the above outline rendering method may further include the steps of:
[0084] Step S201 : Depth information corresponding to the base outer contour is used to render the outer contour.
[0085] Thus, when there is occlusion between two image models, the occluded portion of the outer contour corresponding to the occluded image model will not be rendered, thereby saving rendering workload and reducing the rendering load of the electronic device 100. Moreover, the rendered image will not have a large number of messy and intersecting outer contours, improving the user's visual experience.
[0086] Additionally, proper transparency testing of the color buffer can be performed during post-effects to remove internal noise.
[0087] In order to execute the corresponding steps in the above embodiments and various possible methods, an implementation method of the outer contour rendering device 300 is given below. Optionally, the outer contour rendering device 300 can adopt the above Figure 1 The device structure of the electronic device 100 is shown. Figure 5 , Figure 5 The functional module diagram of an outer contour rendering device 300 provided in an embodiment of the present invention. It should be noted that the outer contour rendering device 300 provided in this embodiment has the same basic principle and technical effects as those in the above-mentioned embodiment. For the sake of brief description, for the parts not mentioned in this embodiment, reference can be made to the corresponding contents in the above-mentioned embodiment. The outer contour rendering device 300 includes: a drawing module 301, an acquisition module 302, an expansion module 303, a clipping module 304 and a determination module 305.
[0088] The drawing module 301 is used to draw according to the image model existing in the scene to obtain the image to be processed.
[0089] The acquisition module 302 is used to acquire the transparent channel parameter array corresponding to the image to be processed to obtain first image data.
[0090] The expansion module 303 is used to expand the array area representing the image model in the transparent channel parameter array outward to obtain second image data.
[0091] The cropping module 304 is configured to perform a transparent test cropping on the second image data using the first image data to obtain an outer contour.
[0092] The determination module 305 is used to determine the depth information corresponding to the outer contour according to the image to be processed, so as to render the outer contour according to the depth information.
[0093] In some embodiments, the expansion module 303 is specifically used for:
[0094] Determine, from the transparent channel parameter array, a first element belonging to the image model and a second element not belonging to the image model;
[0095] The transparent channel parameter corresponding to the target element adjacent to the first element in the second element is changed to the transparent channel parameter corresponding to the first element to obtain a new transparent channel parameter array and generate the corresponding second image data.
[0096] In some embodiments, the contour rendering device 300 further includes:
[0097] The acquisition module 302 is further configured to acquire a target element adjacent to the first element from the second element by using a cross sampling method.
[0098] In some embodiments, the expansion module 303 is specifically used for:
[0099] Acquire first image data corresponding to the transparent channel parameter array;
[0100] The edge of the image region representing the image model in the first image data is expanded by using a Gaussian blur algorithm.
[0101] In some embodiments, the determination module 305 is specifically used to:
[0102] Mapping the outer contour onto the image to be processed to obtain a target image region where the image model corresponding to the outer contour appears in the image to be processed;
[0103] Sequentially matching the target pixel points closest to each pixel point on the outer contour in the target image area;
[0104] The depth information of the target pixel point is assigned to the matching pixel point on the outer contour.
[0105] In some embodiments, the contour rendering device 300 further includes:
[0106] A rendering module is used to render the outer contour based on the depth information corresponding to the outer contour.
[0107] In some embodiments, the drawing module 301 is specifically used for:
[0108] The image model existing in the scene is drawn using a pre-calculated screen depth algorithm.
[0109] Optionally, the above modules can be stored in the form of software or firmware. Figure 1 The memory 110 shown in the figure may be fixed in the operating system (OS) of the electronic device 100 and may be Figure 1 Meanwhile, the data and program codes required for executing the above modules may be stored in the memory 110.
[0110] In summary, the embodiments of the present invention provide a contour rendering method, device, electronic device and computer-readable storage medium. The contour rendering method includes: drawing according to the image model existing in the scene to obtain the image to be processed; obtaining the transparent channel parameter array corresponding to the image to be processed to obtain the first image data; expanding the array area representing the image model in the transparent channel parameter array outward to obtain the second image data; using the first image data to perform transparent test cropping on the second image data to obtain the outer contour; according to the image to be processed, determining the depth information corresponding to the outer contour so as to render the outer contour according to the depth information. The object can be highlighted by stroking, so that the emphasized object is more intuitively presented without changing the relative color with other objects; the method can significantly reduce the number of internal point edges; using the mobile platform solution can significantly reduce performance loss and run at an acceptable frame rate on current mobile devices.
[0111] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0112] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0113] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0114] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A contour rendering method, characterized in that: The outline rendering method comprises: Drawing is performed according to the image model existing in the scene to obtain an image to be processed; the image to be processed carries depth information corresponding to the image model; Acquire a transparent channel parameter array corresponding to the image to be processed to obtain first image data; in the first image data, transparent channel parameters of pixels belonging to the image model are different from transparent channel parameters of pixels not belonging to the image model; Expanding an array area in the transparent channel parameter array that represents the image model outward to obtain second image data; in the second image data, transparent channel parameters of pixels belonging to the expanded area are consistent with transparent channel parameters of pixels belonging to the image model; Obtaining a transparent channel parameter corresponding to each pixel in the second image data and comparing it with a transparent channel parameter of a pixel at the same position in the first image data; If a transparent channel parameter of any target pixel point belonging to the image model in the second image data is the same as a transparent channel parameter corresponding to a pixel point at the same position as the target pixel point in the first image data, then the target pixel point is changed in the second image data to be consistent with the transparent channel parameter corresponding to a pixel point not belonging to the image model, so as to obtain an outer contour; Determining depth information corresponding to the outer contour according to the image to be processed, so as to render the outer contour according to the depth information; Wherein, the step of expanding outwardly the array area representing the image model in the transparent channel parameter array comprises: Determine, from the transparent channel parameter array, a first element belonging to the image model and a second element not belonging to the image model; The transparent channel parameter corresponding to the target element adjacent to the first element in the second element is changed to the transparent channel parameter corresponding to the first element to obtain a new transparent channel parameter array and generate the corresponding second image data.
2. The contour rendering method according to claim 1, characterized in that: The outline rendering method further comprises: A target element adjacent to the first element is obtained from the second element using a cross sampling method.
3. The contour rendering method according to claim 1, characterized in that: The step of expanding outwardly the array area representing the image model in the transparent channel parameter array comprises: Acquire first image data corresponding to the transparent channel parameter array; The edge of the image region representing the image model in the first image data is expanded by using a Gaussian blur algorithm.
4. The contour rendering method according to claim 1, characterized in that: The step of determining the depth information corresponding to the outer contour according to the image to be processed comprises: Mapping the outer contour onto the image to be processed to obtain a target image region where the image model corresponding to the outer contour appears in the image to be processed; Sequentially matching the target pixel points closest to each pixel point on the outer contour in the target image area; The depth information of the target pixel point is assigned to the matching pixel point on the outer contour.
5. The contour rendering method according to claim 1, characterized in that: The outline rendering method further comprises: The outer contour is rendered based on the depth information corresponding to the outer contour.
6. The contour rendering method according to claim 1, characterized in that: The step of drawing according to the image model existing in the scene includes: The image model existing in the scene is drawn using a pre-calculated screen depth algorithm.
7. A contour rendering device, characterized in that: The outline rendering device comprises: A drawing module, used for drawing according to the image model existing in the scene to obtain an image to be processed; the image to be processed carries depth information corresponding to the image model; an acquisition module, configured to acquire a transparent channel parameter array corresponding to the image to be processed to obtain first image data; in the first image data, transparent channel parameters of pixels belonging to the image model are different from transparent channel parameters of pixels not belonging to the image model; an expansion module, configured to expand outwardly an array area in the transparent channel parameter array representing the image model to obtain second image data; in the second image data, transparent channel parameters of pixel points belonging to the expansion area are consistent with transparent channel parameters of pixel points belonging to the image model; The cropping module is used to: Obtaining a transparent channel parameter corresponding to each pixel in the second image data and comparing it with a transparent channel parameter of a pixel at the same position in the first image data; If a transparent channel parameter of any target pixel point belonging to the image model in the second image data is the same as a transparent channel parameter corresponding to a pixel point at the same position as the target pixel point in the first image data, then the target pixel point is changed in the second image data to be consistent with the transparent channel parameter corresponding to a pixel point not belonging to the image model, so as to obtain an outer contour; A determination module, configured to determine depth information corresponding to an outer contour according to the image to be processed, so as to render the outer contour according to the depth information; Among them, the expansion module is specifically used to: determine the first element belonging to the image model and the second element not belonging to the image model from the transparent channel parameter array; change the transparent channel parameter corresponding to the target element adjacent to the first element in the second element to the transparent channel parameter corresponding to the first element, so as to obtain a new transparent channel parameter array and generate the corresponding second image data.
8. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor can execute the machine executable instructions to implement any one of the methods of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Method for rendering contour edges of models
CN102708585A
Picture processing method and terminal
CN105245774A
Character display method and device
CN106384373A
Image processing method and device
CN106780313A
Image processing method, device and electronic apparatus
CN108230252A
