Image processing method and apparatus

By determining the sampling point coordinates and sampling pixel values ​​of the target image in the video website for sharpening, the problems of poor resampling effect and high memory consumption in the existing technology are solved, and efficient image quality enhancement and image processing efficiency are achieved.

CN117196994BActive Publication Date: 2026-02-27SHANGHAI BILIBILI TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311241161.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-22
Publication Date
2026-02-27
Estimated Expiration
2043-09-22

AI Technical Summary

Technical Problem

In existing technologies, the image processing methods of video websites generally have poor resampling effects when scaling up the screen and enhancing image quality, resulting in blurry images. Furthermore, they require additional memory space and multiple shaders in series, which increases memory consumption and complexity.

Method used

By determining the coordinates of each pixel in the target image to the target sampling point in the original image, sampling multiple pixel values, and performing sharpening processing based on these pixel values, a single shader is used to achieve an integrated operation of resampling and image quality enhancement, reducing memory overhead and improving image quality.

Benefits of technology

It achieves integrated operation of resampling and image quality enhancement, improves image quality, reduces memory consumption and program complexity, and enhances the image processing efficiency of terminal devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117196994B_ABST
    Figure CN117196994B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a kind of image processing method and device, comprising: according to the size of original image and the size of target image, the coordinate of each pixel point on the target image corresponding target sampling point on the original image is determined;For each pixel point on the target image, according to the coordinate of the target sampling point, the multiple pixel values of the preset pixel are obtained by sampling from the original image, and the pixel value of the target sampling point corresponding to the pixel point is determined according to the multiple pixel values of the preset pixel;According to the pixel value of the target sampling point, each pixel point on the target image is sharpened, and the sharpened pixel value is obtained;According to the pixel value of target sampling point and the sharpened pixel value, the target image is rendered on the display screen of terminal equipment. Thus, using a single shader can realize the operation of resampling and picture quality enhancement, which is simpler than the mode of serial multiple shaders, and reduces the memory overhead.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of Internet, and in particular, to an image processing method and device, computer equipment and a computer readable storage medium. BACKGROUND

[0002] With the development of multimedia technology, image processing technology is applied more and more widely. In a video website, image processing technologies commonly applied include picture scaling function, super-resolution processing function, and picture quality enhancement function, etc.

[0003] In the prior art, picture scaling (full screen) in a video website is mostly rendered to a screen after resampling based on a hardware-based bilinear interpolation method. This resampling method has the advantage of being integrated in hardware and processing very quickly, but the effect after resampling is generally poor, resulting in a blurred picture and the disappearance of some texture details. In addition, super-resolution and picture quality enhancement algorithms based on a shader need to be implemented by connecting two shaders in series, wherein the first shader performs an image resampling operation, and the resampled image buffer is saved as the input of the second shader, and the second shader performs a picture quality enhancement operation and renders to the screen. This method needs to configure two shaders and needs to additionally open up a memory space for storing intermediate results. SUMMARY

[0004] An object of embodiments of the present application is to provide an image processing method and device, computer equipment and a computer readable storage medium, to solve the problem of how to improve the effect of image picture resampling while enhancing the display effect of picture quality and reducing memory consumption.

[0005] One aspect of embodiments of the present application provides an image processing method, comprising:

[0006] According to the size of the original image and the size of the target image, determining the coordinates of the target sampling point corresponding to each pixel point on the target image on the original image;

[0007] For each pixel point on the target image, sampling a plurality of pixel values of a preset pixel from the original image according to the coordinates of the target sampling point, and determining the pixel value of the target sampling point corresponding to the pixel point according to the plurality of pixel values of the preset pixel;

[0008] According to the pixel value of the target sampling point, performing sharpening processing on each pixel point on the target image to obtain a sharpened pixel value;

[0009] According to the pixel value of the target sampling point and the sharpened pixel value, rendering the target image on the display screen of the terminal device.

[0010] Optionally, the determining the pixel value of the target sampling point corresponding to the pixel point according to the plurality of pixel values of the preset pixel comprises:

[0011] determining a weight value of each pixel point in the preset pixel relative to the target sampling point;

[0012] weighting the plurality of pixel values of the preset pixel according to the weight value to obtain the pixel value of the target sampling point corresponding to the pixel point.

[0013] Optionally, the sharpening processing each pixel point on the target image according to the pixel value of the target sampling point to obtain a sharpened pixel value comprises:

[0014] determining a plurality of filter regions from the preset pixel, and determining a Gaussian filter value corresponding to each filter region;

[0015] determining a target filter value according to the Gaussian filter value corresponding to each filter region;

[0016] determining a sharpened pixel value according to the pixel value of the target sampling point and the target filter value.

[0017] Optionally, the determining a target filter value according to the Gaussian filter value corresponding to each filter region comprises:

[0018] determining a weight value corresponding to each filter region based on a preset bilinear interpolation algorithm;

[0019] determining a target filter value according to the weight value corresponding to each filter region and the Gaussian filter value.

[0020] Optionally, the determining a sharpened pixel value according to the pixel value of the target sampling point and the target filter value comprises:

[0021] determining a sharpening intensity value corresponding to each filter region according to the plurality of pixel values of the preset pixel;

[0022] determining a sharpened pixel value according to the pixel value of the target sampling point, the target filter value and the sharpening intensity value.

[0023] Optionally, when the preset pixel is 16 pixels, the filter region is a square region.

[0024] Optionally, when the preset pixel is 12 pixels, the filter region is a cross-shaped region.

[0025] Optionally, before the step of determining the coordinates of the target sampling point corresponding to each pixel point on the target image on the original image according to the size of the original image and the size of the target image, the method further comprises:

[0026] obtaining the size of a display area on a display screen of the terminal device;

[0027] determining the size of the target image according to the size of the display area.

[0028] An aspect of an embodiment of the present application further provides an image processing device, comprising:

[0029] a target sampling point coordinate determining module configured to determine the coordinates of the target sampling point corresponding to each pixel point on the target image on the original image according to the size of the original image and the size of the target image;

[0030] a target sampling point pixel value determining module configured to, for each pixel point on the target image, sample a plurality of pixel values of a preset pixel from the original image according to the coordinates of the target sampling point, and determine the pixel value of the target sampling point corresponding to the pixel point according to the plurality of pixel values of the preset pixel;

[0031] a pixel point sharpening processing module configured to sharpen each pixel point on the target image according to the pixel value of the target sampling point to obtain a sharpened pixel value;

[0032] an image rendering module configured to render the target image on a display screen of a terminal device according to the pixel value of the target sampling point and the sharpened pixel value.

[0033] An aspect of an embodiment of the present application further provides a computer device, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the image processing method as described above when executing the computer program.

[0034] An aspect of an embodiment of the present application further provides a computer readable storage medium, which stores a computer program, and the computer program is executable by at least one processor, so that the at least one processor implements the steps of the image processing method as described above when executing the computer program.

[0035] The image processing method, apparatus, device, and computer-readable storage medium provided in this application embodiment achieve integrated operation of resampling and image quality enhancement by sampling the region of the preset pixel closest to the target sampling point and sharpening the pixel value of the target sampling point to enhance image quality. This allows resampling and image quality enhancement to be performed using a single shader, which is simpler than methods that require multiple shaders to be chained together. Moreover, the integration of the resampling algorithm and the image quality enhancement algorithm reduces memory overhead and improves program running efficiency. The image quality enhancement fully utilizes the information in the resampling process to effectively improve image quality. Attached Figure Description

[0036] Figure 1 A schematic diagram of a module for an image enhancement algorithm based on two shaders is shown.

[0037] Figure 2 This diagram schematically illustrates an application environment of an image processing method according to an embodiment of this application.

[0038] Figure 3 A flowchart illustrating an image processing method according to Embodiment 1 of this application is shown schematically;

[0039] Figure 4 A schematic diagram illustrating a 16-pixel sampling method is shown.

[0040] Figure 5 A schematic diagram illustrating a 12-pixel sampling method is shown.

[0041] Figure 6 The diagram illustrates a set of four square filtering regions with 16-pixel sampling.

[0042] Figure 7 A schematic diagram of a 12-pixel sampled four cross-shaped filtering region is shown.

[0043] Figure 8 A schematic diagram of a Gaussian kernel corresponding to a square filtering region is shown.

[0044] Figure 9 A schematic diagram of a Gaussian kernel corresponding to a cross-shaped filtering region is shown.

[0045] Figure 10 This diagram illustrates the horizontal and vertical distances from a target sampling point to its four nearest pixels.

[0046] Figure 11 The diagram illustrates an edge filter kernel corresponding to a square filter region.

[0047] Figure 12A schematic diagram of an edge filter kernel corresponding to a cross-shaped filter region is shown schematically;

[0048] Figure 13 A block diagram of an image processing apparatus according to Embodiment Two of the present application is shown schematically; and

[0049] Figure 14 A hardware architecture schematic diagram of a computer device suitable for implementing the image processing method according to Embodiment Three of the present application is shown schematically. DETAILED DESCRIPTION

[0050] In order to make the objects, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and should not be used to limit the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.

[0051] It should be noted that the description of "first", "second" and the like in the embodiments of the present application is only for the purpose of description and should not be understood as indicating or implying the relative importance of the technical features indicated or the number of the technical features indicated. Therefore, the features with "first", "second" can explicitly or implicitly include at least one of the features. In addition, the technical solutions of each embodiment can be combined with each other, but it must be based on the fact that those of ordinary skill in the art can realize it. When the combination of technical solutions appears contradictory or unachievable, it should be considered that the combination of technical solutions does not exist and is not within the scope of protection claimed by the present application.

[0052] In the prior art, lightweight image processing algorithms can be deployed on mobile phone APPs, PC clients, and web clients through shaders. The advantage is that it can cover most end-side devices and has very low power consumption. Common cross-platform shader back-end environments include OpenGL, WebGL, WebGPU, etc.

[0053] The implementation of picture scaling of a video website generally adopts a hardware-based bilinear interpolation method. The picture scaling is realized by calling the GPU in a software algorithm based on the shader.

[0054] At present, picture scaling (full screen) of a video website is mostly realized by a hardware-based bilinear interpolation method, which is then rendered to the screen. The advantage of this resampling method is that it can be integrated in hardware and has very fast processing speed. The disadvantage is that the effect after resampling is generally poor, resulting in a blurred picture and the disappearance of some texture details.

[0055] In addition, the super-resolution and quality enhancement algorithm based on the shader needs to be realized by two shaders in series, the first shader performs image resampling operation, the resampled image buffer is used as the input of the second shader, and the second shader performs quality enhancement operation and renders to the screen. Figure 1 A module schematic diagram of a quality enhancement algorithm realized based on two shaders is shown. Figure 1 It can be seen that this way needs to configure two shaders, and needs to additionally open a memory space for storing intermediate results.

[0056] Therefore, the present application aims to provide an image processing method, which determines the coordinates of a target sampling point corresponding to each pixel point on a target image on an original image according to the size of the original image and the size of the target image; for each pixel point on the target image, a plurality of pixel values of a preset pixel are sampled from the original image according to the coordinates of the target sampling point, and a pixel value of the target sampling point corresponding to the pixel point is determined according to the plurality of pixel values of the preset pixel; each pixel point on the target image is sharpened according to the pixel value of the target sampling point to obtain a sharpened pixel value; and the target image is rendered on the display screen of a terminal device according to the pixel value of the target sampling point and the sharpened pixel value. By sampling the area of the preset pixel closest to the target sampling point and sharpening according to the pixel value of the target sampling point obtained by sampling to enhance the quality, the integration of resampling and quality enhancement is realized, so that resampling and quality enhancement can be realized by using a single shader, which is simpler than the way of connecting multiple shaders in series. Moreover, the resampling algorithm and the quality enhancement algorithm are integrated, which reduces the memory overhead and improves the running efficiency of the program. The quality enhancement fully utilizes the information in the resampling process to effectively improve the quality.

[0057] The present application provides a plurality of embodiments to further introduce the image processing scheme, which will be described in detail below.

[0058] In the description of the present application, it should be understood that the reference numerals before the steps do not indicate the order of executing the steps, but are only used for the convenience of describing the present application and distinguishing each step, and therefore should not be understood as limiting the present application.

[0059] The following is the explanation of the terms of the present application:

[0060] Shader: a simple program that describes the characteristics of a vertex or a pixel. Vertex shaders describe the attributes of a vertex (position, texture coordinates, color, etc.), while pixel shaders describe the characteristics of a pixel (color, z-depth, and alpha value).

[0061] Image resampling: This refers to the process of enlarging or reducing an image using a sampling method. Common sampling methods include nearest neighbor difference, bilinear interpolation, and bicubic interpolation. In this invention, super-resolution refers to image resampling with the enlargement function.

[0062] Image quality enhancement: Improves image quality and enhances visual experience through super-resolution, noise reduction, deblurring, sharpening, brightness adjustment, and color adjustment.

[0063] USM: UnSharp Masking sharpening algorithm, which extracts high-frequency information from the original image and superimposes it onto the original image to enhance the details and edges of the original image.

[0064] Figure 1 A schematic diagram illustrating an environmental application according to an embodiment of this application is provided. Figure 1 As shown:

[0065] Computer device 10000 can connect to client 30000 via network 20000.

[0066] Computer device 10000 can provide services such as network debugging or returning image processing results to client 30000.

[0067] Computer equipment 10000 may be located in a data center, such as a single site, or distributed across different geographical locations (e.g., multiple sites). Computer equipment 10000 may provide services via one or more networks 20000. Network 20000 includes various network devices, such as routers, switches, multiplexers, hubs, modems, bridges, repeaters, firewalls, agent devices, and / or similar devices. Network 20000 may include physical links, such as coaxial cable links, twisted-pair cable links, fiber optic links, combinations thereof, etc. Network 20000 may include wireless links, such as cellular links, satellite links, Wi-Fi links, etc.

[0068] Computer device 10000 can be implemented by one or more compute nodes. One or more compute nodes can include virtualized compute instances. Virtualized compute instances can include virtual machines, such as emulations of computer systems, operating systems, servers, etc. Compute nodes can load virtual machines based on virtual images and / or other data defining specific software used for emulation (e.g., operating systems, dedicated applications, servers). As the demand for different types of processing services changes, different virtual machines can be loaded and / or terminated on one or more compute nodes. A hypervisor can be implemented to manage the use of different virtual machines on the same compute node.

[0069] The client 30000 can be configured to access content and services of the computer device 10000. The client 30000 can include any type of electronic device, such as a mobile device, a tablet device, a laptop computer, a workstation, a virtual reality device, a gaming device, a set-top box, a digital streaming media device, a vehicle terminal, a smart television, a set-top box, etc.

[0070] The client 30000 can output (e.g., display, render, present) image processing result data, etc. to a user.

[0071] The network debugging scheme will be introduced below through multiple embodiments. The scheme can be implemented by the computer device 10000.

[0072] Embodiment One

[0073] Figure 3 A flowchart of an image processing method according to Embodiment One of the present application is schematically shown. It includes steps S302-S308, wherein,

[0074] In step S302, coordinates of a target sampling point corresponding to each pixel point on a target image on an original image are determined according to a size of the original image and a size of the target image.

[0075] In the display process of an image, an original image is transmitted into a pixel shader in the form of a 2D texture, and the value of each pixel point rendered onto a screen is calculated according to the local information of the 2D texture to complete the display of the image. In this embodiment, the original image is referred to as an original image, and the image rendered onto the screen is referred to as a target image.

[0076] Since the size of the original image and the size of the rendered target image are not necessarily the same, the coordinates mapped onto the original image can not be integers, which are referred to as sub-pixel coordinates, i.e., the coordinates of the target sampling point. In this embodiment, let the coordinates of the target sampling point be (u, v), which satisfy the following formula:

[0077]

[0078]

[0079] wherein W s represents the width of the original image, H s represents the height of the original image, W d represents the width of the target image, H d represents the height of the target image, (x d , y d ) is the coordinates of a pixel point on the target image, and (u, v) is the coordinates of the pixel point on the target image mapped onto the original image, i.e., the coordinates of the target sampling point.

[0080] In a preferred embodiment of the present application, before the step S202, the method can further comprise the following steps:

[0081] Obtaining the size of the display area on the display screen of the terminal device; determining the size of the target image according to the size of the display area.

[0082] In the present embodiment, the size of the display area is different, and the size of the target image for display is also different. The size of the target image for display is determined according to the size of the display area by obtaining the size of the display area on the display screen of the terminal device.

[0083] In the step S304, for each pixel point on the target image, a plurality of pixel values of a preset pixel are sampled from the original image according to the coordinates of the target sampling point, and the pixel value of the target sampling point corresponding to the pixel point is determined according to the plurality of pixel values of the preset pixel.

[0084] In the present embodiment, the preset pixel is a sampling area within a certain range size, for example, the preset pixel is 12 pixels, and the 12 pixel coordinates closest to the target sampling point need to be sampled; the preset pixel is 16 pixels, and the 16 pixel coordinates closest to the target sampling point need to be sampled. It should be noted that the calculation amount of 12 pixel coordinates is less than that of 16 pixel coordinates, and the hardware calculation power is freely selected in the actual application process, and the present embodiment does not make specific limitation thereto.

[0085] As an example, as shown in Figure 4 As a 16-pixel sampling schematic diagram, Figure 5 As a 12-pixel sampling schematic diagram, wherein * represents the target sampling point, and the target sampling point is within the dashed box.

[0086] In a preferred embodiment of the present application, the step S304 can comprise the following steps:

[0087] Determining the weight value of each pixel point in the preset pixel relative to the target sampling point; and performing weighted processing on the plurality of pixel values of the preset pixel according to the weight value, to obtain the pixel value of the target sampling point corresponding to the pixel point.

[0088] Since the distance between each pixel point of the sampling and the target sampling point is different, in the present embodiment, the corresponding weight value of each pixel point of the sampling can be calculated, and then the pixel value of the target sampling point corresponding to the pixel point on the target image is calculated according to the weight value.

[0089] In a specific implementation, the horizontal weight and the vertical weight of each pixel point relative to the target sampling point are calculated, and then the color value of the target sampling point is calculated, and the calculation formula is as follows:

[0090]

[0091]

[0092]

[0093] wherein, is the horizontal weight of the i-th pixel point relative to the target sampling point, is the vertical weight of the i-th pixel point relative to the target sampling point, x i is the horizontal coordinate of the i-th pixel point, y i is the vertical coordinate of the i-th pixel point, u is the horizontal coordinate of the target sampling point, and v is the vertical coordinate of the target sampling point, C (u,v) is the color value of the target sampling point, is the color value of the i-th pixel point, and n is 16 or 12.

[0094] In step S306, each pixel point on the target image is sharpened according to the pixel value of the target sampling point, and the pixel value of the sharpened pixel point is obtained.

[0095] After the original image is resampled, the image quality enhancement processing can be further performed to improve the display effect of the image. In a specific implementation, the pixels of the target image are sharpened to achieve the effect of image quality enhancement.

[0096] In this embodiment, the pixels of the target image can be sharpened from the same sampling space, i.e., 16-pixel sampling or 12-pixel sampling. The sharpening operation is based on the USM algorithm, which requires Gaussian filtering operation on the target pixel and its surrounding pixels. However, in this embodiment, the pixel value of each pixel point on the target image is calculated by 16-pixel sampling or 12-pixel sampling, and the surrounding pixels cannot be obtained by the same 16-pixel sampling or 12-pixel sampling. In this embodiment, for each pixel point on the target image, the 16-pixel sampling or 12-pixel sampling is divided into multiple filtering regions (such as four filtering regions), the Gaussian filtering result of each region is calculated according to the pixel value of the target sampling point corresponding to each pixel point, and the four Gaussian filtering results are weighted and summed by using the weight of bilinear interpolation, to obtain the filtering result of each pixel point on the target image, and then the sharpened pixel value of the pixel point is calculated based on the filtering result.

[0097] Step S308, according to the pixel value of each pixel point on the target image and the sharpened pixel value, rendering the target image on the display screen of the terminal device.

[0098] In this embodiment, after calculating the pixel value of each pixel point on the target image and the sharpened pixel value, the target image can be rendered on the display screen of the terminal device to present a video picture with the effects of picture zooming in or out and picture quality enhancement on the display screen.

[0099] In a specific implementation, before rendering the target image, chroma enhancement processing can also be performed according to the pixel value of the target sampling point and the sharpened pixel value to further improve the picture quality of the image. The chroma processing algorithm in the prior art can be used for processing, which is not described here in detail.

[0100] The following provides several optional embodiments to optimize the image processing method, as follows:

[0101] In a preferred embodiment of the present application, the step S306 can include the following steps:

[0102] A plurality of filter regions are determined from the preset pixels, and a Gaussian filter value corresponding to each of the filter regions is determined. A target filter value is determined according to the Gaussian filter value corresponding to each of the filter regions. A sharpened pixel value is determined according to the pixel value of the target sampling point and the target filter value.

[0103] In this embodiment, by dividing the sampled preset pixel region into a plurality of filter regions, such as four filter regions, a Gaussian filter value corresponding to each filter region is calculated, and the sharpened pixel value is preferably calculated according to the pixel value of the target sampling point and the target filter value.

[0104] When the preset pixel is 16 pixels, the divided filter region is a square region, such as Figure 6 A schematic diagram of four square filter regions of 16-pixel sampling is shown. When the preset pixel is 12 pixels, the divided filter region is a cross-shaped region, such as Figure 7 A schematic diagram of four cross-shaped filter regions of 12-pixel sampling is shown.

[0105] In a specific implementation, for each filter region, a Gaussian filter value corresponding to the filter region is calculated according to the preset Gaussian kernel of the filter region. As an example, a schematic diagram of a Gaussian kernel corresponding to a square filter region is shown, such as Figure 8 A schematic diagram of a Gaussian kernel corresponding to a square filter region is shown, such as Figure 9 A schematic diagram of a Gaussian kernel corresponding to a cross-shaped filter region is shown.

[0106] In the embodiment, the Gaussian filtering value satisfies the following formula:

[0107]

[0108] wherein, patch i is a pixel value of the i-th square or cross-shaped region, kernel is a Gaussian kernel corresponding to the square or cross-shaped region, is an element point multiplication, is a summation of all elements, Gauss i is the Gaussian filtering value of the i-th square or cross-shaped region.

[0109] In a preferred embodiment of the present application, the target filtering value is determined according to the Gaussian filtering value corresponding to each filtering region, comprising:

[0110] determining a weight value corresponding to each filtering region based on a preset bilinear interpolation algorithm; and determining the target filtering value according to the weight value corresponding to each filtering region and the Gaussian filtering value.

[0111] Since the target sampling point can be different from the distance of each filtering region, the influence degree of the Gaussian filtering value corresponding to each filtering region on the target sampling point is different, and the Gaussian filtering values cannot be simply averaged. The embodiment can calculate the final filtering value corresponding to the target sampling point by using the bilinear interpolation method. The preset bilinear interpolation algorithm is a pre-set algorithm model,

[0112] As Figure 10 shows a schematic diagram of the vertical and horizontal distances of a target sampling point to the nearest four pixels. The top vertices of the dashed box are the nearest four pixel points to the target sampling point, and the four pixel points also represent the center points of the four filtering regions, respectively. (x0, y0) is the coordinate of the top-left pixel point, which is also the center point of the top-left filtering region. In a specific implementation, according to the calculation method of the bilinear interpolation, the weight corresponding to the top-left filtering region is Figure 10 the area of the first region in FIG. 1, the weight corresponding to the top-right filtering region is Figure 10 the area of the second region in FIG. 1, the weight corresponding to the bottom-left filtering region is Figure 10 the area of the third region in FIG. 1, and the weight corresponding to the bottom-right filtering region is Figure 10 the area of the fourth region in FIG. 1. The weights of the four filtering regions are expressed by the following formula,

[0113] W1 = (1-u+x0)*(1-v+y0)

[0114] W2 = (u-x0)*(1-v+y0)

[0115] W3 = (1-u+x0)*(v-y0)

[0116] W4 = (u - x0) * (v - y0)

[0117] After calculating the weight value for each filtering region separately, the final filtered value C of the target sampling point is calculated by weighted summation using the following formula. blur :

[0118]

[0119] Among them, W i G represents the weight value of the i-th filtering region. i Let i be the filtered value for the i-th filtering region.

[0120] In a preferred embodiment of this application, determining the sharpened pixel value based on the pixel value of the target sampling point and the target filtered value includes the following steps:

[0121] The sharpening intensity value corresponding to each filtering region is determined based on multiple pixel values ​​of the preset pixel; the sharpened pixel value is determined based on the pixel value of the target sampling point, the target filtering value, and the sharpening intensity value.

[0122] In this embodiment, after calculating the pixel value of the target sampling point and the target filter value, the final sharpened pixel value can be calculated based on a preset USM algorithm. Specifically, let the sharpened pixel value be C. s Then C s Satisfy the following formula:

[0123] C s =C (u,v) +k*(C (u,v) -C blur )

[0124] Among them, C (u,v) C represents the pixel value of the target sampling point. blur is the target filter value, and k is a coefficient that controls the sharpening intensity.

[0125] In this embodiment, the value of k is adaptive and related to the edge gradient of the target sampling point. For each filtering region, the edge filter value corresponding to that filtering region is calculated based on the preset edge filter kernel of that region. As an example, such as... Figure 11 A schematic diagram of an edge filter kernel corresponding to a square filter region is shown, wherein G x G represents the horizontal edge filter kernel of the square filter region. y This represents the vertical edge filter kernel of a square filter region. For example... Figure 12 A schematic diagram of an edge filter kernel corresponding to a cross-shaped filter region is shown, wherein G x G represents the lateral edge filter kernel of the cross-shaped filter region.y a vertical edge filter kernel representing a cross-shaped filter region.

[0126] For a square region or a cross-shaped region, the approximate gradient value GradX i of the horizontal edge and the approximate gradient GradY i of the vertical edge of the target sampling point can be obtained by element-wise multiplication of the corresponding edge filter kernel and summation, and the specific calculation formula is as follows:

[0127] GradX i =∑gray i ⊙G x

[0128] GradY i =∑gray i ⊙G y

[0129] wherein gray i represents the normalized gray value of the i-th square region or cross-shaped region, that is, the numerical value of each pixel of the square region or cross-shaped region in RGB or other color representation form is converted into a gray value, and the value range is scaled to 0 to 1.

[0130] After obtaining the approximate gradient of the horizontal and vertical edges of the target sampling point, the intensity of the edge gradient can be further calculated by the following formula:

[0131]

[0132] wherein Grad i represents the intensity of the edge gradient of the i-th square region or cross-shaped region, the maxValue of the square region is 20, and the maxValue of the cross-shaped region is 2.

[0133] Further, the sharpening intensity coefficient corresponding to each filter region can be calculated according to Grad i , and the specific calculation formula can be represented as follows:

[0134] k i =2.0-Grad i

[0135] wherein k i is the sharpening intensity coefficient of the i-th square region or cross-shaped region.

[0136] Finally, the final sharpening intensity coefficient of the target sampling point can be obtained by bilinear interpolation, and the weight of the corresponding four filter regions can reuse the weight value W iSpecifically, the calculation formula of the sharpening intensity value k corresponding to the filtering region is as follows:

[0137]

[0138] wherein, W i is the weight value of the i th filtering region, k i is the sharpening intensity coefficient of the i th square region or cross region.

[0139] In a specific implementation, when the edge intensity of the target sampling point becomes larger, the value of k becomes smaller, and the sharpening intensity of the target sampling point becomes lower, thereby preventing the picture from being distorted due to over-sharpening of the edge. The target sampling point after sharpening also needs to be subjected to value restriction to limit the color range. A commonly used limiting method is numerical truncation, that is, a value smaller than a preset value range takes the minimum value in the range, and a value larger than the value range takes the maximum value in the range.

[0140] Embodiment Two

[0141] Figure 13 A block diagram of an image processing apparatus according to Embodiment Two of the present application is schematically shown, which can be divided into one or more program modules, the one or more program modules are stored in a storage medium and executed by one or more processors to complete the embodiments of the present application. The program module referred to in the embodiments of the present application refers to a series of computer program instruction segments capable of completing a specific function, and the functions of the program modules in the embodiments of the present application will be specifically described below.

[0142] As Figure 14 shown, the image processing apparatus 1300 can include the following modules:

[0143] A target sampling point coordinate determination module 1301 is configured to determine, according to the size of an original image and the size of a target image, the coordinates of a target sampling point corresponding to each pixel point on the target image in the original image.

[0144] A target sampling point pixel value determination module 1302 is configured to, for each pixel point on the target image, sample a plurality of pixel values of a preset pixel from the original image according to the coordinates of the target sampling point, and determine the pixel value of the target sampling point corresponding to the pixel point according to the plurality of pixel values of the preset pixel.

[0145] A pixel point sharpening processing module 1303 is configured to sharpen each pixel point on the target image according to the pixel value of the target sampling point to obtain a sharpened pixel value.

[0146] An image rendering module 1304 is configured to render the target image on a display screen of a terminal device according to the pixel value of the target sampling point and the sharpened pixel value.

[0147] In an embodiment of the present application, the pixel value determination module 1302 comprises:

[0148] a weight value determination sub-module, configured to determine a weight value of each pixel point in the preset pixel relative to the target sampling point;

[0149] a pixel value determination sub-module, configured to perform weighted processing on the pixel values of the preset pixel according to the weight value, to obtain the pixel value of the target sampling point corresponding to the pixel point.

[0150] In an embodiment of the present application, the pixel sharpening processing module 1303 comprises:

[0151] a Gaussian filter value determination sub-module, configured to determine a plurality of filter regions from the preset pixel, and determine a Gaussian filter value corresponding to each filter region;

[0152] a target filter value determination sub-module, configured to determine a target filter value according to the Gaussian filter value corresponding to each filter region;

[0153] a sharpened pixel value determination sub-module, configured to determine a sharpened pixel value according to the pixel value of the target sampling point and the target filter value.

[0154] In an embodiment of the present application, the target filter value determination sub-module comprises:

[0155] a weight value determination unit, configured to determine a weight value corresponding to each filter region based on a preset bilinear interpolation algorithm;

[0156] a target filter value determination unit, configured to determine a target filter value according to the weight value corresponding to each filter region and the Gaussian filter value.

[0157] In an embodiment of the present application, the sharpened pixel value determination sub-module comprises:

[0158] a sharpening intensity value determination unit, configured to determine a sharpening intensity value corresponding to each filter region according to the pixel values of the preset pixel;

[0159] a sharpened pixel value determination unit, configured to determine a sharpened pixel value according to the pixel value of the target sampling point, the target filter value and the sharpening intensity value.

[0160] In an embodiment of the present application, when the preset pixel is 16 pixels, the filter region is a square region.

[0161] In a preferred embodiment of the present application, when the preset pixel is 12 pixels, the filtering region is a cross-shaped region.

[0162] In a preferred embodiment of the present application, the device further comprises:

[0163] a display region size obtaining module, configured to obtain a size of a display region on a display screen of the terminal device;

[0164] a target image size determining module, configured to determine a size of a target image according to the size of the display region.

[0165] Embodiment Three

[0166] Figure 14 A hardware architecture schematic diagram of a computer device 10000 suitable for implementing the image processing method according to Embodiment Three of the present application is schematically shown. In this embodiment, the computer device 10000 is a device capable of automatically performing numerical calculation and / or information processing according to pre-set or stored instructions. For example, it can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a rack-mounted server, a blade server, a tower server or a cabinet server (including a FEN independent server or a server cluster composed of multiple servers), etc. As shown in the figure, the computer device 10000 at least includes but is not limited to a memory 10010, a processor 10020 and a network interface 10030 which are communicatively linked through a system bus. Among them: Figure 14

[0167] ​The memory 10010 includes at least one type of computer-readable storage media, such as a flash memory, a hard disk, a multimedia card micro (e.g., SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, and the like. In some embodiments, the memory 10010 can be an internal memory module of the computer device 10000, such as a hard disk or a memory of the computer device 10000. In other embodiments, the memory 10010 can also be an external memory device of the computer device 10000, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, and the like. Of course, the memory 10010 can include both an internal memory module and an external memory device of the computer device 10000. In this embodiment, the memory 10010 is generally used to store an operating system and various application programs installed in the computer device 10000, such as program codes of an image processing method, and the like. In addition, the memory 10010 can also be used to temporarily store various data that have been output or will be output.

[0168] The processor 10020 can be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip in some embodiments. The processor 10020 is generally used to control the overall operation of the computer device 10000, such as performing control and processing related to data interaction or communication of the computer device 10000, and the like. In this embodiment, the processor 10020 is used to run program codes or process data stored in the memory 10010.

[0169] The network interface 10030 can include a wireless network interface or a wired network interface, and is generally used to establish a communication link between the computer device 10000 and other computer devices. For example, the network interface 10030 is used to connect the computer device 10000 with an external terminal through a network, to establish a data transmission channel and a communication link between the computer device 10000 and the external terminal, and the like. The network can be an Intranet, the Internet, a Global System of Mobile communication (GSM), a Wideband Code Division Multiple Access (WCDMA), a 4G network, a 5G network, Bluetooth, Wi-Fi, or other wireless or wired networks.

[0170] It should be noted that, ​ Only the computer device with the components 10010-10030 is shown, but it should be understood that all the shown components are not required to be implemented, and more or fewer components can be alternatively implemented.

[0171] In this embodiment, the image processing method stored in the memory 10010 can also be divided into one or more program modules, and executed by one or more processors (in this embodiment, the processor 10020) to complete the image processing method in the embodiments of the present application.

[0172] Embodiment Four

[0173] The embodiments of the present application also provide a computer readable storage medium, and the computer readable storage medium has a computer program stored thereon. The computer program is executed by a processor to implement the steps of the image processing method in the embodiments.

[0174] In this embodiment, the computer readable storage medium includes a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the computer readable storage medium can be an internal storage unit of the computer device, such as a hard disk or a memory of the computer device. In other embodiments, the computer readable storage medium can also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device. Of course, the computer readable storage medium can also include both the internal storage unit and the external storage device of the computer device. In this embodiment, the computer readable storage medium is usually used to store an operating system and various application software installed on the computer device, such as program codes of the image processing method in the embodiments, etc. In addition, the computer readable storage medium can also be used to temporarily store various data that have been output or will be output.

[0175] Obviously, those skilled in the art should understand that each module or each step of the above-mentioned embodiments of the present application can be realized by a general computing device, which can be concentrated on a single computing device or distributed on a network composed of multiple computing devices, and optionally, each module or each step can be realized by program codes executable by a computing device, so that each module or each step can be stored in a storage device and executed by a computing device, and in some cases, the steps shown or described can be executed in different order, or each module or each step can be manufactured into an individual integrated circuit module, or multiple modules or steps can be manufactured into a single integrated circuit module. Therefore, the embodiments of the present application are not limited to any specific combination of hardware and software.

[0176] The above is only the preferred embodiment of the present application, and does not limit the patent scope of the present application, and any equivalent structure or equivalent process transformation using the content of the specification and drawings of the present application, or direct or indirect application in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. An image processing method, characterized by, The method comprises the following steps: determining the coordinates of the target sampling point corresponding to each pixel point on the target image on the original image according to the size of the original image and the size of the target image; for each pixel point on the target image, obtaining a plurality of pixel values of a preset pixel by sampling from the original image according to the coordinates of the target sampling point, and determining the pixel value of the target sampling point corresponding to the pixel point according to the plurality of pixel values of the preset pixel; performing sharpening processing on each pixel point on the target image according to the pixel value of the target sampling point to obtain a sharpened pixel value; rendering the target image on the display screen of the terminal device according to the pixel value of the target sampling point and the sharpened pixel value; the step of performing sharpening processing on each pixel point on the target image according to the pixel value of the target sampling point to obtain a sharpened pixel value comprises the following steps: determining a plurality of filter regions from the preset pixel, and determining a Gaussian filter value corresponding to each filter region; 2. The image processing method of claim 1, wherein, determining a target filter value according to the Gaussian filter value corresponding to each filter region; and determining a sharpened pixel value according to the pixel value of the target sampling point and the target filter value. the step of determining the pixel value of the target sampling point corresponding to the pixel point according to the plurality of pixel values of the preset pixel comprises the following steps: determining a weight value of each pixel point in the preset pixel relative to the target sampling point; 3. The image processing method of claim 1, wherein, performing weighted processing on the plurality of pixel values of the preset pixel according to the weight value to obtain the pixel value of the target sampling point corresponding to the pixel point. the step of determining a target filter value according to the Gaussian filter value corresponding to each filter region comprises the following steps: determining a weight value corresponding to each filter region based on a preset bilinear interpolation algorithm; 4. The image processing method of claim 1, wherein, determining a target filter value according to the weight value corresponding to each filter region and the Gaussian filter value. the step of determining a sharpened pixel value according to the pixel value of the target sampling point and the target filter value comprises the following steps: determining a sharpening intensity value corresponding to each filter region according to the plurality of pixel values of the preset pixel; 5. The image processing method of claim 1, wherein, determining a sharpened pixel value according to the pixel value of the target sampling point, the target filter value and the sharpening intensity value.

6. The image processing method of claim 1, wherein, when the preset pixel is 16 pixels, the filter region is a square region.

7. The image processing method of claim 1, wherein, when the preset pixel is 12 pixels, the filter region is a cross-shaped region. before the step of determining the coordinates of the target sampling point corresponding to each pixel point on the target image on the original image according to the size of the original image and the size of the target image, the method further comprises the following steps: obtaining the size of a display region on the display screen of the terminal device; 8. An image processing apparatus characterized by comprising: determining the size of the target image according to the size of the display region. The device comprises: a target sampling point coordinate determination module configured to determine the coordinates of the target sampling point corresponding to each pixel point on the target image on the original image according to the size of the original image and the size of the target image. The pixel value determination module is configured to, for each pixel point on the target image, sample a plurality of pixel values of a preset pixel from the original image according to the coordinates of the target sampling point, and determine a pixel value of the target sampling point corresponding to the pixel point according to the plurality of pixel values of the preset pixel. The pixel point sharpening processing module is configured to perform sharpening processing on each pixel point on the target image according to the pixel value of the target sampling point, to obtain a sharpened pixel value. The image rendering module is configured to render the target image on a display screen of a terminal device according to the pixel value of the target sampling point and the sharpened pixel value. The pixel value determination module is configured to, for each pixel point on the target image, sample a plurality of pixel values of a preset pixel from the original image according to the coordinates of the target sampling point, and determine a pixel value of the target sampling point corresponding to the pixel point according to the plurality of pixel values of the preset pixel. The pixel value determination module is configured to, for each pixel point on the target image, sample a plurality of pixel values of a preset pixel from the original image according to the coordinates of the target sampling point, and determine a pixel value of the target sampling point corresponding to the pixel point according to the plurality of pixel values of the preset pixel.

9. A computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor, when executing the computer program, is configured to implement the steps of the image processing method in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executable by at least one processor to enable the at least one processor to perform the steps of the image processing method in any one of claims 1 to 7.

11. A computer program product, characterised in that, The computer program is executable by at least one processor to enable the at least one processor to perform the steps of the image processing method in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Industrial camera image sharpening method, device and equipment and storage medium

    CN115311242A