Data processing method and device, electronic equipment and readable storage medium
By generating and merging directed distance field maps, building blank maps and outputting distance information, determining multiple distance thresholds to split the target maps, solving the problem of edge blurring caused by small size of mask map sequences in the prior art, and achieving high-definition masking effect.
Patent Information
- Application Number
- CN202411573288.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-03-28
AI Technical Summary
In the prior art, in order to save resources, mask map sequences are usually made with small sizes, resulting in blurred edges of masks and low clarity.
By obtaining the mask map sequence, the corresponding directed distance field map is generated, and the directed distance field map is merged to obtain the directed distance field merge map. Build a blank map based on the pixel resolution of the merged map, output the distance information to the first image channel of the blank map, and generate the target map. Then, multiple distance thresholds are determined within the range of distance information, and the target map is split to obtain the target mask map corresponding to each distance threshold.
While reducing the size of the map and saving resources, special-shaped masks are applied to ensure the clarity of the mask edges.
Smart Images

Figure CN119722889A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a data processing method, device, electronic device and readable storage medium. Background Art
[0002] The main function of the mask map is to display or hide specific parts of the image through black and white grayscale information. Games often use a series of mask maps to control some ablation, diffusion or fusion effects, such as the effect of water soaking the surface of an object, the effect of corroded floor, etc.
[0003] In order to save resources during texture production, mask texture sequences are often produced in very small sizes. For example, a normal material texture may be 1k-4k in size, while a frame of texture in a mask texture sequence can only use approximately (128x128) px. Although this can effectively control the volume of the mask texture sequence, the low resolution will result in blurred mask edges and lower clarity. Summary of the invention
[0004] The present disclosure provides a data processing method, device, electronic device and readable storage medium to solve or at least partially solve the above problems, as follows.
[0005] In a first aspect, the present disclosure provides a data processing method, the method comprising:
[0006] Obtaining a mask map sequence; the mask map sequence includes a plurality of mask maps;
[0007] Generating a corresponding signed distance field map for the mask map, and merging the signed distance field maps to obtain a signed distance field merged map;
[0008] Constructing a blank map according to the pixel resolution of the signed distance field merge map;
[0009] Outputting the distance information of the directed distance field merge map through the first image channel of the blank map to generate a target map;
[0010] Determine multiple distance thresholds within the distance range where the distance information of the directional distance field merge map is located; the distance range is a range consisting of the minimum value and the maximum value of all distance information of the directional distance field merge map;
[0011] The target map is split based on the multiple distance thresholds to obtain a target mask map corresponding to each distance threshold.
[0012] In a second aspect, the present disclosure further provides a data processing device, the device comprising:
[0013] A sequence frame acquisition module, used to acquire a mask map sequence; the mask map sequence includes a plurality of mask maps;
[0014] A texture merging module, used for generating a corresponding signed distance field texture for the mask texture, and merging the signed distance field textures to obtain a signed distance field merged texture;
[0015] A blank map construction module, used to construct a blank map according to the pixel resolution of the directed distance field merge map;
[0016] A target map generation module, used for outputting the distance information of the directed distance field merge map through the first image channel of the blank map to generate a target map;
[0017] A threshold determination module, used to determine a plurality of distance thresholds within a distance range where the distance information of the directed distance field merge map is located; the distance range is a range consisting of a minimum value and a maximum value of all distance information of the directed distance field merge map;
[0018] The texture splitting module is used to split the target texture based on the multiple distance thresholds respectively to obtain the target mask texture corresponding to each distance threshold.
[0019] In a third aspect, the present disclosure further provides an electronic device, comprising: a processor, a memory, and computer program instructions stored in the memory and executable on the processor;
[0020] When the processor executes the computer program instructions, the data processing method described in the first aspect above is implemented.
[0021] In a fourth aspect, the present disclosure further provides a computer-readable storage medium, in which computer program instructions are stored. When the computer program instructions are executed by a processor, they are used to implement the data processing method described in the first aspect above.
[0022] The exemplary embodiments of the present disclosure have the following beneficial effects:
[0023] The data processing method provided by the present disclosure first obtains a mask map sequence, the mask map sequence includes multiple mask maps, then generates a corresponding directed distance field map for the mask map, merges the directed distance field map to obtain a directed distance field merge map, constructs a blank map according to the pixel resolution of the directed distance field merge map, and then outputs the distance information of the directed distance field merge map through the first image channel of the blank map, so as to generate a target map; then, multiple distance thresholds are determined within the distance range where the distance information of the directed distance field merge map is located, and the target map can be split based on the multiple distance thresholds to obtain a target mask map corresponding to each distance threshold. In the present disclosure, multiple mask maps can be converted into a target map based on the distance information of multiple mask maps, and a series of mask maps in time sequence can be restored according to the target map, so as to reduce the map volume, save resources, and apply special shape masks while ensuring the clarity of the mask edge. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 is a flow chart of a data processing method provided by one of the embodiments of the present disclosure;
[0025] Figure 2 is a schematic diagram of a mask map sequence provided by one of the embodiments of the present disclosure;
[0026] Figure 3 It is a visualization result of a directed distance field merge map provided by one of the embodiments of the present disclosure;
[0027] Figure 4 It is a visualization result of transparency information of a mask map provided by one of the embodiments of the present disclosure;
[0028] Figure 5 is a schematic diagram of a target map provided by one of the embodiments of the present disclosure;
[0029] Figure 6 is a block diagram of a data processing device provided by one of the embodiments of the present disclosure;
[0030] Figure 7 It is a logical structure diagram of an electronic device for implementing data processing provided by one of the embodiments of the present disclosure. DETAILED DESCRIPTION
[0031] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, each other embodiment obtained by those skilled in the art without making creative work belongs to the scope of protection of the present disclosure.
[0032] The terms "a", "an", "the" and "said" are used in this specification to indicate the presence of one or more elements / components / etc.; the terms "including" and "having" are used to express an open-ended inclusion and mean that additional elements / components / etc. may exist in addition to the listed elements / components / etc.; the terms "first" and "second" etc. are used only as labels and are not intended to limit the quantity of their objects.
[0033] It should be understood that in the embodiments of the present disclosure, "at least one" means one or more, and "more than one" means two or more. "And / or" is merely a way to describe the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previous and subsequent associated objects are in an "or" relationship. "Including A, B and / or C" means including any one, any two, or any three of A, B, and C.
[0034] It should be understood that in the embodiments of the present disclosure, "B corresponding to A", "B corresponding to A", "A corresponds to B", or "B corresponds to A" means that B is associated with A, and B can be determined according to A. Determining B according to A does not mean that B is determined only according to A, and B can also be determined according to A and / or other information.
[0035] The data processing method in one embodiment of the present disclosure can be run on a terminal device or a server, and the terminal device can be a desktop computer, a laptop computer, a tablet computer, a mobile phone, etc., or other electronic devices, which are not specifically limited in the present disclosure. The server is used to provide background services for the client of the application in the terminal device. For example, the server can be the background server of the above-mentioned application. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and big data and artificial intelligence platforms, which are not specifically limited in the present disclosure.
[0036] Before describing the embodiments of the present disclosure in detail, the related art is firstly further introduced.
[0037] In an existing technical solution, in order to save resources in texture production, a very small size is often used to produce a mask texture sequence. For example, a normal material texture may be 1k-4k in size, while a frame of texture in a mask texture sequence can only use approximately (128x128) px. Although the volume of the mask texture sequence can be effectively controlled, the low resolution will result in blurred mask edges and low clarity.
[0038] In another existing technical solution, the mask can also be implemented using a mathematically programmed shader, such as a Noise node or a Fractal node. Although this technical solution does not have the problem of texture volume, it has low controllability and is difficult to implement for some special custom shapes.
[0039] Based on the above-mentioned prior art, the present disclosure can provide a data processing method. In the exemplary embodiment provided by the present disclosure, the clarity of the mask edge can be ensured while reducing the map volume, saving resources, and applying special shape masks.
[0040] Figure 1 A data processing method provided by one embodiment of the present disclosure is shown. Figure 1 As shown, the method includes the following steps S101 to S106.
[0041] Step S101: obtaining a mask map sequence; the mask map sequence includes a plurality of mask maps.
[0042] Multiple mask maps can reflect the change process of the mask shape in time sequence, and multiple mask maps are also key frames of the mask shape in the change process. Figure 2 The water drop mask map sequence may include three water drop mask maps, which may indicate the dissipation process of water droplets in a positive order (ie, from left to right) and the diffusion process of water droplets in a reverse order (ie, from right to left).
[0043] Step S102: generating a corresponding signed distance field map for the mask map, and merging the signed distance field maps to obtain a signed distance field merged map.
[0044] In this step, for each mask map in the mask map sequence, a corresponding signed distance field (SDF) map can be generated. SDF map involves an image processing technology based on signed distance field, which is widely used for efficient rendering of complex edges and contours, especially in text rendering and anti-aliasing processing of vector graphics. Each pixel in the SDF map can record the signed distance between the pixel and a given shape / boundary / point, and can be stored in the alpha channel of the SDF map.
[0045] Then, the signed distance field maps corresponding to each mask map in the mask map sequence may be merged to obtain a signed distance field merged map that merges the distance information in all the signed distance field maps.
[0046] For example, Figure 2 The three water drop mask maps shown generate corresponding water drop signed distance field maps respectively, and obtain three water drop signed distance field maps. Then, these three water drop signed distance field maps are merged to obtain a water drop signed distance field merge map. The visualization result of the water drop signed distance field merge map is as follows: Figure 3 shown.
[0047] Optionally, when merging the signed distance field maps, the distance information of each signed distance field map may be divided by the number of frames of the mask map sequence (for example, in the example of the three water drop signed distance field maps, the distance data of each water drop signed distance field map is divided by 3), so as to visualize the merged result in RGB color mode. Then, the distance information of each signed distance field map divided by the number of frames of the mask map sequence is added together to obtain the distance information of the merged signed distance field map.
[0048] Step S103: construct a blank map according to the pixel resolution of the signed distance field merge map.
[0049] In this step, a blank map can be constructed, and the pixel resolution of the blank map is the same as the pixel resolution of the signed distance field merge map.
[0050] Step S104: Outputting the distance information of the directed distance field merge map through the first image channel of the blank map to generate a target map.
[0051] In this step, the distance information of the directed distance field merge map can be output through the first image channel of the blank map, so as to generate a target map having the distance information of the mask map sequence recorded through the first image channel.
[0052] Since the pixel resolution of the blank map is the same as that of the merged map in the signed distance field, for any pixel in the merged map in the signed distance field, the pixel corresponding to the pixel position can be found in the blank map, that is, the pixels of the merged map in the signed distance field correspond one-to-one with the pixels in the target map.
[0053] In one of the embodiments of the present disclosure, the step of outputting the distance information of the directed distance field merged map through the first image channel of the blank map can be specifically implemented in the following manner, including: for the fifth pixel in the directed distance field merged map, outputting the distance information of the fifth pixel through the second image channel of the sixth pixel in the blank map, wherein the sixth pixel is a pixel in the blank map corresponding to the position of the fifth pixel, and the fifth pixel is one of the pixels in the directed distance field merged map.
[0054] In the above embodiment, the fifth pixel is one of the pixels in the signed distance field merge map. As described above, the sixth pixel corresponding to the position of the fifth pixel can be found in the blank map, and then the distance information of the fifth pixel can be output through the first image channel of the sixth pixel in the blank map.
[0055] Exemplarily, when the distance information of the fifth pixel is output through the first image channel of the sixth pixel in the blank map, the distance range of the distance information of the directed distance field merge map can be first mapped with the value range of the first image channel of the blank map to obtain a mapping relationship between the two, and then the value corresponding to the distance information of the fifth pixel in the first image channel can be determined based on the mapping relationship.
[0056] In an optional embodiment, the first image channel may be a color channel, such as an R (red) channel, a G (green) channel, or a B (blue) channel in an RGB color model.
[0057] In this embodiment, a series of mask maps can be converted into a target map containing the directed distance field information of the mask, and the distance information of the mask map can be stored through the first image channel of the target map. In subsequent steps, a series of target mask maps can be restored according to the distance information stored in the first image channel of the target map.
[0058] Step S105: determining a plurality of distance thresholds within a distance range where the distance information of the directed distance field merge map is located.
[0059] The distance range where the distance information of the merged map of the directed distance occasions is located refers to the range formed by the minimum value and the maximum value of all the distance information of the merged map of the directed distance occasions. In this step, multiple distance thresholds can be selected within the distance range where the distance information of the merged map of the directed distance occasions is located. The number of selected distance thresholds determines the number of target mask maps that can be restored.
[0060] In one embodiment of the present disclosure, a step size may be preset, and then starting from the minimum value of the distance information of the directional distance field merged map, a distance value is taken every step size within the distance range where the distance information of the directional distance field merged map is located, so that multiple distance values may be obtained as distance thresholds within the distance range where the distance information of the directional distance field merged map is located based on the preset step size. In this embodiment, how many distance thresholds can be determined from the distance range is related to the preset step size and the distance range.
[0061] Step S106: splitting the target map based on the multiple distance thresholds respectively to obtain a target mask map corresponding to each distance threshold.
[0062] In this step, the target map can be split according to the order of multiple distance thresholds to obtain multiple target mask maps, wherein the mask shapes in the multiple target mask maps obtained by splitting according to the order of multiple distance thresholds from small to large and from large to small are changed in opposite patterns, that is, by splitting the target map according to different orders of multiple distance thresholds, the process of the mask shapes in the mask map sequence changing in positive or reverse order in time sequence can be restored.
[0063] Exemplarily, the splitting is performed in the order from small to large according to multiple distance thresholds, and the mask shapes in the split multiple target mask maps can be from small to large; the splitting is performed in the order from large to small according to multiple distance thresholds, and the mask shapes in the split multiple target mask maps are from large to small.
[0064] Exemplarily, the splitting is performed in the order from small to large according to multiple distance thresholds, and the mask shapes in the split multiple target mask maps can be from large to small; the splitting is performed in the order from large to small according to multiple distance thresholds, and the mask shapes in the split multiple target mask maps are from small to large.
[0065] In one of the embodiments of the present disclosure, this step can be specifically implemented in the following manner, including: based on the distance information represented by the first image channel of the target map and one of the distance thresholds, converting the target map into a binary image, and obtaining a target mask map corresponding to one of the distance thresholds.
[0066] Take the nth distance threshold T among multiple distance thresholds n Take the nth distance threshold T as an example. n The nth target mask map in a series of target mask maps can be restored. The distance threshold T can be used n , the distance information recorded by the first image channel of the target map is divided into two parts, one part is less than or equal to the distance threshold T n The other part is greater than the distance threshold T n distance information.
[0067] In an optional example, for one pixel in the target map, if the distance information recorded on the first image channel of the pixel is less than or equal to the distance threshold T n , it can be determined that the pixel value of the pixel in the nth target mask map is 1; if the distance information recorded on the first image channel of the pixel is greater than the distance threshold T n , it can be determined that the pixel value of the pixel in the nth target mask map is 0.
[0068] In an optional example, for one pixel in the target map, if the distance information recorded on the first image channel of the pixel is less than or equal to the distance threshold T n , it can be determined that the pixel value of the pixel in the nth target mask map is 0; if the distance information recorded on the first image channel of the pixel is greater than the distance threshold T n , it can be determined that the pixel value of the pixel in the nth target mask map is 1.
[0069] The difference between the above two examples is that the changing rules of the mask shapes in the restored series of target mask maps are opposite.
[0070] Optionally, the binarization process in the above example can be implemented by a step function.
[0071] For example, if five distance thresholds are determined within the distance range where the distance information of the directed distance map is located, and the water drop mask map sequence only includes three water drop mask maps, the three water drop mask maps can reflect the shape of the water drop at the three time nodes of t=0, t=t1, and t=t2 in the time period 0-t2. 01 , t = t1, t = t 12 , t=t2, where t 01 ∈(0,t1), t 12 ∈(t1,t2). For another example, by using another five distance thresholds, we can restore the water droplets at t=0, t=t2 in the time period 0-t2. 01-1 , t=t 01-2 , t=t 12-1 , t=t 12-2 , t=t2, where t 01-1 ∈(0,t1), t 01-2 ∈(0,t1), t 01-1 <t 01-2 , t 12-1 ∈(t1,t2), t 12-2 ∈(t1,t2), t 12-1 <t 12-2 .
[0072] The data processing method provided in one of the embodiments of the present disclosure may further include the following step S107: determining transparency information of the mask map.
[0073] In this step, the transparency information of each mask map in the mask map sequence may be determined, wherein all pixels constituting a mask shape in a mask map may have the same transparency or different transparency.
[0074] In this embodiment, the above step S104 can be implemented by the following step S1041.
[0075] Step S1041: outputting the distance information of the directed distance field merge map through the first image channel of the blank map, and outputting the transparency information of the mask map through the second image channel of the blank map, to generate a target map.
[0076] In this embodiment, the distance information of the mask map sequence may be stored through the first image channel of the target map, and the transparency information of the mask map sequence may be stored through the second image channel of the target map.
[0077] For example, Figure 2The three water drop mask maps shown in the figure can be visualized by referring to the transparency information. Figure 4 , the transparency of the three water drop mask maps gradually decreases, and the resolution of each water drop mask map in the visualization result is 1 / 3 of the resolution of the water drop mask map.
[0078] For example, the distance information after merging each water drop mask map (refer to Figure 3 ) and the transparency information of each water drop mask map (refer to Figure 4 ) are stored through the R channel and G channel of the target map respectively, and the following can be obtained: Figure 5 The target map shown. Figure 5 In the target map shown, the pixel area corresponding to the first water drop mask map is pixel area a, the pixel area corresponding to the second water drop mask map is pixel area b, and the pixel area corresponding to the third water drop mask map is pixel area c.
[0079] In an optional implementation, the step of outputting the transparency information of the mask map through the second image channel of the blank map in step S1041 can be implemented by the following steps S1041 - 1 to S1041 - 2.
[0080] Step S1041-1: Determine the pixel area corresponding to the mask map in the blank map.
[0081] Step S1041 - 2 : Outputting the transparency information of the mask map through the second image channel of the pixels in the blank map that are located in the pixel area corresponding to the mask map.
[0082] First, a corresponding pixel area can be selected in the blank map for each mask map, wherein the pixel areas corresponding to the respective mask maps in the blank map do not overlap with each other. The pixels in the pixel area a selected for the mask map A are used to store the transparency information of the mask map A through the second image channel. Then, the transparency information of the mask map A can be output through the second image channel of the pixels in the pixel area a corresponding to the mask map A in the blank map.
[0083] The pixel area corresponding to the mask map in the blank map may include one or more pixels.
[0084] Optionally, step S1041-2 can be specifically implemented in the following manner: for the first pixel in the mask map, the transparency information of the first pixel is output through the second image channel of the second pixel in the blank map, wherein the second pixel is located in the pixel area corresponding to the mask map in the blank map, and the first pixel is one or more pixels in the mask map.
[0085] In the above implementation, the first pixel is one of the pixels in the mask map A. As described above, the second pixel corresponding to the first pixel can be found in the pixel area a corresponding to the mask map A in the blank map, and then the transparency information of the first pixel can be output through the second image channel of the second pixel in the blank map.
[0086] In one embodiment, when the transparency of the mask shape in the mask map A is uniform, the pixel area a may include a pixel p, that is, the transparency information of the mask shape in the mask map A may be stored through the second image channel of a pixel p (the outside of the mask shape is opaque by default), and the corresponding pixel in the pixel area a for each pixel in the mask shape in the mask map A is the pixel p.
[0087] In one embodiment, when the transparency of the mask shape in the mask map A is uniform or non-uniform, the pixel area a may include multiple pixels p, that is, the transparency information of the mask shape in the mask map A may be stored through the second image channel of the multiple pixels p, and for each pixel in the mask shape in the mask map A, the pixel p corresponding to the position may be found in the pixel area a.
[0088] For example, when the transparency information of the first pixel in the mask map A is output through the second image channel of the second pixel in the blank map, the transparency range of the transparency information of the mask map A can be first mapped with the value range of the second image channel of the blank map to obtain a mapping relationship between the two, and then the value corresponding to the transparency information of the first pixel in the second image channel can be determined based on the mapping relationship.
[0089] In this embodiment, the transparency information of each mask map may be stored in the pixel area corresponding to each mask map in the target map, that is, the transparency change of the mask shape in time sequence is stored through a series of pixel areas in the target map.
[0090] In an optional embodiment, the second image channel may be a color channel, such as an R (red) channel, a G (green) channel, or a B (blue) channel in an RGB color mode. The first image channel and the second image channel may select different color channels, respectively. For example, the first image channel may be the R channel in an RGB color mode, and the second image channel may be the G channel in an RGB color mode; the first image channel may be the R channel in an RGB color mode, and the second image channel may be the B channel in an RGB color mode; the first image channel may be the G channel in an RGB color mode, and the second image channel may be the R channel in an RGB color mode; the first image channel may be the G channel in an RGB color mode, and the second image channel may be the B channel in an RGB color mode; the first image channel may be the B channel in an RGB color mode, and the second image channel may be the R channel in an RGB color mode; the first image channel may be the B channel in an RGB color mode, and the second image channel may be the G channel in an RGB color mode.
[0091] The pixel data of the remaining image channels except the first image channel and the second image channel can be default values. For example, if the first image channel is the R channel and the second image channel is the G channel, the B channel pixel data of all pixels in the target map can be set to 0, 100, 200, or 255.
[0092] In this way, a series of mask maps can be converted into a target map containing the mask's directed distance field information and the mask's transparency information, and the distance information of the mask map can be stored through the first image channel of the target map, and the transparency information of the mask map can be stored through the second image channel of the target map. In subsequent steps, a series of target mask maps can be restored based on the distance information stored in the first image channel of the target map, and the transparency of each target mask map can be restored based on the transparency information stored in the second image channel of the target map.
[0093] The data processing method provided in one of the embodiments of the present disclosure may further include the following steps S108 to S110, which are used to restore the transparency of each target mask map according to the transparency information stored in the second image channel of the target map.
[0094] Step S108: For the third pixel in the target map, determine the transparency range of the third pixel according to the pixel data of the third pixel corresponding to the pixel areas corresponding to the first mask map and the last mask map in the mask map sequence on the second image channel; the third pixel is one of the pixels in the target map.
[0095] The following will be Figure 5The target map shown in FIG. 1 is used as an example for explanation. In an optional example, the first image channel is the R channel, the second image channel is the G channel, Figure 5 The target map shown includes a pixel P, and the position coordinates of the pixel P are (x p ,y p ), pixel data G of pixel P on channel G of target texture p , determine the distance variation range of pixel P as [S min ,S p ], where G p The transparency information represented by T p .
[0096] The first mask map and the last mask map in the mask map sequence are the first mask map and the last mask map in the mask map sequence respectively. Figure 5 The target map shown in FIG. 1 is used as an example for explanation. In an optional example, the first image channel is the R channel, the second image channel is the G channel, Figure 5 The target map shown includes a pixel P, and the position coordinates of the pixel P are (x p ,y p ). Reference Figure 5 The target map shown in the figure has a pixel area corresponding to the first mask map (i.e., the first water drop mask map) as pixel area a, and the pixel corresponding to pixel P in pixel area a is pixel P1. The position coordinate of pixel P1 in the target map is (1 / 3x p , 1 / 3y p ), the pixel data of pixel P1 on the G channel is G p1 The pixel area corresponding to the last mask map (i.e. the third water drop mask map) is pixel area c. The pixel corresponding to pixel P in pixel area c is pixel P3. The position coordinates of pixel P3 in the target map are (2 / 3h+1 / 3x p , 1 / 3y p ), where the resolution of the target map in both the width and height directions is h, and the pixel data of pixel P3 on the G channel is G p3 Among them, G p1 The transparency information represented is 100, G p3 The transparency information represented is 20, so the transparency range of pixel P is [100,20].
[0097] Step S109: determining a mapping relationship between a distance range where the distance information of the directed distance field merge map is located and a transparency range of the third pixel.
[0098] Exemplarily, the distance range where the distance information of the directed distance field is located is [S min ,S p] is mapped to the transparency range [100,20] of pixel P.
[0099] Step S110: determining the transparency of a fourth pixel corresponding to the third pixel position in the target mask map according to the distance threshold corresponding to the target mask map and the mapping relationship.
[0100] For example, the distance range where the distance information of the map is located is merged by the directed distance field [S min ,S p ] and the transparency range [100,20] of pixel P, we can determine that the mapping value of the distance threshold T1 corresponding to the target mask map M1 in [100,20] is k1, and the mapping value k1 is the position coordinate (x p ,y p ) pixels.
[0101] For example, for a pixel P(x p ,y p ), the pixel data of pixel P on the R channel of the target map is R p , R p The distance information represented is S p , S p <T1, then the position coordinates in the target mask map M1 are (x p ,y p ) is 1 (indicating that it needs to be displayed, i.e., it is located within the mask shape). That is, the pixel corresponding to the position of pixel P in the target mask map M1 needs to be displayed, and the transparency is k1.
[0102] In an optional embodiment, the target map can be generated by production software such as Photoshop, ZBrush, etc., and the step of restoring the target map to a series of target mask maps can be implemented in a game engine.
[0103] The data processing method provided by the present disclosure first obtains a mask map sequence, the mask map sequence includes multiple mask maps, then generates a corresponding directed distance field map for the mask map, merges the directed distance field map to obtain a directed distance field merge map, constructs a blank map according to the pixel resolution of the directed distance field merge map, and then outputs the distance information of the directed distance field merge map through the first image channel of the blank map, so as to generate a target map; then, multiple distance thresholds are determined within the distance range where the distance information of the directed distance field merge map is located, and the target map can be split based on the multiple distance thresholds to obtain a target mask map corresponding to each distance threshold. In the present disclosure, multiple mask maps can be converted into a target map based on the distance information of multiple mask maps, and a series of mask maps in time sequence can be restored according to the target map, so as to reduce the map volume, save resources, and apply special shape masks while ensuring the clarity of the mask edge.
[0104] In the exemplary embodiment of the present disclosure, since the mask is still controlled by a map, it is more controllable and intuitive than controlling by a program node.
[0105] In an exemplary embodiment of the present disclosure, not only can a single texture be used to restore the sequence mask animation effect in a game engine, but also the mask edge can be guaranteed to be clear, and the transparent information setting of a single mask can be supported, thereby obtaining more effect control.
[0106] The exemplary embodiments of the present disclosure have the following advantages:
[0107] 1. Resource saving: Convert a series of sequence frame masks into a single frame map and keep the clarity of the mask edge.
[0108] 2. Controllability: Since the mask is still controlled by graphics, any graphics can be drawn according to actual needs.
[0109] 3. Versatility: The exemplary embodiments of the present disclosure are compatible with different game engines and production software.
[0110] Corresponding to the data processing method provided by the embodiment of the present disclosure, the embodiment of the present disclosure also provides a data processing device. Figure 6 As shown, the device 700 includes:
[0111] The sequence frame acquisition module 701 is used to acquire a mask map sequence; the mask map sequence includes a plurality of mask maps;
[0112] A texture merging module 702, configured to generate a corresponding signed distance field texture for the mask texture, and merge the signed distance field textures to obtain a signed distance field merged texture;
[0113] A blank map construction module 703, used to construct a blank map according to the pixel resolution of the directed distance field merge map;
[0114] A target map generation module 704 is used to output the distance information of the directed distance field merge map through the first image channel of the blank map to generate a target map;
[0115] A threshold determination module 705 is used to determine multiple distance thresholds within a distance range where the distance information of the directed distance field merge map is located; the distance range is a range consisting of the minimum and maximum values of all distance information of the directed distance field merge map;
[0116] The texture splitting module 706 is used to split the target texture based on the multiple distance thresholds respectively to obtain a target mask texture corresponding to each distance threshold.
[0117] Optionally, the device is also used for:
[0118] Determining transparency information of the mask map;
[0119] The step of outputting the distance information of the directed distance field merge map through the first image channel of the blank map to generate a target map comprises:
[0120] The distance information of the directed distance field merge map is output through the first image channel of the blank map, and the transparency information of the mask map is output through the second image channel of the blank map to generate a target map.
[0121] Optionally, outputting the transparency information of the mask map through the second image channel of the blank map includes:
[0122] Determine a pixel area corresponding to the mask map in the blank map;
[0123] The transparency information of the mask map is outputted through the second image channel of the pixels in the blank map that are located in the pixel area corresponding to the mask map.
[0124] Optionally, the step of outputting the transparency information of the mask map through the second image channel of pixels in the blank map located within a pixel area corresponding to the mask map comprises:
[0125] For a first pixel in the mask map, transparency information of the first pixel is output through a second image channel of a second pixel in the blank map, wherein the second pixel is located in a pixel area corresponding to the mask map in the blank map, and the first pixel is one or more pixels in the mask map.
[0126] Optionally, the device is also used for:
[0127] For a third pixel in the target map, determining a transparency range of the third pixel according to pixel data of pixels corresponding to the third pixel in pixel areas corresponding to the first mask map and the last mask map in the mask map sequence on the second image channel; the third pixel is one of the pixels in the target map;
[0128] Determine a mapping relationship between a distance range where the distance information of the directed distance field merge map is located and a transparency range of the third pixel;
[0129] For the target mask map that is located between the first mask map and the last mask map in time sequence, the transparency of the fourth pixel in the target mask map corresponding to the third pixel position is determined according to the distance threshold corresponding to the target mask map and the mapping relationship.
[0130] Optionally, the first image channel and the second image channel are different color channels.
[0131] Optionally, the step of outputting the distance information of the directed distance field merged map through the first image channel of the blank map comprises:
[0132] For the fifth pixel in the directed distance field merged map, the distance information of the fifth pixel is output through the first image channel of the sixth pixel in the blank map, wherein the sixth pixel is a pixel in the blank map corresponding to the position of the fifth pixel, and the fifth pixel is one of the pixels in the directed distance field merged map.
[0133] Optionally, the target map is split based on the multiple distance thresholds to obtain a target mask map corresponding to each distance threshold, including:
[0134] Based on the distance information represented by the first image channel of the target map and one of the distance thresholds, the target map is converted into a binary image to obtain a target mask map corresponding to one of the distance thresholds.
[0135] The data processing device provided by the present disclosure first obtains a mask map sequence, the mask map sequence includes multiple mask maps, then generates a corresponding directed distance field map for the mask map, merges the directed distance field map to obtain a directed distance field merge map, constructs a blank map according to the pixel resolution of the directed distance field merge map, and then outputs the distance information of the directed distance field merge map through the first image channel of the blank map, so as to generate a target map; then, multiple distance thresholds are determined within the distance range where the distance information of the directed distance field merge map is located, and the target map can be split based on the multiple distance thresholds to obtain a target mask map corresponding to each distance threshold. In the present disclosure, multiple mask maps can be converted into a target map based on the distance information of multiple mask maps, and a series of mask maps in time sequence can be restored according to the target map, so as to reduce the map volume, save resources, and apply special shape masks while ensuring the clarity of the mask edge.
[0136] Next, an electronic device provided by an embodiment of the present disclosure is introduced. Figure 7 , Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. The electronic device 800 may be deployed with the data processing device described in the embodiment of the present disclosure to implement the functions in the embodiment of the present disclosure. Specifically, the electronic device 800 includes: a receiver 801, a transmitter 802, a processor 803 and a memory 804 (the number of processors 803 in the electronic device 800 may be one or more, Figure 7 In the example of FIG. 801 , the processor 803 may include an application processor 8031 and a communication processor 8032. In some embodiments of the present disclosure, the receiver 801, the transmitter 802, the processor 803 and the memory 804 may be connected via a bus or other means.
[0137] The memory 804 may include a read-only memory and a random access memory, and provides instructions and data to the processor 803. A portion of the memory 804 may also include a non-volatile random access memory (NVRAM). The memory 804 stores processor and operation instructions, executable modules or data structures, or subsets thereof, or extended sets thereof, wherein the operation instructions may include various operation instructions for implementing various operations.
[0138] The processor 803 controls the operation of the execution device. In a specific application, the various components of the execution device are coupled together through a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus, and a status signal bus, etc. However, for the sake of clarity, various buses are referred to as bus systems in the figure.
[0139] The method disclosed in the above embodiment of the present disclosure can be applied to the processor 803, or implemented by the processor 803. The processor 803 can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 803. The above processor 803 can be a general processor, a digital signal processor (digital signal processing, DSP), a microprocessor or a microcontroller, and can further include an application specific integrated circuit (application specific integrated circuit, ASIC), a field programmable gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The processor 803 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiment of the present disclosure. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiment of the present disclosure can be directly embodied as a hardware decoding processor to be executed, or a combination of hardware and software modules in the decoding processor can be executed. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 804, and the processor 803 reads the information in the memory 804 and completes the steps of the above method in combination with its hardware.
[0140] The receiver 801 can be used to receive input digital or character information and generate signal input related to the relevant settings and function control of the execution device. The transmitter 802 can be used to output digital or character information through the first interface; the transmitter 802 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; the transmitter 802 can also include a display device such as a display screen.
[0141] In the embodiment of the present disclosure, the application processor 8031 in the processor 803 is used to execute the data processing method in the embodiment of the present disclosure. It should be noted that the specific manner in which the application processor 8031 executes each step is based on the same concept as the various method embodiments in the present disclosure, and the technical effects brought by it are the same as the various method embodiments in the present disclosure. For specific contents, please refer to the description in the method embodiments shown in the above disclosure, and no further description will be given here.
[0142] The disclosed embodiment also provides a chip for executing instructions, which is used to execute the technical solution of the data processing method in the above embodiment.
[0143] The embodiment of the present disclosure further provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed on a processor, the processor executes the technical solution of the data processing method in the above embodiment.
[0144] The embodiments of the present disclosure further provide a computer program product, including a computer program, which is used to execute the technical solution of the data processing method in the above embodiments when executed by a processor.
[0145] The computer readable storage medium mentioned above can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or dedicated server.
[0146] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
[0147] Although the present disclosure is disclosed as above in the form of a preferred embodiment, it is not intended to limit the present disclosure. Any person skilled in the art may make possible changes and modifications without departing from the spirit and scope of the present disclosure. Therefore, the scope of protection of the present disclosure shall be based on the scope defined by the claims of the present disclosure.
Claims
1. A data processing method, characterized in that: The method comprises: Obtaining a mask map sequence; the mask map sequence includes a plurality of mask maps; Generating a corresponding signed distance field map for the mask map, and merging the signed distance field maps to obtain a signed distance field merged map; Constructing a blank map according to the pixel resolution of the signed distance field merge map; Outputting the distance information of the directed distance field merge map through the first image channel of the blank map to generate a target map; Determine multiple distance thresholds within the distance range where the distance information of the directional distance field merge map is located; the distance range is a range consisting of the minimum value and the maximum value of all distance information of the directional distance field merge map; The target map is split based on the multiple distance thresholds to obtain a target mask map corresponding to each distance threshold.
2. The method according to claim 1, characterized in that The method further comprises: Determining transparency information of the mask map; The step of outputting the distance information of the directed distance field merge map through the first image channel of the blank map to generate a target map comprises: The distance information of the directed distance field merge map is output through the first image channel of the blank map, and the transparency information of the mask map is output through the second image channel of the blank map to generate a target map.
3. The method according to claim 2, characterized in that The step of outputting the transparency information of the mask map through the second image channel of the blank map comprises: Determine a pixel area corresponding to the mask map in the blank map; The transparency information of the mask map is outputted through the second image channel of the pixels in the blank map that are located in the pixel area corresponding to the mask map.
4. The method according to claim 3, characterized in that The step of outputting the transparency information of the mask map through the second image channel of the pixels in the blank map located in the pixel area corresponding to the mask map comprises: For a first pixel in the mask map, transparency information of the first pixel is output through a second image channel of a second pixel in the blank map, wherein the second pixel is located in a pixel area corresponding to the mask map in the blank map, and the first pixel is one or more pixels in the mask map.
5. The method according to claim 3, characterized in that: The method further comprises: For a third pixel in the target map, determining a transparency range of the third pixel according to pixel data of pixels corresponding to the third pixel in pixel areas corresponding to the first mask map and the last mask map in the mask map sequence on the second image channel; the third pixel is one of the pixels in the target map; Determine a mapping relationship between a distance range where the distance information of the directed distance field merge map is located and a transparency range of the third pixel; For the target mask map that is located between the first mask map and the last mask map in time sequence, the transparency of the fourth pixel in the target mask map corresponding to the third pixel position is determined according to the distance threshold corresponding to the target mask map and the mapping relationship.
6. The method according to claim 2, characterized in that The first image channel and the second image channel are different color channels.
7. The method according to claim 1, characterized in that The step of outputting the distance information of the directed distance field merged map through the first image channel of the blank map comprises: For the fifth pixel in the directed distance field merged map, the distance information of the fifth pixel is output through the first image channel of the sixth pixel in the blank map, wherein the sixth pixel is a pixel in the blank map corresponding to the position of the fifth pixel, and the fifth pixel is one of the pixels in the directed distance field merged map.
8. The method according to claim 1, characterized in that The step of splitting the target map based on the multiple distance thresholds to obtain a target mask map corresponding to each distance threshold comprises: Based on the distance information represented by the first image channel of the target map and one of the distance thresholds, the target map is converted into a binary image to obtain a target mask map corresponding to one of the distance thresholds.
9. A data processing device, characterized in that: The device comprises: A sequence frame acquisition module, used to acquire a mask map sequence; the mask map sequence includes a plurality of mask maps; A texture merging module, used for generating a corresponding signed distance field texture for the mask texture, and merging the signed distance field textures to obtain a signed distance field merged texture; A blank map construction module, used to construct a blank map according to the pixel resolution of the directed distance field merge map; A target map generation module, used for outputting the distance information of the directed distance field merge map through the first image channel of the blank map to generate a target map; A threshold determination module, used to determine a plurality of distance thresholds within a distance range where the distance information of the directed distance field merge map is located; the distance range is a range consisting of a minimum value and a maximum value of all distance information of the directed distance field merge map; The texture splitting module is used to split the target texture based on the multiple distance thresholds respectively to obtain the target mask texture corresponding to each distance threshold.
10. An electronic device, characterized in that: include: A processor, a memory, and computer program instructions stored on the memory and executable on the processor; When the processor executes the computer program instructions, the data processing method according to any one of claims 1 to 8 is implemented.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, they are used to implement the data processing method as described in any one of claims 1 to 8 above.