Image processing method and device, equipment, medium and product
By determining the distance from image pixels to the boundary of the target object and setting a preset color in two-dimensional space, an image with a shadow effect is generated. This solves the problems of complex and inefficient shadow generation in existing technologies, achieves fast and convenient shadow effect presentation, and improves the image processing experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING ZITIAO NETWORK TECH CO LTD
- Filing Date
- 2024-10-30
- Publication Date
- 2026-05-01
AI Technical Summary
Existing technologies for adding shadow effects in image processing suffer from problems such as complex shadow generation, low efficiency, and large memory consumption, making it difficult to achieve fast and convenient shadow effect rendering.
By determining the target distance value from the image pixel to the boundary of the target object in two-dimensional space, and determining the shadow pixel value according to the preset color, a target image containing shadow effect is generated, and the shadow effect is simulated by a directed distance field function.
It simplifies the image processing workflow, reduces the complexity of shadow generation, saves memory and computing power, improves the image processing experience, and enriches the image display effect.
Smart Images

Figure CN121962402A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer processing technology, and more particularly to an image processing method, apparatus, device, medium, and product. Background Technology
[0002] In some image processing scenarios, in order to make the image present a more realistic light and shadow effect, a shadow effect is added to the image to simulate the shadow of the object in the image when the light shines on it.
[0003] In related technologies, there are two ways to add shadow effects to images. One is to use a shadow camera set up in a 3D rendering space and a real-time lighting algorithm to add shadows to objects in the image. However, this real-time rendering method is relatively complex to implement, requires a lot of 3D spatial calculations, is prone to shadow effect rendering delays, and produces very sharp shadow edges. It is also difficult to transition naturally from shadow color to lighting color, resulting in poor shadow rendering effects and low shadow generation efficiency. The other method is to pre-generate shadow animation sequence frames through an offline rendering application and then present shadows in the image by playing the shadow animation sequence frames. However, this offline rendering method requires more memory space. Summary of the Invention
[0004] This disclosure provides an image processing method, apparatus, device, medium, and product to achieve the effect of quickly and conveniently displaying the object shadow of a target object in an image to be processed.
[0005] In a first aspect, embodiments of this disclosure provide an image processing method, the method comprising:
[0006] In response to an image processing request, an image to be processed is acquired, wherein the image to be processed includes a target object;
[0007] Determine the target distance values from multiple image pixels in the image to the object boundary of the target object, and determine the target pixel corresponding to the target object among the multiple image pixels based on the target distance values;
[0008] The shadow pixel value of the target object at the target pixel is determined according to the preset color, the target image is determined according to the shadow pixel value corresponding to the target pixel, and the target image is displayed.
[0009] Secondly, embodiments of this disclosure also provide an image processing apparatus, the apparatus comprising:
[0010] An image processing request module is used to obtain an image to be processed in response to an image processing request, wherein the image to be processed includes a target object;
[0011] The target pixel determination module is used to determine the target distance value from multiple image pixels in the image to the object boundary of the target object, and to determine the target pixel corresponding to the target object among the multiple image pixels based on the target distance value;
[0012] The target image display module is used to determine the shadow pixel value of the target object at the target pixel point based on a preset color, determine the target image based on the shadow pixel value corresponding to the target pixel point, and display the target image.
[0013] Thirdly, embodiments of this disclosure also provide an electronic device, the electronic device comprising:
[0014] One or more processors;
[0015] Storage device for storing one or more programs.
[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the image processing method as described in any of the embodiments of this disclosure.
[0017] Fourthly, embodiments of this disclosure also provide a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform the image processing method as described in any of the embodiments of this disclosure.
[0018] Fifthly, embodiments of this disclosure also provide a computer program product, including a computer program that, when executed by a processor, implements the image processing method as described in any of the embodiments of this disclosure.
[0019] The technical solution of this disclosure, in response to an image processing request, acquires an image to be processed including a target object. Upon receiving the image processing request, it automatically enters the image processing flow and acquires the image to be processed. Then, by determining the target distance values from multiple image pixels in the image to be processed to the object boundary of the target object, and based on these target distance values, it determines the target pixel corresponding to the target object among the multiple image pixels. This method only requires determining the target distance values between the image pixels and the object boundary of the target object in two-dimensional space to identify the target pixels in the image to be processed that require the addition of a shadow effect. This allows for a simple, fast, and accurate determination of the target pixel. The process involves marking pixels; finally, determining the shadow pixel value of the target object at the target pixel based on a preset color, determining the target image based on the shadow pixel value corresponding to the target pixel, and displaying the target image. This supports flexibly setting shadow effects at the target pixel, generating a target image containing shadow effects, enriching the image display effect, and solving the technical problems of complex shadow effect generation methods, large memory space consumption, and low shadow generation efficiency in related technologies. It reduces the complexity of shadow generation for target objects, saves memory and computing power, expands the scope of application, simplifies the image processing process, and improves the image processing experience. Attached Figure Description
[0020] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.
[0021] Figure 1 This is a schematic flowchart of an image processing method provided in an embodiment of the present disclosure;
[0022] Figure 2 A schematic flowchart of another image processing method provided in an embodiment of this disclosure;
[0023] Figure 3 This is a schematic diagram of the structure of an image processing apparatus provided in an embodiment of the present disclosure;
[0024] Figure 4 This is a schematic diagram of the structure of an electronic device for implementing an embodiment of the present disclosure. Detailed Implementation
[0025] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0026] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.
[0027] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.
[0028] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0029] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0030] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0031] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.
[0032] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the software or hardware, such as the electronic device, application, server, or storage medium performing the operations of this disclosed technical solution, based on the prompt message.
[0033] As an optional but non-limiting implementation, in response to a user's active request, sending a prompt message to the user can be done via a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0034] It is understood that the above notification and user authorization process are merely illustrative and do not constitute a limitation on the implementation of this disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of this disclosure.
[0035] It is understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and related provisions.
[0036] Figure 1 This is a flowchart illustrating an image processing method provided in an embodiment of the present disclosure. This embodiment is applicable to scenarios where shadow effects are added to objects in an image. The method can be executed by an image processing device, which can be implemented in software and / or hardware, optionally through an electronic device, such as a mobile terminal, PC, or server. Figure 1 As shown, the method in this embodiment may specifically include:
[0037] S110. In response to an image processing request, obtain an image to be processed, wherein the image to be processed includes a target object.
[0038] In this embodiment of the disclosure, the image processing request is used to request the commencement of an operation to process the image to be processed. The image to be processed can be understood as an image to which a shadow effect is to be added. The image processing request can be generated in various ways. Exemplarily, the image processing request can be triggered by at least one of the following methods: triggered by a control trigger operation targeting a preset image processing control; generated when the image to be processed meets preset shadow addition conditions; generated when a preset trigger event is detected; generated when the image display time meets a preset shadow addition time, etc. The shadow addition conditions may include, but are not limited to, the image to be processed including image content of a preset type. The target object can be understood as an object to which a shadow effect needs to be added. Specifically, the target object can be an object of a preset type in the image to be processed. The target object can be one or more objects in the image to be processed. Exemplarily, the target image can be one or more of the following in the image to be processed: a book, a person, a plant, and a building. The target object can also be an object in the image to be processed with a preset shape.
[0039] Optionally, the image to be processed can be at least one of the following: an image uploaded based on an image upload control, an image captured based on an image capture control, or an image transmitted by a target application or target interface. The image to be processed can also be at least one of the following: an image after processing an uploaded image, an image after processing a captured image, or an image after processing a received transmitted image. It should be noted that the image processing method can be based on a preset image processing flow, or on processing the image according to a received image processing operation, etc. The image processing flow can include at least one image processing method. When the image processing flow includes multiple image processing methods, the multiple image processing methods can be combined according to a preset processing logic.
[0040] As an optional technical solution in an embodiment of this disclosure, obtaining an image to be processed in response to an image processing request may include: obtaining a set original image in response to an image setting operation; and determining an image to be processed based on the original image in response to a processing trigger operation for the original image.
[0041] S120. Determine the target distance value from multiple image pixels in the image to be processed to the object boundary of the target object, and determine the target pixel corresponding to the target object among the multiple image pixels based on the target distance value.
[0042] The object boundary of the target object can be understood as the display boundary between the target object and other objects in the image to be processed. In other words, the object boundary of the target object can be the boundary of the display area of the target object in the image to be processed.
[0043] Specifically, the target distance values from multiple image pixels to the object boundary of the target object can be: the target distance values from image pixels located outside the object boundary of the target object in the image to be processed to the object boundary; or the target distance value from each image pixel in the image to the object boundary. The target distance values corresponding to pixels located inside the object boundary can be set to a preset value or have the opposite sign to the target distance values corresponding to image pixels located outside the object boundary of the target object. For example, the target distance values corresponding to pixels located inside the object boundary can be set to negative numbers, and the target distance values corresponding to image pixels located outside the object boundary of the target object can be set to positive numbers.
[0044] As an optional implementation of this disclosure, the target pixel corresponding to the target object among a plurality of image pixels is determined based on the target distance value. Specifically, the target pixel corresponding to the target object among a plurality of image pixels can be determined based on the target distance value and a preset distance range. More specifically, the image pixels corresponding to the target distance value that are within the preset distance range can be determined as the target pixels corresponding to the target object. In other words, when the target distance value is within the preset distance range, the image pixels corresponding to the target distance value are obtained as the target pixels in the image to be processed. The target pixels can be understood as image pixels in the image to be processed that require the addition of a shadow effect corresponding to the target object.
[0045] S130. Determine the shadow pixel value of the target object at the target pixel point according to the preset color, determine the target image according to the shadow pixel value corresponding to the target pixel point, and display the target image.
[0046] The preset color can be understood as a pre-set base color for presentation in the shadow area. The shadow pixel value can be obtained by adjusting the preset color. The shadow pixel value can be understood as the color value of the target pixel displayed in the target image.
[0047] Optionally, determining the shadow pixel value of the target object acting on the target pixel based on a preset color includes: for each target pixel, determining the shadow pixel value of the target object acting on the target pixel based on the preset color of the target pixel and the display color value of the target pixel in the image to be processed. Specifically, the preset color of the target pixel and the display color value of the target pixel in the image to be processed can be fused using a preset fusion method to obtain the shadow pixel value of the target object acting on the target pixel. The preset fusion method may include, but is not limited to, multiplication, weighted multiplication, summation, or weighted summation. Using this technical solution, the shadow effect of the target pixel in the target image can be made more closely match the original display effect of the image to be processed, making the shadow effect in the target image more realistic, thereby improving the display effect of the target image.
[0048] As an optional technical solution in this disclosure, more specifically, a shadow weighting value can be determined based on the target distance value corresponding to the target pixel, and the shadow pixel value of the target object acting on the target pixel can be determined based on the display pixel value of the target pixel in the image to be processed, a preset color, and the shadow weighting value. By associating the shadow pixel value corresponding to the target pixel with the target distance value corresponding to the target pixel, the shadow effect of the target object can be displayed in a more layered manner.
[0049] The display color value of the target pixel in the image to be processed can be understood as the color value displayed by the target pixel in the image to be processed, that is, the color value displayed by the target pixel in the image to be processed before adding the shadow effect. The magnitude of the shadow weighting value corresponds to the depth of the shadow presented by the target pixel. When the shadow value corresponding to the target pixel is one, the color presented by the target pixel in the target image (i.e., the shadow pixel value) is a preset color; when the shadow value corresponding to the target pixel is zero, the color presented by the target pixel in the target image (i.e., the shadow pixel value) is the display color of the target pixel in the image to be processed, that is, the original color presented by the target pixel.
[0050] Optionally, determining the shadow weighting value based on the target distance value corresponding to the target pixel specifically includes: determining the shadow weighting value based on the target distance value and a distance boundary value corresponding to the target pixel. The distance boundary value can be a pre-set distance value used to control the transition range of the shadow. The larger the distance boundary value, the larger the transition range of the shadow. As an optional implementation of this disclosure, determining the shadow weighting value based on the target distance value and the distance boundary value corresponding to the target pixel may include: using the ratio of the difference between the distance boundary value and the target distance value to the distance boundary value as the shadow weighting value.
[0051] As an optional technical solution of this disclosure, after determining the shadow pixel value of the target object acting on the target pixel point according to the preset color, the method further includes: when the image to be processed includes multiple target objects and there exists a single target pixel point corresponding to multiple target objects, for the target pixel point corresponding to multiple target objects, determining the maximum value among the shadow pixel values of the multiple target objects acting on the target pixel point as the shadow pixel value corresponding to the target pixel point; or, when the image to be processed includes multiple target objects and there exists a single target pixel point corresponding to multiple target objects, for the target pixel point corresponding to multiple target objects, determining the sum of the shadow pixel values of the target objects acting on the target pixel point as the shadow pixel value corresponding to the target pixel point.
[0052] In this context, the same target pixel corresponding to multiple target objects can be understood as the shadow regions corresponding to multiple target objects overlapping. In other words, there are duplicate image pixels among the target pixels corresponding to multiple target objects. The target pixels corresponding to multiple target objects are, i.e., duplicate pixels among the target pixels corresponding to multiple target objects. In this case, the duplicate pixel will have multiple shadow pixel values determined according to different target objects. The shadow pixel value presented by the duplicate pixel in the target image can be the maximum value among the multiple shadow pixel values corresponding to the duplicate pixel, or the sum of the multiple shadow pixel values.
[0053] For example, taking the target pixel in the overlapping shadow area of multiple pages as an example, the shadow pixel value of each page acting on the target pixel can be calculated separately, and the maximum value of the multiple shadow pixel values can be taken as the final shadow pixel value of the target pixel.
[0054] This technical solution supports adding shadow effects to multiple target objects in the image to be processed. In particular, when multiple target objects overlap, it can present the effect of overlapping shadow areas of multiple target objects.
[0055] The technical solution of this disclosure, in response to an image processing request, acquires an image to be processed including a target object. Upon receiving the image processing request, it automatically enters the image processing flow and acquires the image to be processed. Then, by determining the target distance values from multiple image pixels in the image to be processed to the object boundary of the target object, and based on these target distance values, it determines the target pixel corresponding to the target object among the multiple image pixels. This method only requires determining the target distance values between the image pixels and the object boundary of the target object in two-dimensional space to identify the target pixels in the image to be processed that require the addition of a shadow effect. This allows for a simple, fast, and accurate determination of the target pixel. The process involves marking pixels; finally, determining the shadow pixel value of the target object at the target pixel based on a preset color, determining the target image based on the shadow pixel value corresponding to the target pixel, and displaying the target image. This supports flexibly setting shadow effects at the target pixel, generating a target image containing shadow effects, enriching the image display effect, and solving the technical problems of complex shadow effect generation methods, large memory space consumption, and low shadow generation efficiency in related technologies. It reduces the complexity of shadow generation for target objects, saves memory and computing power, expands the scope of application, simplifies the image processing process, and improves the image processing experience.
[0056] Figure 2 This is a flowchart illustrating another image processing method provided in this embodiment. Based on the above embodiments, this embodiment further refines the method for determining the target distance values from multiple image pixels in the image to be processed to the object boundary of the target object. Optionally, a directed distance field function corresponding to the target object is determined, and the target distance values from multiple image pixels in the image to be processed to the object boundary of the target object are determined according to the directed distance field function, wherein the directed distance field function is associated with the boundary shape of the target object. For detailed implementation, please refer to the description of this embodiment. Technical features that are the same as or similar to those in the foregoing embodiments will not be repeated here. Figure 2 As shown, the method in this embodiment may specifically include:
[0057] S210. In response to an image processing request, obtain an image to be processed, wherein the image to be processed includes a target object.
[0058] S220. Determine the directed distance field function corresponding to the target object, determine the target distance value from multiple image pixels in the image to be processed to the object boundary of the target object according to the directed distance field function, and determine the target pixel corresponding to the target object among the multiple image pixels according to the target distance value.
[0059] In this embodiment, the directed distance field (SDF) is associated with the boundary shape of the target object. The input to the SDF is the position of any point in a two-dimensional plane, and the output is the distance from the input point to the boundary of a specific set. By constructing different functions, the shape of the set boundary can be controlled, such as a circle, square, or triangle. Therefore, in a two-dimensional plane, a shadow of a specific shape can be drawn using the SDF, and the shade of the shadow is determined by the calculated target distance value.
[0060] Specifically, determining the target distance values from multiple image pixels in the image to be processed to the object boundary of the target object based on the directed distance field function includes: determining the directed distance values from multiple image pixels in the image to be processed to the object boundary of the target object based on the directed distance field function, and determining the target distance value corresponding to the image pixel based on the directed distance value corresponding to the image pixel. Compared to using a shadow camera set up in a 3D rendering space and employing a real-time lighting algorithm to add shadows to objects in the image, this technical solution saves significant computational resources and can quickly calculate the directed distance values from multiple image pixels in the image to be processed to the object boundary of the target object using 2D image information.
[0061] Taking a rectangle as an example (the same applies to other shapes such as circles and parallelograms), the target distance value corresponding to the image pixels inside the rectangle is less than zero, the target distance value corresponding to the image pixels at the edge of the rectangle is equal to zero, and the target distance value corresponding to the image pixels outside the rectangle is greater than zero. The farther away from the boundary of the rectangle, the greater the target distance value.
[0062] As an optional implementation of this disclosure, specifically, determining the directed distance field function corresponding to the target object may include: obtaining a pre-set directed distance field function corresponding to the target object. Specifically, directed distance field functions corresponding to multiple preset shapes may be pre-set. Further, obtaining the pre-set directed distance field function corresponding to the target object may include: determining the pre-set directed distance field function corresponding to the target object based on the shape of the target object. This technical solution is particularly suitable for situations where the shape of the target object is determined. It can concisely and quickly determine the directed distance field function corresponding to the target object. Compared to storing shadow animation sequence frames, storing the directed distance field function does not require much memory space, reducing the computational resource consumption of shadow processing.
[0063] As an optional implementation of this disclosure, specifically, determining the directed distance field function corresponding to the target object may include: determining an object boundary function corresponding to the target object based on the boundary shape of the target object and a preset shape function, and constructing a directed distance field function based on the object boundary function. Here, the boundary shape of the target object can be understood as the shape of the object boundary of the target object. This technical solution is applicable to adding shadows to target objects of various shapes. By determining the object boundary function corresponding to the target object through a preset shape function, the object boundary function corresponding to the target object can be quickly determined. Then, by constructing a directed distance field function based on the object boundary function, flexible construction of the directed distance field function can be achieved, thereby expanding the range of target objects to which the directed distance field function is applicable.
[0064] As an optional implementation of this disclosure, specifically, constructing the directed distance field function based on the object boundary function may include: when the object boundary function includes multiple preset shape functions, constructing a directed distance field function based on each preset shape function. In other words, when the boundary shape of the target object needs to be obtained by combining multiple sub-shapes, the object boundary function needs to be constructed by multiple preset shape functions. It should be noted that the multiple sub-shapes used to form the boundary shape of the target object may have overlapping areas when combined to form the boundary shape of the target object. For example, the preset shape function may include a rectangle function corresponding to a rectangle shape. When the boundary shape of the target object is a shadow, the object boundary function can be constructed by shape functions corresponding to two parallelograms, and the shape functions corresponding to the parallelograms can be obtained by adjusting the parameters of the rectangle function. That is, the transformation of the shadow shape can be controlled by controlling the parameters of the directed distance field function.
[0065] Further, determining the target distance values from multiple image pixels in the image to be processed to the object boundary of the target object based on the directed distance field function includes: determining the directed distance values from multiple image pixels in the image to be processed to the object boundary of the target object based on each of the directed distance field functions; and for a single image pixel, determining the target distance value corresponding to the image pixel based on the directed distance values corresponding to the multiple directed distance field functions. Specifically, determining the target distance value corresponding to the image pixel based on the directed distance values corresponding to the multiple directed distance field functions may include: determining the maximum value among the directed distance values corresponding to the multiple directed distance field functions as the target distance value corresponding to the image pixel. Furthermore, the shadow pixel value of the target object acting on the target pixel can be determined based on a preset color. Using this technical solution, the overlapping of sub-shapes constituting the boundary shape of the target object can be avoided from affecting the shadow effect, making the determined shadow shape more closely match the actual lighting effect of the target object.
[0066] As an optional implementation of this disclosure, specifically, determining the object boundary function corresponding to the target object based on the boundary shape of the target object and a preset shape function includes: when a preset shape function consistent with the boundary shape of the target object is obtained, determining the preset shape function as the object boundary function corresponding to the target object. That is, determining the preset shape function consistent with the boundary shape of the target object as the object boundary function corresponding to the target object. In this case, the object boundary function corresponding to the target object can be quickly determined through the preset shape function, thereby constructing the directed distance field function consistent with the boundary shape of the target object to determine the shadow shape consistent with the boundary shape of the target object.
[0067] As an optional implementation of this disclosure, specifically, determining the object boundary function corresponding to the target object based on the boundary shape of the target object and a preset shape function includes: if no preset shape function consistent with the boundary shape of the target object is obtained, transforming the preset shape function into an object boundary function corresponding to the target object based on the boundary shape of the target object. That is, at least one parameter of the preset shape function can be adjusted according to the boundary shape of the target object to obtain a shape function consistent with the boundary shape of the target object, i.e., an object boundary function corresponding to the target object. By dynamically setting the function parameters of the directed distance field function, the dynamic changes of the projection of a three-dimensional object during movement can be simulated in a two-dimensional plane.
[0068] In this embodiment of the disclosure, the transformation of the preset shape function includes transforming at least one parameter of the preset shape, such as its position, size, rotation angle, and tilt. By transforming the preset shape function, the shadow shape can be made to conform to the shape of the target object.
[0069] Taking a book as an example, when the pages of the book are parallel to a two-dimensional plane, the shape of the shadow is the shape of the page. After the pages are turned, the shape of the page projection changes accordingly because the angles between the page, the two-dimensional plane, and the light source change. At this time, the original shape of the page can be stretched by modifying the parameters of the directed distance field function to make it fit the shape of the projection produced after the page is turned.
[0070] As an optional implementation of this disclosure, specifically, determining the object boundary function corresponding to the target object based on the boundary shape of the target object and a preset shape function includes: when no preset shape function matching the boundary shape of the target object is obtained, obtaining multiple preset shape functions that can be used to construct the boundary shape of the target object, and determining the multiple preset shape functions as the object boundary function corresponding to the target object. By employing this technical solution, shadow effects can be added to the target object with more shapes in the image to be processed based on the combination of the preset shape functions, making the addition of shadow effects more flexible and adaptable to a wider range of scenarios.
[0071] S230. Determine the shadow pixel value of the target object at the target pixel point according to the preset color, determine the target image according to the shadow pixel value corresponding to the target pixel point, and display the target image.
[0072] In this embodiment of the disclosure, when the object boundary function corresponding to the target object is determined by the plurality of preset shape functions, the target pixel point corresponding to each object boundary function can be determined respectively, and the shadow pixel value corresponding to each target pixel point can be determined respectively; for the repeated pixel points among the target pixel points corresponding to the plurality of object boundary functions, the maximum value among the shadow pixel values of the repeated pixel points determined according to the plurality of object boundary functions can be determined as the shadow pixel value corresponding to the target pixel point.
[0073] The technical solution of this disclosure determines a directed distance field function corresponding to the target object and associates the directed distance field function with the boundary shape of the target object to specifically determine the shadow region that matches the boundary shape of the target object. By determining the target distance values from multiple image pixels in the image to be processed to the object boundary of the target object according to the directed distance field function, the target distance values corresponding to multiple image pixels in the image to be processed can be quickly determined without complex three-dimensional spatial calculations. This effectively characterizes the relative positional relationship between multiple image pixels in the image to be processed and the target object, so as to conveniently and quickly determine the image pixels in the image to be processed that need to have a shadow effect corresponding to the target object added.
[0074] Figure 3 This is a schematic diagram of the structure of an image processing apparatus provided in an embodiment of the present disclosure, as shown below. Figure 3 As shown, the device includes: an image processing request module 310, a target pixel determination module 320, and a target image display module 330. The image processing request module is used to acquire an image to be processed in response to an image processing request, wherein the image to be processed includes a target object; the target pixel determination module is used to determine target distance values from multiple image pixels in the image to the object boundary of the target object, and to determine the target pixel corresponding to the target object among the multiple image pixels based on the target distance values; the target image display module is used to determine the shadow pixel value of the target object acting on the target pixel based on a preset color, to determine the target image based on the shadow pixel value corresponding to the target pixel, and to display the target image.
[0075] The technical solution of this embodiment responds to an image processing request via an image processing request module 310 to acquire an image to be processed, including a target object. Upon receiving the image processing request, it automatically enters the image processing flow and acquires the image to be processed. Then, a target pixel determination module 320 determines the target distance values from multiple image pixels in the image to be processed to the object boundary of the target object. Based on these target distance values, it determines the target pixel corresponding to the target object among the multiple image pixels. This method only requires determining the target distance values between the image pixels and the object boundary of the target object in two-dimensional space to identify the target pixels in the image to be processed that require the addition of a shadow effect. This approach is simple, fast, and accurate. The target pixel is accurately identified; finally, the target image display module 330 determines the shadow pixel value of the target object at the target pixel based on the preset color, determines the target image based on the shadow pixel value corresponding to the target pixel, and displays the target image. This supports flexibly setting shadow effects at the target pixel, generating a target image containing shadow effects, enriching the image display effect, and solving the technical problems of complex shadow effect generation, large memory space occupation, and low shadow generation efficiency in related technologies. It reduces the complexity of shadow generation for target objects, saves memory and computing power, expands the scope of application, simplifies the image processing process, and improves the image processing experience.
[0076] Based on any optional technical solution in the embodiments of this disclosure, the target pixel determination module 320 may optionally include a directed distance field function determination unit, wherein the directed distance field function determination unit is used to obtain a pre-set directed distance field function corresponding to the target object; or, determine an object boundary function corresponding to the target object based on the boundary shape of the target object and a preset shape function, and construct a directed distance field function based on the object boundary function.
[0077] Based on any optional technical solution in the embodiments of this disclosure, the directed distance field function determining unit can be specifically used to construct a directed distance field function according to each of the preset shape functions when the object boundary function includes multiple preset shape functions. Further, the target pixel determining module also includes a target distance value determining unit, which is used to determine the directed distance values from multiple image pixels in the image to be processed to the object boundary of the target object according to each directed distance field function; and, for a single image pixel, to determine the target distance value corresponding to the image pixel according to the directed distance values corresponding to the multiple directed distance field functions.
[0078] Based on any optional technical solution in the embodiments of this disclosure, optionally, the directed distance field function determining unit is used to perform at least one of the following operations: when a preset shape function consistent with the boundary shape of the target object is obtained, the preset shape function is determined as the object boundary function corresponding to the target object; when a preset shape function consistent with the boundary shape of the target object is not obtained, the preset shape function is transformed into the object boundary function corresponding to the target object by adjusting at least one parameter of the preset shape function according to the boundary shape of the target object; when a preset shape function consistent with the boundary shape of the target object is not obtained, a plurality of preset shape functions that can be spliced to form the boundary shape of the target object are obtained, and the plurality of preset shape functions are determined as the object boundary functions corresponding to the target object.
[0079] Based on any optional technical solution in the embodiments of this disclosure, the target image display module 330 is optionally configured to determine a shadow weighting value according to the target distance value corresponding to the target pixel, and determine the shadow pixel value of the target object acting on the target pixel according to the display pixel value of the target pixel in the image to be processed, the preset color, and the shadow weighting value.
[0080] Optionally, based on any optional technical solution in the embodiments of this disclosure, the target pixel determination module 320 is specifically used to determine the image pixel corresponding to the target distance value within a preset distance range as the target pixel corresponding to the target object.
[0081] Optionally, based on any optional technical solution in the embodiments of this disclosure, the image processing device further includes: a pixel distance value determination module. Specifically, the pixel distance value determination module is used to, when the image to be processed includes multiple target objects and the same target pixel corresponds to multiple target objects, after determining the shadow pixel value at the target pixel point affected by the target object according to a preset color, determine the maximum value among the shadow pixel values at the target pixel point affected by the multiple target objects as the shadow pixel value corresponding to the target pixel point; or, determine the sum of the shadow pixel values at the target pixel point affected by the target objects as the shadow pixel value corresponding to the target pixel point.
[0082] The live streaming processing apparatus provided in this disclosure can execute the live streaming processing method provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects for executing the live streaming processing method.
[0083] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be realized; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the protection scope of the embodiments of this disclosure.
[0084] The following is for reference. Figure 4 The diagram illustrates a structural schematic of an electronic device (e.g., a terminal device or a server) 400 suitable for implementing embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 4 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0085] like Figure 4 As shown, electronic device 400 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 401, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 402 or a program loaded from storage device 408 into random access memory (RAM) 403. RAM 403 also stores various programs and data required for the operation of electronic device 400. Processing device 401, ROM 402, and RAM 403 are interconnected via bus 404. Input / output (I / O) interface 405 is also connected to bus 404.
[0086] Typically, the following devices can be connected to I / O interface 405: input devices 406 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 407 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 408 including, for example, magnetic tapes, hard disks, etc.; and communication devices 409. Communication device 409 allows electronic device 400 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 4 An electronic device 400 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0087] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 409, or installed from storage device 408, or installed from ROM 402. When the computer program is executed by processing device 401, it performs the functions defined in the methods of embodiments of this disclosure.
[0088] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0089] The electronic device provided in this disclosure and the image processing method provided in the above embodiments belong to the same inventive concept. Technical details not described in detail in this disclosure can be found in the above embodiments, and this embodiment has the same beneficial effects as the above embodiments.
[0090] This disclosure provides a computer storage medium storing a computer program that, when executed by a processor, implements the image processing method provided in the above embodiments.
[0091] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0092] According to one or more embodiments of this disclosure, [Example 1] provides an image processing method, comprising: in response to an image processing request, acquiring an image to be processed, wherein the image to be processed includes a target object; determining target distance values from a plurality of image pixels in the image to the object boundary of the target object, determining a target pixel among the plurality of image pixels corresponding to the target object based on the target distance values; determining shadow pixel values at the target pixel point where the target object acts based on a preset color, determining a target image based on the shadow pixel values corresponding to the target pixel point, and displaying the target image.
[0093] According to one or more embodiments of this disclosure, [Example 2] provides the method of Example 1, which further includes: optionally, determining the target distance value from a plurality of image pixels in the image to be processed to the object boundary of the target object includes: determining a directed distance field function corresponding to the target object, and determining the target distance value from a plurality of image pixels in the image to be processed to the object boundary of the target object according to the directed distance field function, wherein the directed distance field function is associated with the boundary shape of the target object.
[0094] According to one or more embodiments of this disclosure, [Example 3] provides the method of Example 2, which further includes: optionally, determining the directed distance field function corresponding to the target object includes: obtaining a pre-set directed distance field function corresponding to the target object; or, determining an object boundary function corresponding to the target object based on the boundary shape of the target object and a preset shape function, and constructing a directed distance field function based on the object boundary function.
[0095] According to one or more embodiments of this disclosure, Example 4 provides the method of Example 3, which further includes: optionally, constructing a directed distance field function based on the object boundary function includes: when the object boundary function includes a plurality of the preset shape functions, constructing a directed distance field function based on each of the preset shape functions respectively; determining the target distance value from a plurality of image pixels in the image to be processed to the object boundary of the target object based on the directed distance field function includes: determining the directed distance value from a plurality of image pixels in the image to be processed to the object boundary of the target object based on each of the directed distance field functions respectively; and for a single image pixel, determining the target distance value corresponding to the image pixel based on the directed distance values corresponding to the plurality of directed distance field functions.
[0096] According to one or more embodiments of this disclosure, Example 5 provides the method of Example 3, which further includes: Optionally, determining the object boundary function corresponding to the target object based on the boundary shape of the target object and a preset shape function includes at least one of the following operations: if a preset shape function consistent with the boundary shape of the target object is obtained, determining the preset shape function as the object boundary function corresponding to the target object; if a preset shape function consistent with the boundary shape of the target object is not obtained, transforming the preset shape function into the object boundary function corresponding to the target object by adjusting at least one parameter of the preset shape function according to the boundary shape of the target object; if a preset shape function consistent with the boundary shape of the target object is not obtained, obtaining a plurality of preset shape functions that can be spliced to form the boundary shape of the target object, and determining the plurality of preset shape functions as the object boundary functions corresponding to the target object.
[0097] According to one or more embodiments of this disclosure, Example Six provides the method of Example One, which further includes: Optionally, determining the shadow pixel value of the target object acting on the target pixel based on a preset color includes: determining a shadow weighting value based on the target distance value corresponding to the target pixel, and determining the shadow pixel value of the target object acting on the target pixel based on the display pixel value of the target pixel in the image to be processed, the preset color, and the shadow weighting value.
[0098] According to one or more embodiments of this disclosure, [Example Seven] provides the method of Example One, which further includes: Optionally, determining the target pixel corresponding to the target object among a plurality of image pixels based on the target distance value includes: determining the image pixels corresponding to the target distance value within a preset distance range as the target pixel corresponding to the target object.
[0099] According to one or more embodiments of this disclosure, Example 8 provides the method of Example 1, which further includes: Optionally, after determining the shadow pixel value of the target object acting on the target pixel point according to the preset color, the method further includes: when the image to be processed includes multiple target objects and there exists a target pixel point corresponding to multiple target objects, for the target pixel point corresponding to multiple target objects, determining the maximum value among the shadow pixel values of the multiple target objects acting on the target pixel point as the shadow pixel value corresponding to the target pixel point, or determining the sum of the shadow pixel values of the target objects acting on the target pixel point as the shadow pixel value corresponding to the target pixel point.
[0100] According to one or more embodiments of this disclosure, [Example Nine] provides an image processing apparatus, comprising: an image processing request module, configured to acquire an image to be processed in response to an image processing request, wherein the image to be processed includes a target object; a target pixel determination module, configured to determine target distance values from a plurality of image pixels in the image to the object boundary of the target object, and determine a target pixel corresponding to the target object among the plurality of image pixels based on the target distance values; and a target image display module, configured to determine the shadow pixel value of the target object acting on the target pixel based on a preset color, determine a target image based on the shadow pixel value corresponding to the target pixel, and display the target image.
[0101] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0102] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0103] The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: in response to an image processing request, acquire an image to be processed, wherein the image to be processed includes a target object; determine target distance values from a plurality of image pixels in the image to the object boundary of the target object, determine a target pixel among the plurality of image pixels corresponding to the target object based on the target distance values; determine the shadow pixel value of the target object acting on the target pixel based on a preset color, determine a target image based on the shadow pixel value corresponding to the target pixel, and display the target image.
[0104] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including but not limited to object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0105] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0106] The units described in the embodiments of this disclosure can be implemented in software or in hardware. The name of a unit does not necessarily limit the unit itself; for example, a directed distance field function determination unit can also be described as "a unit that determines the directed distance field function corresponding to a target object".
[0107] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0108] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0109] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0110] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0111] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
Claims
1. An image processing method, characterized in that, include: In response to an image processing request, an image to be processed is acquired, wherein the image to be processed includes a target object; Determine the target distance values from multiple image pixels in the image to the object boundary of the target object, and determine the target pixel corresponding to the target object among the multiple image pixels based on the target distance values; The shadow pixel value of the target object at the target pixel is determined according to the preset color, the target image is determined according to the shadow pixel value corresponding to the target pixel, and the target image is displayed.
2. The image processing method according to claim 1, characterized in that, Determining the target distance values from multiple image pixels in the image to be processed to the object boundary of the target object includes: A directed distance field function corresponding to the target object is determined, and a target distance value from multiple image pixels in the image to be processed to the object boundary of the target object is determined based on the directed distance field function, wherein the directed distance field function is associated with the boundary shape of the target object.
3. The image processing method according to claim 2, characterized in that, Determining the directed distance field function corresponding to the target object includes: Obtain a pre-set directed distance field function corresponding to the target object; or, Based on the boundary shape of the target object and a preset shape function, determine the object boundary function corresponding to the target object, and construct a directed distance field function based on the object boundary function.
4. The image processing method according to claim 3, characterized in that, The construction of the directed distance field function based on the object boundary function includes: When the object boundary function includes multiple preset shape functions, a directed distance field function is constructed according to each preset shape function; Determining the target distance values from multiple image pixels in the image to the object boundary of the target object based on the directed distance field function includes: The directed distance values from multiple image pixels in the image to be processed to the object boundary of the target object are determined according to each of the directed distance field functions. For a single image pixel, the target distance value corresponding to the image pixel is determined based on the directed distance values corresponding to the multiple directed distance field functions.
5. The image processing method according to claim 3, characterized in that, Determining the object boundary function corresponding to the target object based on the boundary shape of the target object and a preset shape function includes at least one of the following operations: If a preset shape function that matches the boundary shape of the target object is obtained, the preset shape function is determined as the object boundary function corresponding to the target object; If a preset shape function that matches the boundary shape of the target object is not obtained, the preset shape function is transformed into an object boundary function corresponding to the target object by adjusting at least one parameter of the preset shape function according to the boundary shape of the target object. If no preset shape function that matches the boundary shape of the target object is obtained, multiple preset shape functions that can be used to construct the boundary shape of the target object are obtained, and the multiple preset shape functions are determined as the object boundary functions corresponding to the target object.
6. The image processing method according to claim 1, characterized in that, The step of determining the shadow pixel value of the target object at the target pixel point based on the preset color includes: The shadow weighting value is determined based on the target distance value corresponding to the target pixel, and the shadow pixel value of the target object at the target pixel is determined based on the display pixel value of the target pixel in the image to be processed, the preset color, and the shadow weighting value.
7. The image processing method according to claim 1, characterized in that, The step of determining the target pixel corresponding to the target object among a plurality of image pixels based on the target distance value includes: The image pixel corresponding to the target distance value within the preset distance range is determined as the target pixel corresponding to the target object.
8. The image processing method according to claim 1, characterized in that, After determining the shadow pixel value of the target object at the target pixel point based on the preset color, the method further includes: In the case where the image to be processed includes multiple target objects and there exists a single target pixel point corresponding to multiple target objects, for the target pixel point corresponding to multiple target objects, the maximum value among the shadow pixel values of the multiple target objects acting on the target pixel point is determined as the shadow pixel value corresponding to the target pixel point, or the sum of the shadow pixel values of the target objects acting on the target pixel point is determined as the shadow pixel value corresponding to the target pixel point.
9. An image processing apparatus, characterized in that, include: An image processing request module is used to obtain an image to be processed in response to an image processing request, wherein the image to be processed includes a target object; The target pixel determination module is used to determine the target distance value from multiple image pixels in the image to the object boundary of the target object, and to determine the target pixel corresponding to the target object among the multiple image pixels based on the target distance value; The target image display module is used to determine the shadow pixel value of the target object at the target pixel point based on a preset color, determine the target image based on the shadow pixel value corresponding to the target pixel point, and display the target image.
10. An electronic device, characterized in that, The electronic device includes: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the image processing method as described in any one of claims 1-8.
11. A storage medium containing computer-executable instructions, characterized in that, The computer-executable instructions, when executed by a computer processor, are used to perform the image processing method as described in any one of claims 1-8.
12. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the image processing method as described in any one of claims 1-8.