WO2023174137A1 - Image processing method and apparatus, and computer device and storage medium - Google Patents

Image processing method and apparatus, and computer device and storage medium Download PDF

Info

Publication number
WO2023174137A1
WO2023174137A1 PCT/CN2023/080379 CN2023080379W WO2023174137A1 WO 2023174137 A1 WO2023174137 A1 WO 2023174137A1 CN 2023080379 W CN2023080379 W CN 2023080379W WO 2023174137 A1 WO2023174137 A1 WO 2023174137A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
processed
target
blur
pixel
Prior art date
Application number
PCT/CN2023/080379
Other languages
French (fr)
Chinese (zh)
Inventor
罗汉铭
Original Assignee
北京字跳网络技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京字跳网络技术有限公司 filed Critical 北京字跳网络技术有限公司
Publication of WO2023174137A1 publication Critical patent/WO2023174137A1/en

Links

Classifications

    • G06T3/04

Definitions

  • the present disclosure relates to the technical field of image processing, and specifically, to an image processing method, device, computer equipment, and storage medium.
  • Radial blur technology simulates the radial effect produced when shooting objects when the camera moves back and forth or when the camera rotates. For example, after performing radial blur processing on the original image as shown in Figure 1(a), a radial blurred image as shown in Figure 1(b) can be obtained.
  • the radially blurred image contains obvious ghosting.
  • the ghosting effect in the captured image is not obvious. Therefore, the ghost images appearing in the radial blur image will affect the simulation effect of the radial blur technology for the radial effect.
  • Embodiments of the present disclosure provide at least an image processing method, device, computer equipment, and storage medium.
  • an embodiment of the present disclosure provides an image processing method, including: acquiring an image to be processed, and determining the center position of the image to be processed and the pixels in a target area of the image to be processed; the target area is the area where the radial blur effect is to be generated; the center position is the generation center of the radial blur effect in the image to be processed; determine the radial direction vector of the pixel point relative to the center position, and based on the The radial direction vector determines the offset distance of the pixel point; the offset distance of the pixel point in different radial directions is different; the pixel point is blurred based on the offset distance to obtain the image to be processed blurred image.
  • determining the radial direction vector of the pixel point relative to the center position includes: determining the pixel coordinates of the center position in the image to be processed, and obtaining the first pixel coordinates, and determine the pixel coordinates of the pixel point in the image to be processed to obtain the second pixel coordinates; determine the radial direction vector based on the first pixel coordinates and the second pixel coordinates.
  • determining the offset distance of the pixel point based on the radial direction vector includes: determining target pixels in the pixel point with the same radial direction based on the radial direction vector. point; the radial direction is the direction of the radial direction vector; generate the same random value for the target pixel point through a preset random function; use the same random value as the offset of the target pixel point distance.
  • the radial direction vector includes a vector component in the transverse axis direction and a vector component in the longitudinal axis direction;
  • the offset distance includes: an offset component of the vector component in the transverse axis direction. and the offset component of the vector component in the longitudinal axis direction.
  • blurring the pixels based on the offset distance to obtain a blurred image of the image to be processed includes: obtaining a target blur preset for the pixels. distance; superimpose the target blur distance and the offset distance of the pixel point according to the preset superposition method to obtain the target offset distance; based on the target offset distance, blur the corresponding pixel point to obtain the target offset distance. Describe the blurred image of the image to be processed.
  • superposing the target blur distance and the offset distance of the pixel points according to a preset superposition method to obtain the target offset distance includes: according to a preset calculation method, The target blur distance and the offset distance of each pixel point are calculated to obtain the target offset distance, wherein the preset calculation method includes any of the following: multiplication and addition.
  • the method further includes: determining a target difference result in which the offset distance is within a preset difference range; and adding the target blur distance and the target blur distance in a preset superposition manner.
  • Superposing the offset distances of the pixel points to obtain the target offset distance includes: superimposing the target blur distance and the target difference result according to the preset superposition method to obtain the target offset distance.
  • determining the radial direction vector of the pixel point relative to the center position includes: determining the effect type of the radial blur effect, and based on the effect type in the Determine a target object in the image to be processed; determine the center position based on the target object, and determine the radial direction vector of the pixel point based on the center position.
  • the method further includes: when the effect type is a first type, obtaining a first blur parameter; wherein the first type is used to indicate the blur parameter of the image to be processed.
  • the effect type is a volumetric light and shadow effect; the first blur parameter includes a brightness parameter and/or a color parameter; and the blur processing of the pixel point based on the offset distance is performed to obtain a blurred image of the image to be processed, including : Perform blur processing on the pixel points based on the first blur parameter and the offset distance to obtain a blurred image of the image to be processed.
  • the method further includes: when the effect type is a second type, obtaining a second blur parameter; wherein the second type is used to indicate the blur parameter of the image to be processed.
  • the effect type is an image speed line adding effect.
  • the second blur parameter is used to indicate the adding density of the image speed line and/or the adding direction of the image speed line.
  • the image speed line is used to display the target object in the image to be processed. Movement effect; the blurring of the pixels based on the offset distance to obtain a blurred image of the image to be processed includes: blurring the pixels based on the second blur parameter and the offset distance. Perform blur processing to obtain a blurred image of the image to be processed.
  • an embodiment of the present disclosure provides an image processing device, including: an acquisition unit, used to acquire an image to be processed; a first determination unit, used to determine the center position of the image to be processed and the image to be processed. Pixel points in the target area; the target area is the area where the radial blur effect is to be generated; the center position is the generation center of the radial blur effect in the image to be processed; a second determination unit is used to determine the The radial direction vector of the pixel point relative to the center position, and the offset distance of the pixel point is determined based on the radial direction vector; the offset distances of pixel points in different radial directions are different; the blur processing unit , used to blur the pixel points based on the offset distance to obtain a blurred image of the image to be processed.
  • embodiments of the present disclosure also provide a computer device, including: a processor, a memory, and a bus.
  • the memory stores machine-readable instructions executable by the processor.
  • the processing communicates with the memory through a bus, the machine
  • the readable instructions are executed by the processor, the steps in the above-mentioned first aspect, or any possible implementation manner of the first aspect, are performed.
  • embodiments of the present disclosure also provide a computer-readable storage medium.
  • a computer program is stored on the computer-readable storage medium.
  • the computer program executes the above-mentioned first aspect, or any of the first aspects. steps in a possible implementation.
  • embodiments of the present disclosure also provide a computer program product.
  • the computer program product When the computer program product is run on a computer, the computer implements the above-mentioned first aspect, or any possible implementation manner of the first aspect. steps in.
  • the pixels in the target area in the image to be processed can be determined. Then, determine the center position of the image to be processed and the radial direction vector of the pixel point relative to the center position, and generate a corresponding offset distance for the pixel point based on the radial direction vector. Since the technical solution of the present disclosure is to generate different offset distances for pixels corresponding to different radial direction vectors, it can be achieved that pixels corresponding to the same abscissa have different offset distances in the horizontal axis direction, and the pixels corresponding to the same vertical coordinate can have different offset distances. The pixel points of the coordinates have different offset distances in the vertical axis direction. This effectively eliminates ghost images in blurred images to improve the blur effect of radial blur.
  • Figure 1(a) shows a schematic diagram of an original image to be processed
  • Figure 1(b) shows a schematic diagram of the effect of radial blur processing on the original image shown in Figure 1(a) through existing radial blur technology
  • Figure 2 shows another schematic diagram of the effect of existing radial blur technology
  • Figure 3 shows a flow chart of an image processing method provided by an embodiment of the present disclosure
  • Figure 4 shows a schematic diagram of the technical principle of an existing radial blur technology
  • Figure 5 shows a flowchart of a specific method for determining the radial direction + directional vector of each pixel in the image to be processed based on the center position in the image processing method provided by the embodiment of the present disclosure
  • Figure 6 shows a schematic diagram of the technical principles of an image processing method provided by an embodiment of the present disclosure
  • Figure 7 shows a sampling effect diagram after cyclic sampling processing of the radial blur image processed by the image processing method provided by the embodiment of the present disclosure through different sampling times;
  • Figure 8 shows a schematic diagram of an image processing device provided by an embodiment of the present disclosure
  • FIG. 9 shows a schematic diagram of a computer device provided by an embodiment of the present disclosure.
  • a and/or B can mean: A alone exists, A and B exist simultaneously, and B alone exists. situation.
  • at least one herein refers to any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, and C, which can mean including from A, Any one or more elements selected from the set composed of B and C.
  • radial blur technology simulates the radial effect produced when shooting objects when the camera moves back and forth or when the camera rotates. For example, after performing radial blur processing on the original image as shown in Figure 1(a), a radial blurred image as shown in Figure 1(b) can be obtained.
  • the radially blurred image contains obvious ghosting.
  • the ghosting effect in the captured image is not obvious. Therefore, the ghost images appearing in the radial blur image will affect the simulation effect of the radial blur technology for the radial effect.
  • the radial blur processing process can be repeated multiple times on the image. By repeating the radial blur processing multiple times, the ghosting can be diluted. However, as shown in Figure 2, there are still obvious ghosts in the radial blur image, and repeating the radial blur process multiple times will consume a lot of computing resources.
  • the blur offset process is usually performed on each pixel in the image using the same offset component.
  • the offset distance of pixel points corresponding to the same abscissa in the horizontal axis direction will remain consistent, and the offset distance of pixel points corresponding to the same ordinate coordinate in the vertical axis direction will remain consistent, so that the radial A very regular ghosting phenomenon is formed in the blurred image.
  • ghosting can be reduced through downsampling and upsampling, combined with multiple radial blurs.
  • the number of pixels in the image that need to be radially blurred can be reduced to achieve the effect of diluting ghosting.
  • this method still consumes a lot of computing resources, and the ghosting problem is still obvious.
  • embodiments of the present disclosure provide an image processing method, device, computer equipment, and storage medium.
  • the pixel points in the target area in the image to be processed can be determined, and then the radial direction vector corresponding to the center position of the pixel point is determined, and based on the radial direction vector Generate corresponding offset distances for pixels.
  • the technical solution of the present disclosure is to generate different offset distances for pixels corresponding to different radial direction vectors, it can be achieved that pixels corresponding to the same abscissa have different offset distances in the horizontal axis direction, and the pixels corresponding to the same vertical coordinate can have different offset distances.
  • the pixel points of the coordinates have different offset distances in the vertical axis direction. This effectively eliminates ghost images in blurred images to improve the blur effect of radial blur.
  • an image processing method disclosed in the embodiment of the present disclosure is The method will be introduced in detail.
  • the execution subject of the image processing method provided by the embodiment of the present disclosure is generally a computer device with certain computing capabilities.
  • FIG. 3 a flow chart of an image processing method provided by an embodiment of the present disclosure is shown.
  • the method includes steps S301 to S305, wherein:
  • S301 Obtain the image to be processed, and determine the center position of the image to be processed and the pixels in the target area in the image to be processed; the target area is the area where the radial blur effect is to be generated; the center position is The center of generation of the radial blur effect in the image to be processed.
  • the generation center of the radial blur effect in the image to be processed is first determined, that is, the center position; then, the pixel points in the target area in the image to be processed are determined.
  • the generation center (ie, the center position) of the radial blur effect in the image to be processed can be understood as a pixel in the image to be processed.
  • the center position may be a pixel manually marked by the user in advance in the image to be processed.
  • the center position may be determined in response to an annotation operation for the image to be processed and based on an annotation position corresponding to the annotation operation.
  • it can also be pixels automatically selected in the image to be processed according to preset selection rules. For example, the above-mentioned center position is determined based on the effect type of the radial blur effect corresponding to the image to be processed.
  • a matching target object can be determined in the image to be processed based on the effect type, and then the above-mentioned center position can be determined based on the position of the target object.
  • the center position of the matching target object is determined as the center position. If the number of matching target objects is detected to be multiple, the target object may be specified among the multiple matching target objects, and the center position of the specified target object may be determined as the above-mentioned center position.
  • the image center position of the image to be processed can also be determined as the center position.
  • the target area may be the entire image area in the image to be processed, or may be a partial image area in the image to be processed.
  • the target area can be determined in the image to be processed based on the following parameters: effect type, Parameters such as area information (for example, area size and area position), the position (or center position) of the target object in the image to be processed, etc. preset by the user.
  • effect type Parameters such as area information (for example, area size and area position), the position (or center position) of the target object in the image to be processed, etc. preset by the user.
  • the target object in the image to be processed is the light source.
  • the target area is determined in the image to be processed based on the position of the light source and the area size preset by the user.
  • S303 Determine the radial direction vector of the pixel point relative to the center position, and determine the offset distance of the pixel point based on the radial direction vector; wherein, the offset distance of the pixel point in different radial directions different.
  • S305 Perform blur processing on each pixel point based on the offset distance to obtain a blurred image of the image to be processed.
  • the radial direction vector includes: a direction and a module of the vector.
  • the direction in the radial direction vector is the direction in which the central position points to the corresponding pixel point (that is, the radial direction)
  • the modulus in the radial direction vector is the distance between the central position and the corresponding pixel point.
  • a rectangular coordinate system can be constructed using the center position as the coordinate origin, in which the horizontal axis of the rectangular coordinate system is marked as the U axis, and the vertical axis of the rectangular coordinate system is marked as the V axis.
  • a pixel point P0 (U0, V0), P1 (U1, V1), P2 (U2, V2) can be randomly selected.
  • the positions between P0, P1 and P2 can be as shown in Figure 4 Show.
  • an offset d is set for each pixel.
  • the offset distance of each pixel in the U-axis direction and the V-axis direction can be described as:
  • d*float2(U0V0-0.5) can be described by the formula as d*(U 0 -0.5,V 0 -0.5);
  • d* float2(U1V1-0.5) can be described by the formula as d*(U 1 -0.5,V 1 -0.5);
  • d*float2(U2V2-0.5) can be described by the formula as d*(U 2 -0.5,V 2 -0.5 ).
  • different offset distances are determined for pixel points corresponding to different radial directions. For example, for the pixel points P0, P1 and P2, since the radial directions corresponding to the pixel points P0, P1 and P2 are different, different offset distances can be determined for the pixel points P0, P1 and P2 respectively. Based on the offset, When the pixel points P0, P1 and P2 are offset by distance, even if the abscissas of the pixel points P0, P1 and P2 are the same, the offset distances of the pixel points P0, P1 and P2 in the U direction will not be the same.
  • the pixel points in the target area in the image to be processed can be determined, and then the radial direction vector of the pixel point relative to the center position is determined, and based on the radial direction vector Generate corresponding offset distance for each pixel. Since the technical solution of the present disclosure is to generate different offset distances for pixels corresponding to different radial direction vectors, it can be achieved that pixels corresponding to the same abscissa have different offset distances in the horizontal axis direction, and the pixels corresponding to the same vertical coordinate can have different offset distances. The pixel points of the coordinates have different offset distances in the vertical axis direction, thereby effectively eliminating ghosts in the blurred image and improving the blur effect of radial blur.
  • step S303 determining the radial direction vector of the pixel point relative to the center position specifically includes the following steps:
  • Step S501 Determine the pixel coordinates of the center position in the image to be processed to obtain the first pixel coordinates, and determine the pixel coordinates of the pixel point in the image to be processed to obtain the second pixel coordinates;
  • Step S502 Determine the radial direction vector based on the first pixel coordinate and the second pixel coordinate.
  • the central position after the central position is determined, it can be determined that the central position is to be Process the pixel coordinates in the image to obtain the first pixel coordinates.
  • the first pixel coordinates can be recorded as (U1, V1).
  • Pixel coordinates, for example, the second pixel coordinates can be recorded as (U2, V2).
  • the first pixel coordinates and the second pixel coordinates can be calculated to determine the radial direction vector.
  • the vector AB can be determined as the above-mentioned radial direction vector.
  • the above-mentioned radial direction vector (that is, vector AB) can be expressed as: float2(U2-U1, V2-V1).
  • the amount of data processing can be simplified, and the computing resources of the computer device can be saved. Improve image processing efficiency.
  • step S303: determining the offset distance of the pixel point based on the radial direction vector specifically includes the following steps:
  • Step S11 Unitize the radial direction vector
  • Step S12 Determine the offset distance of each pixel point according to the radial direction vector of the unitization process.
  • the radial direction vector can be normalized based on a normalization function, where the normalization function can be normalize.
  • the unitization process of the radial direction vector can be described as the following process:
  • step S303: determining the offset distance of the pixel point based on the radial direction vector specifically includes the following steps:
  • Step S21 Determine target pixel points with the same radial direction among the pixel points based on the radial direction vector; the radial direction is the direction of the radial direction vector;
  • Step S22 Generate the same random value for the target pixel through a preset random function
  • Step S23 Use the same random value as the offset distance of the target pixel point.
  • the processing process can be described as:
  • An offset value is randomly generated for each pixel in the image, where the offset values corresponding to different pixels are different.
  • the offset processing can be performed pixel by pixel, that is, the offset processing of each pixel is achieved by superimposing the offset value of each pixel.
  • this processing method can better avoid ghosting because the offset values are different pixel by pixel, but it also leads to the occurrence of a lot of noise because of the offset pixel by pixel. Therefore, it is necessary to cooperate with the TAA denoising algorithm to denoise the radial blurred image.
  • the radial blur processing of images by combining the dithering algorithm and the TAA noise reduction algorithm consumes a large amount of computing resources and is not conducive to the stable operation of computer equipment.
  • the corresponding same radial direction vector can be determined among multiple pixel points based on the determined radial direction vector. For example, multiple groups of pixels can be determined, and each group of pixels corresponds to target pixels in the same radial direction.
  • the same random value can be generated for each group of pixels through the preset random function random.
  • generating a random value can be implemented based on the following formula:
  • dirNormal represents the radial direction vector (or the radial direction vector of the above-mentioned unitization process).
  • float2ditherDir represents a random value generated based on the radial direction vector.
  • the random value can be determined as the offset distance of the target pixel point.
  • At least one numerical region can be determined first, and then the same random numerical value can be generated for each group of pixels within the numerical interval through a preset random function.
  • the above-mentioned at least one numerical area can be determined based on the effect type, or the user can set at least one numerical area in advance. This disclosure does not specifically limit the setting method of the numerical area.
  • the above-mentioned radial direction vector includes a vector component in the horizontal axis direction and a vector component in the longitudinal axis direction.
  • the radial direction vector (the above vector AB) float2(U2-U1, V2-V1), in this radial direction vector, contains the vector component "U2-U1" in the horizontal axis direction, and the vector containing the vertical axis direction Component "V2-V1".
  • generating the same offset distance for the target pixel point through a preset random function includes: an offset component of the vector component in the horizontal axis direction and an offset component of the vector component in the vertical axis direction.
  • the random value can be determined as an offset component of the vector component in the horizontal axis direction and an offset component of the vector component in the vertical axis direction respectively.
  • offset processing can be performed on each pixel point based on the offset distance. After the processing, the to-be-used pixel point is obtained. Process blurry images of images.
  • step S305 blurring the pixel points based on the offset distance to obtain a blurred image of the image to be processed, specifically includes the following steps:
  • Step S3051 Obtain the target blur distance set in advance for the pixel
  • Step S3052 Superimpose the target blur distance and the offset distance of the pixel point according to a preset superposition method to obtain the target offset distance;
  • Step S3053 Based on the target offset distance, blur the corresponding pixel points to obtain to the blurred image of the image to be processed.
  • the same target blur distance can be set in advance for each pixel in the target area.
  • the target blur distance here includes the blur distance component of the vector component in the horizontal axis direction and the vector in the vertical axis direction.
  • the fuzzy distance component of the component may be the offset distance d*float2(U1-U0, V1-V0) in the above embodiment.
  • the target blur distance and the offset distance can be superimposed according to the preset superposition method to obtain the target offset distance, and the corresponding pixel points can be offset according to the target offset distance.
  • a blurred image of the image to be processed is obtained. For example, a blurred image as shown in Figure 6 can be obtained.
  • the above step superimpose the target blur distance and the offset distance of the pixel point according to a preset superposition method to obtain the target offset distance, which specifically includes the following steps:
  • the target blur distance and the offset distance of each pixel point are calculated to obtain the target offset distance, wherein the preset calculation method includes any of the following: multiplication, addition.
  • the target blur distance and the offset distance of each pixel can be multiplied or added to obtain the target offset distance.
  • the blur distance of the above target is: d*float2(U1-U0, V1-V0), and the offset distance of each pixel above is float2ditherDir.
  • the target blur distance and the offset distance of each pixel can be calculated through the following formula:
  • (U1, V1) is the pixel coordinate of each pixel point
  • (U0, V0) is the pixel coordinate of the center position.
  • the target blur distance and each of the Before the offset distances of pixels are superimposed the offset distance of each pixel can also be difference processed through the difference function.
  • the specific difference processing process can be described as follows:
  • lerp is the above-mentioned preset difference function.
  • the conventional expression of lerp is: lerp (from, to, value).
  • the preset difference function lerp can be understood as being within the preset difference range (from, to). Perform difference processing on the value value, where the value value is "ditherDir" and the preset difference range (from, to) is (1, 1.5).
  • the target blur distance and the offset distance of the pixel are superimposed according to the preset superposition method.
  • the target blur distance can be superimposed according to the preset superposition method.
  • the target blur distance and the target difference result are superimposed to obtain the target offset distance.
  • the target fuzzy distance and target difference results can be multiplied, and the multiplication result is determined as the target offset distance.
  • the specific calculation formula can be described as:
  • each pixel point can be offset based on the target offset distance, and after the processing, a blurred image of the image to be processed is obtained.
  • the same offset distance is determined for pixel points corresponding to the same radial direction, and different offset distances are determined for pixel points corresponding to different radial directions. Not only can it effectively alleviate the ghosting problem of existing radial blur technology, it can also ensure the continuity of pixels in the same direction, and can also reduce noise reduction steps.
  • the offset distance in each radial direction can be set randomly. Therefore, when an appropriate offset distance is set, a good image quality can be generated with a very small number of radial blur samplings.
  • the radial blur effect greatly improves the image processing performance and enhances the applicability of radial blur technology. For example, as shown in Figure 7, from left to right are the effects of radially cyclic sampling 10 times, 5 times and 3 times on the radial blur image, completely avoiding the sense of repetition.
  • step S303 determines the radial direction vector of the pixel point relative to the center position, specifically including the following steps:
  • S31 Determine the effect type of the radial blur effect, and based on the effect type, perform Determine the target object in the processed image;
  • S32 Determine the center position based on the target object, and determine the radial direction vector of the pixel point based on the center position.
  • the effect type of the radial blur effect of the image to be processed may be a type preset by the user.
  • a user can enter an effect type through a computer device.
  • the effect type of the radial blur effect can include any of the following: volumetric light and shadow effects, image speed line addition effects.
  • Radial blur effects for different effect types can correspond to different target objects in the image to be processed.
  • the corresponding target object in the image to be processed can be a light source, such as the sun, a lamp, etc.
  • the corresponding target object in the image to be processed can be any object that needs to express a movement effect.
  • the image speed line can also be called a line.
  • the image speed line is used to express the movement effect of the target object in the image to be processed, for example, movement trajectory and/or movement direction and other information.
  • the target object can be determined based on the effect type, and the center position can be determined based on the target object.
  • the center point of the target object can be determined as the center position.
  • the radial direction vector of the pixel point can be determined based on the center position.
  • the method can also obtain a first blur parameter; wherein the first type is used to indicate the effect type of the image to be processed. It is a volumetric light and shadow effect; the first blur parameter includes a brightness parameter and/or a color parameter.
  • performing blur processing on the pixels based on the offset distance in step S305 to obtain a blurred image of the image to be processed includes: based on the first blur parameter and the offset distance The pixel points are blurred to obtain a blurred image of the image to be processed.
  • the above-mentioned first type is used to indicate that the effect type of the image to be processed is a volumetric light and shadow effect.
  • the volumetric light and shadow effect can be reflected by combining the light and dark threshold (ie, brightness parameter) and color adjustment (ie, color parameter), as well as the image processing method provided by the embodiment of the present disclosure.
  • the light source may be determined in the image to be processed. If multiple light sources (for example, multiple light bulbs) are determined, at this time, the location in the foreground area can be determined among the multiple light sources.
  • the light source of the domain is the target object; or, the user can specify one or more light sources among multiple light sources as the above target object according to actual needs.
  • the center point of the light source can be determined as the center position. Then, the radial direction vector of each pixel in the target area relative to the center position can be determined based on the center position. Then the corresponding offset distance is determined based on the radial direction vector.
  • corresponding offset distances can be randomly generated in the numerical area for target pixels corresponding to the same radial direction.
  • the pixel points can be blurred based on the first blur parameter and the offset distance to obtain a blurred image of the image to be processed.
  • the pixel points can be blurred in the manner described in the above steps S3051 to S3053, thereby obtaining an initial blurred image.
  • brightness adjustment and/or color adjustment can also be performed on the initial blurred image based on the first blur parameter, thereby obtaining a blurred image of the image to be processed.
  • the method can also obtain a second blur parameter; wherein the second type is used to indicate the effect type of the image to be processed.
  • the second blur parameter is used to indicate the adding density and/or the adding direction of the image speed line, which is used to display the movement effect of the target object in the image to be processed.
  • performing blur processing on the pixels based on the offset distance in the above step S305 to obtain a blurred image of the image to be processed includes: based on the second blur parameter and the offset distance The pixel points are blurred to obtain a blurred image of the image to be processed.
  • the above-mentioned second type is used to indicate that the effect type of the image to be processed is the image speed line adding effect, which can also be called: cartoon style screen line (speed line) simulation effect.
  • effects such as line arrangement (speed lines) in comic style can be simulated through open line density (directional random density) and the image processing method provided by the embodiments of the present disclosure.
  • the target object that needs to display the movement effect can be determined in the image to be processed. If multiple target objects are determined, the target object located in the foreground area can be determined among the multiple target objects; or, the user can specify one or more target objects among the multiple target objects according to actual needs.
  • the center point of the target object can be determined as the center position.
  • the target area can be determined in the image to be processed based on the second blur parameter, and the pixel points to be shifted can be determined in the target area.
  • the pixels to be shifted can be all the pixels in the target area, or some of the pixels.
  • a radial direction vector of the pixel point to be offset relative to the center position may be determined based on the central position, and then a corresponding offset distance may be determined based on the radial direction vector.
  • corresponding offset distances can be generated in the numerical area for pixel points to be offset corresponding to the same radial direction. After that, the pixels to be offset can be offset based on the offset distance to obtain a blurred image of the image to be processed.
  • the pixel points can be offset in the manner described in the above steps S3051 to S3053, thereby obtaining an initial blurred image.
  • the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process.
  • the specific execution order of each step should be based on its function and possible The internal logic is determined.
  • the embodiments of the present disclosure also provide an image processing device corresponding to the image processing method. Since the principle of solving the problem of the device in the embodiment of the present disclosure is similar to the above-mentioned image processing method in the embodiment of the present disclosure, the implementation of the device Please refer to the implementation of the method, and the repeated parts will not be repeated.
  • the device includes: an acquisition unit 10, a first determination unit 20, a second determination unit 30, and an offset processing 40; wherein,
  • Acquisition unit 10 used to acquire images to be processed
  • the first determination unit 20 is used to determine the center position of the image to be processed and the pixel points in the target area of the image to be processed; the target area is the area where the radial blur effect is to be generated; the center position is the Describes the generation center of the radial blur effect in the image to be processed;
  • the second determination unit 30 is used to determine the radial direction vector of the pixel point relative to the center position, and determine the offset distance of the pixel point based on the radial direction vector; pixel points in different radial directions The offset distance is different;
  • the blur processing unit 40 is configured to perform blur processing on the pixel points based on the offset distance to obtain a blurred image of the image to be processed.
  • the pixel points in the target area in the image to be processed can be determined, and then the radial direction vector of the pixel point relative to the center position is determined, and based on A corresponding offset distance is generated for each pixel based on the radial direction vector. Since the technical solution of the present disclosure is to generate different offset distances for pixels corresponding to different radial direction vectors, it can be achieved that pixels corresponding to the same abscissa have different offset distances in the horizontal axis direction, and the pixels corresponding to the same vertical coordinate can have different offset distances. The pixel points of the coordinates have different offset distances in the vertical axis direction, thereby effectively eliminating ghosts in the blurred image and improving the blur effect of radial blur.
  • the second determination unit is further configured to: determine the pixel coordinates of the center position in the image to be processed, obtain the first pixel coordinates, and determine the position of the pixel point in the image to be processed.
  • the pixel coordinates in the image are used to obtain the second pixel coordinates; based on the first pixel coordinates and the second pixel coordinates, the radial direction vector is determined.
  • the second determination unit is further configured to: determine target pixel points in the pixel points with the same radial direction based on the radial direction vector; the radial direction is the radial direction The direction of the vector; generate the same random value for the target pixel point through a preset random function; use the same random value as the offset distance of the target pixel point.
  • the radial direction vector includes a vector component in the transverse axis direction and a vector component in the longitudinal axis direction;
  • the offset distance includes: an offset component of the vector component in the transverse axis direction and The offset component of the vector component in the longitudinal axis direction.
  • the blur processing unit is further configured to: obtain a target blur distance preset for the pixel; and combine the target blur distance and the offset distance of the pixel according to a preset superposition method. Superposition is performed to obtain the target offset distance; based on the target offset distance, the corresponding pixel points are blurred to obtain a blurred image of the image to be processed.
  • the blur processing unit is further configured to: calculate the target blur distance and the offset distance of each pixel point according to a preset calculation method to obtain the target offset distance,
  • the preset calculation method includes any of the following: multiplication and addition.
  • the device is further configured to: determine a target difference result in which the offset distance is within a preset difference range; and the offset unit is further configured to: add all the offset values according to the preset superposition method. The target fuzzy distance and the target difference result are superimposed to obtain the target offset distance.
  • the first determination unit is further configured to: determine the effect type of the radial blur effect, and determine the target object in the image to be processed based on the effect type; based on the target object Determine the center position, and determine the radial direction of the pixel based on the center position to vector.
  • the device is further configured to: obtain a first blur parameter when the effect type is a first type; wherein the first type is used to indicate the effect of the image to be processed
  • the type is volumetric light and shadow effect;
  • the first blur parameter includes a brightness parameter and/or a color parameter;
  • a blur processing unit further configured to: blur the pixel based on the first blur parameter and the offset distance , obtain the blurred image of the image to be processed.
  • the device is further configured to: obtain a second blur parameter when the effect type is a second type; wherein the second type is used to indicate the effect of the image to be processed.
  • the type is image speed line adding effect.
  • the second blur parameter is used to indicate the adding density and/or the adding direction of the image speed line.
  • the image speed line is used to display the movement of the target object in the image to be processed.
  • Effect a blur processing unit, further configured to: blur the pixel points based on the second blur parameter and the offset distance to obtain a blurred image of the image to be processed.
  • an embodiment of the present disclosure also provides a computer device 900.
  • Figure 9 is a schematic structural diagram of the computer device 900 provided by an embodiment of the present disclosure, it includes:
  • the processor 91 and the memory 92 communicate through the bus 93, so that The processor 91 executes the following instructions:
  • the image to be processed and determine the center position of the image to be processed and the pixels in the target area of the image to be processed; the target area is the area where the radial blur effect is to be generated; the center position is the area to be processed.
  • Processing the generation center of the radial blur effect in the image determining the radial direction vector of the pixel point relative to the center position, and determining the offset distance of the pixel point based on the radial direction vector; different radial directions
  • the offset distances of the pixel points are different; the pixel points are blurred based on the offset distance to obtain a blurred image of the image to be processed.
  • the instructions of the processor 91 also include:
  • the radial direction vector is determined based on the first pixel coordinate and the second pixel coordinate.
  • the instructions of the processor 91 also include:
  • Target pixel points with the same radial direction among the pixel points are determined based on the radial direction vector;
  • the radial direction is the direction of the radial direction vector;
  • the same random value is used as the offset distance of the target pixel point.
  • the instructions of the processor 91 also include:
  • the radial direction vector includes a vector component in the transverse axis direction and a vector component in the longitudinal axis direction; the offset distance includes: an offset component of the vector component in the transverse axis direction and a vector component in the longitudinal axis direction. offset component.
  • the instructions of the processor 91 also include:
  • the corresponding pixel points are blurred to obtain a blurred image of the image to be processed.
  • the instructions of the processor 91 also include:
  • the target blur distance and the offset distance of each pixel point are calculated to obtain the target offset distance, wherein the preset calculation method includes any of the following: multiplication, addition.
  • the instructions of the processor 91 also include:
  • the target blur distance and the target difference result are superimposed according to the preset superposition method to obtain the target offset distance.
  • the instructions of the processor 91 also include:
  • the center position is determined based on the target object, and the radial direction vector of the pixel point is determined based on the center position.
  • the instructions of the processor 91 also include:
  • a first blur parameter is obtained; wherein the first type is used to indicate that the effect type of the image to be processed is a volumetric light and shadow effect; the first blur parameter includes brightness parameters and/or color parameters; perform blur processing on the pixel points based on the first blur parameter and the offset distance to obtain a blurred image of the image to be processed.
  • the instructions of the processor 91 also include:
  • the effect type is the second type
  • obtain a second blur parameter wherein the second type is used to indicate that the effect type of the image to be processed is an image speed line adding effect, and the second blur parameter Used to indicate the added density of the image speed line and/or the added direction of the image speed line, which is used to display the movement effect of the target object in the image to be processed; based on the second blur parameter and the offset The distance is used to blur the pixel points to obtain a blurred image of the image to be processed.
  • Embodiments of the present disclosure also provide a computer-readable storage medium.
  • the computer-readable storage medium stores a computer program. When the computer program is run by a processor, the steps of the image processing method described in the above method embodiment are executed.
  • the storage medium may be a volatile or non-volatile computer-readable storage medium.
  • Embodiments of the present disclosure also provide a computer program product.
  • the computer program product carries program code.
  • the instructions included in the program code can be used to execute the steps of the image processing method described in the above method embodiment. For details, please refer to the above method. The embodiments will not be described again here.
  • the above-mentioned computer program product can be specifically implemented by hardware, software or a combination thereof.
  • the computer program product is embodied as a computer storage medium.
  • the computer program product is embodied as a software product, such as a Software Development Kit (SDK), etc. wait.
  • SDK Software Development Kit
  • the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or they may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in various embodiments of the present disclosure may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor.
  • the technical solution of the embodiments of the present disclosure is essentially or contributes to the existing technology or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , including several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present disclosure.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program code. .

Landscapes

  • Image Processing (AREA)

Abstract

An image processing method and apparatus, and a computer device and a storage medium. The method comprises: acquiring an image to be processed, and determining a central position of said image and a pixel point in a target area of said image, wherein the target area is an area where a radial blur effect is to be generated, and the central position is a generation center of the radial blur effect in said image (S301); determining a radial direction vector of the pixel point relative to the central position, and determining an offset distance of the pixel point on the basis of the radial direction vector, wherein offset distances of pixel points in different radial directions are different (S303); and performing blurring processing on the pixel point on the basis of the offset distance, so as to obtain a blurred image of said image (S305).

Description

一种图像处理方法、装置、计算机设备以及存储介质An image processing method, device, computer equipment and storage medium
本公开要求于2022年03月17日提交中国国家知识产权局、申请号为202210264780.5、发明名称为“一种图像处理方法、装置、计算机设备以及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本公开中。This disclosure requires the priority of the Chinese patent application submitted to the State Intellectual Property Office of China on March 17, 2022, with the application number 202210264780.5 and the invention title "an image processing method, device, computer equipment and storage medium", all of which The contents are incorporated by reference into this disclosure.
技术领域Technical field
本公开涉及图像处理的技术领域,具体而言,涉及一种图像处理方法、装置、计算机设备以及存储介质。The present disclosure relates to the technical field of image processing, and specifically, to an image processing method, device, computer equipment, and storage medium.
背景技术Background technique
径向模糊技术为模拟相机前后移动或者相机旋转时拍摄物体时所产生的放射状的效果。例如,在对如图1(a)所示的原始图像进行径向模糊处理之后,可以得到如图1(b)所示的径向模糊图像。Radial blur technology simulates the radial effect produced when shooting objects when the camera moves back and forth or when the camera rotates. For example, after performing radial blur processing on the original image as shown in Figure 1(a), a radial blurred image as shown in Figure 1(b) can be obtained.
如图1(b)所示,在通过现有的径向模糊技术对图像进行径向模糊处理之后,在径向模糊图像中包含很明显的重影。然而,相机在前后移动或者旋转状态下对物体进行拍摄时,所拍摄到的图像中的重影效果并不明显。因此,径向模糊图像中所出现的重影将影响径向模糊技术针对放射状效果的模拟效果。As shown in Figure 1(b), after the image is radially blurred through the existing radial blur technology, the radially blurred image contains obvious ghosting. However, when the camera moves forward or backward or rotates to capture an object, the ghosting effect in the captured image is not obvious. Therefore, the ghost images appearing in the radial blur image will affect the simulation effect of the radial blur technology for the radial effect.
发明内容Contents of the invention
本公开实施例至少提供一种图像处理方法、装置、计算机设备以及存储介质。Embodiments of the present disclosure provide at least an image processing method, device, computer equipment, and storage medium.
第一方面,本公开实施例提供了一种图像处理方法,包括:获取待处理图像,并确定所述待处理图像的中心位置和所述待处理图像目标区域内的像素点;所述目标区域为待生成径向模糊效果的区域;所述中心位置为所述待处理图像中径向模糊效果的生成中心;确定所述像素点相对于所述中心位置的径向方向向量,并基于所述径向方向向量确定所述像素点的偏移距离;不同径向方向的像素点的所述偏移距离不同;基于所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像。 In a first aspect, an embodiment of the present disclosure provides an image processing method, including: acquiring an image to be processed, and determining the center position of the image to be processed and the pixels in a target area of the image to be processed; the target area is the area where the radial blur effect is to be generated; the center position is the generation center of the radial blur effect in the image to be processed; determine the radial direction vector of the pixel point relative to the center position, and based on the The radial direction vector determines the offset distance of the pixel point; the offset distance of the pixel point in different radial directions is different; the pixel point is blurred based on the offset distance to obtain the image to be processed blurred image.
一种可选的实施方式中,所述确定所述像素点相对于所述中心位置的径向方向向量,包括:确定所述中心位置在所述待处理图像中的像素坐标,得到第一像素坐标,并确定所述像素点在所述待处理图像中的像素坐标,得到第二像素坐标;基于所述第一像素坐标和所述第二像素坐标,确定所述径向方向向量。In an optional implementation, determining the radial direction vector of the pixel point relative to the center position includes: determining the pixel coordinates of the center position in the image to be processed, and obtaining the first pixel coordinates, and determine the pixel coordinates of the pixel point in the image to be processed to obtain the second pixel coordinates; determine the radial direction vector based on the first pixel coordinates and the second pixel coordinates.
一种可选的实施方式中,所述基于所述径向方向向量确定所述像素点的偏移距离,包括:基于所述径向方向向量确定所述像素点中径向方向相同的目标像素点;所述径向方向为所述径向方向向量的方向;通过预设随机函数为所述目标像素点生成相同的随机数值;将所述相同的随机数值作为所述目标像素点的偏移距离。In an optional implementation, determining the offset distance of the pixel point based on the radial direction vector includes: determining target pixels in the pixel point with the same radial direction based on the radial direction vector. point; the radial direction is the direction of the radial direction vector; generate the same random value for the target pixel point through a preset random function; use the same random value as the offset of the target pixel point distance.
一种可选的实施方式中,所述径向方向向量中包含横轴方向的向量分量和纵轴方向的向量分量;所述偏移距离包括:所述横轴方向的向量分量的偏移分量和所述纵轴方向的向量分量的偏移分量。In an optional implementation, the radial direction vector includes a vector component in the transverse axis direction and a vector component in the longitudinal axis direction; the offset distance includes: an offset component of the vector component in the transverse axis direction. and the offset component of the vector component in the longitudinal axis direction.
一种可选的实施方式中,所述基于所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像,包括:获取预先为所述像素点设定的目标模糊距离;按照预设叠加方式将所述目标模糊距离和所述像素点的偏移距离进行叠加,得到目标偏移距离;基于所述目标偏移距离,对相应的像素点进行模糊处理,得到所述待处理图像的模糊图像。In an optional implementation, blurring the pixels based on the offset distance to obtain a blurred image of the image to be processed includes: obtaining a target blur preset for the pixels. distance; superimpose the target blur distance and the offset distance of the pixel point according to the preset superposition method to obtain the target offset distance; based on the target offset distance, blur the corresponding pixel point to obtain the target offset distance. Describe the blurred image of the image to be processed.
一种可选的实施方式中,所述按照预设叠加方式将所述目标模糊距离和所述像素点的偏移距离进行叠加,得到目标偏移距离,包括:按照预设计算方式,对所述目标模糊距离和每个所述像素点的偏移距离进行计算,得到所述目标偏移距离,其中,所述预设计算方式包括以下任一种:乘法、加法。In an optional implementation, superposing the target blur distance and the offset distance of the pixel points according to a preset superposition method to obtain the target offset distance includes: according to a preset calculation method, The target blur distance and the offset distance of each pixel point are calculated to obtain the target offset distance, wherein the preset calculation method includes any of the following: multiplication and addition.
一种可选的实施方式中,所述方法还包括:确定所述偏移距离在预设差值范围内的目标差值结果;所述按照预设叠加方式将所述目标模糊距离和所述像素点的偏移距离进行叠加,得到目标偏移距离包括:按照所述预设叠加方式将所述目标模糊距离和所述目标差值结果进行叠加,得到目标偏移距离。 In an optional implementation, the method further includes: determining a target difference result in which the offset distance is within a preset difference range; and adding the target blur distance and the target blur distance in a preset superposition manner. Superposing the offset distances of the pixel points to obtain the target offset distance includes: superimposing the target blur distance and the target difference result according to the preset superposition method to obtain the target offset distance.
一种可选的实施方式中,所述确定所述像素点相对于所述中心位置的径向方向向量,包括:确定所述径向模糊效果的效果类型,并基于所述效果类型在所述待处理图像中确定目标对象;基于所述目标对象确定所述中心位置,并基于所述中心位置确定所述像素点的径向方向向量。In an optional implementation, determining the radial direction vector of the pixel point relative to the center position includes: determining the effect type of the radial blur effect, and based on the effect type in the Determine a target object in the image to be processed; determine the center position based on the target object, and determine the radial direction vector of the pixel point based on the center position.
一种可选的实施方式中,所述方法还包括:在所述效果类型为第一类型的情况下,获取第一模糊参数;其中,所述第一类型用于指示所述待处理图像的效果类型为体积光影效果;所述第一模糊参数包括亮度参数和/或颜色参数;所述基于所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像,包括:基于所述第一模糊参数和所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像。In an optional implementation, the method further includes: when the effect type is a first type, obtaining a first blur parameter; wherein the first type is used to indicate the blur parameter of the image to be processed. The effect type is a volumetric light and shadow effect; the first blur parameter includes a brightness parameter and/or a color parameter; and the blur processing of the pixel point based on the offset distance is performed to obtain a blurred image of the image to be processed, including : Perform blur processing on the pixel points based on the first blur parameter and the offset distance to obtain a blurred image of the image to be processed.
一种可选的实施方式中,所述方法还包括:在所述效果类型为第二类型的情况下,获取第二模糊参数;其中,所述第二类型用于指示所述待处理图像的效果类型为图像速度线添加效果,所述第二模糊参数用于指示图像速度线的添加密度和/或图像速度线的添加方向,所述图像速度线用于在待处理图像中显示目标对象的移动效果;所述基于所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像,包括:基于所述第二模糊参数和所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像。In an optional implementation, the method further includes: when the effect type is a second type, obtaining a second blur parameter; wherein the second type is used to indicate the blur parameter of the image to be processed. The effect type is an image speed line adding effect. The second blur parameter is used to indicate the adding density of the image speed line and/or the adding direction of the image speed line. The image speed line is used to display the target object in the image to be processed. Movement effect; the blurring of the pixels based on the offset distance to obtain a blurred image of the image to be processed includes: blurring the pixels based on the second blur parameter and the offset distance. Perform blur processing to obtain a blurred image of the image to be processed.
第二方面,本公开实施例提供了一种图像处理装置,包括:获取单元,用于获取待处理图像;第一确定单元,用于确定所述待处理图像的中心位置和所述待处理图像目标区域内的像素点;所述目标区域为待生成径向模糊效果的区域;所述中心位置为所述待处理图像中径向模糊效果的生成中心;第二确定单元,用于确定所述像素点相对于所述中心位置的径向方向向量,并基于所述径向方向向量确定所述像素点的偏移距离;不同径向方向的像素点的所述偏移距离不同;模糊处理单元,用于基于所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像。In a second aspect, an embodiment of the present disclosure provides an image processing device, including: an acquisition unit, used to acquire an image to be processed; a first determination unit, used to determine the center position of the image to be processed and the image to be processed. Pixel points in the target area; the target area is the area where the radial blur effect is to be generated; the center position is the generation center of the radial blur effect in the image to be processed; a second determination unit is used to determine the The radial direction vector of the pixel point relative to the center position, and the offset distance of the pixel point is determined based on the radial direction vector; the offset distances of pixel points in different radial directions are different; the blur processing unit , used to blur the pixel points based on the offset distance to obtain a blurred image of the image to be processed.
第三方面,本公开实施例还提供一种计算机设备,包括:处理器、存储器和总线,所述存储器存储有所述处理器可执行的机器可读指令,当计算机设备运行时,所述处理器与所述存储器之间通过总线通信,所述机器 可读指令被所述处理器执行时执行上述第一方面,或第一方面中任一种可能的实施方式中的步骤。In a third aspect, embodiments of the present disclosure also provide a computer device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the computer device is running, the processing communicates with the memory through a bus, the machine When the readable instructions are executed by the processor, the steps in the above-mentioned first aspect, or any possible implementation manner of the first aspect, are performed.
第四方面,本公开实施例还提供一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行上述第一方面,或第一方面中任一种可能的实施方式中的步骤。In a fourth aspect, embodiments of the present disclosure also provide a computer-readable storage medium. A computer program is stored on the computer-readable storage medium. When the computer program is run by a processor, the computer program executes the above-mentioned first aspect, or any of the first aspects. steps in a possible implementation.
第五方面,本公开实施例还提供一种计算机程序产品,当所述计算机程序产品在计算机上运行时,使得所述计算机实现上述第一方面,或第一方面中任一种可能的实施方式中的步骤。In a fifth aspect, embodiments of the present disclosure also provide a computer program product. When the computer program product is run on a computer, the computer implements the above-mentioned first aspect, or any possible implementation manner of the first aspect. steps in.
在本公开实施例中,在获取到待处理图像之后,可以确定待处理图像中目标区域内的像素点。然后,确定待处理图像的中心位置和像素点相对于中心位置的径向方向向量,并根据该径向方向向量为像素点生成对应的偏移距离。由于本公开技术方案是为对应不同径向方向向量的像素点生成不同的偏移距离,因此,可以实现对应相同横坐标的像素点在横轴方向上的偏移距离不同,以及导致对应相同纵坐标的像素点在纵轴方向上的偏移距离不同。从而有效消除模糊图像中的重影,以提高径向模糊的模糊效果。In the embodiment of the present disclosure, after acquiring the image to be processed, the pixels in the target area in the image to be processed can be determined. Then, determine the center position of the image to be processed and the radial direction vector of the pixel point relative to the center position, and generate a corresponding offset distance for the pixel point based on the radial direction vector. Since the technical solution of the present disclosure is to generate different offset distances for pixels corresponding to different radial direction vectors, it can be achieved that pixels corresponding to the same abscissa have different offset distances in the horizontal axis direction, and the pixels corresponding to the same vertical coordinate can have different offset distances. The pixel points of the coordinates have different offset distances in the vertical axis direction. This effectively eliminates ghost images in blurred images to improve the blur effect of radial blur.
为使本公开的上述目的、特征和优点能更明显易懂,下文特举可能的实施例,并配合所附附图,作详细说明如下。In order to make the above objects, features and advantages of the present disclosure more obvious and understandable, possible embodiments are listed below and described in detail with reference to the attached drawings.
附图说明Description of the drawings
为了更清楚地说明本公开实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,此处的附图被并入说明书中并构成本说明书中的一部分,这些附图示出了符合本公开的实施例,并与说明书一起用于说明本公开的技术方案。应当理解,以下附图仅示出了本公开的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to explain the technical solutions of the embodiments of the present disclosure more clearly, the drawings required to be used in the embodiments will be briefly introduced below. The drawings here are incorporated into the specification and constitute a part of this specification. These drawings are The drawings illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, without exerting creative efforts, they can also Other relevant drawings are obtained based on these drawings.
图1(a)示出了一种待处理的原始图像的示意图;Figure 1(a) shows a schematic diagram of an original image to be processed;
图1(b)示出了一种通过现有的径向模糊技术对图1(a)所示的原始图像进行径向模糊处理之后的效果示意图;Figure 1(b) shows a schematic diagram of the effect of radial blur processing on the original image shown in Figure 1(a) through existing radial blur technology;
图2示出了另一种通过现有的径向模糊技术的效果示意图; Figure 2 shows another schematic diagram of the effect of existing radial blur technology;
图3示出了本公开实施例所提供的一种图像处理方法的流程图;Figure 3 shows a flow chart of an image processing method provided by an embodiment of the present disclosure;
图4示出了一种现有的径向模糊技术的技术原理示意图;Figure 4 shows a schematic diagram of the technical principle of an existing radial blur technology;
图5示出了本公开实施例所提供的图像处理方法中,基于所述中心位置确定所述待处理图像中每个像素点的径向方+向向量的具体方法的流程图;Figure 5 shows a flowchart of a specific method for determining the radial direction + directional vector of each pixel in the image to be processed based on the center position in the image processing method provided by the embodiment of the present disclosure;
图6示出了本公开实施例所提供的一种图像处理方法的技术原理示意图;Figure 6 shows a schematic diagram of the technical principles of an image processing method provided by an embodiment of the present disclosure;
图7示出了一种通过不同采样次数对采用本公开实施例所提供的图像处理方法处理之后的径向模糊图像进行循环采样处理之后的采样效果图;Figure 7 shows a sampling effect diagram after cyclic sampling processing of the radial blur image processed by the image processing method provided by the embodiment of the present disclosure through different sampling times;
图8示出了本公开实施例所提供的一种图像处理装置的示意图;Figure 8 shows a schematic diagram of an image processing device provided by an embodiment of the present disclosure;
图9示出了本公开实施例所提供的一种计算机设备的示意图。FIG. 9 shows a schematic diagram of a computer device provided by an embodiment of the present disclosure.
具体实施方式Detailed ways
为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合本公开实施例中附图,对本公开实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本公开一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本公开实施例的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本公开的实施例的详细描述并非旨在限制要求保护的本公开的范围,而是仅仅表示本公开的选定实施例。基于本公开的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本公开保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only These are some embodiments of the present disclosure, but not all embodiments. The components of the embodiments of the present disclosure generally described and illustrated in the figures herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the disclosure provided in the appended drawings is not intended to limit the scope of the claimed disclosure, but rather to represent selected embodiments of the disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without any creative efforts shall fall within the scope of protection of the present disclosure.
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。It should be noted that similar reference numerals and letters represent similar items in the following figures, therefore, once an item is defined in one figure, it does not need further definition and explanation in subsequent figures.
本文中术语“和/或”,仅仅是描述一种关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中术语“至少一种”表示多种中的任意一种或多种中的至少两种的任意组合,例如,包括A、B、C中的至少一种,可以表示包括从A、B和C构成的集合中选择的任意一个或多个元素。 The term "and/or" in this article only describes an association relationship, indicating that three relationships can exist. For example, A and/or B can mean: A alone exists, A and B exist simultaneously, and B alone exists. situation. In addition, the term "at least one" herein refers to any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, and C, which can mean including from A, Any one or more elements selected from the set composed of B and C.
经研究发现,径向模糊技术为模拟相机前后移动或者相机旋转时拍摄物体时所产生的放射状的效果。例如,在对如图1(a)所示的原始图像进行径向模糊处理之后,可以得到如图1(b)所示的径向模糊图像。After research, it was found that radial blur technology simulates the radial effect produced when shooting objects when the camera moves back and forth or when the camera rotates. For example, after performing radial blur processing on the original image as shown in Figure 1(a), a radial blurred image as shown in Figure 1(b) can be obtained.
如图1(b)所示,在通过现有的径向模糊技术对图像进行径向模糊处理之后,在径向模糊图像中包含很明显的重影。然而,相机在前后移动或者旋转状态下对物体进行拍摄时,所拍摄到的图像中的重影效果并不明显。因此,径向模糊图像中所出现的重影将影响径向模糊技术针对放射状效果的模拟效果。As shown in Figure 1(b), after the image is radially blurred through the existing radial blur technology, the radially blurred image contains obvious ghosting. However, when the camera moves forward or backward or rotates to capture an object, the ghosting effect in the captured image is not obvious. Therefore, the ghost images appearing in the radial blur image will affect the simulation effect of the radial blur technology for the radial effect.
为了解决上述所描述的重影问题,可以对图像重复多次径向模糊处理过程,通过重复多次径向模糊处理,可以淡化重影。然而,如图2所示,在径向模糊图像中依然存在较为明显的重影,且重复多次径向模糊处理将消耗大量的计算资源。In order to solve the ghosting problem described above, the radial blur processing process can be repeated multiple times on the image. By repeating the radial blur processing multiple times, the ghosting can be diluted. However, as shown in Figure 2, there are still obvious ghosts in the radial blur image, and repeating the radial blur process multiple times will consume a lot of computing resources.
针对重复多次径向模糊处理中的每次径向模糊处理,通常通过相同的偏移分量对图像中的每个像素点进行模糊偏移处理。此时,将导致对应相同横坐标的像素点在横轴方向上的偏移距离保持一致,以及导致对应相同纵坐标的像素点在纵轴方向上的偏移距离保持一致,这样也就在径向模糊图像中形成了非常规律的重影现象。For each radial blur process in repeated multiple radial blur processes, the blur offset process is usually performed on each pixel in the image using the same offset component. At this time, the offset distance of pixel points corresponding to the same abscissa in the horizontal axis direction will remain consistent, and the offset distance of pixel points corresponding to the same ordinate coordinate in the vertical axis direction will remain consistent, so that the radial A very regular ghosting phenomenon is formed in the blurred image.
除此之外,还可以通过降采样和升采样,并配合多次径向模糊处理来淡化重影。通过对图像进行降采样和升采样处理,可以减少图像中需要进行径向模糊处理的像素点的数量,以达到淡化重影的效果。然而,该方式依然会消耗大量的计算资源,且重影问题依然很明显。In addition, ghosting can be reduced through downsampling and upsampling, combined with multiple radial blurs. By downsampling and upsampling the image, the number of pixels in the image that need to be radially blurred can be reduced to achieve the effect of diluting ghosting. However, this method still consumes a lot of computing resources, and the ghosting problem is still obvious.
基于上述研究,本公开实施例提供了一种图像处理方法、装置、计算机设备以及存储介质。在本公开实施例中,在获取到待处理图像之后,可以确定待处理图像中目标区域内的像素点,然后,确定像素点相对应中心位置的径向方向向量,并根据该径向方向向量为像素点生成对应的偏移距离。由于本公开技术方案是为对应不同径向方向向量的像素点生成不同的偏移距离,因此,可以实现对应相同横坐标的像素点在横轴方向上的偏移距离不同,以及导致对应相同纵坐标的像素点在纵轴方向上的偏移距离不同。从而有效消除模糊图像中的重影,以提高径向模糊的模糊效果。Based on the above research, embodiments of the present disclosure provide an image processing method, device, computer equipment, and storage medium. In the embodiment of the present disclosure, after acquiring the image to be processed, the pixel points in the target area in the image to be processed can be determined, and then the radial direction vector corresponding to the center position of the pixel point is determined, and based on the radial direction vector Generate corresponding offset distances for pixels. Since the technical solution of the present disclosure is to generate different offset distances for pixels corresponding to different radial direction vectors, it can be achieved that pixels corresponding to the same abscissa have different offset distances in the horizontal axis direction, and the pixels corresponding to the same vertical coordinate can have different offset distances. The pixel points of the coordinates have different offset distances in the vertical axis direction. This effectively eliminates ghost images in blurred images to improve the blur effect of radial blur.
为便于对本实施例进行理解,首先对本公开实施例所公开的一种图像处理 方法进行详细介绍,本公开实施例所提供的图像处理方法的执行主体一般为具有一定计算能力的计算机设备。In order to facilitate understanding of this embodiment, first, an image processing method disclosed in the embodiment of the present disclosure is The method will be introduced in detail. The execution subject of the image processing method provided by the embodiment of the present disclosure is generally a computer device with certain computing capabilities.
参见图3所示,为本公开实施例提供的一种图像处理方法的流程图,所述方法包括步骤S301~S305,其中:Referring to Figure 3, a flow chart of an image processing method provided by an embodiment of the present disclosure is shown. The method includes steps S301 to S305, wherein:
S301:获取待处理图像,并确定所述待处理图像的中心位置和所述待处理图像中目标区域内的像素点;所述目标区域为待生成径向模糊效果的区域;所述中心位置为所述待处理图像中径向模糊效果的生成中心。S301: Obtain the image to be processed, and determine the center position of the image to be processed and the pixels in the target area in the image to be processed; the target area is the area where the radial blur effect is to be generated; the center position is The center of generation of the radial blur effect in the image to be processed.
在本公开实施例中,首先确定待处理图像中径向模糊效果的生成中心,即中心位置;之后,在待处理图像中目标区域内的像素点。In the embodiment of the present disclosure, the generation center of the radial blur effect in the image to be processed is first determined, that is, the center position; then, the pixel points in the target area in the image to be processed are determined.
这里,待处理图像中径向模糊效果的生成中心(即,中心位置)可以理解为待处理图像中的一个像素点。Here, the generation center (ie, the center position) of the radial blur effect in the image to be processed can be understood as a pixel in the image to be processed.
在一个可选的实施方式中,该中心位置可以为用户预先在待处理图像中手动标注的像素点。In an optional implementation, the center position may be a pixel manually marked by the user in advance in the image to be processed.
具体实施时,可以响应于用于针对待处理图像的标注操作,并根据标注操作所对应的标注位置确定中心位置。During specific implementation, the center position may be determined in response to an annotation operation for the image to be processed and based on an annotation position corresponding to the annotation operation.
在另一个可选的实施方式中,还可以为按照预设选择规则在待处理图像中自动选择出的像素点。例如,基于待处理图像所对应径向模糊效果的效果类型确定上述中心位置。In another optional implementation, it can also be pixels automatically selected in the image to be processed according to preset selection rules. For example, the above-mentioned center position is determined based on the effect type of the radial blur effect corresponding to the image to be processed.
具体实施时,可以基于效果类型在待处理图像中确定相匹配的目标对象,进而基于该目标对象的位置确定上述中心位置。During specific implementation, a matching target object can be determined in the image to be processed based on the effect type, and then the above-mentioned center position can be determined based on the position of the target object.
如果检测出待处理图像中所包含一个相匹配的目标对象,则将该相匹配的目标对象的中心位置确定为中心位置。如果检测出相匹配的目标对象的数量为多个,则可以在多个相匹配的目标对象中指定目标对象,并将指定目标对象的中心位置确定为上述中心位置。If it is detected that a matching target object is included in the image to be processed, the center position of the matching target object is determined as the center position. If the number of matching target objects is detected to be multiple, the target object may be specified among the multiple matching target objects, and the center position of the specified target object may be determined as the above-mentioned center position.
在又一个可选的实施方式中,还可以将该待处理图像的图像中心位置确定为该中心位置。In yet another optional implementation, the image center position of the image to be processed can also be determined as the center position.
在本公开实施例中,目标区域可以为待处理图像中的全部图像区域,还可以为待处理图像中的部分图像区域。In the embodiment of the present disclosure, the target area may be the entire image area in the image to be processed, or may be a partial image area in the image to be processed.
具体实施时,可以基于以下参数在待处理图像中确定目标区域:效果类型、 用户预先设定的区域信息(例如,区域尺寸和区域位置)、目标对象在待处理图像中的位置(或者中心位置)等参数。During specific implementation, the target area can be determined in the image to be processed based on the following parameters: effect type, Parameters such as area information (for example, area size and area position), the position (or center position) of the target object in the image to be processed, etc. preset by the user.
举例来说,如果效果类型为体积光影效果,那么该待处理图像中的目标对象为光源。此时,基于该光源的位置和用户预先设定的区域尺寸,在待处理图像中确定目标区域。For example, if the effect type is a volumetric light and shadow effect, then the target object in the image to be processed is the light source. At this time, the target area is determined in the image to be processed based on the position of the light source and the area size preset by the user.
S303:确定所述像素点相对于中心位置的径向方向向量,并基于所述径向方向向量确定所述像素点的偏移距离;其中,不同径向方向的像素点的所述偏移距离不同。S303: Determine the radial direction vector of the pixel point relative to the center position, and determine the offset distance of the pixel point based on the radial direction vector; wherein, the offset distance of the pixel point in different radial directions different.
S305:基于所述偏移距离对每个所述像素点进行模糊处理,得到所述待处理图像的模糊图像。S305: Perform blur processing on each pixel point based on the offset distance to obtain a blurred image of the image to be processed.
在本公开实施例中,径向方向向量包含:方向和向量的模。这里,径向方向向量中的方向为中心位置指向对应像素点的方向(也即,径向方向),径向方向向量中的模为中心位置和对应像素点之间的距离。In embodiments of the present disclosure, the radial direction vector includes: a direction and a module of the vector. Here, the direction in the radial direction vector is the direction in which the central position points to the corresponding pixel point (that is, the radial direction), and the modulus in the radial direction vector is the distance between the central position and the corresponding pixel point.
这里,针对对应不同径向方向的像素点均设置了不同的偏移距离,下面结合图1(a)和图4进行介绍。假设,针对任意一个待处理的原始图像,如图1(a)所示的为采用现有的径向模糊技术对该原始图像进行模糊处理之后得到的径向模糊图像,从图1(a)中可以看出,该径向模糊图像中存在较为明显的重影问题。Here, different offset distances are set for pixels corresponding to different radial directions, which will be introduced below in conjunction with Figure 1(a) and Figure 4. Assume that for any original image to be processed, as shown in Figure 1(a), it is the radial blur image obtained after blurring the original image using the existing radial blur technology. From Figure 1(a) It can be seen that there is an obvious ghosting problem in the radial blurred image.
如图4所示,假设,图1(a)中的中心位置的坐标表示为:float2(0.5,0.5),其中,float2表示2个浮点数,float2(0.5,0.5)表示为中心位置的坐标中包含2个浮点数,分别为0.5和0.5。在确定出中心位置之后,就可以以该中心位置为坐标原点,构建直角坐标系,其中,该直角坐标系的横轴记为U轴,该直角坐标系的纵轴记为V轴。As shown in Figure 4, assume that the coordinates of the center position in Figure 1(a) are expressed as: float2(0.5, 0.5), where float2 represents 2 floating point numbers, and float2(0.5, 0.5) represents the coordinates of the center position. contains 2 floating point numbers, 0.5 and 0.5 respectively. After the center position is determined, a rectangular coordinate system can be constructed using the center position as the coordinate origin, in which the horizontal axis of the rectangular coordinate system is marked as the U axis, and the vertical axis of the rectangular coordinate system is marked as the V axis.
在上述待处理的原始图像中,可以随机选取一个像素点P0(U0,V0),P1(U1,V1),P2(U2,V2),P0、P1和P2之间的位置可以如图4所示。针对每个像素点,均为其设置一个偏移量d,此时,每个像素点在U轴方向和V轴方向的偏移距离可以描述为:In the above original image to be processed, a pixel point P0 (U0, V0), P1 (U1, V1), P2 (U2, V2) can be randomly selected. The positions between P0, P1 and P2 can be as shown in Figure 4 Show. For each pixel, an offset d is set. At this time, the offset distance of each pixel in the U-axis direction and the V-axis direction can be described as:
d*float2(U0V0-0.5),d*float2(U1V1-0.5),d*float2(U2V2-0.5)。d*float2(U0V0-0.5), d*float2(U1V1-0.5), d*float2(U2V2-0.5).
这里,d*float2(U0V0-0.5)可以用公式描述为d*(U0-0.5,V0-0.5);d* float2(U1V1-0.5)可以用公式描述为d*(U1-0.5,V1-0.5);d*float2(U2V2-0.5)可以用公式描述为d*(U2-0.5,V2-0.5)。Here, d*float2(U0V0-0.5) can be described by the formula as d*(U 0 -0.5,V 0 -0.5); d* float2(U1V1-0.5) can be described by the formula as d*(U 1 -0.5,V 1 -0.5); d*float2(U2V2-0.5) can be described by the formula as d*(U 2 -0.5,V 2 -0.5 ).
如果像素点P0、P1和P2的横坐标相同,那么像素点P0、P1和P2在U方向上的偏移距离保持一致,如果像素点P0、P1和P2的纵坐标相同,那么像素点P0、P1和P2在V方向上的偏移距离保持一致。此时,在径向模糊图像将会产生如图1(a)所示的较为规律的重影。If the abscissas of pixels P0, P1 and P2 are the same, then the offset distances of pixels P0, P1 and P2 in the U direction remain the same. If the ordinates of pixels P0, P1 and P2 are the same, then the offset distances of pixels P0, P1 and P2 are the same. The offset distance of P1 and P2 in the V direction remains the same. At this time, the radially blurred image will produce relatively regular ghost images as shown in Figure 1(a).
基于此,在本公开实施例中,为对应不同径向方向的像素点确定了不同的偏移距离。例如,针对像素点P0、P1和P2,由于像素点P0、P1和P2所对应的径向方向不同,此时可以为像素点P0、P1和P2分别确定不同的偏移距离,在基于该偏移距离对像素点P0、P1和P2进行偏移处理时,即使像素点P0、P1和P2的横坐标相同,那么像素点P0、P1和P2在U方向上的偏移距离也不会相同,同样地,即使像素点P0、P1和P2的纵坐标相同,那么像素点P0、P1和P2在V方向上的偏移距离也不会相同,从而就可以有效消除现有径向模糊图像中所产生的重影现象。Based on this, in the embodiment of the present disclosure, different offset distances are determined for pixel points corresponding to different radial directions. For example, for the pixel points P0, P1 and P2, since the radial directions corresponding to the pixel points P0, P1 and P2 are different, different offset distances can be determined for the pixel points P0, P1 and P2 respectively. Based on the offset, When the pixel points P0, P1 and P2 are offset by distance, even if the abscissas of the pixel points P0, P1 and P2 are the same, the offset distances of the pixel points P0, P1 and P2 in the U direction will not be the same. Similarly, even if the ordinates of the pixel points P0, P1 and P2 are the same, the offset distances of the pixel points P0, P1 and P2 in the V direction will not be the same, thus effectively eliminating all the problems in the existing radial blur image. The ghosting phenomenon occurs.
在本公开实施例中,在获取到待处理图像之后,可以确定待处理图像中目标区域内的像素点,然后,确定像素点相对于中心位置的径向方向向量,并根据该径向方向向量为每个像素点生成对应的偏移距离。由于本公开技术方案是为对应不同径向方向向量的像素点生成不同的偏移距离,因此,可以实现对应相同横坐标的像素点在横轴方向上的偏移距离不同,以及导致对应相同纵坐标的像素点在纵轴方向上的偏移距离不同,从而有效消除模糊图像中的重影,以提高径向模糊的模糊效果。In the embodiment of the present disclosure, after acquiring the image to be processed, the pixel points in the target area in the image to be processed can be determined, and then the radial direction vector of the pixel point relative to the center position is determined, and based on the radial direction vector Generate corresponding offset distance for each pixel. Since the technical solution of the present disclosure is to generate different offset distances for pixels corresponding to different radial direction vectors, it can be achieved that pixels corresponding to the same abscissa have different offset distances in the horizontal axis direction, and the pixels corresponding to the same vertical coordinate can have different offset distances. The pixel points of the coordinates have different offset distances in the vertical axis direction, thereby effectively eliminating ghosts in the blurred image and improving the blur effect of radial blur.
在一个可选的实施方式中,如图5所示,上述步骤S303:确定所述像素点相对于中心位置的径向方向向量,具体包括如下步骤:In an optional implementation, as shown in Figure 5, the above-mentioned step S303: determining the radial direction vector of the pixel point relative to the center position specifically includes the following steps:
步骤S501:确定所述中心位置在所述待处理图像中的像素坐标,得到第一像素坐标,并确定所述像素点在所述待处理图像中的像素坐标,得到第二像素坐标;Step S501: Determine the pixel coordinates of the center position in the image to be processed to obtain the first pixel coordinates, and determine the pixel coordinates of the pixel point in the image to be processed to obtain the second pixel coordinates;
步骤S502:基于所述第一像素坐标和所述第二像素坐标,确定所述径向方向向量。Step S502: Determine the radial direction vector based on the first pixel coordinate and the second pixel coordinate.
在本公开实施例中,在确定出中心位置之后,就可以确定该中心位置在待 处理图像中的像素坐标,从而得到第一像素坐标,例如,该第一像素坐标可以记为(U1,V1),然后,确定每个像素点在待处理图像中的像素坐标,从而得到第二像素坐标,例如,第二像素坐标可以记为(U2,V2)。In the embodiment of the present disclosure, after the central position is determined, it can be determined that the central position is to be Process the pixel coordinates in the image to obtain the first pixel coordinates. For example, the first pixel coordinates can be recorded as (U1, V1). Then, determine the pixel coordinates of each pixel point in the image to be processed, thereby obtaining the second pixel coordinates. Pixel coordinates, for example, the second pixel coordinates can be recorded as (U2, V2).
之后,就可以计算第一像素坐标和第二像素确定径向方向向量。此时,假设,第一像素坐标表示为A(U1,V1),第二像素坐标表示为B(U2,V2),那么,就可以将向量AB确定为上述径向方向向量。After that, the first pixel coordinates and the second pixel coordinates can be calculated to determine the radial direction vector. At this time, assuming that the first pixel coordinate is expressed as A(U1, V1) and the second pixel coordinate is expressed as B(U2, V2), then the vector AB can be determined as the above-mentioned radial direction vector.
此时,上述径向方向向量(也即,向量AB)可以表示为:float2(U2-U1,V2-V1)。At this time, the above-mentioned radial direction vector (that is, vector AB) can be expressed as: float2(U2-U1, V2-V1).
若第一像素坐标为(0.5,0.5),第二像素坐标为(U,V),则上述径向方向向量还可以表示为:float2dir=float2(UV-0.5),其中,float2(UV-0.5)还可以表示为:(U-0.5,V-0.5)。If the first pixel coordinate is (0.5, 0.5) and the second pixel coordinate is (U, V), then the above radial direction vector can also be expressed as: float2dir=float2(UV-0.5), where, float2(UV-0.5 ) can also be expressed as: (U-0.5, V-0.5).
上述实施方式中,通过基于中心位置的像素坐标和每个像素点的像素坐标,确定每个像素点的径向方向向量的方式,可以简化数据处理量,进而可以节省计算机设备的计算资源,以提高图像处理的效率。In the above embodiment, by determining the radial direction vector of each pixel based on the pixel coordinates of the center position and the pixel coordinates of each pixel, the amount of data processing can be simplified, and the computing resources of the computer device can be saved. Improve image processing efficiency.
在一个可选的实施方式中,上述步骤S303:基于所述径向方向向量确定所述像素点的偏移距离,具体包括如下步骤:In an optional implementation, the above-mentioned step S303: determining the offset distance of the pixel point based on the radial direction vector specifically includes the following steps:
步骤S11:对所述径向方向向量进行单位化处理;Step S11: Unitize the radial direction vector;
步骤S12:根据单位化处理的径向方向向量确定每个所述像素点的偏移距离。Step S12: Determine the offset distance of each pixel point according to the radial direction vector of the unitization process.
在本公开实施例中,可以基于单位化函数对径向方向向量进行单位化处理,其中,该单位化函数可以为normalize。In an embodiment of the present disclosure, the radial direction vector can be normalized based on a normalization function, where the normalization function can be normalize.
对径向方向向量进行单位化处理可以描述为:float2dirNormal=normalize(dir),其中,dir为上述径向方向向量,float2dirNormal为单位化处理的径向方向向量。The normalization process of the radial direction vector can be described as: float2dirNormal=normalize(dir), where dir is the above-mentioned radial direction vector, and float2dirNormal is the radial direction vector of the normalization process.
假设,径向方向向量为float2(U2-U1,V2-V1),那么径向方向向量进行单位化处理可以描述为以下过程:Assume that the radial direction vector is float2(U2-U1, V2-V1), then the unitization process of the radial direction vector can be described as the following process:
令U2-U1=U,以及令V2-V1=Y。然后,通过公式计算径向方向向量的模;之后,计算以及从而得到单位化处理的径向方向向量 Let U2-U1=U, and let V2-V1=Y. Then, through the formula Calculate the module of the radial direction vector; after that, calculate as well as Thus, the unitized radial direction vector is obtained
在对径向方向向量进行单位化处理之后,就可以基于单位化处理的径向方向向量确定对应像素点的偏移距离。After unitizing the radial direction vector, we can use the unitized radial direction vector to Determine the offset distance of the corresponding pixel.
上述实施方式中,通过对每个像素点对应的径向方向向量进行单位化处理,再根据单位化处理之后的径向方向向量确定该像素点的偏移距离的方式,可以保证对应相同径向方向的像素点的连续性,以提高径向模糊处理的质量。In the above embodiment, by unitizing the radial direction vector corresponding to each pixel point, and then determining the offset distance of the pixel point based on the radial direction vector after the unitization process, it can be ensured that the corresponding radial direction vector is the same. The continuity of pixels in the direction to improve the quality of radial blur processing.
在一个可选的实施方式中,上述步骤S303:基于所述径向方向向量确定所述像素点的偏移距离,具体包括如下步骤:In an optional implementation, the above-mentioned step S303: determining the offset distance of the pixel point based on the radial direction vector specifically includes the following steps:
步骤S21:基于所述径向方向向量确定所述像素点中径向方向相同的目标像素点;所述径向方向为所述径向方向向量的方向;Step S21: Determine target pixel points with the same radial direction among the pixel points based on the radial direction vector; the radial direction is the direction of the radial direction vector;
步骤S22:通过预设随机函数为所述目标像素点生成相同的随机值;Step S22: Generate the same random value for the target pixel through a preset random function;
步骤S23:将所述相同的随机值作为所述目标像素点的偏移距离。Step S23: Use the same random value as the offset distance of the target pixel point.
发明人发现,为了解决现有径向模糊技术中所存在的重影问题,一种可选的解决方式是通过抖动算法对图像进行径向模糊处理,该处理过程可以描述为:The inventor found that in order to solve the ghosting problem existing in the existing radial blur technology, an optional solution is to perform radial blur processing on the image through a dithering algorithm. The processing process can be described as:
为图像中的每个像素点均随机生成一个偏移值,其中,不同像素点对应的偏移值不相同。此时,就可以逐像素进行偏移处理,即通过叠加每个像素点的偏移值来实现每个像素点的偏移处理。通过该处理方式,可以有效缓解现有径向模糊技术中所存在的重影问题,来避免左图的那种重复感。然而,该方式因为逐像素的偏移值都不同,因此能比较好的避免重影现象,但也因为逐像素进行偏移,从而导致了大量噪波的出现。因此,需要配合TAA降噪算法来对径向模糊图像进行降噪处理。然而,该通过结合抖动算法和TAA降噪算法对图像进行径向模糊处理,会消耗大量的计算资源,不利于计算机设备的稳定运行。An offset value is randomly generated for each pixel in the image, where the offset values corresponding to different pixels are different. At this time, the offset processing can be performed pixel by pixel, that is, the offset processing of each pixel is achieved by superimposing the offset value of each pixel. Through this processing method, the ghosting problem existing in the existing radial blur technology can be effectively alleviated to avoid the repetitive feeling in the left picture. However, this method can better avoid ghosting because the offset values are different pixel by pixel, but it also leads to the occurrence of a lot of noise because of the offset pixel by pixel. Therefore, it is necessary to cooperate with the TAA denoising algorithm to denoise the radial blurred image. However, the radial blur processing of images by combining the dithering algorithm and the TAA noise reduction algorithm consumes a large amount of computing resources and is not conducive to the stable operation of computer equipment.
基于此,在本公开实施例中,可以通过上述所描述的方式确定每个像素点的径向方向向量之后,就可以基于确定出的径向方向向量在多个像素点中确定对应相同径向方向的目标像素点,例如,可以确定多组像素点,每组像素点对应相同径向方向的目标像素点。Based on this, in the embodiment of the present disclosure, after the radial direction vector of each pixel point is determined in the above-described manner, the corresponding same radial direction vector can be determined among multiple pixel points based on the determined radial direction vector. For example, multiple groups of pixels can be determined, and each group of pixels corresponds to target pixels in the same radial direction.
在得到上述多组像素点之后,就可以通过预设随机函数random为每组像素点生成相同的随机数值。After obtaining the above multiple groups of pixels, the same random value can be generated for each group of pixels through the preset random function random.
在本公开实施例中,生成随机数值可以基于如下公式实现:In this embodiment of the present disclosure, generating a random value can be implemented based on the following formula:
float2ditherDir=random(dirNormal)。 float2ditherDir=random(dirNormal).
这里,dirNormal表示径向方向向量(或者,上述单位化处理的径向方向向量)。float2ditherDir表示基于径向方向向量生成的随机数值。Here, dirNormal represents the radial direction vector (or the radial direction vector of the above-mentioned unitization process). float2ditherDir represents a random value generated based on the radial direction vector.
在确定出随机数值之后,就可以将该随机数值确定为上述目标像素点的偏移距离。After determining the random value, the random value can be determined as the offset distance of the target pixel point.
在本公开实施例中,可以首先确定至少一个数值区域,之后,就可以通过预设随机函数在该数值区间内为每组像素点生成相同的随机数值。In the embodiment of the present disclosure, at least one numerical region can be determined first, and then the same random numerical value can be generated for each group of pixels within the numerical interval through a preset random function.
具体实施时,可以基于效果类型确定上述至少一个数值区域,或者,用户可以预先设定至少一个数值区域,本公开对数值区域的设定方式不作具体限定。During specific implementation, the above-mentioned at least one numerical area can be determined based on the effect type, or the user can set at least one numerical area in advance. This disclosure does not specifically limit the setting method of the numerical area.
上述实施方式中,通过为对应不同径向方向向量的像素点生成不同的偏移距离,可以实现对应相同横坐标的像素点在横轴方向上的偏移距离不同,以及导致对应相同纵坐标的像素点在纵轴方向上的偏移距离不同,从而有效消除模糊图像中的重影,以提高径向模糊的模糊效果。In the above embodiment, by generating different offset distances for pixels corresponding to different radial direction vectors, it is possible to achieve different offset distances in the horizontal axis direction for pixels corresponding to the same abscissa, and result in pixels corresponding to the same ordinate. The offset distances of pixels in the vertical axis direction are different, thereby effectively eliminating ghost images in blurred images and improving the blurring effect of radial blur.
通过上述描述可知,上述径向方向向量中包含横轴方向的向量分量和纵轴方向的向量分量。例如,径向方向向量(上述向量AB)float2(U2-U1,V2-V1),在该径向方向向量中,包含横轴方向的向量分量“U2-U1”,以及包含纵轴方向的向量分量“V2-V1”。It can be seen from the above description that the above-mentioned radial direction vector includes a vector component in the horizontal axis direction and a vector component in the longitudinal axis direction. For example, the radial direction vector (the above vector AB) float2(U2-U1, V2-V1), in this radial direction vector, contains the vector component "U2-U1" in the horizontal axis direction, and the vector containing the vertical axis direction Component "V2-V1".
基于此,在通过预设随机函数为目标像素点生成相同的偏移距离中包括:所述横轴方向的向量分量的偏移分量和所述纵轴方向的向量分量的偏移分量。这里,可以将该随机数值分别确定为该横轴方向的向量分量的偏移分量和纵轴方向的向量分量的偏移分量。Based on this, generating the same offset distance for the target pixel point through a preset random function includes: an offset component of the vector component in the horizontal axis direction and an offset component of the vector component in the vertical axis direction. Here, the random value can be determined as an offset component of the vector component in the horizontal axis direction and an offset component of the vector component in the vertical axis direction respectively.
在本公开实施例中,在按照上述所描述的方式确定出每个像素点的偏移距离之后,就可以基于偏移距离对每个所述像素点进行偏移处理,处理之后得到所述待处理图像的模糊图像。In the embodiment of the present disclosure, after determining the offset distance of each pixel point in the manner described above, offset processing can be performed on each pixel point based on the offset distance. After the processing, the to-be-used pixel point is obtained. Process blurry images of images.
在一个可选的实施方式中,上述步骤S305:基于所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像,具体包括如下步骤:In an optional implementation, the above step S305: blurring the pixel points based on the offset distance to obtain a blurred image of the image to be processed, specifically includes the following steps:
步骤S3051:获取预先为所述像素点设定的目标模糊距离;Step S3051: Obtain the target blur distance set in advance for the pixel;
步骤S3052:按照预设叠加方式将所述目标模糊距离和所述像素点的偏移距离进行叠加,得到目标偏移距离;Step S3052: Superimpose the target blur distance and the offset distance of the pixel point according to a preset superposition method to obtain the target offset distance;
步骤S3053:基于所述目标偏移距离,对相应的像素点进行模糊处理,得 到所述待处理图像的模糊图像。Step S3053: Based on the target offset distance, blur the corresponding pixel points to obtain to the blurred image of the image to be processed.
在本公开实施例中,可以预先为目标区域中的每个像素点设定相同的目标模糊距离,这里的目标模糊距离包含横轴方向的向量分量的模糊距离分量和所述纵轴方向的向量分量的模糊距离分量。例如,该目标模糊距离可以为上述实施方式中的偏移距离d*float2(U1-U0,V1-V0)。In the embodiment of the present disclosure, the same target blur distance can be set in advance for each pixel in the target area. The target blur distance here includes the blur distance component of the vector component in the horizontal axis direction and the vector in the vertical axis direction. The fuzzy distance component of the component. For example, the target blur distance may be the offset distance d*float2(U1-U0, V1-V0) in the above embodiment.
在确定出上述目标模糊距离之后,就可以按照预设叠加方式将目标模糊距离和所述偏移距离进行叠加,得到目标偏移距离,并根据该目标偏移距离,对相应的像素点进行偏移处理,处理之后得到所述待处理图像的模糊图像,例如,可以得到如图6所示的模糊图像。After the above-mentioned target blur distance is determined, the target blur distance and the offset distance can be superimposed according to the preset superposition method to obtain the target offset distance, and the corresponding pixel points can be offset according to the target offset distance. After the processing, a blurred image of the image to be processed is obtained. For example, a blurred image as shown in Figure 6 can be obtained.
通过上述方式进行处理之后,就可以实现对应相同横坐标的像素点在横轴方向上的偏移距离不同,以及导致对应相同纵坐标的像素点在纵轴方向上的偏移距离不同,从而有效消除模糊图像中的重影,以提高径向模糊的模糊效果。After processing in the above manner, it is possible to realize that pixel points corresponding to the same abscissa have different offset distances in the horizontal axis direction, and pixel points corresponding to the same ordinate coordinate have different offset distances in the vertical axis direction, thus effectively Eliminate ghosting in blurred images to improve the blur effect of radial blur.
在一个可选的实施方式中,上述步骤:按照预设叠加方式将所述目标模糊距离和所述像素点的偏移距离进行叠加,得到目标偏移距离,具体包括如下步骤:In an optional implementation, the above step: superimpose the target blur distance and the offset distance of the pixel point according to a preset superposition method to obtain the target offset distance, which specifically includes the following steps:
按照预设计算方式,对所述目标模糊距离和每个所述像素点的偏移距离进行计算,得到所述目标偏移距离,其中,所述预设计算方式包括以下任一种:乘法、加法。According to a preset calculation method, the target blur distance and the offset distance of each pixel point are calculated to obtain the target offset distance, wherein the preset calculation method includes any of the following: multiplication, addition.
在本公开实施例中,可以将上述目标模糊距离和每个像素点的偏移距离进行乘法运算或者加法运算,从而得到目标偏移距离。In the embodiment of the present disclosure, the target blur distance and the offset distance of each pixel can be multiplied or added to obtain the target offset distance.
例如,假设,上述目标模糊距离为:d*float2(U1-U0,V1-V0),上述每个像素点的偏移距离为float2ditherDir。For example, assume that the blur distance of the above target is: d*float2(U1-U0, V1-V0), and the offset distance of each pixel above is float2ditherDir.
此时,可以通过以下公式将目标模糊距离和每个像素点的偏移距离进行计算:At this time, the target blur distance and the offset distance of each pixel can be calculated through the following formula:
ditherDir+d*float2(U1-U0,V1-V0);ditherDir+d*float2(U1-U0, V1-V0);
ditherDir*d*float2(U1-U0,V1-V0)。ditherDir*d*float2(U1-U0,V1-V0).
其中,(U1,V1)为每个像素点的像素坐标,(U0,V0)为中心位置的像素坐标。Among them, (U1, V1) is the pixel coordinate of each pixel point, and (U0, V0) is the pixel coordinate of the center position.
在本公开实施例中,在按照预设叠加方式将所述目标模糊距离和每个所述 像素点的偏移距离进行叠加之前,还可以通过差值函数对每个像素点的偏移距离进行差值处理,具体差值处理过程可以描述如下:In the embodiment of the present disclosure, the target blur distance and each of the Before the offset distances of pixels are superimposed, the offset distance of each pixel can also be difference processed through the difference function. The specific difference processing process can be described as follows:
确定所述偏移距离在预设差值范围内的目标差值结果。Determine the target difference result where the offset distance is within a preset difference range.
上述差值处理过程可以通过以下公式进行表示:lerp(1,1.5,ditherDir)。The above difference processing process can be expressed by the following formula: lerp (1, 1.5, ditherDir).
其中,lerp为上述预设差值函数,其中,lerp的常规表示为:lerp(from,to,value),该预设差值函数lerp可以理解为在预设差值范围(from,to)内对值value进行差值处理,其中,值value为“ditherDir”,预设差值范围(from,to)为(1,1.5)。Among them, lerp is the above-mentioned preset difference function. The conventional expression of lerp is: lerp (from, to, value). The preset difference function lerp can be understood as being within the preset difference range (from, to). Perform difference processing on the value value, where the value value is "ditherDir" and the preset difference range (from, to) is (1, 1.5).
在确定出目标差值结果之后,在按照预设叠加方式将所述目标模糊距离和所述像素点的偏移距离进行叠加,得到目标偏移距离时,就可以按照所述预设叠加方式将所述目标模糊距离和所述目标差值结果进行叠加,得到目标偏移距离。After the target difference result is determined, the target blur distance and the offset distance of the pixel are superimposed according to the preset superposition method. When the target offset distance is obtained, the target blur distance can be superimposed according to the preset superposition method. The target blur distance and the target difference result are superimposed to obtain the target offset distance.
具体实施时,可以将目标模糊距离和目标差值结果进行乘法计算,并将乘法计算结果确定为该目标偏移距离,具体计算公式可以描述为:During specific implementation, the target fuzzy distance and target difference results can be multiplied, and the multiplication result is determined as the target offset distance. The specific calculation formula can be described as:
float2shift=dir*lerp(1,1.5,ditherDir)。float2shift=dir*lerp(1, 1.5, ditherDir).
在得到上述目标偏移距离之后,就可以基于该目标偏移距离对每个所述像素点进行偏移处理,处理之后得到所述待处理图像的模糊图像。After obtaining the above target offset distance, each pixel point can be offset based on the target offset distance, and after the processing, a blurred image of the image to be processed is obtained.
通过上述描述可知,在本公开实施例中,通过为对应相同径向方向的像素点确定相同的偏移距离,并为对应不相同的径向方向的像素点确定不同的偏移距离的方式,不仅可以有效缓解现有径向模糊技术的重影问题,还可以保证同方向上的像素点的连续性,还可以减少节省降噪的步骤。As can be seen from the above description, in the embodiment of the present disclosure, the same offset distance is determined for pixel points corresponding to the same radial direction, and different offset distances are determined for pixel points corresponding to different radial directions. Not only can it effectively alleviate the ghosting problem of existing radial blur technology, it can also ensure the continuity of pixels in the same direction, and can also reduce noise reduction steps.
在本公开实施例中,每个径向方向上的偏移距离是可以进行随机设置的,因此,当设置一个合适的偏移距离时,就可以通过极少的径向模糊采样次数来产生不错的径向模糊效果,从而使得图像处理性能得到极大的提升,从而增强了径向模糊技术的适用性。例如,如图7所示,从左至右分别为对径向模糊图像进行径向循环采样10次,5次和3次的效果,完全避免了重复感。In the embodiment of the present disclosure, the offset distance in each radial direction can be set randomly. Therefore, when an appropriate offset distance is set, a good image quality can be generated with a very small number of radial blur samplings. The radial blur effect greatly improves the image processing performance and enhances the applicability of radial blur technology. For example, as shown in Figure 7, from left to right are the effects of radially cyclic sampling 10 times, 5 times and 3 times on the radial blur image, completely avoiding the sense of repetition.
在一个可选的实施方式中,上述步骤S303确定所述像素点相对于中心位置的径向方向向量,具体包括如下步骤:In an optional implementation, the above-mentioned step S303 determines the radial direction vector of the pixel point relative to the center position, specifically including the following steps:
S31,确定所述径向模糊效果的效果类型,并基于所述效果类型在所述待 处理图像中确定目标对象;S31: Determine the effect type of the radial blur effect, and based on the effect type, perform Determine the target object in the processed image;
S32,基于所述目标对象确定所述中心位置,并基于所述中心位置确定所述像素点的径向方向向量。S32: Determine the center position based on the target object, and determine the radial direction vector of the pixel point based on the center position.
在本公开实施例中,待处理图像的径向模糊效果的效果类型可以为用户预先设定的类型。例如,用户可以通过计算机设备输入效果类型。In the embodiment of the present disclosure, the effect type of the radial blur effect of the image to be processed may be a type preset by the user. For example, a user can enter an effect type through a computer device.
这里,径向模糊效果的效果类型可以包括以下任一种:体积光影效果、图像速度线添加效果。Here, the effect type of the radial blur effect can include any of the following: volumetric light and shadow effects, image speed line addition effects.
针对不同效果类型的径向模糊效果可以在待处理图像中对应不同的目标对象。举例来说,针对体积光影效果,在待处理图像中对应的目标对象可以为光源,例如,太阳、点灯等。针对图像速度线添加效果,在待处理图像中对应的目标对象可以为任意一个需要表示移动效果的对象。这里,图像速度线又可以称为排线,该图像速度线用于在待处理图像中表示出目标对象的移动效果,例如,移动轨迹和/或移动方向等信息。Radial blur effects for different effect types can correspond to different target objects in the image to be processed. For example, for volumetric light and shadow effects, the corresponding target object in the image to be processed can be a light source, such as the sun, a lamp, etc. To add effects to the image speed line, the corresponding target object in the image to be processed can be any object that needs to express a movement effect. Here, the image speed line can also be called a line. The image speed line is used to express the movement effect of the target object in the image to be processed, for example, movement trajectory and/or movement direction and other information.
在确定出效果类型之后,就可以基于该效果类型确定目标对象,并基于该目标对象确定中心位置,例如,将该目标对象的中心点确定为该中心位置。之后,就可以基于该中心位置确定像素点的径向方向向量,具体确定过程如上实施例所述,此处不再详细描述。After the effect type is determined, the target object can be determined based on the effect type, and the center position can be determined based on the target object. For example, the center point of the target object can be determined as the center position. Afterwards, the radial direction vector of the pixel point can be determined based on the center position. The specific determination process is as described in the above embodiment and will not be described in detail here.
在一个可选的实施方式中,在所述效果类型为第一类型的情况下,该方法还可以获取第一模糊参数;其中,所述第一类型用于指示所述待处理图像的效果类型为体积光影效果;所述第一模糊参数包括亮度参数和/或颜色参数。In an optional implementation, when the effect type is a first type, the method can also obtain a first blur parameter; wherein the first type is used to indicate the effect type of the image to be processed. It is a volumetric light and shadow effect; the first blur parameter includes a brightness parameter and/or a color parameter.
在此情况下,上述步骤S305所述基于所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像,包括:基于所述第一模糊参数和所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像。In this case, performing blur processing on the pixels based on the offset distance in step S305 to obtain a blurred image of the image to be processed includes: based on the first blur parameter and the offset distance The pixel points are blurred to obtain a blurred image of the image to be processed.
本公开实施例中,上述第一类型用于指示所述待处理图像的效果类型为体积光影效果。在体积光影效果下,可以通过结合光暗阈值(即,亮度参数)与颜色调整(即颜色参数),以及本公开实施例所提供的图像处理方法,体现体积光影效果。In the embodiment of the present disclosure, the above-mentioned first type is used to indicate that the effect type of the image to be processed is a volumetric light and shadow effect. Under the volumetric light and shadow effect, the volumetric light and shadow effect can be reflected by combining the light and dark threshold (ie, brightness parameter) and color adjustment (ie, color parameter), as well as the image processing method provided by the embodiment of the present disclosure.
在效果类型为第一类型的情况下,可以在待处理图像中确定光源。如果确定出多个光源(例如,多个灯泡),此时,可以在多个光源中确定位于前景区 域的光源为目标对象;或者,用户可以根据实际需要在多个光源中指定一个或多个光源作为上述目标对象。In the case where the effect type is the first type, the light source may be determined in the image to be processed. If multiple light sources (for example, multiple light bulbs) are determined, at this time, the location in the foreground area can be determined among the multiple light sources. The light source of the domain is the target object; or, the user can specify one or more light sources among multiple light sources as the above target object according to actual needs.
在确定出光源作为目标对象之后,就可以将该光源的中心点确定为中心位置,之后,就可以基于该中心位置确定目标区域内的每个像素点相对于该中心位置的径向方向向量,进而基于该径向方向向量确定对应偏移距离。After determining the light source as the target object, the center point of the light source can be determined as the center position. Then, the radial direction vector of each pixel in the target area relative to the center position can be determined based on the center position. Then the corresponding offset distance is determined based on the radial direction vector.
这里,可以在数值区域中为对应相同径向方向的目标像素点随机生成对应的偏移距离。Here, corresponding offset distances can be randomly generated in the numerical area for target pixels corresponding to the same radial direction.
之后,就可以基于第一模糊参数和偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像。After that, the pixel points can be blurred based on the first blur parameter and the offset distance to obtain a blurred image of the image to be processed.
具体实施时,可以通过上述步骤S3051至步骤S3053所描述的方式对像素点进行模糊处理,从而得到初始模糊图像。之后,还可以基于第一模糊参数对初始模糊图像进行亮度调整和/或颜色调整,从而得到待处理图像的模糊图像。During specific implementation, the pixel points can be blurred in the manner described in the above steps S3051 to S3053, thereby obtaining an initial blurred image. Afterwards, brightness adjustment and/or color adjustment can also be performed on the initial blurred image based on the first blur parameter, thereby obtaining a blurred image of the image to be processed.
在一个可选的实施方式中,在所述效果类型为第二类型的情况下,该方法还可以获取第二模糊参数;其中,所述第二类型用于指示所述待处理图像的效果类型为图像速度线添加效果,第二模糊参数用于指示图像速度线的添加密度和/或图像速度线的添加方向,所述图像速度线用于在待处理图像中显示目标对象的移动效果。In an optional implementation, when the effect type is a second type, the method can also obtain a second blur parameter; wherein the second type is used to indicate the effect type of the image to be processed. To add an effect to the image speed line, the second blur parameter is used to indicate the adding density and/or the adding direction of the image speed line, which is used to display the movement effect of the target object in the image to be processed.
在此情况下,上述步骤S305所述基于所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像,包括:基于所述第二模糊参数和所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像。In this case, performing blur processing on the pixels based on the offset distance in the above step S305 to obtain a blurred image of the image to be processed includes: based on the second blur parameter and the offset distance The pixel points are blurred to obtain a blurred image of the image to be processed.
本公开实施例中,上述第二类型用于指示待处理图像的效果类型为图像速度线添加效果,又可以称为:卡通风格屏幕排线(速度线)模拟效果。在本公开实施例中,可以通过开放线体密度(方向随机密度)和本公开实施例所提供的图像处理方法,来模拟漫画风格中的排线(速度线)等效果。In the embodiment of the present disclosure, the above-mentioned second type is used to indicate that the effect type of the image to be processed is the image speed line adding effect, which can also be called: cartoon style screen line (speed line) simulation effect. In the embodiments of the present disclosure, effects such as line arrangement (speed lines) in comic style can be simulated through open line density (directional random density) and the image processing method provided by the embodiments of the present disclosure.
在效果类型为第二类型的情况下,可以在待处理图像中确定需要显示移动效果的目标对象。如果确定出多个目标对象,此时,可以在多个目标对象中确定位于前景区域的目标对象;或者,用户可以根据实际需要在多个目标对象中指定一个或多个目标对象。When the effect type is the second type, the target object that needs to display the movement effect can be determined in the image to be processed. If multiple target objects are determined, the target object located in the foreground area can be determined among the multiple target objects; or, the user can specify one or more target objects among the multiple target objects according to actual needs.
在确定出目标对象之后,就可以将该目标对象的中心点确定为中心位置。 之后,就可以基于第二模糊参数在待处理图像中确定目标区域,并在目标区域中确定待偏移的像素点。这里,待偏移的像素点可以为目标区域内的全部像素点,还可以部分像素点。接下来,可以基于该中心位置确定待偏移的像素点相对于该中心位置的径向方向向量,进而基于该径向方向向量确定对应偏移距离。After the target object is determined, the center point of the target object can be determined as the center position. After that, the target area can be determined in the image to be processed based on the second blur parameter, and the pixel points to be shifted can be determined in the target area. Here, the pixels to be shifted can be all the pixels in the target area, or some of the pixels. Next, a radial direction vector of the pixel point to be offset relative to the center position may be determined based on the central position, and then a corresponding offset distance may be determined based on the radial direction vector.
这里,可以在数值区域中为对应相同径向方向的待偏移的像素点生成对应的偏移距离。之后,就可以基于偏移距离对待偏移的像素点进行偏移处理,得到待处理图像的模糊图像。Here, corresponding offset distances can be generated in the numerical area for pixel points to be offset corresponding to the same radial direction. After that, the pixels to be offset can be offset based on the offset distance to obtain a blurred image of the image to be processed.
具体实施时,可以通过上述步骤S3051至步骤S3053所描述的方式对像素点进行偏移处理,从而得到初始模糊图像。During specific implementation, the pixel points can be offset in the manner described in the above steps S3051 to S3053, thereby obtaining an initial blurred image.
本领域技术人员可以理解,在具体实施方式的上述方法中,各步骤的撰写顺序并不意味着严格的执行顺序而对实施过程构成任何限定,各步骤的具体执行顺序应当以其功能和可能的内在逻辑确定。Those skilled in the art can understand that in the above-mentioned methods of specific embodiments, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be based on its function and possible The internal logic is determined.
基于同一发明构思,本公开实施例中还提供了与图像处理方法对应的图像处理装置,由于本公开实施例中的装置解决问题的原理与本公开实施例上述图像处理方法相似,因此装置的实施可以参见方法的实施,重复之处不再赘述。Based on the same inventive concept, the embodiments of the present disclosure also provide an image processing device corresponding to the image processing method. Since the principle of solving the problem of the device in the embodiment of the present disclosure is similar to the above-mentioned image processing method in the embodiment of the present disclosure, the implementation of the device Please refer to the implementation of the method, and the repeated parts will not be repeated.
参照图8所示,为本公开实施例提供的一种图像处理装置的示意图,所述装置包括:获取单元10、第一确定单元20、第二确定单元30、偏移处理40;其中,Referring to Figure 8 , which is a schematic diagram of an image processing device provided by an embodiment of the present disclosure, the device includes: an acquisition unit 10, a first determination unit 20, a second determination unit 30, and an offset processing 40; wherein,
获取单元10,用于获取待处理图像;Acquisition unit 10, used to acquire images to be processed;
第一确定单元20,用于确定所述待处理图像的中心位置和所述待处理图像目标区域内的像素点;所述目标区域为待生成径向模糊效果的区域;所述中心位置为所述待处理图像中径向模糊效果的生成中心;The first determination unit 20 is used to determine the center position of the image to be processed and the pixel points in the target area of the image to be processed; the target area is the area where the radial blur effect is to be generated; the center position is the Describes the generation center of the radial blur effect in the image to be processed;
第二确定单元30,用于确定所述像素点相对于所述中心位置的径向方向向量,并基于所述径向方向向量确定所述像素点的偏移距离;不同径向方向的像素点的所述偏移距离不同;The second determination unit 30 is used to determine the radial direction vector of the pixel point relative to the center position, and determine the offset distance of the pixel point based on the radial direction vector; pixel points in different radial directions The offset distance is different;
模糊处理单元40,用于基于所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像。The blur processing unit 40 is configured to perform blur processing on the pixel points based on the offset distance to obtain a blurred image of the image to be processed.
在本公开实施例中,在获取到待处理图像之后,可以确定待处理图像中目标区域内的像素点,然后,确定像素点相对于中心位置的径向方向向量,并根 据该径向方向向量为每个像素点生成对应的偏移距离。由于本公开技术方案是为对应不同径向方向向量的像素点生成不同的偏移距离,因此,可以实现对应相同横坐标的像素点在横轴方向上的偏移距离不同,以及导致对应相同纵坐标的像素点在纵轴方向上的偏移距离不同,从而有效消除模糊图像中的重影,以提高径向模糊的模糊效果。In the embodiment of the present disclosure, after obtaining the image to be processed, the pixel points in the target area in the image to be processed can be determined, and then the radial direction vector of the pixel point relative to the center position is determined, and based on A corresponding offset distance is generated for each pixel based on the radial direction vector. Since the technical solution of the present disclosure is to generate different offset distances for pixels corresponding to different radial direction vectors, it can be achieved that pixels corresponding to the same abscissa have different offset distances in the horizontal axis direction, and the pixels corresponding to the same vertical coordinate can have different offset distances. The pixel points of the coordinates have different offset distances in the vertical axis direction, thereby effectively eliminating ghosts in the blurred image and improving the blur effect of radial blur.
一种可能的实施方式中,第二确定单元,还用于:确定所述中心位置在所述待处理图像中的像素坐标,得到第一像素坐标,并确定所述像素点在所述待处理图像中的像素坐标,得到第二像素坐标;基于所述第一像素坐标和所述第二像素坐标,确定所述径向方向向量。In a possible implementation, the second determination unit is further configured to: determine the pixel coordinates of the center position in the image to be processed, obtain the first pixel coordinates, and determine the position of the pixel point in the image to be processed. The pixel coordinates in the image are used to obtain the second pixel coordinates; based on the first pixel coordinates and the second pixel coordinates, the radial direction vector is determined.
一种可能的实施方式中,第二确定单元,还用于:基于所述径向方向向量确定所述像素点中径向方向相同的目标像素点;所述径向方向为所述径向方向向量的方向;通过预设随机函数为所述目标像素点生成相同的随机数值;将所述相同的随机数值作为所述目标像素点的偏移距离。In a possible implementation, the second determination unit is further configured to: determine target pixel points in the pixel points with the same radial direction based on the radial direction vector; the radial direction is the radial direction The direction of the vector; generate the same random value for the target pixel point through a preset random function; use the same random value as the offset distance of the target pixel point.
一种可能的实施方式中,所述径向方向向量中包含横轴方向的向量分量和纵轴方向的向量分量;所述偏移距离包括:所述横轴方向的向量分量的偏移分量和所述纵轴方向的向量分量的偏移分量。In a possible implementation, the radial direction vector includes a vector component in the transverse axis direction and a vector component in the longitudinal axis direction; the offset distance includes: an offset component of the vector component in the transverse axis direction and The offset component of the vector component in the longitudinal axis direction.
一种可能的实施方式中,模糊处理单元,还用于:获取预先为所述像素点设定的目标模糊距离;按照预设叠加方式将所述目标模糊距离和所述像素点的偏移距离进行叠加,得到目标偏移距离;基于所述目标偏移距离,对相应的像素点进行模糊处理,得到所述待处理图像的模糊图像。In a possible implementation, the blur processing unit is further configured to: obtain a target blur distance preset for the pixel; and combine the target blur distance and the offset distance of the pixel according to a preset superposition method. Superposition is performed to obtain the target offset distance; based on the target offset distance, the corresponding pixel points are blurred to obtain a blurred image of the image to be processed.
一种可能的实施方式中,模糊处理单元,还用于:按照预设计算方式,对所述目标模糊距离和每个所述像素点的偏移距离进行计算,得到所述目标偏移距离,其中,所述预设计算方式包括以下任一种:乘法、加法。In a possible implementation, the blur processing unit is further configured to: calculate the target blur distance and the offset distance of each pixel point according to a preset calculation method to obtain the target offset distance, Wherein, the preset calculation method includes any of the following: multiplication and addition.
一种可能的实施方式中,该装置还用于:确定所述偏移距离在预设差值范围内的目标差值结果;偏移单元,还用于:按照所述预设叠加方式将所述目标模糊距离和所述目标差值结果进行叠加,得到目标偏移距离。In a possible implementation, the device is further configured to: determine a target difference result in which the offset distance is within a preset difference range; and the offset unit is further configured to: add all the offset values according to the preset superposition method. The target fuzzy distance and the target difference result are superimposed to obtain the target offset distance.
一种可能的实施方式中,第一确定单元,还用于:确定所述径向模糊效果的效果类型,并基于所述效果类型在所述待处理图像中确定目标对象;基于所述目标对象确定所述中心位置,并基于所述中心位置确定所述像素点的径向方 向向量。In a possible implementation, the first determination unit is further configured to: determine the effect type of the radial blur effect, and determine the target object in the image to be processed based on the effect type; based on the target object Determine the center position, and determine the radial direction of the pixel based on the center position to vector.
一种可能的实施方式中,该装置还用于:在所述效果类型为第一类型的情况下,获取第一模糊参数;其中,所述第一类型用于指示所述待处理图像的效果类型为体积光影效果;所述第一模糊参数包括亮度参数和/或颜色参数;模糊处理单元,还用于:基于所述第一模糊参数和所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像。In a possible implementation, the device is further configured to: obtain a first blur parameter when the effect type is a first type; wherein the first type is used to indicate the effect of the image to be processed The type is volumetric light and shadow effect; the first blur parameter includes a brightness parameter and/or a color parameter; a blur processing unit, further configured to: blur the pixel based on the first blur parameter and the offset distance , obtain the blurred image of the image to be processed.
一种可能的实施方式中,该装置还用于:在所述效果类型为第二类型的情况下,获取第二模糊参数;其中,所述第二类型用于指示所述待处理图像的效果类型为图像速度线添加效果,所述第二模糊参数用于指示图像速度线的添加密度和/或图像速度线的添加方向,所述图像速度线用于在待处理图像中显示目标对象的移动效果;模糊处理单元,还用于:基于所述第二模糊参数和所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像。In a possible implementation, the device is further configured to: obtain a second blur parameter when the effect type is a second type; wherein the second type is used to indicate the effect of the image to be processed. The type is image speed line adding effect. The second blur parameter is used to indicate the adding density and/or the adding direction of the image speed line. The image speed line is used to display the movement of the target object in the image to be processed. Effect; a blur processing unit, further configured to: blur the pixel points based on the second blur parameter and the offset distance to obtain a blurred image of the image to be processed.
关于装置中的各模块的处理流程、以及各模块之间的交互流程的描述可以参照上述方法实施例中的相关说明,这里不再详述。For a description of the processing flow of each module in the device and the interaction flow between the modules, please refer to the relevant descriptions in the above method embodiments, and will not be described in detail here.
对应于图1中的图像处理方法,本公开实施例还提供了一种计算机设备900,如图9所示,为本公开实施例提供的计算机设备900结构示意图,包括:Corresponding to the image processing method in Figure 1, an embodiment of the present disclosure also provides a computer device 900. As shown in Figure 9, which is a schematic structural diagram of the computer device 900 provided by an embodiment of the present disclosure, it includes:
处理器91、存储器92、和总线93;存储器92用于存储执行指令,包括内存921和外部存储器922;这里的内存921也称内存储器,用于暂时存放处理器91中的运算数据,以及与硬盘等外部存储器922交换的数据,处理器91通过内存921与外部存储器922进行数据交换,当所述计算机设备900运行时,所述处理器91与所述存储器92之间通过总线93通信,使得所述处理器91执行以下指令:Processor 91, memory 92, and bus 93; memory 92 is used to store execution instructions, including memory 921 and external memory 922; memory 921 here is also called internal memory, and is used to temporarily store operation data in the processor 91, and with The processor 91 exchanges data with the external memory 922 such as a hard disk through the memory 921 and the external memory 922. When the computer device 900 is running, the processor 91 and the memory 92 communicate through the bus 93, so that The processor 91 executes the following instructions:
获取待处理图像,并确定所述待处理图像的中心位置和所述待处理图像目标区域内的像素点;所述目标区域为待生成径向模糊效果的区域;所述中心位置为所述待处理图像中径向模糊效果的生成中心;确定所述像素点相对于所述中心位置的径向方向向量,并基于所述径向方向向量确定所述像素点的偏移距离;不同径向方向的像素点的所述偏移距离不同;基于所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像。Obtain the image to be processed, and determine the center position of the image to be processed and the pixels in the target area of the image to be processed; the target area is the area where the radial blur effect is to be generated; the center position is the area to be processed. Processing the generation center of the radial blur effect in the image; determining the radial direction vector of the pixel point relative to the center position, and determining the offset distance of the pixel point based on the radial direction vector; different radial directions The offset distances of the pixel points are different; the pixel points are blurred based on the offset distance to obtain a blurred image of the image to be processed.
一种可能的实施方式中,所述处理器91的指令中,还包括: In a possible implementation, the instructions of the processor 91 also include:
确定所述中心位置在所述待处理图像中的像素坐标,得到第一像素坐标,并确定所述像素点在所述待处理图像中的像素坐标,得到第二像素坐标;Determine the pixel coordinates of the center position in the image to be processed to obtain the first pixel coordinates, and determine the pixel coordinates of the pixel point in the image to be processed to obtain the second pixel coordinates;
基于所述第一像素坐标和所述第二像素坐标,确定所述径向方向向量。The radial direction vector is determined based on the first pixel coordinate and the second pixel coordinate.
一种可能的实施方式中,所述处理器91的指令中,还包括:In a possible implementation, the instructions of the processor 91 also include:
基于所述径向方向向量确定所述像素点中径向方向相同的目标像素点;所述径向方向为所述径向方向向量的方向;Target pixel points with the same radial direction among the pixel points are determined based on the radial direction vector; the radial direction is the direction of the radial direction vector;
通过预设随机函数为所述目标像素点生成相同的随机数值;Generate the same random value for the target pixel using a preset random function;
将所述相同的随机数值作为所述目标像素点的偏移距离。The same random value is used as the offset distance of the target pixel point.
一种可能的实施方式中,所述处理器91的指令中,还包括:In a possible implementation, the instructions of the processor 91 also include:
所述径向方向向量中包含横轴方向的向量分量和纵轴方向的向量分量;所述偏移距离包括:所述横轴方向的向量分量的偏移分量和所述纵轴方向的向量分量的偏移分量。The radial direction vector includes a vector component in the transverse axis direction and a vector component in the longitudinal axis direction; the offset distance includes: an offset component of the vector component in the transverse axis direction and a vector component in the longitudinal axis direction. offset component.
一种可能的实施方式中,所述处理器91的指令中,还包括:In a possible implementation, the instructions of the processor 91 also include:
获取预先为所述像素点设定的目标模糊距离;Obtain the target blur distance set in advance for the pixel;
按照预设叠加方式将所述目标模糊距离和所述像素点的偏移距离进行叠加,得到目标偏移距离;Superimpose the target blur distance and the offset distance of the pixel point according to a preset superposition method to obtain the target offset distance;
基于所述目标偏移距离,对相应的像素点进行模糊处理,得到所述待处理图像的模糊图像。Based on the target offset distance, the corresponding pixel points are blurred to obtain a blurred image of the image to be processed.
一种可能的实施方式中,所述处理器91的指令中,还包括:In a possible implementation, the instructions of the processor 91 also include:
按照预设计算方式,对所述目标模糊距离和每个所述像素点的偏移距离进行计算,得到所述目标偏移距离,其中,所述预设计算方式包括以下任一种:乘法、加法。According to a preset calculation method, the target blur distance and the offset distance of each pixel point are calculated to obtain the target offset distance, wherein the preset calculation method includes any of the following: multiplication, addition.
一种可能的实施方式中,所述处理器91的指令中,还包括:In a possible implementation, the instructions of the processor 91 also include:
确定所述偏移距离在预设差值范围内的目标差值结果;Determine the target difference result with the offset distance within a preset difference range;
按照所述预设叠加方式将所述目标模糊距离和所述目标差值结果进行叠加,得到目标偏移距离。The target blur distance and the target difference result are superimposed according to the preset superposition method to obtain the target offset distance.
一种可能的实施方式中,所述处理器91的指令中,还包括:In a possible implementation, the instructions of the processor 91 also include:
确定所述径向模糊效果的效果类型,并基于所述效果类型在所述待处理图像中确定目标对象; Determine an effect type of the radial blur effect, and determine a target object in the image to be processed based on the effect type;
基于所述目标对象确定所述中心位置,并基于所述中心位置确定所述像素点的径向方向向量。The center position is determined based on the target object, and the radial direction vector of the pixel point is determined based on the center position.
一种可能的实施方式中,所述处理器91的指令中,还包括:In a possible implementation, the instructions of the processor 91 also include:
在所述效果类型为第一类型的情况下,获取第一模糊参数;其中,所述第一类型用于指示所述待处理图像的效果类型为体积光影效果;所述第一模糊参数包括亮度参数和/或颜色参数;基于所述第一模糊参数和所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像。When the effect type is the first type, a first blur parameter is obtained; wherein the first type is used to indicate that the effect type of the image to be processed is a volumetric light and shadow effect; the first blur parameter includes brightness parameters and/or color parameters; perform blur processing on the pixel points based on the first blur parameter and the offset distance to obtain a blurred image of the image to be processed.
一种可能的实施方式中,所述处理器91的指令中,还包括:In a possible implementation, the instructions of the processor 91 also include:
在所述效果类型为第二类型的情况下,获取第二模糊参数;其中,所述第二类型用于指示所述待处理图像的效果类型为图像速度线添加效果,所述第二模糊参数用于指示图像速度线的添加密度和/或图像速度线的添加方向,所述图像速度线用于在待处理图像中显示目标对象的移动效果;基于所述第二模糊参数和所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像。When the effect type is the second type, obtain a second blur parameter; wherein the second type is used to indicate that the effect type of the image to be processed is an image speed line adding effect, and the second blur parameter Used to indicate the added density of the image speed line and/or the added direction of the image speed line, which is used to display the movement effect of the target object in the image to be processed; based on the second blur parameter and the offset The distance is used to blur the pixel points to obtain a blurred image of the image to be processed.
本公开实施例还提供一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行上述方法实施例中所述的图像处理方法的步骤。其中,该存储介质可以是易失性或非易失的计算机可读取存储介质。Embodiments of the present disclosure also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is run by a processor, the steps of the image processing method described in the above method embodiment are executed. Wherein, the storage medium may be a volatile or non-volatile computer-readable storage medium.
本公开实施例还提供一种计算机程序产品,该计算机程序产品承载有程序代码,所述程序代码包括的指令可用于执行上述方法实施例中所述的图像处理方法的步骤,具体可参见上述方法实施例,在此不再赘述。Embodiments of the present disclosure also provide a computer program product. The computer program product carries program code. The instructions included in the program code can be used to execute the steps of the image processing method described in the above method embodiment. For details, please refer to the above method. The embodiments will not be described again here.
其中,上述计算机程序产品可以具体通过硬件、软件或其结合的方式实现。在一个可选实施例中,所述计算机程序产品具体体现为计算机存储介质,在另一个可选实施例中,计算机程序产品具体体现为软件产品,例如软件开发包(Software Development Kit,SDK)等等。Among them, the above-mentioned computer program product can be specifically implemented by hardware, software or a combination thereof. In an optional embodiment, the computer program product is embodied as a computer storage medium. In another optional embodiment, the computer program product is embodied as a software product, such as a Software Development Kit (SDK), etc. wait.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统和装置的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。在本公开所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性 的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,又例如,多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些通信接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be described again here. In the several embodiments provided in this disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are only illustrative For example, the division of units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be Ignore, or do not execute. On the other hand, the coupling or direct coupling or communication connection between each other shown or discussed may be through some communication interfaces, and the indirect coupling or communication connection of the devices or units may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or they may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本公开各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in various embodiments of the present disclosure may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个处理器可执行的非易失的计算机可读取存储介质中。基于这样的理解,本公开实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本公开各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the embodiments of the present disclosure is essentially or contributes to the existing technology or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , including several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present disclosure. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program code. .
最后应说明的是:以上所述实施例,仅为本公开的具体实施方式,用以说明本公开的技术方案,而非对其限制,本公开的保护范围并不局限于此,尽管参照前述实施例对本公开进行了详细的说明,本领域的普通技术人员应当理解:任何熟悉本技术领域的技术人员在本公开揭露的技术范围内,其依然可以对前述实施例所记载的技术方案进行修改或可轻易想到变化,或者对其中部分技术特征进行等同替换;而这些修改、变化或者替换,并不使相应技术方案的本质脱离本公开实施例技术方案的精神和范围,都应涵盖在本公开的保护范围之内。因此,本公开的保护范围应所述以权利要求的保护范围为准。 Finally, it should be noted that the above-mentioned embodiments are only specific implementations of the present disclosure and are used to illustrate the technical solutions of the present disclosure rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although refer to the foregoing The embodiments describe the present disclosure in detail. Those of ordinary skill in the art should understand that any person familiar with the technical field can still modify the technical solutions recorded in the foregoing embodiments within the technical scope disclosed in the present disclosure. Changes may be easily imagined, or equivalent substitutions may be made to some of the technical features; and these modifications, changes or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and shall be included in the present disclosure. within the scope of protection. Therefore, the protection scope of the present disclosure should be determined by the protection scope of the claims.

Claims (14)

  1. 一种图像处理方法,包括:An image processing method including:
    获取待处理图像,并确定所述待处理图像的中心位置和所述待处理图像目标区域内的像素点;所述目标区域为待生成径向模糊效果的区域;所述中心位置为所述待处理图像中径向模糊效果的生成中心;Obtain the image to be processed, and determine the center position of the image to be processed and the pixels in the target area of the image to be processed; the target area is the area where the radial blur effect is to be generated; the center position is the area to be processed. Processes the center of generation of radial blur effects in images;
    确定所述像素点相对于所述中心位置的径向方向向量,并基于所述径向方向向量确定所述像素点的偏移距离;不同径向方向的像素点的所述偏移距离不同;Determine the radial direction vector of the pixel point relative to the center position, and determine the offset distance of the pixel point based on the radial direction vector; the offset distances of pixel points in different radial directions are different;
    基于所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像。The pixel points are blurred based on the offset distance to obtain a blurred image of the image to be processed.
  2. 根据权利要求1所述的方法,其中,所述确定所述像素点相对于所述中心位置的径向方向向量,包括:The method according to claim 1, wherein determining the radial direction vector of the pixel relative to the center position includes:
    确定所述中心位置在所述待处理图像中的像素坐标,得到第一像素坐标,并确定所述像素点在所述待处理图像中的像素坐标,得到第二像素坐标;Determine the pixel coordinates of the center position in the image to be processed to obtain the first pixel coordinates, and determine the pixel coordinates of the pixel point in the image to be processed to obtain the second pixel coordinates;
    基于所述第一像素坐标和所述第二像素坐标,确定所述径向方向向量。The radial direction vector is determined based on the first pixel coordinate and the second pixel coordinate.
  3. 根据权利要求1所述的方法,其中,所述基于所述径向方向向量确定所述像素点的偏移距离,包括:The method according to claim 1, wherein determining the offset distance of the pixel point based on the radial direction vector includes:
    基于所述径向方向向量确定所述像素点中径向方向相同的目标像素点;所述径向方向为所述径向方向向量的方向;Target pixel points with the same radial direction among the pixel points are determined based on the radial direction vector; the radial direction is the direction of the radial direction vector;
    通过预设随机函数为所述目标像素点生成相同的随机数值;Generate the same random value for the target pixel using a preset random function;
    将所述相同的随机数值作为所述目标像素点的偏移距离。The same random value is used as the offset distance of the target pixel point.
  4. 根据权利要求3所述的方法,其中,所述径向方向向量中包含横轴方向的向量分量和纵轴方向的向量分量;所述偏移距离包括:所述横轴方向的向量分量的偏移分量和所述纵轴方向的向量分量的偏移分量。The method according to claim 3, wherein the radial direction vector includes a vector component in the transverse axis direction and a vector component in the longitudinal axis direction; the offset distance includes: an offset of the vector component in the transverse axis direction. The shift component and the offset component of the vector component in the longitudinal axis direction.
  5. 根据权利要求1所述的方法,其中,所述基于所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像,包括:The method according to claim 1, wherein the blurring of the pixels based on the offset distance to obtain the blurred image of the image to be processed includes:
    获取预先为所述像素点设定的目标模糊距离;Obtain the target blur distance set in advance for the pixel;
    按照预设叠加方式将所述目标模糊距离和所述像素点的偏移距离进行 叠加,得到目标偏移距离;The target blur distance and the offset distance of the pixel are calculated according to a preset superposition method. Superimpose to get the target offset distance;
    基于所述目标偏移距离,对相应的像素点进行模糊处理,得到所述待处理图像的模糊图像。Based on the target offset distance, the corresponding pixel points are blurred to obtain a blurred image of the image to be processed.
  6. 根据权利要求5所述的方法,其中,所述按照预设叠加方式将所述目标模糊距离和所述像素点的偏移距离进行叠加,得到目标偏移距离,包括:The method according to claim 5, wherein the step of superimposing the target blur distance and the offset distance of the pixel point according to a preset superposition method to obtain the target offset distance includes:
    按照预设计算方式,对所述目标模糊距离和每个所述像素点的偏移距离进行计算,得到所述目标偏移距离,其中,所述预设计算方式包括以下任一种:乘法、加法。According to a preset calculation method, the target blur distance and the offset distance of each pixel point are calculated to obtain the target offset distance, wherein the preset calculation method includes any of the following: multiplication, addition.
  7. 根据权利要求5所述的方法,其中,所述方法还包括:确定所述偏移距离在预设差值范围内的目标差值结果;The method according to claim 5, wherein the method further comprises: determining a target difference result where the offset distance is within a preset difference range;
    所述按照预设叠加方式将所述目标模糊距离和所述像素点的偏移距离进行叠加,得到目标偏移距离,包括:按照所述预设叠加方式将所述目标模糊距离和所述目标差值结果进行叠加,得到目标偏移距离。Superposing the target blur distance and the offset distance of the pixel point according to the preset superposition method to obtain the target offset distance includes: adding the target blur distance and the target offset distance according to the preset superposition method. The difference results are superimposed to obtain the target offset distance.
  8. 根据权利要求1所述的方法,其中,所述确定所述像素点相对于所述中心位置的径向方向向量,包括:The method according to claim 1, wherein determining the radial direction vector of the pixel relative to the center position includes:
    确定所述径向模糊效果的效果类型,并基于所述效果类型在所述待处理图像中确定目标对象;Determine an effect type of the radial blur effect, and determine a target object in the image to be processed based on the effect type;
    基于所述目标对象确定所述中心位置,并基于所述中心位置确定所述像素点的径向方向向量。The center position is determined based on the target object, and the radial direction vector of the pixel point is determined based on the center position.
  9. 根据权利要求8所述的方法,其中,所述方法还包括:The method of claim 8, further comprising:
    在所述效果类型为第一类型的情况下,获取第一模糊参数;其中,所述第一类型用于指示所述待处理图像的效果类型为体积光影效果;所述第一模糊参数包括亮度参数和/或颜色参数;When the effect type is the first type, a first blur parameter is obtained; wherein the first type is used to indicate that the effect type of the image to be processed is a volumetric light and shadow effect; the first blur parameter includes brightness parameters and/or color parameters;
    所述基于所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像,包括:The step of blurring the pixel points based on the offset distance to obtain a blurred image of the image to be processed includes:
    基于所述第一模糊参数和所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像。The pixel points are blurred based on the first blur parameter and the offset distance to obtain a blurred image of the image to be processed.
  10. 根据权利要求8所述的方法,其中,所述方法还包括: The method of claim 8, further comprising:
    在所述效果类型为第二类型的情况下,获取第二模糊参数;其中,所述第二类型用于指示所述待处理图像的效果类型为图像速度线添加效果,所述第二模糊参数用于指示图像速度线的添加密度和/或图像速度线的添加方向,所述图像速度线用于在待处理图像中显示目标对象的移动效果;When the effect type is the second type, obtain a second blur parameter; wherein the second type is used to indicate that the effect type of the image to be processed is an image speed line adding effect, and the second blur parameter Used to indicate the added density of image speed lines and/or the added direction of image speed lines, which are used to display the movement effect of the target object in the image to be processed;
    所述基于所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像,包括:The step of blurring the pixel points based on the offset distance to obtain a blurred image of the image to be processed includes:
    基于所述第二模糊参数和所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像。The pixel points are blurred based on the second blur parameter and the offset distance to obtain a blurred image of the image to be processed.
  11. 一种图像处理装置,包括:An image processing device, including:
    获取单元,用于获取待处理图像;Acquisition unit, used to obtain images to be processed;
    第一确定单元,用于确定所述待处理图像的中心位置和所述待处理图像目标区域内的像素点;所述目标区域为待生成径向模糊效果的区域;所述中心位置为所述待处理图像中径向模糊效果的生成中心;The first determination unit is used to determine the center position of the image to be processed and the pixel points in the target area of the image to be processed; the target area is the area where the radial blur effect is to be generated; the center position is the The center of generation of the radial blur effect in the image to be processed;
    第二确定单元,用于确定所述像素点相对于所述中心位置的径向方向向量,并基于所述径向方向向量确定所述像素点的偏移距离;不同径向方向的像素点的所述偏移距离不同;The second determination unit is used to determine the radial direction vector of the pixel point relative to the center position, and determine the offset distance of the pixel point based on the radial direction vector; the radial direction vector of the pixel point in different radial directions The offset distances are different;
    模糊处理单元,用于基于所述偏移距离对所述像素点进行模糊处理,得到所述待处理图像的模糊图像。A blur processing unit is configured to blur the pixel points based on the offset distance to obtain a blurred image of the image to be processed.
  12. 一种计算机设备,包括:处理器、存储器和总线,所述存储器存储有所述处理器可执行的机器可读指令,当计算机设备运行时,所述处理器与所述存储器之间通过总线通信,所述机器可读指令被所述处理器执行时执行如权利要求1至10任一所述的图像处理方法的步骤。A computer device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the computer device is running, the processor communicates with the memory through the bus. , when the machine-readable instructions are executed by the processor, the steps of the image processing method according to any one of claims 1 to 10 are performed.
  13. 一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行如权利要求1至10任意一项所述的图像处理方法的步骤。A computer-readable storage medium has a computer program stored on the computer-readable storage medium, and the computer program executes the steps of the image processing method according to any one of claims 1 to 10 when run by a processor.
  14. 一种计算机程序产品,当所述计算机程序产品在计算机上运行时,使得所述计算机实现如权利要求1至10任意一项所述的图像处理方法的步骤。 A computer program product, when the computer program product is run on a computer, causes the computer to implement the steps of the image processing method according to any one of claims 1 to 10.
PCT/CN2023/080379 2022-03-17 2023-03-09 Image processing method and apparatus, and computer device and storage medium WO2023174137A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210264780.5A CN114626978A (en) 2022-03-17 2022-03-17 Image processing method and device, computer equipment and storage medium
CN202210264780.5 2022-03-17

Publications (1)

Publication Number Publication Date
WO2023174137A1 true WO2023174137A1 (en) 2023-09-21

Family

ID=81902404

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/080379 WO2023174137A1 (en) 2022-03-17 2023-03-09 Image processing method and apparatus, and computer device and storage medium

Country Status (2)

Country Link
CN (1) CN114626978A (en)
WO (1) WO2023174137A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114626978A (en) * 2022-03-17 2022-06-14 北京字跳网络技术有限公司 Image processing method and device, computer equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130279799A1 (en) * 2010-12-03 2013-10-24 Sharp Kabushiki Kaisha Image processing device, image processing method, and image processing program
CN108305228A (en) * 2018-01-26 2018-07-20 网易(杭州)网络有限公司 Image processing method, device, storage medium and processor
CN108564541A (en) * 2018-03-28 2018-09-21 麒麟合盛网络技术股份有限公司 A kind of image processing method and device
CN112541867A (en) * 2020-12-04 2021-03-23 Oppo(重庆)智能科技有限公司 Image processing method, image processing device, electronic equipment and computer readable storage medium
CN113256785A (en) * 2021-05-31 2021-08-13 北京字跳网络技术有限公司 Image processing method, apparatus, device and medium
CN114626978A (en) * 2022-03-17 2022-06-14 北京字跳网络技术有限公司 Image processing method and device, computer equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130279799A1 (en) * 2010-12-03 2013-10-24 Sharp Kabushiki Kaisha Image processing device, image processing method, and image processing program
CN108305228A (en) * 2018-01-26 2018-07-20 网易(杭州)网络有限公司 Image processing method, device, storage medium and processor
CN108564541A (en) * 2018-03-28 2018-09-21 麒麟合盛网络技术股份有限公司 A kind of image processing method and device
CN112541867A (en) * 2020-12-04 2021-03-23 Oppo(重庆)智能科技有限公司 Image processing method, image processing device, electronic equipment and computer readable storage medium
CN113256785A (en) * 2021-05-31 2021-08-13 北京字跳网络技术有限公司 Image processing method, apparatus, device and medium
CN114626978A (en) * 2022-03-17 2022-06-14 北京字跳网络技术有限公司 Image processing method and device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN114626978A (en) 2022-06-14

Similar Documents

Publication Publication Date Title
EP2291999B1 (en) Image deconvolution using color priors
US8824821B2 (en) Method and apparatus for performing user inspired visual effects rendering on an image
CN105409196B (en) Adaptive Path for video stabilization is smooth
US20090122083A1 (en) Edge evaluation techniques for graphics hardware
EP2164040A1 (en) System and method for high quality image and video upscaling
US9953400B2 (en) Adaptive path smoothing for video stabilization
WO2021115136A1 (en) Anti-shake method and apparatus for video image, electronic device, and storage medium
CN112652046B (en) Game picture generation method, device, equipment and storage medium
US9734551B1 (en) Providing depth-of-field renderings
JP7101269B2 (en) Pose correction
WO2018210308A1 (en) Blurring method and apparatus for image, storage medium, and electronic device
WO2023174137A1 (en) Image processing method and apparatus, and computer device and storage medium
WO2021147374A1 (en) Image processing method and apparatus, and method and apparatus for training image processing model
CN115330986B (en) Method and system for processing graphics in block rendering mode
CN113657518B (en) Training method, target image detection method, device, electronic device, and medium
WO2022048414A1 (en) Image generation method, apparatus, and device, and storage medium
CN116457828A (en) Supervised learning and occlusion masking for optical flow estimation
JP2023501692A (en) light volume rendering
CN107563960A (en) A kind of processing method, storage medium and the mobile terminal of self-timer picture
US9639975B1 (en) System and method for generating shadows
Seychell et al. An approach for objective quality assessment of image inpainting results
KR20230154355A (en) Apparatus and method for denoising based on non-local mean
Hashimoto et al. An FPGA-Based Fully Pipelined Bilateral Grid for Real-Time Image Denoising
US20220292344A1 (en) Processing data in pixel-to-pixel neural networks
TWI815092B (en) A video processing circuit and a method for performing super-resolution (sr) operations

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23769643

Country of ref document: EP

Kind code of ref document: A1