Image processing method and apparatus, computing device, medium and program product
By introducing velocity divergence parameters in image processing, the effectiveness of historical information can be accurately judged, which solves the problem of detail loss caused by the failure of historical information in the existing technology and improves the quality and stability of image output.
Patent Information
- Application Number
- PCT/CN2024/088097
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-04-21
- Filing Date
- 2024-04-16
- Publication Date
- 2024-10-24
AI Technical Summary
Existing temporal anti-aliasing technology is difficult to effectively determine whether historical information is invalid, resulting in the discarding of available historical information in image processing, affecting the preservation of picture details and the output effect.
The velocity divergence parameter is introduced to determine the mixing ratio of the current frame pixels and the previous frame pixels by calculating the velocity change of the surrounding environment of the pixel, and finely determine the historical failure conditions in the geometric information, thereby adjusting the mixing ratio to retain the picture details.
It improves the quality and time stability of image output, avoids incorrect discarding of historical information, enhances the retention of picture details, and improves the anti-aliasing effect.
Smart Images

Figure CN2024088097_24102024_PF_FP_ABST
Abstract
Description
Method, apparatus, computing device, medium and program product for processing images
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application is based on the Chinese patent application with application number 202310436358.8, application date April 21, 2023, and application name “Method, device, computing device and computer-readable storage medium for processing images”, and claims the priority of the Chinese patent application. The entire content of the Chinese patent application is hereby introduced into this application as a reference. Technical Field
[0003] The embodiments of the present application relate to the field of image processing, and relate to a method, apparatus, computing device, computer-readable storage medium, and program product for processing images. Background Art
[0004] Temporal antialiasing (TAA) is an image processing technique used to eliminate jagged edges in images displayed on a monitor. This technique obtains the corresponding historical pixels from the previous frame and linearly blends them with the rendered pixels of the current frame. The resulting pixels are then output to the monitor. This output pixel incorporates both historical and current frame information, resulting in a more accurate representation of the image than the current frame itself, reducing jagged edges.
[0005] Summary of the Invention
[0006] The embodiments of the present application provide a method, apparatus, computing device, computer-readable storage medium, and program product for processing images, which can determine the mixing ratio of the current frame pixels and the previous frame pixels based on the velocity divergence of the pixels, and more fundamentally identify the situations that cause historical failures in the geometric information, thereby retaining as many picture details as possible and improving the output effect of the image.
[0007] In a first aspect, an embodiment of the present application provides a method for processing an image, comprising: acquiring a first image, wherein the first image includes multiple pixels, the first pixel is one of the multiple pixels, and the first color value is the color value of the first pixel; determining a second pixel in a second image based on a pixel velocity of the first pixel, wherein the second image is an output image of a previous frame of the first image, the pixel velocity is used to indicate the distance and direction of movement of a position output by the first pixel on the screen relative to a position output by the second pixel on the screen, and the second color value is the color value of the second pixel; determining a mixing ratio of the first color value to the second color value based on a velocity divergence of the first pixel, wherein the velocity divergence is used to indicate a change in the flux of pixel velocity in a neighborhood space of the first pixel, the neighborhood space being a square range consisting of K×K pixels centered on the first pixel in the first image, where K is an odd number greater than 1; determining a third color value based on the mixing ratio, the third color value being the color value output by the first pixel.
[0008] According to the technical solution provided in the embodiments of the present application, by introducing a new parameter velocity divergence as a reference for determining whether historical pixel information is available, the velocity divergence of a pixel can more essentially reflect whether the geometric shape around the pixel has changed, relative to the pixel velocity. This can avoid erroneously discarding the available information of the previous frame of pixels during pixel movement, retain as many picture details as possible, and improve the image output effect.
[0009] In some embodiments, the velocity divergence is related to the pixel velocity of edge pixels in the neighborhood space.
[0010] According to the above technical solution, velocity divergence can reflect whether the geometric shape of the neighborhood space around a pixel has changed by comparing the pixel velocities of the edges of the neighborhood space around the pixel, thereby reflecting whether the environment around the pixel is stable.
[0011] In some embodiments, the velocity divergence is determined based on the number of pixels on each edge of the neighborhood space, the length of the side of the pixels in the first image output to the screen, the component of the pixel velocity in the x-direction of the edge pixels at the left and right edges of the neighborhood space, and the component of the pixel velocity in the y-direction of the edge pixels at the upper and lower edges of the neighborhood space.
[0012] Among them, the velocity divergence satisfies:
[0013] in, is the velocity divergence, K is the number of pixels on each edge of the neighborhood space, a is the length of the edge of the pixel in the first image output to the screen, (x, y) is the coordinate of the first pixel output to the screen, v x (x,y) is the component of the pixel velocity in the x direction of the pixel at the coordinate (x,y) output to the screen, vy (x,y) is the component of the pixel velocity in the y direction of the pixel at the coordinate (x,y) output to the screen.
[0014] According to the above technical solution, the determination of velocity divergence takes into account the change in pixel velocity within a certain spatial range around the target pixel, so that for pixels with non-zero velocity, whether the environment around the pixel is stable can also be reflected.
[0015] In some embodiments, before determining the mixing ratio of the first color value and the second color value based on the velocity divergence of the first pixel, the method also includes: obtaining the effective sample number of the second pixel and the time domain second-order moment of the second pixel, wherein the effective sample number is used to represent the number of effective pixels mixed in the second pixel, and the time domain second-order moment is used to represent the fluctuation range of the color value of the effective pixel, and the effective pixel is the pixel in the historical frame that contributes to the second color value.
[0016] According to the above technical solution, by introducing two new parameters, the number of effective samples and the second-order moment in the time domain, the statistical distribution law of the historical information contained in the pixels of the previous frame can be reflected in the time domain, thereby providing available reference information in more dimensions for judging whether the historical information is invalid, and improving the accuracy of the judgment criteria.
[0017] In some embodiments, the mixing ratio of the first color value to the second color value is determined based on the velocity divergence of the first pixel, including: determining the valid range of the second color value based on the velocity divergence, the valid range being used to indicate the allowable deviation of the second color value from the first color value; and determining the mixing ratio based on the relationship between the second color value and the valid range.
[0018] According to the above technical solution, by unifying the multi-dimensional reference parameters into the effective range of historical pixels for measurement, the mixing ratio can be adjusted according to whether the value of the historical pixel actually appears within the effective range, thereby converting the reference information of different latitudes into a unified standard.
[0019] In some embodiments, the valid range of the second color value is determined based on the velocity divergence, including: when the velocity divergence is 0, the valid range is determined based on the spatial standard deviation, the temporal standard deviation and the valid sample number of the second pixel, wherein the spatial standard deviation is the standard deviation of the color values of the pixels in the neighborhood space, and the temporal standard deviation is the standard deviation of the color values of the valid pixels.
[0020] According to the above technical solution, when the velocity divergence is 0, the current pixel is not moving or is in a stable translation state where the surrounding environment has not changed, which conforms to the statistical distribution law of historical pixels in the time domain. Therefore, the time domain standard deviation can be used as one of the reference parameters for determining a limited range, providing reference information in the time dimension for judging whether historical information is invalid.
[0021] In some embodiments, the temporal standard deviation is calculated based on the temporal second-order moment of the second pixel and the second color value.
[0022] Among them, the time domain standard deviation satisfies: dev t 2 =M2-hist 2 ;
[0023] Among them, dev t is the temporal standard deviation, M2 is the temporal second-order moment of the second pixel, and hist is the second color value.
[0024] According to the above technical solution, by calculating the equivalent standard deviation of historical valid pixels through known parameters, the equivalent value of the statistical quantity that cannot be directly obtained by statistical methods can be determined in a computational manner, thereby providing the time domain standard deviation as a reference parameter for determining the effective range.
[0025] In some embodiments, the effective range is determined by calculation based on the spatial standard deviation, the temporal standard deviation, and a boundary constraint function.
[0026] Among them, the effective range meets:
[0027] Among them, δ is the effective range, dev s is the spatial standard deviation, dev l is the maximum value between the spatial standard deviation and the temporal standard deviation, N is the number of valid samples of the second pixel, and clamp(x,0,1) represents the boundary constraint function.
[0028] According to the above technical solution, through the calculation formula of the above effective range, when the number of historical effective samples is large, the effective range can be appropriately relaxed from the spatial standard deviation to the larger value of the time domain standard deviation and the spatial standard deviation, thereby avoiding the signal at the position with large fluctuations in the picture from being truncation, resulting in loss of details, and at the same time, it can also ensure better time domain stability and avoid picture jitter.
[0029] In some embodiments, determining the valid range of the second color value based on the velocity divergence includes: when the velocity divergence is not 0, determining the valid range based on the spatial standard deviation, wherein the spatial standard deviation is the standard deviation of the color values of pixels in the neighborhood space.
[0030] According to the above technical solution, when the velocity divergence is not zero, the surrounding environment of the current pixel has changed and may no longer conform to the statistical distribution law of historical pixels in the time domain. Therefore, the reference parameter of the effective range can be limited to the spatial standard deviation, and no longer refers to the information of the time dimension.
[0031] In some embodiments, determining the valid range of the second color value according to the velocity divergence further includes: adjusting the valid range according to the velocity divergence.
[0032] According to the above technical solution, by adjusting the effective range size according to the severity of the change in the pixel surrounding environment reflected by the velocity divergence, the parameters for determining the effective range are made more diverse, thereby improving the accuracy of determining the effective range.
[0033] In some embodiments, the adjusted effective range is calculated based on the spatial standard deviation, velocity divergence, and boundary constraint function.
[0034] Among them, the adjusted effective range meets the following requirements:
[0035] Among them, δ is the effective range, dev s is the spatial standard deviation, is the velocity divergence, and clamp(x,0,1) represents the boundary constraint function.
[0036] According to the above technical solution, through the calculation formula of the above effective range, the greater the velocity divergence, that is, the more drastic the change in the environment around the pixel, the smaller the effective range, and thus the more cautious the historical information is adopted.
[0037] In some embodiments, the mixing ratio includes a first mixing ratio and a second mixing ratio, wherein the first mixing ratio is a fixed value, and the second mixing ratio is used to correct the first mixing ratio when the second color value deviates from the first color value beyond the valid range. The mixing ratio is determined based on the relationship between the second color value and the valid range, including: determining the second mixing ratio based on the relationship between the second color value and the valid range; and correcting the first mixing ratio based on the second mixing ratio to determine the mixing ratio.
[0038] According to the above technical solution, by separating the mixing ratio according to different functions, a part of the base mixing ratio adopts part of the historical information as a fixed refresh, and the other part of the correction mixing ratio reflects the equivalent situation of the historical information being truncated, thereby adjusting the two parts of the mixing ratio separately to improve the processing accuracy.
[0039] In some embodiments, the second mixing ratio is determined by calculation based on the first color value, the second color value, and the valid range.
[0040] The second mixing ratio satisfies:
[0041] Among them, α c is the second mixing ratio, curr is the first color value, hist is the second color value, and δ is the valid range.
[0042] According to the above technical solution, through the calculation formula of the second mixing ratio that reflects the equivalent situation of historical information being truncated, the historical information can be equivalently truncated to the upper or lower limit of the valid range when the historical information exceeds the valid range, thereby discarding the historical information that exceeds the valid range.
[0043] In some embodiments, the first image is generated based on the third image, and the number of pixels of the third image is less than or equal to the number of pixels of the first image, wherein the first pixel is generated based on the third pixel in the third image, and the weight value of the first pixel is used to indicate the contribution of the third pixel to the first color value, and the mixing ratio of the first color value to the second color value is determined based on the velocity divergence of the first pixel, and also includes: when the weight value of the first pixel is 0, the second mixing ratio of the first pixel is determined based on the second mixing ratio of the four pixels surrounding the first pixel in the first image.
[0044] According to the above technical solution, the second mixing ratio of the pixels with a weight value of zero is used to fill the holes, so that even if the current pixel does not obtain information from the current frame, it can know that historical information truncation has occurred in its neighborhood, and thus make the same decision as the neighboring pixels, avoiding the occurrence of holes in the neighborhood where historical information is discarded when the sampling rate is low.
[0045] In some embodiments, the method further includes: generating the effective sample number of the first pixel based on the effective sample number and the mixing ratio of the second pixel; generating the temporal second-order moment of the first pixel based on the temporal second-order moment of the second pixel and the mixing ratio.
[0046] According to the above technical solution, by using the time domain distribution parameters and mixing ratio of the previous frame that have been determined to calculate the time domain distribution parameters of the current frame, the equivalent value of the statistical quantity that cannot be directly obtained by statistical methods can be determined in a computational manner, thereby providing the effective sample number and time domain standard deviation for the corresponding pixels of the next frame.
[0047] In some embodiments, the effective sample number of the first pixel is determined based on the effective sample number of the second pixel and the mixing ratio, and the temporal second-order moment of the first pixel is determined based on the temporal second-order moment of the second pixel and the mixing ratio.
[0048] The effective sample number of the first pixel and the time domain second-order moment of the first pixel satisfy the following conditions: M′2=(1-α)*M2+α*curr 2 ;
[0049] Wherein, α is the mixing ratio, N′ is the effective sample number of the first pixel, N is the effective sample number of the second pixel, M′2 is the temporal second-order moment of the first pixel, M2 is the temporal second-order moment of the second pixel, and curr is the first color value.
[0050] According to the above technical solution, through the calculation formula of the above time domain distribution parameters, the equivalent value of the statistical quantity that cannot be directly obtained by statistical methods can be determined by calculation, thereby providing the effective sample number and time domain standard deviation for the corresponding pixels of the next frame.
[0051] In a second aspect, an embodiment of the present application provides an image processing device, comprising: an acquisition part, configured to acquire a first image, wherein the first image includes multiple pixels, the first pixel is one of the multiple pixels, and the first color value is the color value of the first pixel; a sampling part, configured to determine a second pixel in a second image based on a pixel velocity of the first pixel, wherein the second image is an output image of a previous frame of the first image, the pixel velocity is used to indicate the distance and direction of movement of a position output by the first pixel on the screen relative to a position output by the second pixel on the screen, and the second color value is the color value of the second pixel; a determination part, configured to determine a mixing ratio of the first color value to the second color value based on a velocity divergence of the first pixel, wherein the velocity divergence is used to indicate a change in the flux of pixel velocity in a neighborhood space of the first pixel, the neighborhood space being a square range consisting of K×K pixels centered on the first pixel in the first image, where K is an odd number greater than 1; a mixing part, configured to determine a third color value based on the mixing ratio, the third color value being the color value output by the first pixel.
[0052] In some embodiments, the velocity divergence is related to the pixel velocity of edge pixels in the neighborhood space.
[0053] In some embodiments, the velocity divergence is determined based on the number of pixels on each edge of the neighborhood space, the length of the side of the pixels in the first image output to the screen, the component of the pixel velocity in the x-direction of the edge pixels at the left and right edges of the neighborhood space, and the component of the pixel velocity in the y-direction of the edge pixels at the upper and lower edges of the neighborhood space.
[0054] Among them, the velocity divergence satisfies:
[0055] in, is the velocity divergence, K is the number of pixels on each edge of the neighborhood space, a is the length of the edge of the pixel in the first image output to the screen, (x, y) is the coordinate of the first pixel output to the screen, v x (x,y) is the component of the pixel velocity in the x direction of the pixel at the coordinate (x,y) output to the screen, v y (x,y) is the component of the pixel velocity in the y direction of the pixel at the coordinate (x,y) output to the screen.
[0056] In some embodiments, before determining the mixing ratio of the first color value and the second color value based on the velocity divergence of the first pixel, the sampling part is further configured to: obtain the effective sample number of the second pixel and the time domain second-order moment of the second pixel, wherein the effective sample number is used to represent the number of effective pixels mixed in the second pixel, and the time domain second-order moment is used to represent the fluctuation range of the color value of the effective pixel, and the effective pixel is the pixel in the historical frame that contributes to the second color value.
[0057] In some embodiments, the determination part is further configured to: determine the valid range of the second color value based on the velocity divergence, where the valid range is used to indicate the size by which the second color value is allowed to deviate from the first color value; and determine the mixing ratio based on the relationship between the second color value and the valid range.
[0058] In some embodiments, the determination part is further configured to: when the velocity divergence is 0, determine the effective range based on the spatial standard deviation, the temporal standard deviation and the effective sample number of the second pixel, wherein the spatial standard deviation is the standard deviation of the color values of the pixels in the neighborhood space, and the temporal standard deviation is the standard deviation of the color values of the effective pixels.
[0059] In some embodiments, the temporal standard deviation is calculated based on the temporal second-order moment of the second pixel and the second color value.
[0060] Among them, the time domain standard deviation satisfies: dev t 2 =M2-hist 2 ;
[0061] Among them, dev t is the temporal standard deviation, M2 is the temporal second-order moment of the second pixel, and hist is the second color value.
[0062] In some embodiments, the effective range is determined by calculation based on the spatial standard deviation, the temporal standard deviation, and a boundary constraint function.
[0063] Among them, the effective range meets:
[0064] Among them, δ is the effective range, dev s is the spatial standard deviation, dev l is the maximum value between the spatial standard deviation and the temporal standard deviation, N is the number of valid samples of the second pixel, and clamp(x,0,1) represents the boundary constraint function.
[0065] In some embodiments, the determining part is further configured to: when the velocity divergence is not 0, determine the effective range according to the spatial standard deviation, wherein the spatial standard deviation is the standard deviation of the color values of pixels in the neighborhood space.
[0066] In some embodiments, the determining portion is further configured to adjust the effective range according to the speed divergence.
[0067] In some embodiments, the adjusted effective range is calculated based on the spatial standard deviation, velocity divergence, and boundary constraint function.
[0068] Among them, the adjusted effective range meets the following requirements:
[0069] Among them, δ is the effective range, dev s is the spatial standard deviation, is the velocity divergence, and clamp(x,0,1) represents the boundary constraint function.
[0070] In some embodiments, the mixing ratio includes a first mixing ratio and a second mixing ratio, wherein the first mixing ratio is a fixed value, and the second mixing ratio is used to correct the first mixing ratio when the second color value deviates from the first color value beyond the valid range. The determination part is also configured to: determine the second mixing ratio based on the relationship between the second color value and the valid range; and correct the first mixing ratio based on the second mixing ratio to determine the mixing ratio.
[0071] In some embodiments, the second mixing ratio is determined by calculation based on the first color value, the second color value, and the valid range.
[0072] The second mixing ratio satisfies:
[0073] Among them, α c is the second mixing ratio, curr is the first color value, hist is the second color value, and δ is the valid range.
[0074] In some embodiments, the first image is generated based on a third image, the number of pixels of the third image is less than or equal to the number of pixels of the first image, wherein the first pixel is generated based on the third pixel in the third image, and the weight value of the first pixel is used to indicate the degree of contribution of the third pixel to the first color value. The determination part is also configured to: when the weight value of the first pixel is 0, determine the second mixing ratio of the first pixel based on the second mixing ratio of the four pixels surrounding the first pixel in the first image.
[0075] In some embodiments, the mixing part is further configured to: generate the effective sample number of the first pixel based on the effective sample number and the mixing ratio of the second pixel; generate the time domain second order moment of the first pixel based on the time domain second order moment of the second pixel and the mixing ratio.
[0076] In some embodiments, the effective sample number of the first pixel is determined based on the effective sample number of the second pixel and the mixing ratio, and the temporal second-order moment of the first pixel is determined based on the temporal second-order moment of the second pixel and the mixing ratio.
[0077] The effective sample number of the first pixel and the time domain second-order moment of the first pixel satisfy the following conditions: M′2=(1-α)*M2+α*curr 2 ;
[0078] Wherein, α is the mixing ratio, N′ is the effective sample number of the first pixel, N is the effective sample number of the second pixel, M′2 is the temporal second-order moment of the first pixel, M2 is the temporal second-order moment of the second pixel, and curr is the first color value.
[0079] In a third aspect, an embodiment of the present application provides a computing device comprising a processor and a memory, wherein the processor is configured to execute instructions stored in the memory, and the computing device executes the method in the first aspect or any possible implementation of the first aspect.
[0080] The processor may be a general-purpose processor that can be implemented in hardware or software. In the case of hardware implementation, the processor may be a logic circuit, an integrated circuit, or the like. In the case of software implementation, the processor may be a general-purpose processor that is implemented by reading software code stored in a memory, which may be integrated into the processor or located independently of the processor.
[0081] In a fourth aspect, an embodiment of the present application provides a chip, which is configured to implement the steps in the method in the above-mentioned first aspect or any possible implementation manner of the first aspect when obtaining an instruction and executing the instruction.
[0082] In some embodiments, the chip includes a processor and a data interface, and the processor reads instructions stored in the memory through the data interface to execute the steps in the method in the above-mentioned first aspect or any possible implementation of the first aspect.
[0083] In some embodiments, the chip may also include a memory storing instructions, and the processor is configured to execute the instructions stored on the memory. When the instructions are executed, the processor is configured to execute the steps in the method in the above-mentioned first aspect or any possible implementation of the first aspect.
[0084] In a fifth aspect, an embodiment of the present application provides a computer program product, comprising a computer program or instructions, which, when executed by a processor, implements the steps in the method of the above-mentioned first aspect or any possible implementation of the first aspect.
[0085] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the method in the above-mentioned first aspect or any possible implementation of the first aspect.
[0086] By way of example, these computer-readable storage media include, but are not limited to, one or more of the following: Read Only Memory (ROM), Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Ferromagnetic Random Access Memory (FRAM), Flash Memory, magnetic surface storage, CD-ROM, or Compact Disc Read-Only Memory (CD-ROM), and hard drive.
[0087] Optionally, in some embodiments, the computer-readable storage medium may be a non-volatile storage medium.
[0088] It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0089] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be described below.
[0090] The drawings herein are incorporated into and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and, together with the specification, are used to illustrate the technical solutions of the present application.
[0091] FIG1 is a schematic flowchart of a method for processing an image provided in an embodiment of the present application.
[0092] FIG2 is a schematic flowchart of another method for processing an image provided in an embodiment of the present application.
[0093] FIG3 is a schematic structural block diagram of an apparatus for processing an image provided in an embodiment of the present application.
[0094] FIG4 is a schematic structural block diagram of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0095] The technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings.
[0096] The embodiments of the present application will present various aspects, embodiments, or features around systems including multiple devices, components, parts, etc. It should be understood and appreciated that each system may include additional devices, components, parts, etc., and / or may not include all of the devices, components, parts, etc. discussed in conjunction with the figures. Furthermore, combinations of these solutions may also be used.
[0097] Additionally, in the embodiments of this application, words such as "exemplarily" and "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described in this application as an "exemplary" should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of the word "exemplary" is intended to present concepts in a concrete manner.
[0098] In the embodiments of the present application, “correspondingly” and “correspondingly” may sometimes be used interchangeably. It should be noted that when the distinction between them is not emphasized, the meanings they intend to express are consistent.
[0099] The network architecture and business scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. A person skilled in the art will appreciate that, with the evolution of the network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are equally applicable to similar technical problems.
[0100] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in yet other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0101] In the embodiments of the present application, "at least one" refers to one or more, and "more" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: including the existence of A alone, the existence of A and B at the same time, and the existence of B alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.
[0102] To facilitate understanding, the following first introduces relevant terms and concepts that may be involved in the embodiments of this application.
[0103] 1. Anti-aliasing (AA): Anti-aliasing technology is a technique that eliminates jagged edges on images displayed on monitors. It can also be called anti-aliasing, edge softening, anti-aliasing, or anti-lossy image aliasing. High-resolution source signals or continuous analog signals can store a large amount of data. However, through sampling, this data is replaced with fewer data points, and some data is ignored, resulting in lossy sampling. When the machine converts the sampled digital signals into human-readable analog signals, these signals overlap and become lossy, resulting in harsh, discordant tones or noise in the audio.
[0104] In 3D graphics, each graphic consists of pixels, and each instantaneous image consists of frames. Because the number of pixels on a screen is limited, absolute coordinate positioning is not feasible due to technical limitations. Relative positioning requires sampling at approximate locations. Because there aren't enough samples to represent all the objects in the 3D world, the resulting image will exhibit artifacts such as wavy, rounded, jagged edges, and flickering, severely impacting image quality.
[0105] 2. Super sampling antialiasing (SSAA): SSAA is an early post-processing antialiasing technology that multiplies the current image resolution (for example, if the current resolution is 1024×768 and 2x SSAA is enabled, the image is enlarged to 2048×1536) and then scales the image to the current display. While the display size remains unchanged, the resolution is increased and individual pixels become smaller, thus reducing the jaggedness of the image.
[0106] The general process of SSAA is as follows: First, an image is created in a separate buffer with a higher resolution than the screen resolution. After doubling the number of pixels, two or four adjacent pixels are selected for blending, ensuring that the final pixel inherits the characteristics of its neighbors. This makes the transitions between pixels more similar, resulting in smoother color transitions across the entire image. The processed pixels are then output to the frame buffer, stored as an image, and displayed on the monitor as the current frame.
[0107] It can be seen that the processing idea of SSAA is relatively simple and direct. Therefore, although the effect is good, it consumes more resources and has a slower processing speed because each pixel needs to be sampled multiple times.
[0108] 3. Temporal Anti-Aliasing: TAA works on the same principle as SSAA, with multiple sampling points per pixel. However, unlike SSAA, which uses multiple sampling points within the same frame, TAA implements anti-aliasing by integrating data from corresponding pixels in previous frames. This allows the multiple sampling points for each pixel to be evenly distributed across multiple frames, reducing resource overhead.
[0109] The general process of TAA is as follows: Before rendering, a small perturbation is applied to the entire image to ensure that each frame receives different information. The perturbation is less than 1 pixel and is pseudo-random. This perturbation is typically added to the transformation matrix as a translation. While rendering, the velocity of each pixel is output and recorded in a texture. Pixel velocity is defined as the vertex's screen position in the current frame minus the vertex's screen position in the previous frame. Based on the pixel velocity, the pixel's corresponding historical position is traced back through the historical frames. The sample corresponding to this position is the pixel's historical information. This historical pixel is linearly blended with the current frame's pixel to produce the final output pixel. This output pixel contains both historical and current frame information, thus more accurately describing the image than the current frame itself, reducing aliasing. The blended pixel is then output to the display device and recorded as the historical information for the next frame.
[0110] 4. Temporal super-sampling (TSS): TSS is a variant of TAA, incorporating the concepts of SSAA. The difference between TSS and TAA is that TSS processes images rendered at low resolution, while both the historical information and the output image are high-resolution images. Therefore, TSS needs to first upsample the low-resolution image to a high-resolution image as the current frame through filtering, making it have the same resolution as the historical frames and the target output, thereby mixing the current frame pixels with the corresponding pixels in the historical frames to obtain the pixels to be output.
[0111] Because when acquiring a high-resolution image in TSS, the sampling points do not necessarily cover every pixel of the high-resolution image. Therefore, the mixing of the current frame and historical information is performed selectively: the sampling position of the current frame is determined by the amount of disturbance, and each pixel adopts the current frame based on its distance from the sampling position. The weight value of the pixel in the high-resolution image reflects the degree of acceptance of the current frame. The weight value of the pixel can also be called the pixel's confidence, represented by the symbol conf. For example, if the sampling position of the current frame is far away from the pixel and fails to fall on the grid where the pixel is located, the weight value of the pixel is 0, and the current frame information is not mixed. The output pixel is obtained through historical information.
[0112] However, some situations may cause historical information to become invalid (for example, changes in lighting, reflections, shadows, or changes in the mask relationship between objects). In such cases, historical information must be discarded and only the current frame's information must be used. Otherwise, incorrect content will appear in the image.
[0113] Currently, the standard for determining whether historical information is usable is relatively crude, resulting in a lot of available historical information being discarded, resulting in poor anti-aliasing processing. Therefore, how to retain as much available historical frame information as possible when processing the current frame has become a technical problem that needs to be solved urgently.
[0114] However, both TAA and TSS technologies face a problem: historical information may have expired. For example, when historical information becomes invalid due to changes in lighting, reflection, shadows, or changes in the mask relationship between objects, it is necessary to discard the historical information and only use the information of the current frame. Otherwise, incorrect content will appear in the picture. For example, when the mask relationship of an object changes, if the historical information is not discarded in time, the foreground occluder in the next frame will leave an afterimage on the background occluded object; for example, when the lighting conditions of an object change, using unavailable historical information will cause the reflection and projection of the object's surface to lag behind what it should actually be.
[0115] In order to avoid errors in the screen caused by the use of expired historical information, current solutions generally use more cautious standards to screen credible historical information, and the dimensions considered in the standards are relatively single.
[0116] For example, the color values of 9 pixels within a 3×3 spatial range around the target pixel are used as reference standards, and historical information that exceeds the maximum or minimum value range is discarded.
[0117] For another example, using the expected and variance values of the nine pixels within a 3×3 spatial range surrounding the target pixel as a reference standard, only historical information that can only appear within a certain number of variances around this expected value is accepted. If the historical information exceeds this range, it is truncated to the upper / lower limit. Furthermore, the adjustment range is based on whether the pixel is moving. For pixels with motion, the range is 0.5 standard deviations; for pixels with zero motion, the range is 2.5 standard deviations.
[0118] The above solution can reduce the interference of failed historical information to a certain extent, but it may cause a lot of available historical information that has not failed to be discarded. For example, for the solution that uses the expectation and standard deviation within the spatial range as the standard, if the small details in the picture are due to large signal fluctuations and a large number of outliers, they will be incorrectly discarded, resulting in blurred details, jagged edges due to insufficient sampling, and other adverse consequences. For another example, using pixel speed as the basis for the adjustment range, for scenes where the object is moving and the mask relationship has not changed, a lot of historical information will be discarded due to the pixel existence speed. However, since the environment around the target pixel is stable and has not changed, the historical information is actually not invalid. The above judgment criteria cause the originally available historical information to be discarded, and the anti-aliasing processing effect is deteriorated.
[0119] In view of this, embodiments of the present application provide a method for processing images, providing a more refined historical information discrimination standard with more reference dimensions, thereby providing more effective sampling in the time domain and obtaining a higher quality output image with better temporal stability. By proposing a new parameter, the velocity divergence of the pixel, the method provided in embodiments of the present application can determine the mixing ratio of the current frame pixels and the previous frame pixels based on the velocity divergence of the pixels, and more fundamentally determine the conditions in the geometric information that cause historical failures, thereby preserving as much image detail as possible and improving the image output effect.
[0120] In order to better understand the solution of the embodiment of the present application, the method provided in the embodiment of the present application is described below with reference to FIG1 .
[0121] Figure 1 shows a schematic flow chart of a method for processing an image provided in an embodiment of the present application. As shown in Figure 1 , the method includes the following steps.
[0122] S110: Acquire a first image.
[0123] For example, in step S110, the computing device may obtain a current frame image. Specifically, the current frame image has the same resolution as the historical information and the display device to be output, wherein the historical information refers to the image of the historical frame ultimately output to the display device. For ease of illustration, the current frame image obtained is referred to as the first image, and the previous frame image ultimately output to the display device is referred to as the second image. The first image and the second image have the same number of pixels. In some embodiments, a color value is used to describe the color of a pixel, the first pixel is one of multiple pixels in the first image, and the first color value is the color value of the first pixel.
[0124] In some embodiments, the first image can be obtained by upsampling the image rendered at a low resolution to increase the resolution. The upsampling method includes but is not limited to Lanzcos sampling, Monte Carlo sampling, etc., which is not specifically limited in the embodiments of the present application. Taking Lanzcos2 filter upsampling as an example, after the image rendered at a low resolution is upsampled to a high-resolution first image through Lanzcos2 filtering, each pixel in the first image has a Lanzcos2 weight according to the distance from the sampling point, and the maximum Lanzcos2 weight of each pixel is recorded as confidence (conf), which can also be called the weight value of the pixel, which is used to represent the contribution of the pixel in the low-resolution image to the pixel in the high-resolution image.
[0125] It should be understood that the above-mentioned method of obtaining a high-resolution image by increasing the number of pixels of a low-resolution image is only one way to obtain the first image, and the embodiment of the present application does not limit the first image to be obtained by upsampling. The first image can also be obtained without changing the resolution. For example, the first image can be an image directly rendered at a high resolution; for another example, a computer device can also render and generate an image at a high resolution (the same resolution as the display device to be output), and then obtain the first image by processing without changing the resolution. The embodiment of the present application does not make specific limitations. In the above case, each pixel in the first image obtains information from the current frame, so the weight value of the pixel is 1.
[0126] S120: Determine a second pixel in the second image according to the pixel velocity of the first pixel.
[0127] For example, in step S120, the computing device can backtrack to obtain the corresponding pixel in the second image based on the speed of each pixel in the first image. As described above, the second image is the previous frame image that is finally output to the display device, and the pixel speed is used to indicate the distance and direction of movement of the position on the screen of the geometric shape represented by the pixel in the current frame relative to the position on the screen of the pixel corresponding to the geometric shape in the previous frame. The pixel determined by backtracking the first pixel in the second image based on the pixel speed of the first pixel is called the second pixel, and the color value of the second pixel is called the second color value. The pixel speed of the first pixel can be determined when the current frame image is rendered. For example, the position on the screen of the vertex of the geometric shape represented by the first pixel in the current frame is subtracted from the screen position of the vertex in the previous frame to generate the pixel speed of the first pixel. The screen position can be calculated by multiplying the transformation matrix when the corresponding frame is rendered by the coordinate position of the vertex.
[0128] Since the second image is the previous frame ultimately output to the display device—that is, it's actually a mixture of the image rendered by the previous frame and the information contained in the historical frames—the second pixel actually includes information about corresponding pixels from a series of historical frames in the temporal sequence. Therefore, two new parameters are introduced: the effective sample number N and the temporal second-order moment M2, which reflect the temporal statistical distribution of the historical information contained in the previous frame's pixels. The effective sample number N represents the number of effective pixels mixed in the second pixel, and the temporal second-order moment M2 represents the range of color value fluctuations for effective pixels. Effective pixels are pixels in the historical frames that contribute to the second color value.
[0129] After backtracking to determine the second pixel based on the pixel velocity, the computing device can also obtain the effective sample number and temporal second-order moment of the second pixel. For example, after the second image is generated and output to the display device, the computing device can record the color value of the second pixel, the effective sample number corresponding to the second pixel, and the temporal second-order moment in the memory, so that the second color value, the effective sample number of the second pixel, and the temporal second-order moment can be obtained from the memory when processing the first image.
[0130] Since the pixels finally output to the display device are generated by mixing the current pixels and the historical pixels in a certain mixing ratio, the true values of the number of effective samples and the second-order moment in the time domain cannot be obtained through statistical methods. However, the equivalent values of the effective number of samples and the second-order moment in the time domain of the current frame can be calculated based on the effective number of samples and the second-order moment in the time domain of the previous frame and the mixing ratio of the current frame to the previous frame.
[0131] In the case where there is information from the previous frame for reference, the number of valid samples of pixels in the current frame can be determined according to formula (1):
[0132] The temporal second-order moment of the current frame pixel can be determined according to formula (2): M′2=(1-α)*M2+α*curr 2 Formula (2);
[0133] Among them, α is the mixing ratio of the current frame pixel and the previous frame output pixel, N′ is the effective sample number of the current frame pixel, N is the effective sample number of the previous frame output pixel, M′2 is the temporal second-order moment of the current frame pixel, M2 is the temporal second-order moment of the previous frame output pixel, and curr is the color value of the current frame pixel.
[0134] When there is no previous frame information to refer to, for example, when the current frame is the initial frame, the effective sample number and temporal second-order moment of the pixels in the current frame are initial values, and both the effective sample number and the temporal second-order moment are 0.
[0135] S130: Determine a mixing ratio of the first color value to the second color value according to the velocity divergence of the first pixel.
[0136] For example, in step S130, the computing device can determine the mixing ratio α of the first pixel and the second pixel in the output image of the previous frame based on the velocity divergence of the first pixel in the current frame, wherein the color value determined by mixing the first color value of the first pixel and the second color value of the second pixel according to the mixing ratio α is used as the color value of the pixel finally output to the display device in the current frame.
[0137] The velocity divergence of the first pixel is determined based on the pixel velocity of edge pixels in the neighborhood space of the first pixel. The neighborhood space is a square range of K×K pixels centered on the first pixel in the first image, where K is an odd number greater than 1. Edge pixels are the pixels in the outermost circle of the neighborhood space. Taking a neighborhood space of K×K size as an example, the pixels located in the 1st column, the Kth column, the 1st row, and the Kth row in the neighborhood space are called edge pixels, where the pixels in the 1st column are left edge pixels, the pixels in the Kth column are right edge pixels, the pixels in the 1st row are upper edge pixels, and the pixels in the Kth row are lower edge pixels. The velocity divergence of the first pixel is calculated based on the difference in pixel velocity between the right edge pixel and the left edge pixel in the x direction, and the difference in pixel velocity between the upper edge pixel and the lower edge pixel in the y direction in the neighborhood space.
[0138] The velocity divergence of the first pixel can be defined according to formula (3):
[0139] in, is the velocity divergence in the K×K neighborhood space of the first pixel, where the neighborhood space is the square range formed by the pixels centered on the first pixel in the first image, K is the number of pixels on each side of the neighborhood space, and K is an odd number greater than 1; a is the side length of the pixel in the first image output to the screen; (x, y) is the coordinate of the first pixel output to the screen; v x (x,y) is the component of the pixel velocity in the x direction of the pixel at the coordinate (x,y) output to the screen; v y (x,y) is the component of the pixel velocity in the y direction of the pixel at the coordinate (x,y) output to the screen.
[0140] In some embodiments, the size K of the neighborhood space can be adjusted according to the requirements of the actual judgment standard, and a neighborhood space with K equal to 5 can be taken.
[0141] In some embodiments, the computing device can adjust the effective range of the historical information based on the velocity divergence, thereby achieving regulation of the mixing ratio based on whether the historical information falls within the effective range. For example, when the velocity divergence is 0, there is no speed difference between the pixels in the neighborhood space, and the pixels in the neighborhood space are stationary or move at the same speed. Therefore, the surrounding environment of the pixel in the current frame has not changed drastically relative to the previous frame. Therefore, a larger effective range can be given, so that more historical information falls within the effective range, and a mixing ratio that is more biased towards the historical information may be obtained; for another example, when the velocity divergence is not 0, the pixels in the neighborhood space also have relative motion, and the surrounding environment of the pixel in the current frame may have changed relative to the previous frame. Therefore, by reducing the effective range, more historical information is discarded, thereby obtaining a mixing ratio that may be more biased towards the pixels of the current frame.
[0142] S140: Determine a third color value according to the mixing ratio.
[0143] For example, in step S140, the computing device may mix the first color value of the first pixel with the second color value of the second pixel according to the mixing ratio α between the current frame pixel and the historical information determined in step S130, thereby determining the color value of the pixel ultimately output to the display device in the current frame. The computing device may also store the mixed pixel color value information in a memory as historical information for the next frame.
[0144] The color value of the output pixel of the current frame can be determined according to formula (4): (1-α)*hist+α*curr Formula (4);
[0145] Wherein, α is the mixing ratio of the current frame and the historical information, curr is the first color value of the first pixel, and hist is the second color value of the second pixel.
[0146] In some embodiments, the computing device may further generate the effective number of samples N′ and the temporal second-order moment M′2 of the first pixel in the current frame based on the above-mentioned mixing ratio and store them in a memory to provide reference information for the next frame. The effective number of samples N′ of the first pixel is calculated in accordance with formula (5):
[0147] The calculation method of the temporal second-order moment M′2 of the first pixel conforms to formula (6): M′2=(1-α)*M2+α*curr 2 Formula (6);
[0148] Wherein, α is the mixing ratio, N′ is the effective sample number of the first pixel, N is the effective sample number of the second pixel, M′2 is the temporal second-order moment of the first pixel, M2 is the temporal second-order moment of the second pixel, and curr is the first color value.
[0149] Through the technical solution of the embodiments of the present application, by introducing a new parameter velocity divergence as a reference for determining whether historical pixel information is available, the velocity divergence of the pixel can more essentially reflect whether the geometric shape around the pixel has changed, relative to the pixel velocity. This can avoid erroneously discarding the available information of the previous frame of pixels during pixel movement, retain as many picture details as possible, and improve the image output effect.
[0150] For the above-mentioned step S130, in some embodiments, in order to further refine the criteria for determining the effective range, parameters reflecting the statistical distribution law of historical information in the time domain (such as the effective sample number N and the time domain second-order moment M2 mentioned above) can be introduced when certain conditions are met, thereby providing available reference information in more dimensions for judging whether the historical information is invalid, thereby improving the accuracy of the judgment criteria.
[0151] In this case, Fig. 2 shows a schematic flow chart of another method for processing an image provided by an embodiment of the present application. The following describes in detail the calculation method of the mixing ratio α in conjunction with Fig. 2 and a specific embodiment.
[0152] S210: Acquire a first color value and a pixel velocity of a first pixel in a first image, and acquire a second color value, a valid sample number, and a temporal second-order moment of a second pixel in a second image according to the pixel velocity.
[0153] As shown in Figure 2, the computing device first obtains a first color value and pixel velocity of a first pixel in a first image. Based on the pixel velocity, it obtains a second color value, effective sample count, and temporal second-order moment of a second pixel in a second image. Furthermore, it calculates the velocity divergence of the first pixel. The first image is the current frame to be processed, and the second image is the previous frame output to the display device. For the specific implementation of these steps, please refer to the description of steps S110 to S310.
[0154] S220: Calculate the velocity divergence of the first pixel, and determine whether the velocity divergence is zero.
[0155] The computing device may select different final standard deviations according to whether the velocity divergence of the first pixel is 0.
[0156] In some embodiments, when the velocity divergence is not 0, step S230 is executed; when the velocity divergence is 0, step S240 is executed.
[0157] S230: The spatial standard deviation is the final standard deviation.
[0158] For example, when the velocity divergence is not 0, select the spatial standard deviation dev s As the final standard deviation dev, where the spatial standard deviation dev s is the standard deviation (i.e., the square root of the variance) of the color values of the pixels in the neighborhood space of the first pixel. At this time, the surrounding environment of the current pixel has changed and may no longer conform to the statistical distribution of historical pixels in the time domain. Therefore, the reference parameter of the effective range can be limited to the spatial standard deviation, without reference to the time dimension.
[0159] S240: Determine a final standard deviation based on the spatial standard deviation, the temporal standard deviation, and the number of valid samples.
[0160] For example, when the velocity divergence is 0, according to the spatial standard deviation dev s , time domain standard deviation dev t The final standard deviation dev is determined by the number of valid samples N of the second pixel, where the time domain standard deviation dev t Is the standard deviation of the color values of the effective pixels mixed in the second pixel. Since the time domain second-order moment M2 is the equivalent value of the second-order moment of the effective pixels mixed in the second pixel, and the second color value hist of the second pixel obtained by weighted mixing of the color values of the effective pixels is equivalent to the average value of the color values of the effective pixels, according to formula (7), it can be obtained: dev t 2 =M2-hist 2 Formula (7);
[0161] Among them, dev t is the temporal standard deviation, M2 is the temporal second-order moment of the second pixel, and hist is the second color value.
[0162] The final standard deviation dev can be determined based on the number of valid samples N. The larger the number of valid samples, the more the final standard deviation dev tends to the spatial standard deviation dev. s And the time domain standard deviation dev t The larger value dev l , and the smaller the number of effective samples, the more the final standard deviation dev tends to the spatial standard deviation dev s , can be determined according to formula (8):
[0163] Among them, dev is the final standard deviation, dev s is the spatial standard deviation, dev l is the spatial standard deviation dev s and time domain standard deviation dev t where N is the maximum value between , and N is the number of valid samples of the second pixel.
[0164] Where clamp(x,0,1) represents the boundary constraint function, which is defined according to formula (9):
[0165] Wherein, lerp(x1,x2,weight) represents the linear interpolation function, which is defined according to formula (10): lerp(x1,x2,weight)=x1+(x2-x1)×weight Formula (10);
[0166] At this time, when the number of historical valid samples is large, the effective range can be gradually relaxed from the spatial standard deviation to the larger value of the time domain standard deviation and the spatial standard deviation, so as to avoid the signal being truncated at the position with large fluctuations in the picture, resulting in loss of details. At the same time, it can also ensure better time domain stability and avoid picture jitter.
[0167] S250: Determine the effective range according to the final standard deviation and velocity divergence.
[0168] The computing device can adjust the final standard deviation number amp within the effective range according to the magnitude of the velocity divergence. For example, the final standard deviation number amp can fluctuate within the range of 0.5 to 3. The larger the velocity divergence, the smaller the final standard deviation number amp, and the smaller the velocity divergence, the larger the final standard deviation number amp. It can be determined according to formula (11):
[0169] in, is the velocity divergence of the first pixel. The larger the velocity divergence, the more dramatic the change in the pixel's surrounding environment, and the smaller the effective range, so the more cautious the historical information is adopted.
[0170] The valid range δ of the second color value is determined according to the final standard deviation dev and the number of final standard deviations amp, referring to formula (12): δ=dev×amp Formula (12);
[0171] Therefore, when the velocity divergence is 0, amp is the maximum value 3, and the effective range δ can be calculated based on the spatial standard deviation dev s , time domain standard deviation dev t The effective sample number N of the second pixel is determined by referring to formula (13):
[0172] When the velocity divergence is 0, the effective range δ can be calculated based on the spatial standard deviation dev s and velocity divergence Determine, refer to formula (14):
[0173] The computing device can determine the upper limit ub of the second color value hist that can be accepted based on the valid range δ and the first color value curr, referring to formula (15): ub=curr+δ Formula (15);
[0174] According to the valid range δ and the first color value curr, the lower limit lb of the second color value hist that can be accepted can be determined, referring to formula (16): lb = curr - δ Formula (16);
[0175] The computing device can determine a mixing ratio α of the first color value to the second color value according to whether the second color value hist exceeds the upper limit ub or the lower limit lb.
[0176] In some embodiments, the mixing ratio α includes a first mixing ratio α b and the second mixing ratio α c Among them, the first mixing ratio α b It can also be called the base mixing ratio, α b It is a fixed value, used to accept part of the historical information as a fixed refresh. b The value of can be 0.0625. The second mixing ratio α c It can also be called a correction mixing ratio, which is used to correct the first mixing ratio when the second color value deviates from the first color value beyond the valid range, thereby reflecting the equivalent situation of historical information being truncated.
[0177] S260: Determine a second mixing ratio according to the first color value, the second color value, and the valid range.
[0178] The second mixing ratio α c The specific relationship between the first color value curr, the second color value hist and the effective range δ can be determined according to formula (17):
[0179] When the second color value hist falls within the valid range, the second mixing ratio α c 0, indicating that no correction is required. When the second color value hist exceeds the upper limit ub or the lower limit lb, the more α c The larger it is, the more the mixed result tends to the first color value curr.
[0180] S270: Determine whether the weight value of the first pixel is 0.
[0181] In some embodiments, the first image may be generated by upsampling a low-resolution image, and the weight value (confidence) conf of the first pixel may be equal to 0, indicating that the current pixel does not obtain information from the current frame.
[0182] In this case, the computing device may also determine whether the weight value conf is equal to 0 and determine different mixing ratios α.
[0183] In some embodiments, when the weight value conf is not 0, S280 is executed; when the weight value conf is 0, S290 is executed.
[0184] S280: Determine the mixing ratio of the first pixel according to the first mixing ratio, the second mixing ratio, and the weight value of the first pixel.
[0185] For example, when the weight value conf is not 0, the first pixel obtains information from the current frame and can make an accurate judgment on whether the historical information needs to be truncated. Therefore, the mixing ratio α is calculated based on the first mixing ratio α of the first pixel itself. b , the second mixing ratio α c And the weight value determines conf, refer to formula (18): α=α b ×conf+α c Formula (18);
[0186] S290: Determine the mixing ratio of the first pixel according to the second mixing ratios of the surrounding four pixels.
[0187] For example, when the weight value conf is 0, the first pixel does not obtain information from the current frame. At this time, it is necessary to use the historical information truncation of the four pixels around the first pixel to correct the mixing ratio of the first pixel. At this time, the second mixing ratio α of the first pixel is c The second mixing ratio α is determined by weighted average of the four pixels around the first pixel, and the weight of the weighted average is the weight value conf of the above four pixels. Since the weight value conf of the first pixel is 0, according to the formula above, the second mixing ratio α determined by the four pixels around it is c It is also the mixing ratio α of the first pixel.
[0188] Through the technical solution of the embodiment of the present application, by using the second mixing ratio of the surrounding pixels as the second mixing ratio of the pixels with a weight value of zero to fill the holes, even if the current pixel does not obtain information from the current frame, it can be known that the neighborhood of the current pixel has undergone historical information truncation, and thus make the same decision as the neighboring pixels, avoiding the occurrence of holes in the neighborhood where historical information is discarded when the sampling rate is low.
[0189] The above describes the method for processing an image provided by an embodiment of the present application in conjunction with Figures 1 and 2. The following describes an embodiment of the device for processing an image provided by an embodiment of the present application in conjunction with Figures 3 to 4.
[0190] FIG3 shows a schematic structural block diagram of an apparatus 300 for processing an image provided in an embodiment of the present application.
[0191] As shown in FIG3 , the apparatus 300 for processing an image includes: an acquisition part 310 , a sampling part 320 , a determination part 330 , and a mixing part 340 .
[0192] The acquisition part 310 is configured to acquire a first image, wherein the first image includes a plurality of pixels, the first pixel is one of the plurality of pixels, and the first color value is a color value of the first pixel.
[0193] The sampling part 320 is configured to determine the second pixel in the second image based on the pixel velocity of the first pixel, wherein the second image is the output image of the previous frame of the first image, the pixel velocity is used to indicate the distance and direction in which the position of the first pixel output on the screen moves relative to the position of the second pixel output on the screen, and the second color value is the color value of the second pixel.
[0194] In some embodiments, the sampling part 320 is further configured to obtain the effective sample number of the second pixel and the time domain second-order moment of the second pixel, wherein the effective sample number is used to represent the number of effective pixels mixed in the second pixel, and the time domain second-order moment is used to represent the fluctuation range of the color value of the effective pixel, and the effective pixel is the pixel in the historical frame that contributes to the second color value.
[0195] The determination part 330 is configured to determine the mixing ratio of the first color value and the second color value based on the velocity divergence of the first pixel, wherein the velocity divergence is used to represent the change in the flux of the pixel velocity in the neighborhood space of the first pixel, and the neighborhood space is a square range consisting of K×K pixels centered on the first pixel in the first image, where K is an odd number greater than 1.
[0196] In some embodiments, the determination portion 330 is further configured to determine a valid range of the second color value based on the velocity divergence, where the valid range is used to indicate the allowable deviation of the second color value from the first color value; and determine the mixing ratio based on the relationship between the second color value and the valid range.
[0197] In some embodiments, when the velocity divergence is 0, the determination part 330 is also configured to determine the effective range based on the spatial standard deviation, the temporal standard deviation and the effective sample number of the second pixel, wherein the spatial standard deviation is the standard deviation of the color values of the pixels in the neighborhood space, the temporal standard deviation is the standard deviation of the color values of the effective pixels, and the temporal standard deviation is determined based on the temporal second-order moment of the second pixel and the second color value.
[0198] In some embodiments, when the velocity divergence is not 0, the determining part 330 is further configured to determine the effective range according to a spatial standard deviation, wherein the spatial standard deviation is a standard deviation of color values of pixels in the neighborhood space.
[0199] In some embodiments, the determining portion 330 is further configured to adjust the effective range according to the velocity divergence.
[0200] In some embodiments, the mixing ratio includes a first mixing ratio and a second mixing ratio, wherein the first mixing ratio is a fixed value, and the second mixing ratio is used to correct the first mixing ratio when the second color value deviates from the first color value by a magnitude outside a valid range. Determining portion 330 is further configured to determine the second mixing ratio based on the relationship between the second color value and the valid range, and to correct the first mixing ratio based on the second mixing ratio to determine the mixing ratio.
[0201] In some embodiments, the determination part 330 is also configured to determine the second mixing ratio of the first pixel based on the second mixing ratio of four pixels surrounding the first pixel in the first image when the weight value of the first pixel is 0, wherein the weight value of the first pixel is used to represent the degree of contribution of the third pixel used to generate the first pixel in the third image to the first color value, and the number of pixels of the third image is less than or equal to the number of pixels of the first image.
[0202] The mixing part 340 is configured to determine a third color value according to the mixing ratio, the third color value being a color value of the output of the first pixel.
[0203] In some embodiments, the mixing portion 340 is further configured to generate the effective sample number of the first pixel based on the effective sample number of the second pixel and the mixing ratio; and generate the temporal second-order moment of the first pixel based on the temporal second-order moment of the second pixel and the mixing ratio.
[0204] Parts of the image processing apparatus 300 may be implemented by software or hardware.
[0205] It should be noted that, in other embodiments, the acquisition part 310, the sampling part 320, the determination part 330 and the mixing part 340 can be used to respectively execute any steps in the above-mentioned method for processing an image, and the steps that the acquisition part 310, the sampling part 320, the determination part 330 and the mixing part 340 are responsible for implementing can be specified as needed. The full functions of the device for processing an image are realized by respectively implementing different steps in the above-mentioned method for processing an image through the acquisition part 310, the sampling part 320, the determination part 330 and the mixing part 340.
[0206] The present embodiment also provides a computing device 100. As shown in FIG4 , computing device 100 includes a bus 102, a processor 104, a memory 106, and a communication interface 108. Processor 104, memory 106, and communication interface 108 communicate with each other via bus 102. Computing device 100 can be a server or a terminal device. It should be understood that the present embodiment does not limit the number of processors and memories in computing device 100.
[0207] Bus 102 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, among others. Buses may be classified as address buses, data buses, control buses, and the like. For ease of illustration, FIG4 illustrates a single bus line, but this does not imply a single bus or type of bus. Bus 102 may include a path for transmitting information between various components of computing device 100 (e.g., memory 106, processor 104, and communication interface 108).
[0208] The processor 104 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0209] The memory 106 may include volatile memory, such as random access memory (RAM). The processor 104 may also include non-volatile memory, such as read-only memory, flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0210] Memory 106 stores executable program code. Processor 104 executes the executable program code to implement the functions of the aforementioned acquisition portion 310, sampling portion 320, determination portion 330, and blending portion 340, thereby implementing the aforementioned image processing method. In other words, memory 106 stores instructions for executing the aforementioned image processing method.
[0211] The communication interface 108 uses a transceiver part such as, but not limited to, a network interface card, a transceiver, etc. to implement communication between the computing device 100 and other devices or a communication network.
[0212] An embodiment of the present application provides a chip, which is configured to implement some or all of the steps in the above-mentioned method for processing an image when acquiring an instruction and executing the instruction.
[0213] In some embodiments, the chip includes a processor and a data interface. The processor reads instructions stored in a memory through the data interface to execute part or all of the steps in the above-mentioned method for processing an image.
[0214] In some embodiments, the chip may further include a memory storing instructions, and the processor is configured to execute the instructions stored on the memory. When the instructions are executed, the processor is configured to execute some or all of the steps in the above-mentioned method for processing images.
[0215] The present application also provides a computer program product, which includes a computer program or instructions, and when executed by a processor, implements some or all of the steps in the above-mentioned method for processing an image.
[0216] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements some or all of the steps in the above-mentioned image processing method. The computer-readable storage medium may be any available medium that a computing device can store or a data storage device such as a data center containing one or more available media. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a high-density digital video disc (DVD)), or a semiconductor medium (e.g., a solid-state drive), etc.
[0217] The technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above-mentioned embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0218] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the protection scope of the technical solutions of the embodiments of the present application. Industrial Applicability
[0219] The embodiments of the present application relate to the field of image processing and provide a method, apparatus, computing device, and computer-readable storage medium for processing images, including: acquiring a first image, wherein a first pixel is one of a plurality of pixels included in the first image; determining a second pixel in a second image based on the pixel velocity of the first pixel, wherein the second image is an output image of a previous frame of the first image; determining a mixing ratio of a first color value to a second color value based on the velocity divergence of the first pixel, wherein the velocity divergence is used to represent the change in the flux of pixel velocity within the neighborhood space of the first pixel; and determining a third color value based on the mixing ratio, wherein the third color value is the color value output by the first pixel. By introducing a new parameter, velocity divergence, as a reference for determining whether historical pixel information is available, the above method can more essentially reflect whether the geometric shape around the pixel has changed, thereby preserving as much picture detail as possible and improving the image output effect.
Claims
1. A method for processing an image, applied to a computing device, the method for processing an image comprising: Acquire a first image, wherein the first image includes a plurality of pixels, the first pixel is one of the plurality of pixels, and the first color value is a color value of the first pixel; Determine a second pixel in a second image according to a pixel speed of the first pixel, wherein the second image is an output image of a previous frame of the first image, the pixel speed is used to indicate a distance and direction in which a position of the first pixel output on a screen moves relative to a position of the second pixel output on the screen, and the second color value is a color value of the second pixel; Determining a mixing ratio of the first color value to the second color value according to a velocity divergence of the first pixel, wherein the velocity divergence is used to represent a change in a flux of pixel velocity in a neighborhood space of the first pixel, the neighborhood space being a square range consisting of K×K pixels centered on the first pixel in the first image, where K is an odd number greater than 1; A third color value is determined according to the mixing ratio, where the third color value is a color value outputted by the first pixel.
2. The method according to claim 1, wherein: The velocity divergence is related to the pixel velocity of edge pixels in the neighborhood space.
3. The method according to claim 1 or 2, wherein: The velocity divergence is determined by calculating the number of pixels on each edge of the neighborhood space, the length of the edge of the pixels in the first image output to the screen, the component of the pixel velocity in the x direction of the edge pixels at the left and right edges of the neighborhood space, and the component of the pixel velocity in the y direction of the edge pixels at the upper and lower edges of the neighborhood space.
4. The method according to claim 1 or 2, wherein: Before determining the mixing ratio of the first color value and the second color value according to the velocity divergence of the first pixel, the method further includes: Obtain the effective sample number of the second pixel and the time-domain second-order moment of the second pixel, wherein the effective sample number is used to represent the number of effective pixels mixed in the second pixel, and the time-domain second-order moment is used to represent the fluctuation range of the color value of the effective pixel, and the effective pixel is a pixel in the historical frame that contributes to the second color value.
5. The method according to claim 4, wherein: The step of determining a mixing ratio of the first color value to the second color value according to the velocity divergence of the first pixel includes: Determine, according to the velocity divergence, a valid range of the second color value, wherein the valid range is used to indicate an allowable deviation of the second color value from the first color value; The mixing ratio is determined according to the relationship between the second color value and the effective range.
6. The method according to claim 5, wherein: The determining, according to the velocity divergence, a valid range of the second color value comprises: When the velocity divergence is 0, the effective range is determined according to the spatial standard deviation, the temporal standard deviation and the effective sample number of the second pixel, wherein the spatial standard deviation is the standard deviation of the color values of the pixels in the neighborhood space, and the temporal standard deviation is the standard deviation of the color values of the effective pixels.
7. The method according to claim 6, wherein: The temporal standard deviation is calculated and determined based on the temporal second-order moment of the second pixel and the second color value.
8. The method according to claim 6 or 7, wherein: The effective range is determined by calculation based on the spatial standard deviation, the temporal standard deviation and a boundary constraint function.
9. The method according to claim 5, wherein: The determining, according to the velocity divergence, a valid range of the second color value comprises: When the velocity divergence is not 0, the effective range is determined according to a spatial standard deviation, wherein the spatial standard deviation is a standard deviation of color values of pixels in the neighborhood space.
10. The method according to claim 9, wherein: The determining, according to the velocity divergence, a valid range of the second color value further comprises: The effective range is adjusted according to the velocity divergence.
11. The method according to claim 10, wherein: The adjusted effective range is determined by calculation based on the spatial standard deviation, the velocity divergence and the boundary constraint function.
12. The method according to any one of claims 5 to 7, wherein: The mixing ratio includes a first mixing ratio and a second mixing ratio, wherein the first mixing ratio is a fixed value, and the second mixing ratio is used to correct the first mixing ratio when the second color value deviates from the first color value beyond the effective range. The determining the mixing ratio according to the relationship between the second color value and the effective range includes: determining the second mixing ratio according to a relationship between the second color value and the effective range; The first mixing ratio is corrected according to the second mixing ratio to determine the mixing ratio.
13. The method according to claim 12, wherein: The second mixing ratio is determined by calculation based on the first color value, the second color value and the effective range.
14. The method according to claim 12, wherein: The first image is generated based on the third image, the number of pixels of the third image is less than or equal to the number of pixels of the first image, wherein the first pixel is generated based on the third pixel in the third image, and the weight value of the first pixel is used to represent the contribution degree of the third pixel to the first color value, The determining, according to the velocity divergence of the first pixel, a mixing ratio of the first color value to the second color value further includes: When the weight value of the first pixel is 0, the second mixing ratio of the first pixel is determined according to the second mixing ratios of four pixels surrounding the first pixel in the first image.
15. The method according to claim 4, wherein: The method further comprises: generating the effective number of samples of the first pixel according to the effective number of samples of the second pixel and the mixing ratio; The temporal second order moment of the first pixel is generated according to the temporal second order moment of the second pixel and the mixing ratio.
16. The method according to claim 15, wherein: The effective sample number of the first pixel is determined by calculation based on the effective sample number of the second pixel and the mixing ratio, and the time domain second order moment of the first pixel is determined by calculation based on the time domain second order moment of the second pixel and the mixing ratio.
17. A device for processing an image, comprising: An acquisition part is configured to acquire a first image, wherein the first image includes a plurality of pixels, the first pixel is one of the plurality of pixels, and the first color value is a color value of the first pixel; The sampling part is configured to determine a second pixel in a second image according to a pixel speed of the first pixel, wherein the second image is an output image of a previous frame of the first image, and the pixel speed is used to indicate a relative position of the first pixel output to the screen. For the distance and direction in which the second pixel is output to move to the position on the screen, the second color value is the color value of the second pixel; a determining part, configured to determine a mixing ratio of the first color value to the second color value according to a velocity divergence of the first pixel, wherein the velocity divergence is used to represent a change in a flux of pixel velocity in a neighborhood space of the first pixel, the neighborhood space being a square range consisting of K×K pixels centered on the first pixel in the first image, where K is an odd number greater than 1; The mixing part is configured to determine a third color value according to the mixing ratio, where the third color value is a color value of an output of the first pixel.
18. A computing device, comprising a processor and a memory, wherein the memory stores a computer program executable on the processor, and when the processor executes the program, the steps in the method according to any one of claims 1 to 16 are implemented.
19. A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps in the method according to any one of claims 1 to 16 are implemented.
20. A computer program product, comprising a computer program or instructions, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 16.
21. A chip, wherein the chip is configured to implement the steps in the method according to any one of claims 1 to 16 when fetching instructions and executing the instructions.
Citation Information
Patent Citations
Image processing method and device, computing equipment and computer readable storage medium
CN116156089A
Image processing apparatus, image processing method, and image capturing apparatus
JP2010004396A
Method for data reuse and applications to spatio-temporal supersampling and de-noising
US20170272722A1
Adding greater realism to a computer-generated image by smoothing jagged edges
US20210398253A1
