Method, apparatus, electronic device, and storage medium for generating image special effects

By dividing the grid area in image processing and calculating the rotation radius and angle to determine the position of the sampling pixel points, the problem of low realism in the prior art is solved, and a more realistic and rich Van Gogh style special effects are achieved.

CN114170068BActive Publication Date: 2025-06-10BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111375555.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-19
Publication Date
2025-06-10
Estimated Expiration
2041-11-19

AI Technical Summary

Technical Problem

The existing image effects that simulate Van Gogh's style are relatively realistic, and the rotation and distortion style is relatively single.

Method used

By dividing the image to be processed into multiple grid areas, the target pixel points in each grid area are determined, and the corresponding position of the sampling pixel points is calculated based on the rotation radius and rotation angle of each target pixel point, and the color of the target pixel point is filled to the sampling pixel point, thereby achieving the spiral twisting effect of the image.

Benefits of technology

It improves the authenticity of image special effects and realizes special effects that simulate Van Gogh's painting style, making the image present a richer and more dynamic spiral twisting effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114170068B_ABST
    Figure CN114170068B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a method, apparatus, electronic device, and storage medium for generating image special effects, and pertains to the field of image processing, aiming to at least solve the problem of low authenticity of image special effects in related technologies. The method includes: obtaining a plurality of grid regions corresponding to the image to be processed, and determining a plurality of target pixel points within each grid region; each target pixel point is within the action region of the central pixel point of each grid region; for each target pixel point within each grid region, determining the sampling pixel point corresponding to each target pixel point; the sampling pixel point is the pixel point obtained by rotating each target pixel point around the central pixel point based on the rotation radius and rotation angle of each target pixel point; the rotation radius is the distance between each target pixel point and the central pixel point, and the rotation angle is positively correlated with the rotation radius; filling the color of each target pixel point with the color of the corresponding sampling pixel point.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of image processing, and in particular, to a method, apparatus, electronic device, and storage medium for generating image special effects. Background Art

[0002] Image special effects in an electronic device can improve the fun of shooting and enhance the tension of an image to attract more users. For example, image special effects in an electronic device include comic special effects, filter special effects, etc. Comic special effects can convert pictures in the electronic device into two-dimensional anime pictures; filter special effects can include various types, such as converting pictures in the electronic device into black-and-white pictures.

[0003] In related technologies, these image special effects can be set based on user preferences. For example, image special effects can be used to thin the face, increase the height, and enlarge the eyes of the people in the picture. In practice, since many users like the styles of some famous paintings, providing famous painting simulation special effects for pictures is a good design direction in special effect design. For example, the paintings of Van Gogh present a rotating and distorted style, which can be simulated as an image special effect. The existing image special effects that simulate the Van Gogh painting style are usually based on circles, forming circles in the image, and the rotating and distorted style is relatively single. Summary of the Invention

[0004] The present disclosure provides a method, apparatus, electronic device, and storage medium for generating image special effects to at least solve the problem of low authenticity of image special effects in related technologies. The technical solutions of the present disclosure are as follows:

[0005] According to a first aspect of an embodiment of the present disclosure, there is provided a method for generating an image special effect, including: obtaining a plurality of grid regions corresponding to an image to be processed, and determining a plurality of target pixel points in each grid region; each target pixel point is within an action region of a central pixel point of each grid region; the action region is a region that affects the rotation of a plurality of target pixel points around the central pixel point; for each target pixel point in each grid region, determining a corresponding sampled pixel point; the sampled pixel point is a pixel point obtained by rotating each target pixel point around the central pixel point based on the rotation radius and rotation angle of each target pixel point; the rotation radius is the distance between each target pixel point and the central pixel point, and the rotation angle is positively correlated with the rotation radius; filling the color of each target pixel point with the color of the corresponding sampled pixel point.

[0006] Optionally, the above-mentioned action area is circular. Determining multiple target pixel points within each grid area includes: for each non-center pixel point within each grid area except the center pixel point, determining the target distance between each non-center pixel point and the center pixel point; when the target distance is less than or equal to the preset initial action radius corresponding to the center pixel point, determining each non-center pixel point as a target pixel point; the preset initial action radius is the radius of the action area.

[0007] Optionally, the above method further includes: when the preset initial action radius is greater than the minimum value from the center pixel point to the boundary of the image to be processed, deleting the non-center pixel points located outside the boundary of the image to be processed from the multiple target pixel points.

[0008] Optionally, the above method further includes: determining the rotation radius of each target pixel point, and determining the ratio of the rotation radius to the preset target action radius as the rotation angle coefficient of each target pixel point; the preset target action radius is negatively correlated with the size of the action area; determining the rotation angle of each target pixel point according to the product of the rotation angle coefficient and the preset rotation intensity; the preset rotation intensity is used to adjust the size of the rotation angle, and the size of the rotation angle is positively correlated with the preset rotation intensity.

[0009] Optionally, the above-mentioned action area is circular, and the method further includes: determining the product of the preset initial action radius corresponding to the center pixel point and the preset radius coefficient, and using the product as the preset target action radius; the preset initial action radius is the radius of the action area, and the preset radius coefficient is negatively correlated with the resolution size of the image to be processed.

[0010] Optionally, the above determination of the sampling pixel point corresponding to each target pixel point includes: determining the sampling pixel point corresponding to each target pixel point according to the position of each target pixel point, the position of the center pixel point, the rotation radius of each target pixel point, and the rotation angle of each target pixel point.

[0011] Optionally, the sampling pixel point corresponding to each target pixel point satisfies the following formula:

[0012] (x', y') = (dis.x * c + dis.y * s, -dis.x + dis.y * c);

[0013] where, (x', y') is the position of the sampling pixel point, dis.x is the horizontal distance between each target pixel point and the center pixel point, dis.y is the vertical distance between each target pixel point and the center pixel point, c = dis * cosα, s = dis * sinα, dis is the rotation radius of each pixel point, and α is the rotation angle of each target pixel point.

[0014] According to a second aspect of the embodiments of the present disclosure, there is provided a special effect processing device for images, including: an acquisition unit, a determination unit, and a processing unit; the acquisition unit is configured to acquire a plurality of grid regions corresponding to the image to be processed; the determination unit is configured to determine a plurality of target pixel points in each grid region; each target pixel point is located within the action region of the central pixel point of each grid region; the action region is a region that affects the rotation of a plurality of target pixel points around the central pixel point; the determination unit is further configured to, for each target pixel point in each grid region, determine the sampling pixel point corresponding to each target pixel point; the sampling pixel point is a pixel point obtained by rotating each target pixel point around the central pixel point based on the rotation radius and rotation angle of each target pixel point; the rotation radius is the distance between each target pixel point and the central pixel point, and the rotation angle is positively correlated with the rotation radius; the processing unit is configured to fill the color of each target pixel point with the color of the corresponding sampling pixel point.

[0015] Optionally, the above-mentioned action region is circular, and the determination unit is specifically configured to: for each non-central pixel point other than the central pixel point in each grid region, determine the target distance between each non-central pixel point and the central pixel point; when the target distance is less than or equal to the preset initial action radius corresponding to the central pixel point, determine each non-central pixel point as a target pixel point; the preset initial action radius is the radius of the action region.

[0016] Optionally, the above-mentioned generating device further includes a deletion unit; the deletion unit is configured to, when the preset initial action radius is greater than the minimum value from the central pixel point to the boundary of the image to be processed, delete the non-central pixel points located outside the boundary of the image to be processed from the plurality of target pixel points.

[0017] Optionally, the above-mentioned determination unit is further configured to: determine the rotation radius of each target pixel point, and determine the ratio of the rotation radius to the preset target action radius as the rotation angle coefficient of each target pixel point; the preset target action radius is negatively correlated with the size of the action region; determine the rotation angle of each target pixel point according to the product of the rotation angle coefficient and the preset rotation intensity; the preset rotation intensity is used to adjust the size of the rotation angle, and the size of the rotation angle is positively correlated with the preset rotation intensity.

[0018] Optionally, the above-mentioned action region is circular, and the determination unit is further configured to: determine the product of the preset initial action radius corresponding to the central pixel point and the preset radius coefficient, and use the product as the preset target action radius; the preset initial action radius is the radius of the action region, and the preset radius coefficient is negatively correlated with the resolution size of the image to be processed.

[0019] Optionally, the above determination unit is specifically configured to: determine the sampling pixel points corresponding to each target pixel point according to the positions of each target pixel point, the position of the central pixel point, the rotation radius of each target pixel point, and the rotation angle of each target pixel point.

[0020] Optionally, the sampling pixel points corresponding to each of the above target pixel points satisfy the following formula:

[0021] (x', y') = (dis.x * c + dis.y * s, -dis.x + dis.y * c);

[0022] Where (x', y') is the position of the sampling pixel point, dis.x is the horizontal distance between each target pixel point and the central pixel point, dis.y is the vertical distance between each target pixel point and the central pixel point, c = dis * cosα, s = dis * sinα, dis is the rotation radius of each pixel point, and α is the rotation angle of each target pixel point.

[0023] According to a third aspect of the embodiments of the present disclosure, an electronic device is provided, including: a processor; a memory for storing processor-executable instructions; wherein, the processor is configured to execute the instructions to implement the method for generating an image special effect provided in the first aspect.

[0024] According to a fourth aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided, the computer-readable storage medium includes instructions; when the instructions are executed by a processor of an electronic device, the electronic device is caused to execute the method for generating an image special effect provided in the first aspect.

[0025] According to a fifth aspect of the embodiments of the present disclosure, a computer program product is provided, the computer program product includes instructions, when the instructions run on a processor of an electronic device, the electronic device is caused to execute the method for generating an image special effect provided in the first aspect.

[0026] The technical solutions provided by the embodiments of the present disclosure at least bring the following beneficial effects: The electronic device can determine the target pixel points in each grid area of the plurality of grid areas corresponding to the image to be processed, and for each target pixel point, fill the color of each target pixel point with the color of the corresponding sampling pixel point. Since the above sampling pixel points are the pixel points obtained by rotating each target pixel point around the central pixel point based on the rotation radius and rotation angle of each target pixel point, and the rotation angle increases as the rotation radius increases, in this way, a special effect of the target pixel points spirally twisting around the central pixel point of the grid area will be presented to the user, that is, the special effect of simulating Van Gogh's painting style is realized, and the authenticity of the image special effect is improved.

[0027] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and do not limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The accompanying drawings herein are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure, and do not constitute an improper limitation to the present disclosure.

[0029] Figure 1 is a schematic diagram of the architecture of an implementation environment shown according to an exemplary embodiment;

[0030] Figure 2 is one of the schematic flowcharts of a method for generating an image special effect shown according to an exemplary embodiment;

[0031] Figure 3 is a schematic polar coordinate diagram shown according to an exemplary embodiment;

[0032] Figure 4 is a schematic diagram of a Van Gogh painting style shown according to an exemplary embodiment;

[0033] Figure 5 is a schematic diagram of an image to be processed and a distortion and rotation effect shown according to an exemplary embodiment;

[0034] Figure 6 is another schematic flowchart of a method for generating an image special effect shown according to an exemplary embodiment;

[0035] Figure 7 is yet another schematic flowchart of a method for generating an image special effect shown according to an exemplary embodiment;

[0036] Figure 8 is still another schematic flowchart of a method for generating an image special effect shown according to an exemplary embodiment;

[0037] Figure 9 is yet still another schematic flowchart of a method for generating an image special effect shown according to an exemplary embodiment;

[0038] Figure 10 is a schematic structural diagram of an image special effect processing device shown according to an exemplary embodiment;

[0039] Figure 11 is a schematic structural diagram of an electronic device shown according to an exemplary embodiment. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0040] To enable those of ordinary skill in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.

[0041] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0042] In the related art, built-in cameras or picture editing software in electronic devices are all provided with a variety of special effects, which can add corresponding special effects to pictures to increase the interest of picture editing. Currently, there are various image special effects, such as beauty filters (such as slimming faces, increasing height, whitening, enlarging eyes, etc. for people), distortion special effects (deforming people into corresponding animals, etc.). The existence of these image special effects has greatly improved the attraction to users. The design of these image special effects is usually based on user preferences. Since many users have a certain preference for famous paintings, simulating the style of famous paintings is also a design direction for special effects. However, not all of these famous paintings have corresponding painting styles. Therefore, when simulating the style of famous paintings, only the famous paintings of some painters with obvious personal styles can be simulated to achieve the special effect of simulating famous paintings. For example, Van Gogh is a world-famous painter, and his corresponding painting style mainly presents a spiral distortion effect in the paintings. Therefore, a special effect simulating Van Gogh's painting style can be designed. However, the existing image special effects simulating Van Gogh's painting style in the related art are usually based on circles, forming circles in the image, and the rotating and twisting style is relatively single.

[0043] To provide a special effect simulating Van Gogh's painting style, an embodiment of the present disclosure provides a method for generating an image special effect, which can divide a to-be-processed image into multiple grid regions, and combine the central pixel points of each grid region and the target pixel points within the grid region to determine the sampling pixel points corresponding to the target pixel points within the range of the action of the central pixel points. Then, according to the determined corresponding sampling pixel points, the colors of these target pixel points are filled with the colors of the corresponding sampling pixel points to achieve the spiral distortion effect of the image, that is, to achieve the special effect of simulating Van Gogh's painting style, thereby improving the authenticity of the image special effect.

[0044] Figure 1 is an architecture diagram of an implementation environment shown according to an exemplary embodiment, as Figure 1As shown, the following method for generating image special effects can be applied to this implementation environment. This implementation environment includes terminal 01 and electronic device 02. Among them, terminal 01 establishes a communication connection with electronic device 02 through an application installed on terminal 01.

[0045] In an implementable manner, terminal 01 can run an application associated with electronic device 02 to achieve communication with electronic device 02. The application can be a short video application, a social network application, or a browser. In the embodiments of the present disclosure, taking the application as a short video application as an example, users can use image special effects in the short video application to achieve special effects on the captured images.

[0046] In an implementable manner, electronic device 02 can be a server, a server cluster composed of multiple servers, or a cloud computing service center. Of course, electronic device 02 can also be other terminal devices, which can include a processor, a memory, and a network interface, etc.

[0047] In an implementable manner, terminal 01 is used to provide voice and / or data connectivity services to users. Terminal 01 can have different names, such as UE, terminal, terminal unit, terminal station, mobile station, mobile unit, remote station, remote terminal, mobile device, wireless communication device, vehicle user equipment, terminal agent, or terminal device, etc.

[0048] Optionally, terminal 01 can be various handheld devices, vehicle-mounted devices, wearable devices, or computers with communication functions, and the embodiments of the present disclosure do not make any limitations in this regard. For example, the handheld device can be a smart phone. The vehicle-mounted device can be a vehicle navigation system. The wearable device can be a smart bracelet. The computer can be a personal digital assistant (PDA) computer, a tablet computer, or a laptop computer.

[0049] The following method for generating image special effects can be applied to the above-mentioned terminal 01 or the above-mentioned electronic device 02.

[0050] Those skilled in the art should understand that the above terminals are only examples, and other existing or future terminals that are applicable to the present disclosure should also be included within the protection scope of the present disclosure and are hereby incorporated by reference.

[0051] Based on the above implementation environment, the specific implementation process of the method for generating image special effects provided by the embodiments of the present disclosure is as follows:

[0052] The following will exemplarily describe the method for generating image special effects provided by the embodiments of the present disclosure with reference to each drawing.

[0053] Figure 2 is a flowchart of a method for generating an image special effect shown according to an exemplary embodiment. As shown in Figure 2 the figure, the method for generating an image special effect can be applied to the above-mentioned electronic device, and this method includes the following S11-S14.

[0054] S11. The electronic device acquires an image to be processed and acquires a plurality of grid regions corresponding to the image to be processed.

[0055] As a possible implementation manner, the electronic device here can be a photographing device, such as a mobile phone, a tablet computer Pad, etc., or can be an image processing device, such as a computer, etc. Therefore, the above-mentioned image to be processed can be a photo taken by the electronic device or a picture stored in the electronic device.

[0056] After the electronic device acquires the image to be processed, it can divide the image to be processed into a plurality of grid regions to rotate the pixel points in these grid regions around the central pixel point respectively.

[0057] Exemplarily, if the image to be processed is an image of 720px*1280px, when the image to be processed is divided into 10*10 grid regions, the size of these grid regions can be 72px*128px.

[0058] As another implementation manner, the electronic device can also acquire a background region from the image to be processed and divide the background region into a plurality of grid regions. In this case, the plurality of grid regions corresponding to the image to be processed are obtained by dividing based on the background image.

[0059] S12. The electronic device determines a plurality of target pixel points in each grid region.

[0060] Among them, each target pixel point is located within the action region of the central pixel point of each grid region. The action region is the region that affects the rotation of a plurality of target pixel points around the central pixel point.

[0061] As a possible implementation manner, for each grid region among the plurality of grid regions, the electronic device determines the central pixel point in the grid region and determines the action region including the central pixel point based on the determined central pixel point. Further, the electronic device determines the non-central pixel points located within the action region as a plurality of target pixel points.

[0062] It can be understood that the target pixel points within the action region can rotate around the central pixel point.

[0063] It should be noted that the action area can be of any shape. In some cases, the action area can be circular, and in other cases, the action area can be an irregular shape.

[0064] S13. For each target pixel point in each grid area, the electronic device determines the sampling pixel point corresponding to each target pixel point.

[0065] Among them, the sampling pixel point is the pixel point obtained by rotating each target pixel point around the central pixel point based on the rotation radius and rotation angle of each target pixel point. The rotation radius is the distance between each target pixel point and the central pixel point, and the rotation angle is positively correlated with the rotation radius.

[0066] As a possible implementation, the electronic device determines the distance between the target pixel point and the central pixel point as the rotation radius, and determines the rotation angle according to the determined rotation radius. Further, the electronic device determines the position of the sampling pixel point according to the determined rotation radius, rotation angle, the position of the target pixel point, and the position of the central pixel point.

[0067] In some embodiments, in order to determine the position of the sampling pixel point, as Figure 3 shown, a polar coordinate system can be established with the central pixel point of the grid area as the pole, and the polar axis can be Ox as Figure 3 shown. The target pixel point can be point M on this polar coordinate system. Here, the polar coordinates of the target pixel point can be represented according to the distance between the target pixel point and the central pixel point, and the angle between the ray from the central pixel point to the target pixel point and the polar axis.

[0068] Exemplarily, as Figure 3 shown, if the target pixel point is point M as Figure 3 shown, and the distance between point M and the pole O is ρ, and the angle between OM and Ox is θ, then the polar coordinates of point M are (ρ, θ). If the polar coordinates of the target pixel point are (3, 60°), it can represent a pixel point 3 pixels away from the pole and with an angle of 60° with the polar axis. If the polar coordinates of the target pixel point are (6, 30°), it can represent a pixel point 6 pixels away from the pole and with an angle of 30° with the polar axis. Here, the angle in the polar coordinates refers to the angle between the target pixel point and the polar axis in the counterclockwise direction.

[0069] The above rotation angle can indicate the angular offset of the target pixel point rotating around the central pixel point in the polar coordinates. For example, if the rotation angle is α, it indicates that the counterclockwise angular offset of the target pixel point in the corresponding polar coordinates is α, and α can be the offset angle between the target pixel point and the sampling pixel point. After determining the polar coordinates of the central pixel point and the target pixel point, as well as the rotation radius and rotation angle, the sampling pixel point corresponding to the target pixel point can be determined according to the corresponding distortion algorithm.

[0070] Since the mapping relationship between the sampled pixel points and the corresponding target pixel points is determined by the above-mentioned warping algorithm, it can be approximated here that the target pixel points are offset to the sampled pixel points to achieve the warping rotation of the image to be processed. However, in practice, the positions of the target pixel points are not moved in this step, but only the sampled pixel points corresponding to the target pixel points are determined.

[0071] For the specific implementation of this step, reference can be made to the subsequent description of the embodiments of the present disclosure, and details will not be elaborated here.

[0072] S14. The electronic device fills the color of each target pixel point with the color of the corresponding sampled pixel point.

[0073] As a possible implementation manner, after the electronic device determines the sampled pixel points corresponding to each target pixel point in each grid area, it can fill the colors of these target pixel points with the colors of the corresponding sampled pixel points, so as to present the special effect of the spiral warping of the image.

[0074] Exemplarily, as Figure 4 shown, an image in the style of Van Gogh is provided, which has multiple irregular spirals. As Figure 5 shown, if the image to be processed can be as shown in Figure 5 (a) in, then according to the above embodiment, the image to be processed is rotated and warped, and as shown in Figure 5 (b) in can be obtained, that is, the warping rotation of the image to be processed is realized, making it conform to the style of Van Gogh.

[0075] The technical solutions provided by the above embodiments have at least the following beneficial effects: The electronic device can determine the target pixel points in each grid area of the multiple grid areas corresponding to the image to be processed, and for each target pixel point, fill the color of each target pixel point with the color of the corresponding sampled pixel point. Since the above-mentioned sampled pixel points are the pixel points obtained by rotating each target pixel point around the central pixel point based on the rotation radius and rotation angle of each target pixel point, and the rotation angle increases as the rotation radius increases, in this way, a special effect of the target pixel points spirally warping around the central pixel point of the grid area will be presented to the user, that is, the special effect of simulating the style of Van Gogh is realized, improving the authenticity of the image special effect.

[0076] In an implementable manner, the above-mentioned action area provided by the embodiments of the present disclosure can be circular. In this case, in order to determine multiple target pixel points in the target area, in combination with Figure 2 , as Figure 6 shown, S11 provided by the embodiments of the present disclosure specifically includes the following S21-S23.

[0077] S21. For each non - central pixel point except the central pixel point within each grid region, the electronic device determines the target distance between each non - central pixel point and the central pixel point.

[0078] As a possible implementation, the electronic device can determine the target distance between each non - central pixel point and the central pixel point according to the positions of each non - central pixel point and the central pixel point in polar coordinates.

[0079] S22. The electronic device determines whether the target distance is less than or equal to the preset initial action radius corresponding to the central pixel point.

[0080] Wherein, the preset initial action radius is the radius of the action area.

[0081] As a possible implementation, the electronic device obtains the preset initial action radius corresponding to the central pixel point and determines whether the target distance is less than or equal to the preset initial action radius corresponding to the central pixel point.

[0082] It should be noted that the above - mentioned preset initial action radius can be set by the operation and maintenance personnel in the server in advance.

[0083] In some embodiments, each central pixel point of each grid region can correspond to a preset initial action radius. For example, the preset initial action radius of the first grid region can be R 1 , the preset initial action radius of the second grid region can be R 2 , R 1 and R 2 can be the same or different. Here, the first grid region and the second grid region can be any grid region in the image to be processed.

[0084] S23. When the target distance is less than or equal to the preset initial action radius corresponding to the central pixel point, the electronic device determines each non - central pixel point as a target pixel point.

[0085] It can be understood that within each grid region, all non - central pixel points within the action area with the central pixel point as the center and the preset initial action radius as the radius are multiple target pixel points.

[0086] The technical solutions provided in the above - mentioned embodiments have at least the following beneficial effects: Based on the preset initial action radius, an implementation method for determining multiple target pixel points corresponding to each central pixel point is given. Further, each central pixel point corresponds to a different preset initial action radius, which can achieve spiral distortions of different sizes in the image to be processed and can improve the authenticity of image special effects.

[0087] In an implementable manner, in order to improve the authenticity of the special effect generation of the image to be processed, such asFigure 7 As shown in Figure 7 , the method for generating an image special effect provided by an embodiment of the present disclosure further includes the following S31 - S33.

[0088] S31. For the central pixel point in each grid region, the electronic device determines the minimum value from the central pixel point to the boundary of the image to be processed.

[0089] As a possible implementation, the electronic device determines the vertical distance between the central pixel point and each point on the boundary of the image to be processed, and determines the minimum value among the determined vertical distances as the minimum value from the central pixel point to the boundary of the image to be processed.

[0090] S32. The electronic device determines whether the preset initial action radius is greater than the minimum value from the central pixel point to the boundary of the image to be processed.

[0091] As a possible implementation, the electronic device obtains the preset initial action radius corresponding to the central pixel point, and determines whether the preset initial action radius is greater than the minimum value from the central pixel point to the boundary of the image to be processed.

[0092] S33. When the preset initial action radius is greater than the minimum value from the central pixel point to the boundary of the image to be processed, the electronic device deletes the non - central pixel points located outside the boundary of the image to be processed from the multiple target pixel points.

[0093] It can be understood that when the preset initial action radius is less than or equal to the minimum value from the central pixel point to the boundary of the image to be processed, all the target pixel points are located within the boundary of the image to be processed. When the preset initial action radius is greater than the minimum value from the central pixel point to the boundary of the image to be processed, some of the target pixel points may be located outside the boundary of the image to be processed. Therefore, deleting the non - central pixel points located outside the boundary of the image to be processed from the multiple target pixel points can ensure the authenticity of the special effect generation of the image to be processed.

[0094] The technical solution provided by the above - mentioned embodiment has at least the following beneficial effects: Deleting the non - central pixel points located outside the boundary of the image to be processed from the multiple target pixel points can ensure that each target pixel point is located within the boundary of the image to be processed, thereby improving the authenticity of the special effect generation of the image to be processed.

[0095] In an implementable manner, in order to be able to determine the rotation radius of the target pixel point, as Figure 8 shown in Figure 8 , the method for generating an image special effect provided by an embodiment of the present disclosure further includes the following S41 - S43.

[0096] S41. The electronic device determines the rotation radius of each target pixel point.

[0097] As a possible implementation, for any target pixel, the electronic device can obtain the position information of the target pixel in polar coordinates and the position information of the central pixel in polar coordinates, and based on the obtained position information, determine the target distance between the target pixel and the central pixel as the rotation radius.

[0098] For example, if the target pixel and the central pixel are horizontally separated by x pixels and vertically separated by y pixels, the first distance between the target pixel and the central pixel can be determined according to the following formula:

[0099]

[0100] where dis is the target distance, which can also be called the rotation radius.

[0101] S42. The electronic device determines the ratio of the rotation radius to the preset target action radius as the rotation angle coefficient of each target pixel.

[0102] Among them, the preset target action radius is negatively correlated with the size of the action area.

[0103] As a possible implementation, the electronic device calculates the ratio of the rotation radius to the preset target action radius, and determines the determined ratio as the rotation angle coefficient of the target pixel.

[0104] It should be noted that the preset target action radius is set in the electronic device by the operation and maintenance personnel in advance, or can be set by the electronic device itself based on the resolution of the image to be processed.

[0105] Exemplarily, the rotation angle coefficient is r = dis / R, where R is the preset target action radius. As the size of the action area corresponding to each central pixel is different, the preset target action radius of each grid area is also different. When the grid area is large and the action area increases accordingly, the target action radius decreases, and thus the rotation angle coefficient increases.

[0106] S43. The electronic device determines the rotation angle of each target pixel according to the product of the rotation angle coefficient and the preset rotation intensity.

[0107] Among them, the preset rotation intensity is used to adjust the size of the rotation angle, and the size of the rotation angle is positively correlated with the preset rotation intensity.

[0108] As a possible implementation, after determining the rotation angle coefficient, the electronic device determines the product of the rotation angle coefficient and the preset rotation intensity to obtain the target rotation intensity. Further, the electronic device determines the rotation angle according to the target rotation intensity.

[0109] It should be noted that the rotation angle is positively correlated with the target rotation intensity.

[0110] It can be understood that for different grid regions, as the area of the acting region increases, the preset target acting radius decreases, and correspondingly, the rotation angle is larger.

[0111] The technical solution provided by the above embodiment has at least the following beneficial effects: Since the preset target acting radius decreases as the area of the acting region increases, as the area of the acting region is larger, the rotation angle of the target pixel point is larger, so that within a sufficiently large acting region, the color change of the target pixel point is more obvious, which can greatly improve the authenticity of image special effect generation.

[0112] In an implementable manner, in order to be able to determine the preset target acting radius, the acting region provided by the embodiments of the present disclosure is circular. As Figure 9 shown, the method for generating an image special effect provided by the embodiments of the present disclosure further includes the following S51-S52.

[0113] S51. The electronic device determines the product of the preset initial acting radius corresponding to the central pixel point and the preset radius coefficient.

[0114] Wherein, the preset initial acting radius is the radius of the acting region, and the preset radius coefficient is negatively correlated with the resolution of the image to be processed.

[0115] As a possible implementation manner, the electronic device obtains the preset radius coefficient of the image to be processed and calculates the product of the preset initial acting radius corresponding to the central pixel point and the preset radius coefficient.

[0116] It can be understood that as the resolution of the image to be processed is larger, the preset radius coefficient is smaller.

[0117] S52. The electronic device uses the product as the preset target acting radius.

[0118] It can be understood that for the image to be processed, when the number of grid regions is certain, the larger the resolution of the image to be processed is, the larger the area of the grid region is, and correspondingly, the smaller the preset target acting radius is, and further, the larger the determined rotation angle can be.

[0119] The technical solution provided by the above embodiment has at least the following beneficial effects: As the resolution of the image to be processed is larger, the preset target acting radius is smaller, and correspondingly, the rotation angle of the target pixel point is larger, so that within a sufficiently large acting region, the color change of the target pixel point is more obvious, which can greatly improve the authenticity of image special effect generation.

[0120] In one design, in order to be able to determine the sampling pixel corresponding to each target pixel, S13 provided by the embodiments of the present disclosure specifically includes S131.

[0121] S131. The electronic device determines the sampling pixel corresponding to each target pixel according to the position of each target pixel, the position of the central pixel, the rotation radius of each target pixel, and the rotation angle of each target pixel.

[0122] As a possible implementation, the electronic device obtains the position of each target pixel and the position of the central pixel, and determines the position of the sampling pixel corresponding to each target pixel according to the position of each target pixel, the position of the central pixel, the rotation radius of each target pixel, and the rotation angle of each target pixel.

[0123] It should be noted that the positions involved above can specifically be the positions of the target pixel and the central pixel in polar coordinates.

[0124] In some embodiments, when each target pixel rotates clockwise, the position of the sampling pixel satisfies the following formula:

[0125] (x′, y′) = (dis.x * cosα + dis.y * sinα, -dis.x * sinα + dis.y * cosα).

[0126] Where, (x′, y′) is the position of the sampling pixel, dis.x is the horizontal distance between each target pixel and the central pixel, dis.y is the vertical distance between each target pixel and the central pixel, dis is the rotation radius of each pixel, and α is the rotation angle of each target pixel.

[0127] The technical solutions provided by the above embodiments have at least the following beneficial effects: It is possible to establish a corresponding mapping relationship between the target pixel and the sampling pixel based on a preset method, and correspondingly, an implementation manner for determining the sampling pixel corresponding to each target pixel is also provided; the calculation method of the above formula gives a detailed calculation method for the sampling pixel, and the accurate position information of the sampling pixel can be obtained.

[0128] Figure 10 It is a schematic structural diagram of an image special effect processing device 60 shown according to an exemplary embodiment, as Figure 10 shown, the image special effect processing device 60 includes an acquisition unit 601, a determination unit 602, and a processing unit 603.

[0129] The acquisition unit 601 is configured to acquire a plurality of grid regions corresponding to the image to be processed.

[0130] Determination unit 602 is configured to determine a plurality of target pixel points within each grid region. Each target pixel point is located within the action region of the central pixel point of each grid region. The action region is the region that affects the rotation of the plurality of target pixel points around the central pixel point.

[0131] Determination unit 602 is further configured to, for each target pixel point within each grid region, determine a corresponding sampled pixel point for each target pixel point. The sampled pixel point is the pixel point obtained by rotating each target pixel point around the central pixel point based on the rotation radius and rotation angle of each target pixel point. The rotation radius is the distance between each target pixel point and the central pixel point, and the rotation angle is positively correlated with the rotation radius.

[0132] Processing unit 603 is configured to fill the color of each target pixel point with the color of the corresponding sampled pixel point.

[0133] Optionally, as Figure 10 shown, the action region provided by the embodiment of the present disclosure is circular, and the determination unit 602 is specifically configured to:

[0134] For each non-central pixel point within each grid region except the central pixel point, determine the target distance between each non-central pixel point and the central pixel point.

[0135] When the target distance is less than or equal to the preset initial action radius corresponding to the central pixel point, determine each non-central pixel point as a target pixel point. The preset initial action radius is the radius of the action region.

[0136] Optionally, as Figure 10 shown, the generating device provided by the embodiment of the present disclosure further includes a deletion unit 604.

[0137] Deletion unit 604 is configured to, when the preset initial action radius is greater than the minimum value from the central pixel point to the boundary of the image to be processed, delete the non-central pixel points located outside the boundary of the image to be processed from the plurality of target pixel points.

[0138] Optionally, as Figure 10 shown, the determination unit 602 provided by the embodiment of the present disclosure is further configured to:

[0139] Determine the rotation radius of each target pixel point, and determine the ratio of the rotation radius to the preset target action radius as the rotation angle coefficient of each target pixel point. The preset target action radius is negatively correlated with the size of the action region.

[0140] Determine the rotation angle of each target pixel point according to the product of the rotation angle coefficient and the preset rotation intensity. The preset rotation intensity is used to adjust the size of the rotation angle, and the size of the rotation angle is positively correlated with the preset rotation intensity.

[0141] Optionally, as shown in Figure 10 , the action area provided by the embodiment of the present disclosure is circular, and the determining unit 602 is further configured to:

[0142] Determine the product of the preset initial action radius corresponding to the central pixel point and the preset radius coefficient, and use the product as the preset target action radius. The preset initial action radius is the radius of the action area, and the preset radius coefficient is negatively correlated with the resolution of the image to be processed.

[0143] Optionally, as shown in Figure 10 , the determining unit 602 provided by the embodiment of the present disclosure is specifically configured to:

[0144] Determine the sampling pixel points corresponding to each target pixel point according to the positions of each target pixel point, the position of the central pixel point, the rotation radius of each target pixel point, and the rotation angle of each target pixel point.

[0145] Optionally, the sampling pixel points corresponding to each target pixel point provided by the embodiment of the present disclosure satisfy the following formula:

[0146] (x′, y′) = (dis.x * cosα + dis.y * sinα, -dis.x * sinα + dis.y * cosα).

[0147] Where (x′, y′) is the position of the sampling pixel point, dis.x is the horizontal distance between each target pixel point and the central pixel point, dis.y is the vertical distance between each target pixel point and the central pixel point, dis is the rotation radius of each pixel point, and α is the rotation angle of each target pixel point.

[0148] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment related to the method, and will not be elaborated here.

[0149] Figure 11 is a schematic structural diagram of an electronic device 70 provided by the present disclosure. As shown in Figure 11 , the electronic device 70 may include at least one processor 701 and a memory 703 for storing executable instructions of the processor 701. Among them, the processor 701 is configured to execute the instructions in the memory 703 to implement the special effect processing method of the image in the above embodiment. As an example, in combination with Figure 10 , the functions implemented by the obtaining unit 601, the determining unit 602, and the processing unit 603 in the special effect processing device of the image are the same as the functions of Figure 11 the processor 701 in

[0150] In addition, the electronic device 70 may further include a communication bus 702 and at least one communication interface 704.

[0151] The processor 701 may be a GPU, a microprocessing unit, an ASIC, or one or more integrated circuits for controlling the execution of the program of the present disclosure.

[0152] The communication bus 702 may include a path for transmitting information between the above components.

[0153] The communication interface 704 uses any device such as a transceiver for communicating with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area networks (WLAN), etc.

[0154] The memory 703 may be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (RAM) or other type of dynamic storage device that can store information and instructions, or may also be an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM), or other optical disc storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory may exist independently and be connected to the processing unit through a bus. The memory may also be integrated with the processing unit and be a volatile storage medium in the GPU.

[0155] Among them, the memory 703 is used to store instructions for executing the present disclosure and is controlled by the processor 701 for execution. The processor 701 is used to execute the instructions stored in the memory 703, thereby implementing the functions in the method of the present disclosure.

[0156] In a specific implementation, as an embodiment, the processor 701 may include one or more GPUs, for example Figure 11 the GPU0 and GPU1 in

[0157] In a specific implementation, as an embodiment, the electronic device 70 may include multiple processors, for example Figure 11The processors 701 and 707 therein. Each of these processors can be a single-CPU processor or a multi-GPU processor. The processors here can refer to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions).

[0158] In a specific implementation, as an embodiment, the electronic device 70 may further include an output device 705 and an input device 706. The output device 705 communicates with the processor 701 and can display information in various ways. For example, the output device 705 can be a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector, etc. The input device 706 communicates with the processor 701 and can accept user input in various ways. For example, the input device 706 can be a mouse, a keyboard, a touch screen device, or a sensing device, etc.

[0159] Those skilled in the art can understand that Figure 11 the structure shown in does not constitute a limitation on the electronic device 70, and it may include more or fewer components than shown in the figure, or combine certain components, or adopt different component arrangements.

[0160] In addition, the present disclosure also provides a computer-readable storage medium. The computer-readable storage medium includes instructions that, when executed by a processor of an electronic device, cause the electronic device to execute the method for generating image special effects as provided in the above embodiments.

[0161] In addition, the present disclosure also provides a computer program product. The computer program product includes instructions that, when running on a processor of an electronic device, cause the electronic device to execute the method for generating image special effects as provided in the above embodiments.

[0162] Those skilled in the art will readily conceive of other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure, which follow the general principles of the present disclosure and include known common knowledge or conventional technical means in the technical field not disclosed in the present disclosure. The specification and embodiments are only regarded as exemplary, and the true scope and spirit of the present disclosure are pointed out by the following claims.

[0163] It should be understood that the present disclosure is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present disclosure is only limited by the appended claims.

Claims

1. A method for generating an image special effect, characterized in that, it includes: Obtain multiple grid regions corresponding to the image to be processed, and determine multiple target pixel points in each grid region; Each target pixel point is within the action area of the central pixel point of each grid region; the action area is the area that affects the rotation of the multiple target pixel points around the central pixel point; For each target pixel point in each grid region, determine the sampling pixel point corresponding to each target pixel point; The sampling pixel point is the pixel point obtained by rotating each target pixel point around the central pixel point based on the rotation radius and rotation angle of each target pixel point; the rotation radius is the distance between each target pixel point and the central pixel point, and the rotation angle is positively correlated with the rotation radius; Fill the color of each target pixel point with the color of the corresponding sampling pixel point; The action area is circular, and determining multiple target pixel points in each grid region includes: For each non-central pixel point other than the central pixel point in each grid region, determine the target distance between each non-central pixel point and the central pixel point; When the target distance is less than or equal to the preset initial action radius corresponding to the central pixel point, determine each non-central pixel point as a target pixel point, and the preset initial action radius is the radius of the action area; The method further includes: Determine the rotation radius of each target pixel point, and determine the ratio of the rotation radius to the preset target action radius as the rotation angle coefficient of each target pixel point; the preset target action radius is negatively correlated with the size of the action area; Determine the rotation angle of each target pixel point according to the product of the rotation angle coefficient and the preset rotation intensity; the preset rotation intensity is used to adjust the size of the rotation angle, and the size of the rotation angle is positively correlated with the preset rotation intensity.

2. The method for generating an image special effect according to claim 1, characterized in that, the method further includes: When the preset initial action radius is greater than the minimum value from the central pixel point to the boundary of the image to be processed, delete the non-central pixel points located outside the boundary of the image to be processed from the multiple target pixel points.

3. The method for generating an image special effect according to claim 1, characterized in that, the method further includes: Determine the product of the preset initial action radius corresponding to the central pixel point and the preset radius coefficient, and use the product as the preset target action radius; the preset initial action radius is the radius of the action area, and the preset radius coefficient is negatively correlated with the resolution size of the image to be processed.

4. The method for generating an image special effect according to any one of claims 1-3, characterized in that, the determining the sampling pixel point corresponding to each target pixel point includes: Determine the sampling pixel points corresponding to each target pixel point according to the position of each target pixel point, the position of the central pixel point, the rotation radius of each target pixel point, and the rotation angle of each target pixel point.

5. The method for generating an image special effect according to claim 4, wherein, when each target pixel point rotates clockwise, the sampling pixel points corresponding to each target pixel point satisfy the following formula: (x ′ , y ′ ) = (dis.x * cosα + dis.y * sinα, -dis.x * sinα + dis.y * cosα); where (x′, y′) is the position of the sampling pixel point, dis.x is the horizontal distance between each target pixel point and the central pixel point, dis.y is the vertical distance between each target pixel point and the central pixel point, dis is the rotation radius of each pixel point, and α is the rotation angle of each target pixel point.

6. An apparatus for generating an image special effect, wherein, it includes an acquisition unit, a determination unit, and a processing unit; the acquisition unit is configured to acquire a plurality of grid regions corresponding to the image to be processed; the determination unit is configured to determine a plurality of target pixel points in each grid region; each target pixel point is located within the action region of the central pixel point of each grid region; the action region is the region that affects the rotation of the plurality of target pixel points around the central pixel point; the determination unit is further configured to, for each target pixel point in each grid region, determine the sampling pixel point corresponding to each target pixel point; the sampling pixel point is the pixel point obtained by rotating each target pixel point around the central pixel point based on the rotation radius and rotation angle of each target pixel point; the rotation radius is the distance between each target pixel point and the central pixel point, and the rotation angle is positively correlated with the rotation radius; the processing unit is configured to fill the color of each target pixel point with the color of the corresponding sampling pixel point; the action region is circular, and the determination unit is specifically configured to: for each non - central pixel point other than the central pixel point in each grid region, determine the target distance between each non - central pixel point and the central pixel point; when the target distance is less than or equal to the preset initial action radius corresponding to the central pixel point, determine each non - central pixel point as a target pixel point, and the preset initial action radius is the radius of the action region; the determination unit is further configured to: determine the rotation radius of each target pixel point, and determine the ratio of the rotation radius to the preset target action radius as the rotation angle coefficient of each target pixel point; the preset target action radius is negatively correlated with the size of the action region; determine the rotation angle of each target pixel point according to the product of the rotation angle coefficient and the preset rotation intensity; the preset rotation intensity is used to adjust the size of the rotation angle, and the size of the rotation angle is positively correlated with the preset rotation intensity.

7. The apparatus for generating an image special effect according to claim 6, wherein, The generating device further includes a deletion unit; The deletion unit is configured to delete non - central pixel points located outside the boundary of the to - be - processed image from the plurality of target pixel points when the preset initial action radius is greater than the minimum value from the central pixel point to the boundary of the to - be - processed image.

8. The generating device for image special effects according to claim 6, wherein, The determining unit is further configured to: Determine the product of the preset initial action radius corresponding to the central pixel point and a preset radius coefficient, and use the product as the preset target action radius; the preset initial action radius is the radius of the action area, and the preset radius coefficient is negatively correlated with the resolution of the to - be - processed image.

9. The generating device for image special effects according to any one of claims 6 - 8, wherein, The determining unit is specifically configured to: Determine the sampling pixel points corresponding to each target pixel point according to the position of each target pixel point, the position of the central pixel point, the rotation radius of each target pixel point, and the rotation angle of each target pixel point.

10. The generating device for image special effects according to claim 9, wherein, When each target pixel point rotates clockwise, the sampling pixel points corresponding to each target pixel point satisfy the following formula: (x ′ , y ′ ) = (dis.x * cosα + dis.y * sinα, -dis.x * sinα + dis.y * cosα); where (x′, y′) is the position of the sampling pixel point, dis.x is the horizontal distance between each target pixel point and the central pixel point, dis.y is the vertical distance between each target pixel point and the central pixel point, dis is the rotation radius of each pixel point, and α is the rotation angle of each target pixel point.

11. An electronic device, wherein, It includes: A processor; A memory for storing instructions executable by the processor; wherein, the processor is configured to execute the instructions to implement the image special effect generating method according to any one of claims 1 to 5.

12. A computer - readable storage medium, wherein, The computer - readable storage medium includes instructions; when the instructions are executed by a processor of an electronic device, the electronic device is caused to execute the image special effect generating method according to any one of claims 1 to 5.

13. A computer program product, wherein, The computer program product includes instructions, and when the instructions run on a processor of an electronic device, the electronic device is caused to execute the image special effect generating method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Image processing method and device and electronic equipment

    CN108447023A