Image processing method, device and electronic equipment
By acquiring pixel coordinates and values in the image and generating and superimposing images with high brightness, the problem of poor adding high brightness in the image in the prior art is solved, and the visual effect of high brightness is achieved.
Patent Information
- Application Number
- CN202210022321.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-10
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2042-01-10
AI Technical Summary
The prior art is difficult to effectively add highlights to images, resulting in poor visual effects.
By acquiring at least one pixel coordinates in the image and the corresponding pixel values, a second image including the high brightness point is generated and superimposed on the original image, the addition of the high brightness point is achieved.
The effect of adding highlights to the image is achieved, improving the visual effect, and making the image present a highlight display effect.
Smart Images

Figure CN114363519B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular to an image processing method, device and electronic device. Background Art
[0002] Currently, when performing image processing, in order to achieve better visual effects, highlights can be added to the image, and an image processing method for adding highlights to the image is urgently needed. Summary of the invention
[0003] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides an image processing method, device and electronic device, which can superimpose highlight points on an image to achieve the effect of adding highlight points to the image.
[0004] In order to achieve the above objectives, the technical solutions provided by the embodiments of the present disclosure are as follows:
[0005] In a first aspect, an image processing method is provided, comprising:
[0006] acquiring a first image;
[0007] Obtain at least one pixel coordinate and a first pixel value of the at least one pixel coordinate;
[0008] generating a second image including at least one highlight point based on the at least one pixel coordinate and the first pixel value of the at least one pixel coordinate;
[0009] The second image is superimposed on the first image to obtain a target image.
[0010] As an optional implementation of the embodiment of the present disclosure, the acquiring at least one pixel coordinate and the first pixel value of the at least one pixel coordinate includes:
[0011] Obtain at least one three-dimensional world coordinate;
[0012] Determining the at least one pixel coordinate according to the at least one three-dimensional world coordinate;
[0013] A first pixel value of the at least one pixel coordinate is determined according to the at least one three-dimensional world coordinate and a trigonometric function.
[0014] As an optional implementation of the embodiment of the present disclosure, determining the first pixel value of the at least one pixel coordinate according to the at least one three-dimensional world coordinate and the trigonometric function includes:
[0015] Inputting the at least one three-dimensional world coordinate into a trigonometric function to obtain a first pixel value of the at least one pixel coordinate;
[0016] The trigonometric function is expressed as: y=frac(sin(x)*100.99999), wherein x represents a three-dimensional world coordinate and y is used to represent the first pixel value.
[0017] As an optional implementation of the embodiment of the present disclosure, the acquiring at least one pixel coordinate and the first pixel value of the at least one pixel coordinate includes:
[0018] Get a random noise map;
[0019] Determine a target normal vector for each pixel in the random noise image;
[0020] Determine the pixel value of each pixel point based on the target normal vector and the sight direction vector;
[0021] Determine at least one first pixel point from the pixel points, wherein a pixel value of the at least one first pixel point is greater than or equal to a preset value;
[0022] The pixel coordinates of the at least one first pixel point are determined as the at least one pixel coordinate, and the pixel value of the at least one first pixel point is used as the first pixel value corresponding to the at least one pixel coordinate.
[0023] As an optional implementation of the embodiment of the present disclosure, the target normal vector is the object normal vector, or an offset normal vector.
[0024] As an optional implementation of the embodiment of the present disclosure, the target normal vector is an offset normal vector, and determining the target normal vector of each pixel point in the random noise map includes:
[0025] Determine the object normal vector of each pixel in the random noise image;
[0026] Constructing a matrix offset normal vector of each pixel point, wherein the matrix offset normal vector is used to offset the object normal vector;
[0027] The offset normal vector of each pixel point is calculated based on the object normal vector of each pixel point and the matrix offset normal vector of each pixel point.
[0028] As an optional implementation of the embodiment of the present disclosure, generating a second image including at least one highlight point based on the at least one pixel coordinate and the first pixel value of the at least one pixel coordinate includes:
[0029] generating an initial image including the at least one highlight point based on the at least one pixel coordinate and the first pixel value of the at least one pixel coordinate;
[0030] Performing n rounds of convolution operations on the initial image with a target convolution kernel to obtain a second image including the at least one highlight point;
[0031] Among them, the moving direction of the target convolution kernel is the target direction, and n is a positive integer.
[0032] As an optional implementation of the embodiment of the present disclosure, the target convolution kernel is a mean convolution kernel, or a Gaussian convolution kernel.
[0033] As an optional implementation of the embodiment of the present disclosure, the method further includes:
[0034] After the (i-1)th round of convolution operation and before the (i)th round of convolution operation, determine that the first weight value in the target convolution kernel during the (i)th round of convolution operation is 1 / i of the second weight value during the (i-1)th round of convolution operation;
[0035] Among them, the first weight value is the weight value corresponding to the pixel point whose distance from the target highlight point is i pixels wide, the second weight value is the weight value corresponding to the pixel point whose distance from the target highlight point is i-1 pixels wide, the target highlight point is any highlight point among the at least one highlight point, and i is an integer greater than or equal to 2 and less than or equal to n.
[0036] As an optional implementation of the embodiment of the present disclosure, performing n rounds of convolution operations on the initial image with a target convolution kernel to obtain a second image including the at least one highlight point includes:
[0037] The following steps are performed in the jth round of convolution operation:
[0038] Get the rotation angle;
[0039] Calculate the coordinates of the rotated target pixel according to the rotation angle, the pixel width, and the initial pixel coordinates of each pixel point in the convolution result of the j-th round of convolution operation;
[0040] The pixel value of each pixel point in the convolution result of the j-th round of convolution operation is set to the pixel value of the pixel point at the target pixel coordinate, where j is an integer less than or equal to n.
[0041] In a second aspect, an image processing device is provided, comprising:
[0042] An acquisition module, configured to acquire a first image; acquire at least one pixel coordinate and a first pixel value of the at least one pixel coordinate;
[0043] A generating module, configured to generate a second image including at least one highlight point based on the at least one pixel coordinate and the first pixel value of the at least one pixel coordinate;
[0044] The superposition module is used to superimpose the second image on the first image to obtain a target image.
[0045] As an optional implementation of the embodiment of the present disclosure, the acquisition module is specifically used to:
[0046] Obtain at least one three-dimensional world coordinate;
[0047] Determining the at least one pixel coordinate according to the at least one three-dimensional world coordinate;
[0048] A first pixel value of the at least one pixel coordinate is determined according to the at least one three-dimensional world coordinate and a trigonometric function.
[0049] As an optional implementation of the embodiment of the present disclosure, the acquisition module is specifically used to:
[0050] Inputting the at least one three-dimensional world coordinate into a trigonometric function to obtain a first pixel value of the at least one pixel coordinate;
[0051] The trigonometric function is expressed as: y=frac(sin(x)*100.99999), wherein x represents a three-dimensional world coordinate and y is used to represent the first pixel value.
[0052] As an optional implementation of the embodiment of the present disclosure, the acquisition module is specifically used to:
[0053] Get a random noise map;
[0054] Determine a target normal vector for each pixel in the random noise image;
[0055] Determine the pixel value of each pixel point based on the target normal vector and the sight direction vector;
[0056] Determine at least one first pixel point from the pixel points, wherein a pixel value of the at least one first pixel point is greater than or equal to a preset value;
[0057] The pixel coordinates of the at least one first pixel point are determined as the at least one pixel coordinate, and the pixel value of the at least one first pixel point is used as the first pixel value corresponding to the at least one pixel coordinate.
[0058] As an optional implementation of the embodiment of the present disclosure, the target normal vector is the object normal vector, or an offset normal vector.
[0059] As an optional implementation of the embodiment of the present disclosure, the target normal vector is an offset normal vector, and the acquisition module is specifically used to:
[0060] Determine the object normal vector of each pixel in the random noise image;
[0061] Constructing a matrix offset normal vector of each pixel point, wherein the matrix offset normal vector is used to offset the object normal vector;
[0062] The offset normal vector of each pixel point is calculated based on the object normal vector of each pixel point and the matrix offset normal vector of each pixel point.
[0063] As an optional implementation of the embodiment of the present disclosure, the generating module is specifically used for:
[0064] generating an initial image including the at least one highlight point based on the at least one pixel coordinate and the first pixel value of the at least one pixel coordinate;
[0065] Performing n rounds of convolution operations on the initial image with a target convolution kernel to obtain a second image including the at least one highlight point;
[0066] Among them, the moving direction of the target convolution kernel is the target direction, and n is a positive integer.
[0067] As an optional implementation of the embodiment of the present disclosure, the target convolution kernel is a mean convolution kernel, or a Gaussian convolution kernel.
[0068] As an optional implementation of the embodiment of the present disclosure, the generating module is further used to:
[0069] After the i-1th round of convolution operation and before the i-th round of convolution operation,
[0070] Determine that a first weight value in the target convolution kernel during the i-th round of convolution operation is 1 / i of a second weight value during the i-1th round of convolution operation;
[0071] Among them, the first weight value is the weight value corresponding to the pixel point whose distance from the target highlight point is i pixels wide, the second weight value is the weight value corresponding to the pixel point whose distance from the target highlight point is i-1 pixels wide, the target highlight point is any highlight point among the at least one highlight point, and i is an integer greater than or equal to 2 and less than or equal to n.
[0072] As an optional implementation of the embodiment of the present disclosure, the generating module is specifically used for:
[0073] The following steps are performed in the jth round of convolution operation:
[0074] Get the rotation angle;
[0075] Calculate the coordinates of the rotated target pixel according to the rotation angle, the pixel width, and the initial pixel coordinates of each pixel point in the convolution result of the j-th round of convolution operation;
[0076] The pixel value of each pixel point in the convolution result of the j-th round of convolution operation is set to the pixel value of the pixel point at the target pixel coordinate, where j is an integer less than or equal to n.
[0077] In a third aspect, an electronic device is provided, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the image processing method as described in the first aspect or any one of its optional embodiments is implemented.
[0078] In a fourth aspect, a computer-readable storage medium is provided, comprising: a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the image processing method as described in the first aspect or any optional embodiment thereof is implemented.
[0079] In a fifth aspect, a computer program product is provided, characterized in that it includes: when the computer program product is run on a computer, the computer implements the image processing method as described in the first aspect or any optional embodiment thereof.
[0080] The technical solution provided by the embodiment of the present disclosure has the following advantages over the prior art: in the embodiment of the present disclosure, a second image including at least one highlight point can be generated based on at least one pixel coordinate and the first pixel value of the at least one pixel coordinate, and the generated second image can be superimposed on the acquired first image, so that at least one highlight point can be superimposed on the first image, so that the obtained target image presents a highlighted display effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0081] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0082] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0083] Figure 1A schematic diagram of an image processing method provided in an embodiment of the present disclosure Figure 1 ;
[0084] Figure 2 A schematic diagram of an image processing method provided in an embodiment of the present disclosure Figure 2 ;
[0085] Figure 3 A schematic diagram of a cross star shaped highlight point generation process provided by an embodiment of the present disclosure;
[0086] Figure 4A A schematic diagram of a mean convolution kernel provided in an embodiment of the present disclosure;
[0087] Figure 4B A schematic diagram of a Gaussian convolution kernel provided in an embodiment of the present disclosure;
[0088] Figure 5 A structural block diagram of an image processing device provided by an embodiment of the present disclosure;
[0089] Figure 6 A schematic diagram of a hardware structure provided for an embodiment of the present disclosure. DETAILED DESCRIPTION
[0090] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0091] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0092] In order to add a highlight point to an image, the embodiments of the present disclosure provide an image processing method, an apparatus, and an electronic device, which can generate a second image including at least one highlight point based on at least one pixel coordinate and a first pixel value of the at least one pixel coordinate, and superimpose the generated second image on the acquired first image, so that at least one highlight point can be superimposed on the first image, so that the obtained target image presents a highlighted display effect.
[0093] The image processing method provided in the embodiments of the present disclosure may be implemented by an image processing device and an electronic device, wherein the image processing device may be a functional module or functional entity in the electronic device for implementing the image processing method.
[0094] The above-mentioned electronic device may be a tablet computer, a mobile phone, a laptop computer, a PDA, a vehicle-mounted terminal, a wearable device, etc., and the embodiments of the present disclosure do not specifically limit this.
[0095] like Figure 1 FIG. 1 is a flow chart of an image processing method provided by an embodiment of the present disclosure. Figure 1 The method may include the following steps S101 to S104.
[0096] S101: Acquire a first image.
[0097] The first image may be an image stored locally in the electronic device, or the first image may be an image acquired in real time by a camera of the electronic device.
[0098] In the disclosed embodiment, the content of the first image is not limited. That is, no matter what the content of the first image is, highlight points can be superimposed on the first image through the image processing method shown in steps S101 to S104 to present a highlight display effect.
[0099] S102: Obtain at least one pixel coordinate and a first pixel value of at least one pixel coordinate.
[0100] In the disclosed embodiment, a random number can be determined, and the at least one pixel coordinate and the first pixel value of the at least one pixel coordinate can be determined by the random number. Exemplarily, there are two ways to generate random numbers, one is to generate them by a random function (for example, the trigonometric function described below), and the other is to generate random numbers by a random noise graph. In some embodiments, random numbers are generated by random functions. Since only pseudo-random numbers are generated, unlike the relatively high requirements for random numbers in cryptography, a pseudo-random number generator is not required, so random numbers can be obtained by trigonometric functions.
[0101] Exemplarily, the step of acquiring at least one pixel coordinate and a first pixel value of at least one pixel coordinate in S102 includes the following steps:
[0102] S102a: Obtain at least one three-dimensional world coordinate.
[0103] The at least one three-dimensional world coordinate may be randomly acquired, or the at least one three-dimensional world coordinate may be acquired according to a certain acquisition rule. The acquisition rule is not limited in the embodiment of the present disclosure and may be set according to actual needs.
[0104] S102b. Determine at least one pixel coordinate according to at least one three-dimensional world coordinate.
[0105] Each of the at least one three-dimensional world coordinates may be converted into a two-dimensional pixel coordinate, so that at least one pixel coordinate may be obtained.
[0106] S102c. Determine a first pixel value of at least one pixel coordinate according to at least one three-dimensional world coordinate and a trigonometric function.
[0107] The above method of determining the first pixel value of at least one pixel coordinate according to at least one three-dimensional world coordinate and a trigonometric function may include: inputting at least one three-dimensional world coordinate into a trigonometric function to obtain the first pixel value of at least one pixel coordinate.
[0108] The trigonometric function is expressed as Formula 1: y=frac(sin(x)*100.99999), where x represents the three-dimensional world coordinate and y is used to represent the first pixel value.
[0109] It can be understood that the y obtained in the above formula 1 is a random number. In the embodiment of the present disclosure, y is used to characterize the first pixel value. In the above implementation, the random number y obtained can be between 0 and 1 by the characteristic that the value range of the trigonometric function is between [-1,1], and at the same time, it can be ensured that when the difference of the input x is very small, the random number obtained will have a large difference, so that the random effect can be satisfied and a random first pixel value can be obtained. After calculating y, the corresponding highlight point can be generated based on the obtained y and the corresponding two-dimensional coordinates.
[0110] It can be understood that after y is obtained according to Formula 1, y can represent the first pixel value, but the value of y is not directly used as the first pixel value, but y is converted to the corresponding first pixel value through a certain conversion relationship. The larger the y value, the larger the corresponding first pixel value; the smaller the y value, the smaller the corresponding first pixel value.
[0111] It should be noted that the trigonometric function shown in the above formula 1 is a type of random function. In practice, random numbers determined by other forms of random functions may also be used to represent the pixel values corresponding to the highlight points in the embodiments of the present disclosure.
[0112] In some embodiments, random numbers can be generated by random noise graphs. In practice, since the shape of the noise graph is controllable, the method of generating random numbers by random noise graphs is more reliable. In the embodiments of the present disclosure, the random noise graph can be understood as a randomly selected noise graph.
[0113] Exemplarily, the step of acquiring at least one pixel coordinate and a first pixel value of at least one pixel coordinate in S102 includes the following steps:
[0114] S102A, obtain a random noise image.
[0115] S102B, determine the target normal vector of each pixel in the random noise image.
[0116] The target normal vector is the object normal vector, or the offset normal vector. That is, in the embodiments of the present disclosure, one implementation is to determine the at least one pixel coordinate and the first pixel value corresponding to the at least one pixel coordinate based on the object normal vector of each pixel point in the random noise map; another implementation is to determine the at least one pixel coordinate and the first pixel value corresponding to the at least one pixel coordinate based on the offset normal vector of each pixel point in the random noise map.
[0117] In the case where the target normal vector is an offset normal vector, the above method for determining the offset normal vector of each pixel in the random noise image can be:
[0118] (1) Determine the object normal vector of each pixel in the random noise image.
[0119] The object normal vector of a pixel is a vector in the vertical direction of the surface where the pixel corresponds to the object.
[0120] (2) Construct a matrix offset normal vector for each pixel point. The matrix offset normal vector is used to offset the object normal vector.
[0121] Among them, DisMatrix can be arbitrarily constructed according to the random sampling graph, and the construction form is not limited in the embodiment of the present disclosure, so long as it can offset the normal vector of the object.
[0122] Exemplarily, the matrix offset normal vector DisMatrix constructed for a pixel in the random sampling image is as follows:
[0123]
[0124] Among them, in the above matrix offset normal vector, x represents the value of the R (red) color channel of the current pixel, y represents the value of the G (green) color channel of the current pixel, and z represents the value of the B (blue) color channel of the current pixel.
[0125] (3) Based on the object normal vector of each pixel and the matrix offset normal vector of each pixel, the offset normal vector of each pixel is calculated.
[0126] The above-mentioned calculation of the offset normal vector of each pixel point based on the object normal vector of each pixel point and the matrix offset normal vector of each pixel point is implemented by calculating the offset normal vector of each pixel point based on the object normal vector of each pixel point and the corresponding matrix offset normal vector of each pixel point.
[0127] For each pixel, the calculation of the offset normal vector can be expressed as the following formula 2:
[0128] DistortNomal=DisMatrix·normal;
[0129] In Formula 2, DistortNomal represents the offset normal vector, DisMatrix represents the above matrix offset normal vector, and normal represents the object normal vector.
[0130] S102C, determining the pixel value of each pixel point based on the target normal vector and the sight direction vector.
[0131] The calculation can be performed based on the target normal vector and the sight direction vector, as well as Formula 3, and the calculated value is used to represent the pixel value of each pixel. The sight direction vector is dot-producted with the target normal vector and multiplied by a high power. In this way, the more the sight direction and the normal direction coincide, the larger the value obtained.
[0132] Among them, formula three is: (viewDir Q) P , P is a power. The larger the P value is, the larger the pixel value of the obtained pixel point is, the higher the brightness is, and the smaller the range is. viewDir represents the sight direction vector, and Q represents the target normal vector. When the target normal vector is the object normal vector, formula 3 can be converted to (viewDir Normal) P , when the target normal vector is the offset normal vector, then Formula 3 can be converted to (viewDir DistortNormal) P .
[0133] S102D: Determine at least one first pixel point from each pixel point, wherein a pixel value of the at least one first pixel point is greater than or equal to a preset value.
[0134] In the above method, a dot product is made between the sight direction vector and the target normal vector, and then the product is multiplied by a high power to finally obtain a value to represent the pixel value of the pixel point. In this way, the pixel value of each pixel point will obtain values of different sizes according to the degree of deviation from the realization direction. When the pixel value of at least one first pixel point is subsequently selected from each pixel value, some pixel points with a smaller deviation between the sight direction vector and the target normal vector can be determined as highlight points, and the corresponding pixel coordinates and the first pixel value corresponding to the pixel coordinates can be determined. In this way, the highlight points generated are random.
[0135] S102E. Determine pixel coordinates of at least one first pixel point as at least one pixel coordinate, and use a pixel value of at least one first pixel point as a first pixel value corresponding to the at least one pixel coordinate.
[0136] Compared with the implementation method of determining the at least one pixel coordinate and the first pixel value corresponding to the at least one pixel coordinate based on the object normal vector, the implementation method of determining the at least one pixel coordinate and the first pixel value corresponding to the at least one pixel coordinate based on the offset normal vector can offset the object normal vector to make the highlight point random. In this way, there will be multiple random highlight points in the generated image, which can avoid the highlight points finally determined from being too concentrated to form highlight points in a larger area.
[0137] S103 . Generate a second image including at least one highlight point based on at least one pixel coordinate and the first pixel value of the at least one pixel coordinate.
[0138] In some embodiments, in the process of generating a second image including at least one highlight point based on at least one pixel coordinate and a first pixel value of at least one pixel coordinate, after the initial image is generated based on at least one pixel coordinate and a first pixel value of at least one pixel coordinate, some post-processing operations need to be performed on the initial image before the second image is obtained.
[0139] For example, Figure 2 FIG. 1 is a flow chart of an image processing method provided by an embodiment of the present disclosure. Figure 2 After determining at least one pixel coordinate and at least one first pixel value of the pixel coordinate based on the above 102, rendering can be performed based on these parameters to obtain an initial image, that is, to obtain the following: Figure 2 The RT1 shown in the figure may include at least one highlight point, and then the RT1 is post-processed to obtain the final RT2, which can then be stored in the camera buffer. Finally, the first image captured by the camera (the first image may also be a locally stored image) and the RT2 stored in the camera buffer are fused to obtain the corresponding target image.
[0140] In some embodiments, the method may specifically include: generating an initial image including at least one highlight point based on at least one pixel coordinate and a first pixel value of at least one pixel coordinate; performing n rounds of convolution operations on the initial image with a target convolution kernel to obtain a second image including at least one highlight point. The target convolution kernel is a mean convolution kernel or a Gaussian convolution kernel, the moving direction of the target convolution kernel is a target direction, and n is a positive integer.
[0141] The target direction may be any moving direction, or multiple different moving directions.
[0142] In the disclosed embodiment, the target convolution kernel moves along the target direction to perform n rounds of convolution operations on the initial image, so that the highlight point in the initial image can present two opposite sharp corners (or called tails) in the target direction, or the highlight point can present a sharp corner in the positive direction and the reverse direction of the target direction. After n rounds of convolution operations in one or more directions, the highlight point can be processed into a star shape, which can have 2m corners, where m represents the number of different moving directions during the convolution operation of the target convolution kernel.
[0143] For example, the highlight point can be processed into a two-pointed star, a four-pointed star (such as a cross star), a six-pointed star, an eight-pointed star, etc. Among them, the two-pointed star is obtained by performing n rounds of convolution operations on the highlight point in one direction; the four-pointed star is obtained by performing n rounds of convolution operations on the highlight point in two different directions, and in the case of a four-pointed star cross, the two different directions are perpendicular; the six-pointed star is obtained by performing n rounds of convolution operations on the highlight point in three different directions, and the eight-pointed star is obtained by performing n rounds of convolution operations on the highlight point in four different directions.
[0144] Taking the processing of highlight points into a cross star shape as an example, the target convolution kernel can be moved along the X direction and the Y direction (the X direction is perpendicular to the Y direction) respectively to perform n rounds of convolution operations on the pixels in the X direction and the Y direction. By sampling the RGBA values of the pixels around the highlight points in the initial image and superimposing them, the pixels around the highlight points in the initial image will all obtain corresponding RGBA values, so that in the final second image, a cross star-shaped highlight point will be realized. Among them, R in the RGBA value represents the value of the R color channel, G represents the value of the G color channel, B represents the value of the B color channel, and A represents opacity (alpha).
[0145] For example, Figure 3 FIG. 1 is a schematic diagram of a cross star shaped highlight point generation process provided by an embodiment of the present disclosure. Figure 3 As shown in (a) of FIG. 1 , it can be a schematic diagram of a highlight point. After performing n rounds of convolution operations along the X direction shown in the figure, the highlight point obtained can be shown as follows: Figure 3 As shown in (b) of Figure 3 Based on the highlight points shown in (b) in the figure, n rounds of convolution operations are performed again along the Y direction as shown in the figure, so that the following can be obtained: Figure 3 The cross-shaped highlight is shown in (c).
[0146] For example, Figure 4A The figure shows a schematic diagram of a mean convolution kernel provided by an embodiment of the present disclosure. The convolution kernel is a mean convolution kernel that can be used to construct a cross star shape, and the convolution kernel is characterized by having no weight.
[0147] In order to make the constructed cross star shape have a tailing attenuation effect, a weighted convolution kernel can also be used, for example, a Gaussian convolution kernel can be used, for example, Figure 4B FIG. 1 is a schematic diagram of a Gaussian convolution kernel provided by an embodiment of the present disclosure. Figure 4B It can be seen that the weight of the center of the Gaussian convolution kernel is the largest. The farther away from the center, the smaller the weight, and the closer to the center, the larger the weight. After the convolution operation based on such a convolution kernel, the obtained cross star shape will have an obvious tailing attenuation effect, that is, the closer to the center of the cross star shape, the greater the brightness, and the farther away from the center, the lower the brightness.
[0148] It should be noted that Figure 4A and Figure 4B The 3*3 convolution kernel is used as an example. In actual applications, the size of the convolution kernel can be set according to actual needs.
[0149] The Gaussian convolution kernel uses convolution kernels with different weights. The closer to the edge, the smaller the weight. Therefore, the farther away from the center of the highlight point, the less the pixel is affected by the highlight point, and the lower the brightness. This can achieve a better tail attenuation effect. In actual situations, in order to achieve a longer tail effect, we will not use Figure 4B Instead of using a small convolution kernel of 3*3 as shown, a larger convolution kernel is used. Based on this, the size of the convolution kernel is controlled by a loop in the disclosed embodiment, and the loop variable can be used as a weight to affect the size of the weight value in the convolution kernel. In some embodiments, including n rounds of convolution operations, after the i-1th round of convolution operation and before the i-th round of convolution operation, the size of the weight value in the convolution kernel in the current i-th round of convolution operation can be determined. Specifically: Determine that the first weight value in the target convolution kernel during the i-th round of convolution operation is 1 / i of the second weight value during the i-1th round of convolution operation.
[0150] Among them, the first weight value is the weight value corresponding to the pixel point whose distance from the target highlight point is i pixels wide, the second weight value is the weight value corresponding to the pixel point whose distance from the target highlight point is i-1 pixels wide, the target highlight point is any highlight point among the at least one highlight point, and i is an integer greater than or equal to 2 and less than n.
[0151] It should be noted that the above setting of the first weight value to 1 / i of the second weight value is an exemplary description and can also be set according to actual conditions. In fact, it only needs to ensure that the first weight value is smaller than the second weight value.
[0152] In some embodiments, in the second image obtained after post-processing the initial image based on the above-mentioned convolution operation, the obtained highlight point is in the shape of a regular star. For example, the highlight point is in the shape of a regular cross star. In order to obtain a rotated highlight point in the shape of a regular cross star, the following scheme can be used to obtain a rotated cross star-shaped highlight point.
[0153] The implementation method may include: performing n rounds of convolution operations on the initial image with a target convolution kernel to obtain a second image including at least one highlight point, including performing the following steps in the j-th round of convolution operations:
[0154] 1) Get the rotation angle.
[0155] The rotation angle may be a default rotation angle or a rotation angle set by a user.
[0156] 2) Calculate the coordinates of the rotated target pixel based on the rotation angle, pixel width, and the initial pixel coordinates of each pixel in the convolution result of the j-th round of convolution operation.
[0157] Wherein, n rounds of convolution operations are performed, j is greater than or equal to n, and j can be any round of convolution operations in the n rounds of convolution operations.
[0158] 3) The pixel value of each pixel point in the convolution result of the j-th round of convolution operation is set to the pixel value of the pixel point at the target pixel coordinate.
[0159] The target pixel coordinates are the target pixel coordinates corresponding to each pixel after rotation, and it can be understood that a target pixel coordinate is determined for each pixel in the initial image. The pixel value can refer to an RGBA value.
[0160] Taking a cross-shaped highlight point as an example, based on the rotation angle, we can first determine the direction vector after the base vector in the X direction is rotated by the rotation angle, expressed as Xdir; and the direction vector after the base vector in the Y direction is rotated by the rotation angle, expressed as Ydir.
[0161] For the j-th round of convolution operation, the rotated target pixel coordinates can be calculated based on Xdir, Ydir, pixel width, and the following formulas 4 to 7. Specifically, the pixel value of each pixel point in the convolution result of the j-th round of convolution operation is set to the pixel value of the pixel point of the target pixel coordinate. It should be noted that during the calculation process, when the target convolution kernel moves along the X direction and performs a convolution operation, the calculation can be based on formulas 4 and 5 corresponding to the X direction. When the target convolution kernel moves along the Y direction and performs a convolution operation, the calculation can be based on formulas 6 and 7 corresponding to the Y direction.
[0162] The corresponding formula for the X direction is:
[0163] Formula 5:
[0164] finaColor+=texture2D(MainTex,vec2(uv.x+Xdir.x*maintexTexelSize.x*xIndex,uv.y-Xdir.y*maintexTexelSize.y*xIndex));
[0165] Formula 6:
[0166] finaColor+=texture2D(MainTex,vec2(uv.x-Xdir.x*maintexTexelSize.x*xIndex,uv.y+Xdir.y*maintexTexelSize.y*xIndex)).
[0167] In the X direction, each pixel point on the first side of the highlight point is calculated based on Formula 5 to obtain the target pixel coordinates corresponding to each pixel point on the second side of the highlight point, and the RGBA values of each pixel point on the second side of the highlight point are sampled to the pixel point corresponding to the target pixel coordinates; each pixel point on the second side of the highlight point is calculated based on Formula 6 to obtain the target pixel coordinates corresponding to each pixel point on the second side of the highlight point, and the RGBA values of each pixel point on the second side of the highlight point are sampled to the pixel point corresponding to the target pixel coordinates. Among them, the first side is the moving direction of the target convolution kernel when it moves in the X direction, and the second side is the opposite direction of the moving direction of the target convolution kernel when it moves in the X direction.
[0168] Among them, finaColor+ represents the RGBA value corresponding to the target pixel coordinates, texture2D represents RT sampling, MainTex is used to indicate which RT is sampled, which refers to the initial image in the disclosed embodiment, vec2 identifies the sampling method for the sampled RT, uv.x and uv.y represent the initial pixel coordinates of the current pixel point sampled for the initial image, Xdir.x represents the component of Xdir in the X direction, Xdir.y represents the component of Xdir in the Y direction, maintexTexelSize.x represents the pixel width in the X direction, which refers to the distance between two adjacent pixels in the X direction, maintexTexelSize.y represents the pixel width in the Y direction, which refers to the distance between two adjacent pixels in the Y direction, and xIndex represents the number of traversals in the X direction. For example, in the case where the target convolution kernel performs n convolution operations in the X direction, xIndex is n.
[0169] The corresponding formula for the Y direction is:
[0170] Formula 7:
[0171] finaColor+=texture2D(MainTex,vec2(uv.x+Ydir.x*maintexTexelSize.x*yIndex,uv.y+Ydir.y*maintexTexelSize.y*yIndex));
[0172] Formula 8:
[0173] finaColor+=texture2D(MainTex,vec2(uv.x-Ydir.x*maintexTexelSize.x*yIndex,uv.y-Ydir.y*maintexTexelSize.y*yIndex)).
[0174] Among them, Ydir.x represents the component of Ydir in the X direction, and Ydir.y represents the component of Ydir in the Y direction.
[0175] Correspondingly, in the Y direction, each pixel point on the first side of the highlight point is calculated based on Formula 7 to obtain the target pixel coordinates corresponding to each pixel point on the second side of the highlight point, and the RGBA values of each pixel point on the second side of the highlight point are sampled to the pixel point corresponding to the target pixel coordinates; each pixel point on the second side of the highlight point is calculated based on Formula 8 to obtain the target pixel coordinates corresponding to each pixel point on the second side of the highlight point, and the RGBA values of each pixel point on the second side of the highlight point are sampled to the pixel point corresponding to the target pixel coordinates. Among them, the first side is the moving direction of the target convolution kernel when it moves in the Y direction, and the second side is the opposite direction of the moving direction of the target convolution kernel when it moves in the Y direction.
[0176] Based on the above embodiment, a rotating cross-shaped highlight point can be processed to obtain a rotating highlight point, which can present a rotating effect of the highlight point.
[0177] S104: superimpose the second image on the first image to obtain a target image.
[0178] In the process of superimposing the second image on the first image to obtain the target image, the second image and the first image can be set in different layers, wherein the layer where the second image is located is on the upper layer of the first image. After superimposing the second image on the first image, the target image can be obtained, which is an image with a display effect of adding at least one highlight point to the first image.
[0179] In the embodiment of the present disclosure, a second image including at least one highlight point can be generated based on at least one pixel coordinate and the first pixel value of the at least one pixel coordinate, and the generated second image can be superimposed on the acquired first image. In this way, at least one highlight point can be superimposed on the first image, so that the obtained target image presents a highlighted display effect.
[0180] like Figure 5 FIG. 1 is a block diagram of an image processing device provided by an embodiment of the present disclosure, and the device includes:
[0181] The acquisition module 501 is used to acquire a first image; acquire at least one pixel coordinate and a first pixel value of at least one pixel coordinate;
[0182] A generating module 502, configured to generate a second image including at least one highlight point based on at least one pixel coordinate and a first pixel value of at least one pixel coordinate;
[0183] The superimposition module 503 is used to superimpose the second image on the first image to obtain a target image.
[0184] As an optional implementation of the embodiment of the present disclosure, the acquisition module 501 is specifically used to:
[0185] Obtain at least one three-dimensional world coordinate;
[0186] Determining at least one pixel coordinate based on at least one three-dimensional world coordinate;
[0187] A first pixel value of at least one pixel coordinate is determined based on at least one three-dimensional world coordinate and a trigonometric function.
[0188] As an optional implementation of the embodiment of the present disclosure, the acquisition module 501 is specifically used to:
[0189] Inputting at least one three-dimensional world coordinate into a trigonometric function to obtain a first pixel value of at least one pixel coordinate;
[0190] The trigonometric function is expressed as: y=frac(sin(x)*100.99999), wherein x represents a three-dimensional world coordinate and y is used to represent a first pixel value.
[0191] As an optional implementation of the embodiment of the present disclosure, the acquisition module 501 is specifically used to:
[0192] Get a random noise map;
[0193] Determine the target normal vector for each pixel in the random noise image;
[0194] Determine the pixel value of each pixel point based on the target normal vector and the sight direction vector;
[0195] Determine at least one first pixel point from each pixel point, wherein a pixel value of the at least one first pixel point is greater than or equal to a preset value;
[0196] The pixel coordinates of at least one first pixel point are determined as at least one pixel coordinate, and the pixel value of at least one first pixel point is used as the first pixel value corresponding to the at least one pixel coordinate.
[0197] As an optional implementation of the embodiment of the present disclosure, the target normal vector is the object normal vector, or an offset normal vector.
[0198] As an optional implementation of the embodiment of the present disclosure, the target normal vector is an offset normal vector, and the acquisition module 501 is specifically used to:
[0199] Determine the object normal vector for each pixel in the random noise image;
[0200] Constructing a matrix offset normal vector for each pixel point, the matrix offset normal vector is used to offset the object normal vector;
[0201] The offset normal vector of each pixel is calculated based on the object normal vector of each pixel and the matrix offset normal vector of each pixel.
[0202] As an optional implementation of the embodiment of the present disclosure, the generating module 502 is specifically used for:
[0203] generating an initial image including at least one highlight point based on at least one pixel coordinate and a first pixel value of the at least one pixel coordinate;
[0204] Performing n rounds of convolution operations on the initial image with a target convolution kernel to obtain a second image including at least one highlight point;
[0205] Among them, the moving direction of the target convolution kernel is the target direction, and n is a positive integer.
[0206] As an optional implementation of the embodiment of the present disclosure, the target convolution kernel is a mean convolution kernel, or a Gaussian convolution kernel.
[0207] As an optional implementation of the embodiment of the present disclosure, the generating module 502 is further used to:
[0208] After the i-1th round of convolution operation and before the i-th round of convolution operation, the pixel value of the target pixel is set to 1 / i of the pixel value of the target pixel in the convolution result of the i-1th round of convolution operation;
[0209] The target pixel point is a pixel point whose distance from the target highlight point is i pixels wide, the target highlight point is any highlight point among the at least one highlight point, and i is an integer greater than or equal to 2 and less than or equal to n.
[0210] As an optional implementation of the embodiment of the present disclosure, the generating module 502 is specifically used for:
[0211] The following steps are performed in the jth round of convolution operation:
[0212] Get the rotation angle;
[0213] Calculate the coordinates of the rotated target pixel according to the rotation angle, pixel width, and the initial pixel coordinates of each pixel in the convolution result of the j-th convolution operation;
[0214] The pixel value of each pixel point in the convolution result of the j-th round of convolution operation is set to the pixel value of the pixel point at the target pixel coordinate, where j is an integer less than or equal to n.
[0215] like Figure 6 As shown, the embodiment of the present disclosure provides an electronic device, which includes: a processor 601, a memory 602, and a computer program stored in the memory 602 and executable on the processor 601, and when the computer program is executed by the processor 601, each process of the image processing method in the above method embodiment is implemented. And the same technical effect can be achieved, so it will not be repeated here to avoid repetition.
[0216] An embodiment of the present invention provides a computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, the various processes of the image processing method in the above method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0217] The computer readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0218] An embodiment of the present invention provides a computer program product, which stores a computer program. When the computer program is executed by a processor, the various processes of the image processing method in the above method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0219] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program code.
[0220] In the present disclosure, the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0221] In the present disclosure, memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0222] In the present disclosure, computer-readable media include permanent and non-permanent, removable and non-removable storage media. Storage media can be implemented by any method or technology to store information, and the information can be computer-readable instructions, data structures, modules of programs or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. According to the definition in this article, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0223] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0224] The above are only specific embodiments of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to these embodiments herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An image processing method, characterized in that: include: acquiring a first image; Obtain at least one three-dimensional world coordinate; Determining at least one pixel coordinate based on the at least one three-dimensional world coordinate; Determine a first pixel value of the at least one pixel coordinate according to the at least one three-dimensional world coordinate and the trigonometric function; wherein both the pixel coordinate and the first pixel value of the pixel coordinate are determined based on a random number, the random number is obtained by a random function or a random noise map, and the random noise map is a randomly selected noise map; Based on the at least one pixel coordinate and the first pixel value of the at least one pixel coordinate, generating a second image including at least one highlight point; wherein the second image is not generated based on the first image; The second image is superimposed on the first image to obtain a target image; wherein the first image and the second image are located in different layers.
2. The method according to claim 1, characterized in that The step of generating a second image including at least one highlight point based on the at least one pixel coordinate and the first pixel value of the at least one pixel coordinate comprises: generating an initial image including the at least one highlight point based on the at least one pixel coordinate and the first pixel value of the at least one pixel coordinate; Performing n rounds of convolution operations on the initial image with a target convolution kernel to obtain a second image including the at least one highlight point; Among them, the moving direction of the target convolution kernel is the target direction, and n is a positive integer.
3. The method according to claim 2, characterized in that The target convolution kernel is a mean convolution kernel or a Gaussian convolution kernel.
4. The method according to claim 2, characterized in that: The performing n rounds of convolution operations on the initial image with a target convolution kernel to obtain a second image including the at least one highlight point comprises: The following steps are performed in the jth round of convolution operation: Get the rotation angle; Calculate the coordinates of the target pixel after rotation according to the rotation angle, the pixel width, and the initial pixel coordinates of each pixel point in the convolution result of the j-th round of convolution operation; The pixel value of each pixel point in the convolution result of the j-th round of convolution operation is set to the pixel value of the pixel point at the target pixel coordinate, where j is an integer less than or equal to n.
5. An image processing device, characterized in that: include: An acquisition module, used for acquiring a first image; Acquire at least one three-dimensional world coordinate; determine at least one pixel coordinate according to the at least one three-dimensional world coordinate; Determine a first pixel value of the at least one pixel coordinate according to the at least one three-dimensional world coordinate and the trigonometric function; wherein the pixel coordinate and the first pixel value are obtained by obtaining a random noise map, and the random noise map is a randomly selected noise map; A generating module, configured to generate a second image including at least one highlight point based on the at least one pixel coordinate and the first pixel value of the at least one pixel coordinate; wherein the second image is not generated based on the first image; The superposition module is used to superimpose the second image on the first image to obtain a target image; wherein the first image and the second image are located in different layers.
6. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the image processing method according to any one of claims 1 to 4 when executed by the processor.
7. A computer-readable storage medium, characterized in that: include: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the image processing method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Photographing method and terminal
CN106791016A
Image special effect generation method and device, electronic equipment and storage medium
CN113240578A