Image processing method, processing device, electronic device and readable storage medium

By obtaining and updating mask information and using shaders to express Mask functions, the problem of large overhead of drawing Mask components in the Unity engine is solved and the program run efficiency is improved.

CN114445521BActive Publication Date: 2024-11-08BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210121268.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-09
Publication Date
2024-11-08
Estimated Expiration
2042-02-09

AI Technical Summary

Technical Problem

In the Unity engine, the drawing overhead of Mask components is high, resulting in a reduced program operation efficiency.

Method used

By obtaining the mask information of the target image, determining the mask value of the object to be drawn, and updating the processing information based on the mask value, using the shader to express the Mask function, reducing logical judgments, and reducing the time complexity of Mask drawing.

Benefits of technology

It effectively reduces the overhead of Mask drawing, improves the operation efficiency of the program, simplifies the logical judgment of the drawing object itself or Mask, and reduces the computational complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114445521B_ABST
    Figure CN114445521B_ABST
Patent Text Reader

Abstract

The present application discloses an image processing method, a processing device, an electronic device and a readable storage medium. The image processing method comprises: obtaining mask information of a target image, wherein the target image comprises a plurality of objects to be drawn, and the mask information comprises: the allowed mask state of the object to be drawn, and the carrying information of the mask component associated with the object to be drawn; determining the mask value corresponding to each object to be drawn according to the mask information, wherein the mask value is used to indicate drawing the object to be drawn or drawing the mask component; updating the processing information of the target image according to the mask value, and processing the target image based on the processing information. The embodiment of the present application classifies the mask of the object based on whether the object to be drawn carries the Mask component and the switch state of the Maskable of the object to be drawn, thereby reducing the time complexity of the Mask drawing overhead and improving the running efficiency of the program.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the technical field of electronic equipment, and specifically relates to an image processing method, a processing device, an electronic device and a readable storage medium. Background Art

[0002] In the related technology, there is a Mask component in UGUI (Unity Graphical User Interface, a graphical user interface provided by the Unity engine), and objects with the Mask component need to perform mask drawing and mask clearing operations respectively, resulting in high mask drawing overhead and dragging down the program's running efficiency. Summary of the invention

[0003] The purpose of the embodiments of the present application is to provide an image processing method, a processing device, an electronic device and a readable storage medium, which can reduce the overhead of Mask drawing and thus improve the program running efficiency.

[0004] In a first aspect, an embodiment of the present application provides an image processing method, comprising: obtaining mask information of a target image, wherein the target image includes multiple objects to be drawn, and the mask information includes: the allowed mask state of the object to be drawn, and the carrying information of the mask component associated with the object to be drawn; determining a mask value corresponding to each object to be drawn according to the mask information, wherein the mask value is used to indicate drawing the object to be drawn or drawing the mask component; updating processing information of the target image according to the mask value, and processing the target image based on the processing information.

[0005] In a second aspect, an embodiment of the present application provides an image processing device, comprising: an acquisition module, for acquiring mask information of a target image, wherein the target image includes multiple objects to be drawn, and the mask information includes: the allowed mask status of the objects to be drawn, and the carrying information of the mask components associated with the objects to be drawn; a calculation module, for determining, according to the mask information, a mask value corresponding to each object to be drawn, wherein the mask value is used to indicate the drawing of the object to be drawn or the drawing of the mask component; an update module, for updating the processing information of the target image according to the mask value; and a drawing module, for processing the target image based on the processing information.

[0006] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method of the first aspect.

[0007] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method of the first aspect are implemented.

[0008] In a fifth aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the steps of the method of the first aspect.

[0009] In the embodiment of the present application, when drawing the mask of the target image, first, the mask information of the target image is obtained. The target image includes multiple objects to be drawn, and each object to be drawn can be one or more primitives or one or more pixels.

[0010] The mask information includes the information carried by the mask component associated with each object to be drawn, specifically including whether the current object to be drawn carries a mask component. The mask information also includes the masking status of the current object to be drawn, that is, the switch status of Maskable.

[0011] According to the mask information, the mask value of the object to be drawn is confirmed, so as to calculate and update the mask array (MaskArray) of the target image. According to the updated mask array, the target image and the mask of the target image are processed, and finally the drawing of the target image and the mask of the target image is completed.

[0012] The embodiment of the present application classifies the mask of the object based on whether the object to be drawn carries a Mask component and the on / off state of the Maskable of the object to be drawn. Therefore, in a drawing process, the carrying state of the Mask component and the on / off state of the Maskable are judged at the same time, thereby effectively reducing the logical judgment during Mask drawing. Therefore, the Mask function can be expressed by a shader, which effectively reduces the time complexity of the Mask drawing overhead and improves the running efficiency of the program. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 A flowchart of an image processing method according to an embodiment of the present application is shown;

[0014] Figure 2 A structural block diagram of an image processing device according to an embodiment of the present application is shown;

[0015] Figure 3 A structural block diagram of an electronic device according to an embodiment of the present application is shown;

[0016] Figure 4 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application. DETAILED DESCRIPTION

[0017] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.

[0018] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0019] The image processing method, processing device, electronic device and readable storage medium provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.

[0020] In some embodiments of the present application, a method for processing an image is provided. Figure 1 A flow chart of an image processing method according to an embodiment of the present application is shown. Figure 1 As shown, the method includes:

[0021] Step 102, obtaining mask information of the target image;

[0022] In step 102, the target image includes a plurality of objects to be drawn, and the mask information includes: the mask-allowed state of the objects to be drawn, and the carrying information of the mask components associated with the objects to be drawn;

[0023] Step 104, determining a mask value corresponding to each object to be drawn according to the mask information;

[0024] In step 104, the mask value is used to indicate drawing of the object to be drawn or drawing of the mask component;

[0025] Step 106: update the processing information of the target image according to the mask value, and process the target image based on the processing information.

[0026] In the embodiment of the present application, when drawing the mask of the target image, first, the mask information of the target image is obtained. The target image includes multiple objects to be drawn, and each object to be drawn can be one or more primitives or one or more pixels.

[0027] The mask information includes the information carried by the mask component associated with each object to be drawn, specifically including whether the current object to be drawn carries a mask component. The mask information also includes the masking status of the current object to be drawn, that is, the switch status of Maskable.

[0028] According to the mask information, the mask value of the object to be drawn is confirmed, so as to calculate and update the processing information of the target image, and according to the updated processing information, the target image and the mask of the target image are processed, and finally the drawing of the target image and the mask of the target image is completed.

[0029] The mask value can indicate the position of the object to be drawn, specifically whether to draw the object to be drawn or to draw the mask component. If the object to be drawn is drawn, the object to be drawn will not be blocked by the Mask, and if the mask is drawn, the object to be drawn will be blocked by the Mask.

[0030] The embodiment of the present application classifies the mask of the object based on whether the object to be drawn carries a Mask component and the on / off state of the Maskable of the object to be drawn. Therefore, in a drawing process, the carrying state of the Mask component and the on / off state of the Maskable are judged at the same time, thereby effectively reducing the logical judgment during Mask drawing. Therefore, the Mask function can be expressed by a shader, which effectively reduces the time complexity of the Mask drawing overhead and improves the running efficiency of the program.

[0031] In some embodiments of the present application, before determining the mask value corresponding to each object to be drawn, the method also includes: obtaining a first test result corresponding to a first object to be drawn, wherein the multiple objects to be drawn include the first object to be drawn; wherein, when the first test result is passed, the target image includes the first object to be drawn or a first mask component corresponding to the first object to be drawn.

[0032] In the embodiment of the present application, when calculating the mask occlusion of the texture, the transparency calculation of the texture is also considered. Specifically, the first test corresponding to the object to be drawn is performed, and the first test is the alpha test (AlphaTest). AlphaTest is specifically a transparency test. According to the test result of AlphaTest, it can reflect whether a specific object is transparent, so that the specified object and its pixel block can be removed. In the embodiment of the present application, the result Ci of AlphaTest represents whether the corresponding first object to be drawn is clipped.

[0033] When the result of the alpha test passes, it indicates that the first object to be drawn has not been cropped. In this case, depending on whether the first object to be drawn carries a Mask component and whether it is blocked, the corresponding final drawn target image includes the first object to be drawn or the first mask component corresponding to the first object to be drawn.

[0034] When the result of the alpha test (AlphaTest) fails, it means that the first object to be drawn has been cut off. At this time, the first object to be drawn or the first mask component will not be drawn, thereby saving overhead.

[0035] In some embodiments of the present application, determining a mask value corresponding to each object to be drawn according to the mask information includes:

[0036] According to the allowed mask state and the carried information, the mask generation information of the object to be drawn and the mask information of the object to be drawn are determined, wherein the mask generation information is used to indicate whether a mask is generated for the object to be drawn, and the mask information is used to indicate the color of the object to be drawn or the mask component; according to the mask generation information, the mask information and the preset rules, the mask value is determined.

[0037] In an embodiment of the present application, when determining the mask value of the object to be drawn, first, based on the allowed mask state of the object to be drawn (the switch state of Maskable) and the carried information (whether the Mask component is carried), the mask generation information (GenerateMask) of the object to be drawn and the mask information (parentMask) of the object to be drawn are determined.

[0038] Specifically, when the mask generation information GenerateMask=true, a mask is generated, and the mask information parentMask is used to point to the color of the final pixel.

[0039] For example, when object A is not masked and object A itself is drawn, GenerateMask=true, and parentMask points to object A itself. When object A is masked, a mask that masks object A is drawn. At this time, depending on whether object A carries a Mask component, GenerateMask=true / false is set. At this time, parentMask points to the parent node, that is, the final drawn color is determined based on the Mask information of the parent node.

[0040] After the mask generation information and the mask information are determined, the mask value of the object to be drawn is calculated according to a preset rule, and finally the drawing method of the corresponding object to be drawn is processed according to the mask value.

[0041] In some embodiments of the present application, the mask generation information of the object to be drawn and the mask information of the object to be drawn are determined according to the allowed mask state and the carried information, including:

[0042] When the masking state is allowed to be non-maskable, the mask generation information is not to generate a mask, and the mask information points to the object to be drawn itself;

[0043] When the mask-allowed state is maskable and the carried information is a carried mask component, the mask generation information is a generated mask, and the mask information points to the parent node of the object to be drawn;

[0044] When the masking state is allowed to be maskable, and the carried information is that no mask component is carried, the mask information is that no mask is generated, and the mask information points to the parent node of the object to be drawn.

[0045] In the embodiment of the present application, whether to draw the object to be drawn itself is divided into the following three cases based on whether Maskable is turned on and whether the Mask component is carried:

[0046] 1. Turn on the Maskable switch and do not carry the Mask component. At this time, the object to be drawn will be blocked by the Mask of the parent node, but no new Mask will be generated;

[0047] 2. Turn on the Maskable switch and carry the Mask component. At this time, the object to be drawn will be blocked by the Mask of the parent node, and a new Mask will be generated. The new Mask will affect the child nodes;

[0048] 3. Turn off the Maskable switch. At this time, the object to be drawn cannot be blocked and has nothing to do with the Mask.

[0049] Therefore, the following logic exists:

[0050] When the object to be drawn turns on Maskable, only when the value of (PassAlphaTest==true||GenerateMask==true)&&ParentAllowPassMask==true is true (true), whether the current self-object to be drawn is allowed to pass the test is set to true, and the object to be drawn itself is drawn. When the object to be drawn turns off Maskable, it draws itself when the value of PassAlphaTest==true is true.

[0051] Among them, when the object to be drawn turns off Maskable, GenerateMask can be set to False, and Parent can be pointed to the object to be drawn itself, and ParentAllowPassMask can be initialized to 1. Since the ParentAllowPassMask item will not be updated until the above (PassAlphaTest==true||GenerateMask==true)&&ParentAllowPassMask==true operation is completed, this means that when the object to be drawn turns off Maskable, GenerateMask==true and ParentAllowPassMask must be true.

[0052] In summary, when the mask state is allowed to be non-maskable, that is, Maskable is turned off, the mask generation information is not to generate a mask, that is, GenerateMask is set to False, and the board information points to the object to be drawn itself, that is, parent points to itself.

[0053] When the mask state is allowed to be maskable, that is, Maskable is turned on, it is determined whether to generate a mask (GenerateMask == true / false) based on whether a mask component (Mask component) is carried, and parent is pointed to its parent node.

[0054] After completing the above calculations, you only need to update the obtained Mask to its corresponding ParentAllowPassMask and multiply the obtained color by the Mask.

[0055] The embodiment of the present application simplifies the logic of judging whether to draw the object itself or to draw the Mask, thereby reducing the time complexity of the Mask drawing overhead from 2n to n, and can correctly express the Mask function through the Shader, effectively reducing the time complexity of the Mask drawing overhead and improving the running efficiency of the program.

[0056] In some embodiments of the present application, the preset rules include: determining a target vector based on a first vector composed of a first test result and a second vector composed of mask information; and determining a mask value based on the target vector and the mask information.

[0057] In the embodiment of the present application, the preset rule can be embodied as the following formula:

[0058] Mask=dot(float3(PassTest, 1, PassTest), float3(1, generateMask, -generateMask))×parentMask;

[0059] Among them, Mask is the mask value, PassTest is the first test result, generateMask is the mask information, and parentMask is the mask information.

[0060] By setting preset rules, the logical operations in the above embodiments are algebraized, thereby improving the compatibility during operations.

[0061] Specifically, the AND operation in the logic operation can be equivalent to an algebraic operation with 0 as the zero element and 1 as the unit element, and the OR operation can be equivalent to an algebraic operation with 1 as the zero element and 0 as the unit element. Therefore, the AND operation can be replaced by multiplication.

[0062] As for the OR operation, it is known through research that the binary operation a+ba×b satisfies the operation rule of taking 1 as the zero element and 0 as the identity element. Therefore, the OR operation can be algebraically transformed into the following formula:

[0063] a||b=dot((a,1,a),(1,b,-b)).

[0064] Therefore, you can convert:

[0065] "When the masking state is allowed to be non-maskable, the mask generation information is to generate a mask, and the mask information points to the object to be drawn itself;

[0066] When the mask-allowed state is maskable and the carried information is a carried mask component, the mask generation information is a generated mask, and the mask information points to the parent node of the object to be drawn;

[0067] In the case where the mask state is allowed to be maskable, and the carried information is not a mask component, the mask information is not to generate a mask, and the mask information points to the parent node of the object to be drawn, the following formula is used for algebraic operation:

[0068] Mask=dot(float3(PassAlphaTest, 1, PassAlphaTest), float3(1, generateMask, -generateMask))×parentMask;

[0069] Among them, Mask is the mask value, the first test is used to test transparency, here the alpha test is the first test, then PassAlphaTest is the alpha test result, generateMask is the mask information, and parentMask is the mask information.

[0070] The embodiment of the present application can effectively avoid compatibility issues and branch statement problems by converting logical operations into equivalent algebraic operations, and can effectively improve operation compatibility. At the same time, it can reduce the time complexity of the Mask drawing overhead and improve the running efficiency of the program.

[0071] In some embodiments of the present application, the processing information includes a mask array; before updating the processing information of the target image, the method further includes: generating the mask array, and initializing the value of the mask array to 1.

[0072] In an embodiment of the present application, the processing information specifically includes a mask array (MaskArray). When performing occlusion calculations on Masks between multiple textures, first, the parent node index of each texture and whether the current texture needs to generate a Mask are input from the outside world. If the current texture neither generates a Mask nor is Masked by other textures, the parent node index is pointed to itself.

[0073] Furthermore, an initial mask array MaskArray is generated, and all mask values ​​are initialized to 1. After the initial mask array is generated, the mask value of the object to be drawn is confirmed according to the mask information, so that the mask array (MaskArray) of the target image is calculated and updated, and the target image and the mask of the target image are processed according to the updated mask array, and finally the drawing of the target image and the mask of the target image is completed.

[0074] The mask array is expressed as:

[0075] MaskArray[i]=dot((Ci,1,Ci),(1,GenerateMask_i,-GenerateMask_i))×MaskArray[ParentIndex_i];

[0076] Among them, MaskArray[i] is the mask array i, C1 is the result of PassAlphaTest, GenerateMask_i is the mask information of the object i to be drawn, and ParentIndex_i is the parent node pointing to the mask information of the object i to be drawn.

[0077] In some embodiments of the present application, the processing method further includes: displaying the target image.

[0078] In an embodiment of the present application, after drawing the target image and the mask corresponding to the target image, the target image is displayed, wherein the target image expresses the Mask function through a shader, which effectively reduces the time complexity of the Mask drawing overhead and improves the running efficiency of the program.

[0079] In some embodiments of the present application, a device for processing an image is provided. Figure 2 A structural block diagram of an image processing device according to an embodiment of the present application is shown. Figure 2 As shown, the processing device 200 includes:

[0080] The acquisition module 202 acquires mask information of a target image, wherein the target image includes a plurality of objects to be drawn, and the mask information includes: a mask-allowed state of the objects to be drawn, and carrying information of mask components associated with the objects to be drawn;

[0081] The calculation module 204 determines the mask value corresponding to each object to be drawn according to the mask information, wherein the mask value is used to indicate drawing the object to be drawn or drawing the mask component;

[0082] An updating module 206, used for updating the processing information of the target image according to the mask value;

[0083] The rendering module 208 is used to process the target image based on the processing information.

[0084] In the embodiment of the present application, when drawing the mask of the target image, first, the mask information of the target image is obtained. The target image includes multiple objects to be drawn, and each object to be drawn can be one or more primitives or one or more pixels.

[0085] The mask information includes the information carried by the mask component associated with each object to be drawn, specifically including whether the current object to be drawn carries a mask component. The mask information also includes the masking status of the current object to be drawn, that is, the switch status of Maskable.

[0086] According to the mask information, the mask value of the object to be drawn is confirmed, so as to calculate and update the processing information (MaskArray) of the target image, and according to the updated processing information, the target image and the mask of the target image are processed, and finally the drawing of the target image and the mask of the target image is completed.

[0087] The mask value can indicate the position of the object to be drawn, specifically whether to draw the object to be drawn or to draw the mask component. If the object to be drawn is drawn, the object to be drawn will not be blocked by the Mask, and if the mask is drawn, the object to be drawn will be blocked by the Mask.

[0088] The embodiment of the present application classifies the mask of the object based on whether the object to be drawn carries a Mask component and the on / off state of the Maskable of the object to be drawn. Therefore, in a drawing process, the carrying state of the Mask component and the on / off state of the Maskable are judged at the same time, thereby effectively reducing the logical judgment during Mask drawing. Therefore, the Mask function can be expressed by a shader, which effectively reduces the time complexity of the Mask drawing overhead and improves the running efficiency of the program.

[0089] In some embodiments of the present application, the acquisition module is also used to obtain an alpha test result corresponding to a first object to be drawn, wherein the multiple objects to be drawn include the first object to be drawn; wherein, when the alpha test result is passed, the target image includes the first object to be drawn or a first mask component corresponding to the first object to be drawn.

[0090] In the embodiment of the present application, when calculating the mask occlusion of the texture, the transparency calculation of the texture is also considered. Specifically, the first test corresponding to the object to be drawn is performed, and the first test is the alpha test (AlphaTest). AlphaTest is specifically a transparency test. According to the test result of AlphaTest, it can reflect whether a specific object is transparent, so that the specified object and its pixel block can be removed. In the embodiment of the present application, the result Ci of AlphaTest represents whether the corresponding first object to be drawn is clipped.

[0091] When the result of the alpha test passes, it indicates that the first object to be drawn has not been cropped. In this case, depending on whether the first object to be drawn carries a Mask component and whether it is blocked, the corresponding final drawn target image includes the first object to be drawn or the first mask component corresponding to the first object to be drawn.

[0092] When the result of the alpha test (AlphaTest) fails, it means that the first object to be drawn has been cut off. At this time, the first object to be drawn or the first mask component will not be drawn, thereby saving overhead.

[0093] In some embodiments of the present application, the determination module is also used to determine the mask generation information of the object to be drawn and the mask information of the object to be drawn based on the allowed mask state and the carried information, wherein the mask generation information is used to indicate whether a mask is generated for the object to be drawn, and the mask information is used to indicate the color of the object to be drawn or the mask component; the mask value is determined based on the mask generation information, the mask information and preset rules.

[0094] In an embodiment of the present application, when determining the mask value of the object to be drawn, first, based on the allowed mask state of the object to be drawn (the switch state of Maskable) and the carried information (whether the Mask component is carried), the mask generation information (GenerateMask) of the object to be drawn and the mask information (parentMask) of the object to be drawn are determined.

[0095] After the mask generation information and the mask information are determined, the mask value of the object to be drawn is calculated according to a preset rule, and finally the drawing method of the corresponding object to be drawn is processed according to the mask value.

[0096] In some embodiments of the present application, the determination module is further configured to:

[0097] When the masking state is allowed to be non-maskable, the mask generation information is to generate a mask, and the mask information points to the object to be drawn itself;

[0098] When the mask-allowed state is maskable and the carried information is a carried mask component, the mask generation information is a generated mask, and the mask information points to the parent node of the object to be drawn;

[0099] When the masking state is allowed to be maskable, and the carried information is that no mask component is carried, the mask information is that no mask is generated, and the mask information points to the parent node of the object to be drawn.

[0100] In an embodiment of the present application, when the mask state is allowed to be non-maskable, that is, Maskable is turned off, the mask generation information is to generate a mask, that is, GenerateMask is set to true, and the board information points to the object to be drawn itself, that is, parent points to itself.

[0101] When the mask state is allowed to be maskable, that is, Maskable is turned on, it is determined whether to generate a mask (GenerateMask == true / false) based on whether a mask component (Mask component) is carried, and parent is pointed to its parent node.

[0102] After completing the above calculations, you only need to update the obtained Mask to its corresponding ParentAllowPassMask and multiply the obtained color by the Mask.

[0103] The embodiment of the present application simplifies the logic of judging whether to draw the object itself or to draw the Mask, thereby reducing the time complexity of the Mask drawing overhead from 2n to n, and can correctly express the Mask function through the Shader, effectively reducing the time complexity of the Mask drawing overhead and improving the running efficiency of the program.

[0104] In some embodiments of the present application, the preset rules include: determining a target vector based on a first vector composed of a first test result and a second vector composed of mask information; and determining a mask value based on the target vector and the mask information.

[0105] In the embodiment of the present application, the preset rule can be embodied as the following formula:

[0106] Mask=dot(float3(PassTest, 1, PassTest), float3(1, generateMask, -generateMask))×parentMask;

[0107] Among them, Mask is the mask value, PassTest is the first test result, generateMask is the mask information, and parentMask is the mask information.

[0108] By converting logical operations into equivalent algebraic operations, compatibility issues and branch statement problems can be effectively avoided, and operation compatibility can be effectively improved. At the same time, the time complexity of the Mask drawing overhead can be reduced, and the running efficiency of the program can be improved.

[0109] In some embodiments of the present application, the processing information includes a mask array; the processing device further includes: a generation module, configured to generate the mask array and initialize the value of the mask array to 1.

[0110] In an embodiment of the present application, the processing information specifically includes a mask array (MaskArray). When performing occlusion calculations on Masks between multiple textures, first, the parent node index of each texture and whether the current texture needs to generate a Mask are input from the outside world. If the current texture neither generates a Mask nor is Masked by other textures, the parent node index is pointed to itself.

[0111] Furthermore, an initial mask array MaskArray is generated, and all mask values ​​are initialized to 1. After the initial mask array is generated, the mask value of the object to be drawn is confirmed according to the mask information, so that the mask array (MaskArray) of the target image is calculated and updated, and the target image and the mask of the target image are processed according to the updated mask array, and finally the drawing of the target image and the mask of the target image is completed.

[0112] In some embodiments of the present application, the processing device further includes: a display module, configured to display the target image.

[0113] In an embodiment of the present application, after drawing the target image and the mask corresponding to the target image, the target image is displayed, wherein the target image expresses the Mask function through a shader, which effectively reduces the time complexity of the Mask drawing overhead and improves the running efficiency of the program.

[0114] The control device of the test device in the embodiment of the present application can be a device, or a component, an integrated circuit, or a chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a palmtop computer, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and the non-mobile electronic device can be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., and the embodiment of the present application is not specifically limited.

[0115] The control device of the test device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0116] The control device of the test device provided in the embodiment of the present application can implement each process implemented in the above method embodiment, and will not be described again here to avoid repetition.

[0117] Optionally, an embodiment of the present application further provides an electronic device, Figure 3 A structural block diagram of an electronic device according to an embodiment of the present application is shown. Figure 3 As shown, the electronic device 300 includes a processor 302, a memory 304, and a program or instruction stored in the memory 304 and executable on the processor 302. When the program or instruction is executed by the processor 302, each process of the above-mentioned method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0118] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.

[0119] Figure 4 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.

[0120] The electronic device 400 includes but is not limited to components such as a radio frequency unit 401 , a network module 402 , an audio output unit 403 , an input unit 404 , a sensor 405 , a display unit 406 , a user input unit 407 , an interface unit 408 , a memory 409 , and a processor 410 .

[0121] Those skilled in the art will appreciate that the electronic device 400 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 410 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 4 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.

[0122] The processor 410 is used to obtain mask information of a target image, wherein the target image includes a plurality of objects to be drawn, and the mask information includes: the mask-allowed state of the objects to be drawn, and the carrying information of the mask components associated with the objects to be drawn;

[0123] Determine a mask value corresponding to each object to be drawn according to the mask information, wherein the mask value is used to indicate drawing the object to be drawn or drawing a mask component;

[0124] According to the mask value, the processing information of the target image is updated, and the target image is processed based on the processing information.

[0125] The embodiment of the present application classifies the mask of the object based on whether the object to be drawn carries a Mask component and the on / off state of the Maskable of the object to be drawn. Therefore, in a drawing process, the carrying state of the Mask component and the on / off state of the Maskable are judged at the same time, thereby effectively reducing the logical judgment during Mask drawing. Therefore, the Mask function can be expressed by a shader, which effectively reduces the time complexity of the Mask drawing overhead and improves the running efficiency of the program.

[0126] Optionally, the processor 410 is further used to obtain a first test result corresponding to a first object to be drawn, wherein the multiple objects to be drawn include the first object to be drawn; wherein, when the first test result is passed, the target image includes the first object to be drawn or a first mask component corresponding to the first object to be drawn.

[0127] In the embodiment of the present application, when calculating the mask occlusion of the map, the transparency calculation of the map is also considered. Specifically, the corresponding alpha test (AlphaTest) result is performed on the object to be drawn, wherein the structure Ci of AlphaTest represents whether the corresponding first object to be drawn is clipped.

[0128] When the result of the alpha test passes, it indicates that the first object to be drawn has not been cropped. In this case, depending on whether the first object to be drawn carries a Mask component and whether it is blocked, the corresponding final drawn target image includes the first object to be drawn or the first mask component corresponding to the first object to be drawn.

[0129] When the result of the alpha test (AlphaTest) fails, it means that the first object to be drawn has been cut off. At this time, the first object to be drawn or the first mask component will not be drawn, thereby saving overhead.

[0130] Optionally, the processor 410 is also used to determine the mask generation information of the object to be drawn and the mask information of the object to be drawn based on the allowed mask state and the carried information, wherein the mask generation information is used to indicate whether a mask is generated for the object to be drawn, and the mask information is used to indicate the color of the object to be drawn or the mask component; the mask value is determined based on the mask generation information, the mask information and preset rules.

[0131] In an embodiment of the present application, when determining the mask value of the object to be drawn, first, based on the allowed mask state of the object to be drawn (the switch state of Maskable) and the carried information (whether the Mask component is carried), the mask generation information (GenerateMask) of the object to be drawn and the mask information (parentMask) of the object to be drawn are determined.

[0132] After the mask generation information and the mask information are determined, the mask value of the object to be drawn is calculated according to a preset rule, and finally the drawing method of the corresponding object to be drawn is processed according to the mask value.

[0133] Optionally, the processor 410 is further configured to, when the mask-allowed state is non-maskable, generate mask information indicating that a mask is not generated, and the mask information points to the object to be drawn itself;

[0134] When the mask-allowed state is maskable and the carried information is a carried mask component, the mask generation information is a generated mask, and the mask information points to the parent node of the object to be drawn;

[0135] When the masking state is allowed to be maskable, and the carried information is that no mask component is carried, the mask information is that no mask is generated, and the mask information points to the parent node of the object to be drawn.

[0136] The embodiment of the present application simplifies the logic of judging whether to draw the object itself or to draw the Mask, thereby reducing the time complexity of the Mask drawing overhead from 2n to n, and can correctly express the Mask function through the Shader, effectively reducing the time complexity of the Mask drawing overhead and improving the running efficiency of the program.

[0137] Optionally, the preset rules include:

[0138] Determine a target vector according to a first vector composed of the first test result and a second vector composed of the mask information;

[0139] The mask value is determined based on the target vector and the mask information.

[0140] The embodiment of the present application can effectively avoid compatibility issues and branch statement problems by converting logical operations into equivalent algebraic operations, and can effectively improve operation compatibility. At the same time, it can reduce the time complexity of the Mask drawing overhead and improve the running efficiency of the program.

[0141] Optionally, the processing information includes a mask array; the processor 410 is further configured to generate the mask array and initialize the value of the mask array to 1.

[0142] In an embodiment of the present application, when performing occlusion calculation on the Mask between multiple textures, first, the parent node index of each texture and whether the current texture needs to generate a Mask are input from the outside world. If the current texture neither generates a Mask nor is Masked by other textures, the parent node index is pointed to itself.

[0143] Furthermore, an initial mask array MaskArray is generated, and all mask values ​​are initialized to 1. After the initial mask array is generated, the mask value of the object to be drawn is confirmed according to the mask information, so that the mask array (MaskArray) of the target image is calculated and updated, and the target image and the mask of the target image are processed according to the updated mask array, and finally the drawing of the target image and the mask of the target image is completed.

[0144] Optionally, the processor 410 is further configured to display a target image.

[0145] In an embodiment of the present application, after drawing the target image and the mask corresponding to the target image, the target image is displayed, wherein the target image expresses the Mask function through a shader, which effectively reduces the time complexity of the Mask drawing overhead and improves the running efficiency of the program.

[0146] It should be understood that in an embodiment of the present application, the input unit 404 may include a graphics processor (GPU) 4041 and a microphone 4042, and the graphics processor 4041 processes image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode.

[0147] The display unit 406 may include a display panel 4061, which may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 407 includes a touch panel 4071 and other input devices 4072. The touch panel 4071 is also called a touch screen. The touch panel 4071 may include two parts: a touch detection device and a touch controller. Other input devices 4072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which are not repeated here. The memory 409 may be used to store software programs and various data, including but not limited to applications and operating systems. The processor 410 may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, and applications, etc., and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 410.

[0148] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0149] The processor is the processor in the electronic device in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0150] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0151] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0152] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes 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 one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0153] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of each embodiment of the present application.

[0154] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A method for processing an image, characterized in that: include: Obtaining mask information of a target image, wherein the target image includes a plurality of objects to be drawn, and the mask information includes: a mask-allowed state of the objects to be drawn, and carrying information of mask components associated with the objects to be drawn; Determine a mask value corresponding to each object to be drawn according to the mask information, wherein the mask value is used to indicate drawing the object to be drawn or drawing the mask component; updating processing information of the target image according to the mask value, and processing the target image based on the processing information; Before determining the mask value corresponding to each object to be drawn, the method further includes: Obtaining a first test result corresponding to a first object to be drawn, wherein the plurality of objects to be drawn include the first object to be drawn; Wherein, when the first test result is passed, the target image includes the first object to be drawn or a first mask component corresponding to the first object to be drawn; Determining the mask value corresponding to each object to be drawn according to the mask information includes: Determining mask generation information of the object to be drawn and mask information of the object to be drawn according to the mask-allowed state and the carried information, wherein the mask generation information is used to indicate whether to generate a mask for the object to be drawn, and the mask information is used to indicate the color of the object to be drawn or the mask component; Determining the mask value according to the mask generation information, the mask information and a preset rule; The step of determining the mask generation information of the object to be drawn and the mask information of the object to be drawn according to the mask-allowed state and the carried information includes: When the mask-allowed state is not maskable, the mask generation information indicates not to generate a mask, and the mask information points to the object to be drawn itself; When the mask-allowed state is maskable and the carried information is a carried mask component, the mask generation information is a generated mask, and the mask information points to the parent node of the object to be drawn; When the mask-allowed state is maskable and the carried information is not to carry a mask component, the mask information is not to generate a mask, and the mask information points to the parent node of the object to be drawn; The processing information includes a mask array.

2. The processing method according to claim 1, characterized in that: The preset rules include: Determine a target vector according to a first vector composed of the first test result and a second vector composed of the mask information; The mask value is determined based on the target vector and the mask information.

3. The processing method according to claim 1 or 2, characterized in that: Before updating the processing information of the target image, the method further includes: Generate the mask array and initialize the value of the mask array to 1.

4. The processing method according to claim 1 or 2, characterized in that: Also includes: The target image is displayed.

5. An image processing device, characterized in that: include: An acquisition module is configured to acquire mask information of a target image, wherein the target image includes a plurality of objects to be drawn, and the mask information includes: a mask-allowed state of the objects to be drawn, and carrying information of mask components associated with the objects to be drawn; A calculation module, which determines a mask value corresponding to each object to be drawn according to the mask information, wherein the mask value is used to indicate drawing the object to be drawn or drawing the mask component; An updating module, used for updating the processing information of the target image according to the mask value; A drawing module, used for processing the target image based on the processing information; The acquisition module is further used to acquire a first test result corresponding to a first object to be drawn, wherein the plurality of objects to be drawn include the first object to be drawn; Wherein, when the first test result is passed, the target image includes the first object to be drawn or a first mask component corresponding to the first object to be drawn; The determination module is further used to determine the mask generation information of the object to be drawn and the mask information of the object to be drawn according to the mask-allowed state and the carried information, wherein the mask generation information is used to indicate whether to generate a mask for the object to be drawn, and the mask information is used to indicate the color of the object to be drawn or the mask component; Determining the mask value according to the mask generation information, the mask information and a preset rule; The determining module is also used for: When the mask-allowed state is not maskable, the mask generation information indicates not to generate a mask, and the mask information points to the object to be drawn itself; When the mask-allowed state is maskable and the carried information is a carried mask component, the mask generation information is a generated mask, and the mask information points to the parent node of the object to be drawn; When the mask-allowed state is maskable and the carried information is not to carry a mask component, the mask information is not to generate a mask, and the mask information points to the parent node of the object to be drawn; The processing information includes a mask array.

6. An electronic device, characterized in that: The method comprises a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the processing method according to any one of claims 1 to 4.

7. A readable storage medium, characterized in that: The readable storage medium stores a program or an instruction, and when the program or the instruction is executed by the processor, the steps of the processing method according to any one of claims 1 to 4 are implemented.