CN-122023209-A - Image processing method, apparatus, device, storage medium, and computer program product
Abstract
The application discloses an image processing method, an image processing device, image processing equipment, a storage medium and a computer program product, and belongs to the technical field of image processing. The method comprises the steps of mapping a target pixel point in a target image to an original image to obtain coordinates of a target mapping point, determining a plurality of reference pixel points from the original image based on the coordinates of the target mapping point, determining edge strength of the target pixel point based on gray values of the plurality of reference pixel points, determining weights corresponding to the plurality of reference pixel points based on the edge strength of the target pixel point and distances between the plurality of reference pixel points and the target mapping point, and determining pixel values of the target pixel point based on pixel values of the plurality of reference pixel points and the weights corresponding to the plurality of reference pixel points. Because the edge intensity can well distinguish the image edge and noise, the weight of each reference pixel point is adjusted by adding the edge intensity of the target pixel point, so that the image noise can be reduced, the image edge can be enhanced, and the contrast of the image can be improved.
Inventors
- LIU ZHANHUA
- CAO HAIWEN
- Liang Shansuo
- GUO NIAN
- YU LINYU
- MA ZHONGKE
- CAO ZILONG
Assignees
- 华为技术有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20250912
Claims (20)
- 1. An image processing method, the method comprising: mapping target pixel points in the target image to the original image to obtain coordinates of target mapping points; Determining a plurality of reference pixel points from the original image based on coordinates of the target mapping points; Determining an edge intensity of the target pixel point based on gray values of the plurality of reference pixel points, the edge intensity indicating a significant degree of brightness variation of the target pixel point; Determining weights corresponding to the plurality of reference pixel points respectively based on the edge intensity of the target pixel point and the distances between the plurality of reference pixel points and the target mapping point respectively; And determining the pixel value of the target pixel point based on the pixel values of the plurality of reference pixel points and weights respectively corresponding to the plurality of reference pixel points.
- 2. The method of claim 1, wherein mapping the target pixel point in the target image to the original image to obtain coordinates of the target mapped point comprises: acquiring a scaling ratio between the target image and the original image; Determining initial coordinates of the target mapping points based on the coordinates of the target pixel points and the scaling; And adjusting the initial coordinates of the target mapping points based on the scaling to obtain the coordinates of the target mapping points.
- 3. The method of claim 2, wherein the scaling comprises a lateral scaling and a longitudinal scaling, the initial coordinates comprising lateral initial coordinates and longitudinal initial coordinates; the adjusting the initial coordinates of the target mapping point based on the scaling includes: determining a lateral offset based on the lateral scaling, and adjusting the lateral initial coordinate based on the lateral offset; and determining a longitudinal offset based on the longitudinal scaling, and adjusting the longitudinal initial coordinate based on the longitudinal offset.
- 4. The method of claim 1, wherein the determining the edge intensity of the target pixel based on the gray values of the plurality of reference pixels comprises: determining a reference pixel point adjacent to the target mapping point from the plurality of reference pixel points to obtain at least one first pixel point; For each first pixel point in the at least one first pixel point, determining the edge intensity of the first pixel point based on the gray value of the first pixel point and the gray value of a reference pixel point adjacent to the first pixel point in the plurality of reference pixel points; And determining the edge intensity of the target pixel point based on the sharpening adjustment parameter and the edge intensity of the at least one first pixel point.
- 5. The method of claim 4, wherein the determining the edge intensity of the first pixel based on the gray value of the first pixel and the gray values of reference pixels of the plurality of reference pixels that are adjacent to the first pixel comprises: Determining a lateral gradient component of the first pixel point based on the gray value of the first pixel point and the gray values of two reference pixel points adjacent to the first pixel point in the lateral direction in the plurality of reference pixel points; Determining a longitudinal gradient component of the first pixel point based on the gray value of the first pixel point and the gray values of two reference pixel points adjacent to the first pixel point in the longitudinal direction in the plurality of reference pixel points; And determining the edge strength of the first pixel point based on the transverse gradient component and the longitudinal gradient component of the first pixel point.
- 6. The method of claim 5, wherein the determining the lateral gradient component of the first pixel based on the gray value of the first pixel and gray values of two reference pixels of the plurality of reference pixels that are laterally adjacent to the first pixel comprises: Determining a first gradient through a gradient function based on the difference between the gray value of a first adjacent pixel point and the gray value of the first pixel point, wherein the first adjacent pixel point is a reference pixel point adjacent to the first pixel point in the transverse direction, and the gradient function is an odd function; Determining a second gradient through the gradient function based on the difference between the gray value of the first pixel point and the gray value of a second adjacent pixel point, wherein the second adjacent pixel point is another reference pixel point which is adjacent to the first pixel point in the transverse direction; A lateral gradient component of the first pixel point is determined based on a sum of the first gradient and the second gradient.
- 7. The method of claim 5 or 6, wherein the determining the longitudinal gradient component of the first pixel based on the gray value of the first pixel and gray values of two reference pixels of the plurality of reference pixels that are longitudinally adjacent to the first pixel comprises: determining a third gradient through a gradient function based on the difference between the gray value of a third adjacent pixel point and the gray value of the first pixel point, wherein the third adjacent pixel point is a reference pixel point longitudinally adjacent to the first pixel point, and the gradient function is an odd function; determining a fourth gradient through the gradient function based on the difference between the gray value of the first pixel point and the gray value of a fourth adjacent pixel point, wherein the fourth adjacent pixel point is another reference pixel point longitudinally adjacent to the first pixel point; a longitudinal gradient component of the first pixel point is determined based on a sum of the third gradient and the fourth gradient.
- 8. The method of claim 1, wherein before determining weights for the plurality of reference pixels based on the edge intensities of the target pixel and the distances between the plurality of reference pixels and the target mapping point, respectively, the method further comprises: Determining an edge gradient direction of the target pixel point, wherein the edge gradient direction indicates a brightness change direction of the target pixel point; And correcting the distances between the plurality of reference pixel points and the target mapping point respectively based on the edge gradient direction of the target pixel point.
- 9. The method of claim 8, wherein the correcting the distances between the plurality of reference pixels and the target mapping point, respectively, based on the edge gradient direction of the target pixel comprises: According to the edge gradient direction of the target pixel point, rotating the coordinate system where the plurality of reference pixel points are located to obtain the rotated relative coordinates between the plurality of reference pixel points and the target mapping point respectively; According to the edge gradient direction of the target pixel point and the edge intensity of the target pixel point, scaling the rotated coordinate system to obtain scaled relative coordinates between the plurality of reference pixel points and the target mapping point respectively; And determining corrected distances between the plurality of reference pixel points and the target mapping point respectively based on scaled relative coordinates between the plurality of reference pixel points and the target mapping point respectively.
- 10. The method of claim 8 or 9, wherein the determining the edge gradient direction of the target pixel point comprises: And determining the edge gradient direction of the target pixel point based on the transverse gradient component and the longitudinal gradient component of at least one first pixel point, wherein the at least one first pixel point is a reference pixel point adjacent to the target mapping point in the plurality of reference pixel points.
- 11. An image processing apparatus, characterized in that the apparatus comprises: The pixel mapping module is used for mapping the target pixel point in the target image to the original image to obtain the coordinate of the target mapping point; A reference pixel determining module, configured to determine a plurality of reference pixel points from the original image based on coordinates of the target mapping point; An edge intensity determination module, configured to determine an edge intensity of the target pixel point based on gray values of the plurality of reference pixel points, where the edge intensity indicates a significant degree of brightness variation of the target pixel point; The weight determining module is used for determining weights corresponding to the plurality of reference pixel points respectively based on the edge intensity of the target pixel point and the distances between the plurality of reference pixel points and the target mapping point respectively; And the pixel value determining module is used for determining the pixel value of the target pixel point based on the pixel values of the plurality of reference pixel points and the weights respectively corresponding to the plurality of reference pixel points.
- 12. The apparatus of claim 11, wherein the pixel mapping module comprises: A scaling acquiring sub-module, configured to acquire a scaling between the target image and the original image; an initial coordinate determining sub-module, configured to determine an initial coordinate of the target mapping point based on the coordinate of the target pixel point and the scaling; and the coordinate adjustment sub-module is used for adjusting the initial coordinates of the target mapping points based on the scaling to obtain the coordinates of the target mapping points.
- 13. The apparatus of claim 12, wherein the scaling comprises a lateral scaling and a longitudinal scaling, the initial coordinates comprising lateral initial coordinates and longitudinal initial coordinates; The coordinate adjustment submodule is specifically used for: determining a lateral offset based on the lateral scaling, and adjusting the lateral initial coordinate based on the lateral offset; and determining a longitudinal offset based on the longitudinal scaling, and adjusting the longitudinal initial coordinate based on the longitudinal offset.
- 14. The apparatus of claim 11, wherein the edge strength determination module comprises: An adjacent pixel determining sub-module, configured to determine a reference pixel point adjacent to the target mapping point from the plurality of reference pixel points, and obtain at least one first pixel point; a first edge intensity determining sub-module configured to determine, for each first pixel point of the at least one first pixel point, an edge intensity of the first pixel point based on a gray value of the first pixel point and a gray value of a reference pixel point adjacent to the first pixel point among the plurality of reference pixel points; and the second edge intensity determining submodule is used for determining the edge intensity of the target pixel point based on the sharpening adjustment parameter and the edge intensity of the at least one first pixel point.
- 15. The apparatus of claim 14, wherein the first edge strength determination submodule is specifically configured to: Determining a lateral gradient component of the first pixel point based on the gray value of the first pixel point and the gray values of two reference pixel points adjacent to the first pixel point in the lateral direction in the plurality of reference pixel points; Determining a longitudinal gradient component of the first pixel point based on the gray value of the first pixel point and the gray values of two reference pixel points adjacent to the first pixel point in the longitudinal direction in the plurality of reference pixel points; And determining the edge strength of the first pixel point based on the transverse gradient component and the longitudinal gradient component of the first pixel point.
- 16. The apparatus of claim 15, wherein the first edge strength determination submodule is specifically configured to: Determining a first gradient through a gradient function based on the difference between the gray value of a first adjacent pixel point and the gray value of the first pixel point, wherein the first adjacent pixel point is a reference pixel point adjacent to the first pixel point in the transverse direction, and the gradient function is an odd function; Determining a second gradient through the gradient function based on the difference between the gray value of the first pixel point and the gray value of a second adjacent pixel point, wherein the second adjacent pixel point is another reference pixel point which is adjacent to the first pixel point in the transverse direction; A lateral gradient component of the first pixel point is determined based on a sum of the first gradient and the second gradient.
- 17. The apparatus according to claim 15 or 16, wherein the first edge strength determination submodule is specifically configured to: determining a third gradient through a gradient function based on the difference between the gray value of a third adjacent pixel point and the gray value of the first pixel point, wherein the third adjacent pixel point is a reference pixel point longitudinally adjacent to the first pixel point, and the gradient function is an odd function; determining a fourth gradient through the gradient function based on the difference between the gray value of the first pixel point and the gray value of a fourth adjacent pixel point, wherein the fourth adjacent pixel point is another reference pixel point longitudinally adjacent to the first pixel point; a longitudinal gradient component of the first pixel point is determined based on a sum of the third gradient and the fourth gradient.
- 18. The apparatus of claim 11, wherein the apparatus further comprises: the gradient direction determining module is used for determining an edge gradient direction of the target pixel point, wherein the edge gradient direction indicates the brightness change direction of the target pixel point; And the distance correction module is used for correcting the distances between the plurality of reference pixel points and the target mapping point respectively based on the edge gradient direction of the target pixel point.
- 19. The apparatus of claim 18, wherein the distance correction module is specifically configured to: According to the edge gradient direction of the target pixel point, rotating the coordinate system where the plurality of reference pixel points are located to obtain the rotated relative coordinates between the plurality of reference pixel points and the target mapping point respectively; According to the edge gradient direction of the target pixel point and the edge intensity of the target pixel point, scaling the rotated coordinate system to obtain scaled relative coordinates between the plurality of reference pixel points and the target mapping point respectively; And determining corrected distances between the plurality of reference pixel points and the target mapping point respectively based on scaled relative coordinates between the plurality of reference pixel points and the target mapping point respectively.
- 20. The apparatus according to claim 18 or 19, wherein the gradient direction determination module is specifically configured to: And determining the edge gradient direction of the target pixel point based on the transverse gradient component and the longitudinal gradient component of at least one first pixel point, wherein the at least one first pixel point is a reference pixel point adjacent to the target mapping point in the plurality of reference pixel points.
Description
Image processing method, apparatus, device, storage medium, and computer program product Technical Field The present application relates to the field of image processing technologies, and in particular, to an image processing method, apparatus, device, storage medium, and computer program product. Background With the development of display technology, terminal devices have put higher demands on image processing algorithms, and in particular, in functions of real-time rendering, photographing, and browsing pictures, it is necessary to provide high-definition and low-noise images while ensuring low delay. However, the current image processing algorithm has difficulty in simultaneously considering the definition of the image and the noise suppression. Disclosure of Invention The application provides an image processing method, an image processing device, image processing equipment, a storage medium and a computer program product, which can reduce image noise, strengthen image edges and improve image contrast. The technical scheme is as follows: In a first aspect, an image processing method is provided, and the method includes mapping a target pixel point in a target image to an original image to obtain coordinates of the target mapping point, determining a plurality of reference pixel points from the original image based on the coordinates of the target mapping point, determining edge intensity of the target pixel point based on gray values of the plurality of reference pixel points, the edge intensity indicating a significant degree of brightness change of the target pixel point, determining weights corresponding to the plurality of reference pixel points based on the edge intensity of the target pixel point and distances between the plurality of reference pixel points and the target mapping point, and determining pixel values of the target pixel point based on pixel values of the plurality of reference pixel points and the weights corresponding to the plurality of reference pixel points. In the embodiment of the application, the larger the edge strength of the pixel point is, the larger the probability that the pixel point is an image edge is, and the smaller the probability that the pixel point is noise is, on the contrary, the smaller the edge strength of the pixel point is, the smaller the probability that the pixel point is an image edge is, and the larger the probability that the pixel point is noise is. That is, the edge intensity of the image edge is greater than that of the noise, and the edge intensity can distinguish the image edge from the noise well. Therefore, when the weight corresponding to the reference pixel point is determined, the edge intensity of the target pixel point is added, and the weight of each reference pixel point can be adaptively adjusted through the edge intensity of the target pixel point, so that the image noise can be reduced, the image edge can be enhanced, and the contrast of the image can be improved. The original image refers to an image to be processed, and is, for example, an icon to be zoomed, an image in a gallery, or the like. The target image is an image obtained by processing the original image. The target pixel point is any pixel point in the target image, and the target mapping point is a point corresponding to the target pixel point in the original image. In one possible implementation, mapping a target pixel point in a target image to an original image to obtain coordinates of the target mapping point includes obtaining a scaling ratio between the target image and the original image, determining initial coordinates of the target mapping point based on the coordinates of the target pixel point and the scaling ratio, and adjusting the initial coordinates of the target mapping point based on the scaling ratio to obtain coordinates of the target mapping point. In some embodiments, the initial coordinates of the target mapping points may be directly used as the coordinates of the target mapping points, thereby participating in the subsequent processing procedure. Of course, in other embodiments, the initial coordinates of the target mapping points may be dynamically adjusted according to the resolution of the target image, or the initial coordinates of the target mapping points may be dynamically adjusted according to the scaling between the target image and the original image, and the initial coordinates are adjusted to be the coordinates of the target mapping points, so as to participate in the subsequent processing procedure. In one possible implementation, the scaling between the target image and the original image includes a lateral scaling and a longitudinal scaling, the initial coordinates of the target mapping point include a lateral initial coordinate and a longitudinal initial coordinate, adjusting the initial coordinates of the target mapping point based on the scaling includes determining a lateral offset based on the lateral scaling, adjusting the la