An image processing method, device, equipment and computer readable storage medium

By determining the brightness stretching weight and defocus blur kernel type in the mobile terminal, the initial image is processed, which solves the problem that mobile terminals cannot achieve the rendering effect of SLR cameras. It realizes rich bokeh and depth-of-field blurring effects, and improves the efficiency and effect of image processing.

CN114792283BActive Publication Date: 2026-11-24TCL TECHNOLOGY GROUP CORPORATION
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110105672.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-26
Publication Date
2026-11-24
Estimated Expiration
2041-01-26

AI Technical Summary

Technical Problem

Existing mobile devices cannot achieve the rendering effects of SLR cameras, especially lacking rich bokeh and depth-of-field blurring effects in image processing.

Method used

By determining the brightness stretching weight and defocus blur kernel type of the initial image, the initial image is processed. By combining the mapping relationship between the brightness stretching weight and the defocus blur kernel, the effects of light spot rendering and depth of field blurring are achieved.

Benefits of technology

It enriches the image processing and rendering effects of mobile terminals, improves the efficiency of image processing, and realizes diverse light spot rendering effects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114792283B_ABST
    Figure CN114792283B_ABST
Patent Text Reader

Abstract

This application provides an image processing method, apparatus, device, and computer-readable storage medium, relating to the field of image processing technology. It can process an initial image based on the brightness stretching weights and defocus blur kernels of each pixel, enriching the rendering effects of image processing on mobile terminals. The method includes: determining the brightness stretching weight corresponding to the first pixel of the initial image and determining the type of defocus blur kernel of the initial image; processing the initial image according to the brightness stretching weights and the type of defocus blur kernel to obtain a target image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to an image processing method, apparatus, device, and computer-readable storage medium. Background Technology

[0002] With the widespread use of mobile devices (such as smartphones, wearable devices, and tablets), users can take photos anywhere. Users often want to achieve the rendering effects of a DSLR camera when taking photos with their mobile devices. However, it is currently impossible to replicate some of the rendering effects of a DSLR camera on mobile devices. Summary of the Invention

[0003] This application provides an image processing method, apparatus, device, and computer-readable storage medium that can process an initial image based on the brightness stretching weights and defocus blur kernels of each pixel in the initial image, thereby enriching the rendering effects of image processing in mobile terminals.

[0004] In view of the above, in a first aspect, this application provides an image processing method, comprising:

[0005] Determine the brightness stretching weight corresponding to the first pixel of the initial image and determine the type of defocus blur kernel of the initial image;

[0006] The initial image is processed according to the brightness stretching weight and the type of the defocus blur kernel to obtain the target image.

[0007] Optionally, the step of processing the initial image to obtain the target image based on the brightness stretching weight and the type of the defocus blur kernel includes: determining a mapping relationship based on the brightness stretching weight and the type of the defocus blur kernel; and processing the initial image through the mapping relationship and the defocus blur kernel to obtain the target image.

[0008] Optionally, determining the brightness stretching weight corresponding to the first pixel of the initial image includes: determining the brightness stretching weight corresponding to the first pixel based on the relationship between the brightness value of the first pixel and a preset brightness threshold.

[0009] Optionally, determining the brightness stretching weight corresponding to the first pixel based on the relationship between the brightness value of the first pixel and a preset brightness threshold includes: when the brightness value of the first pixel is greater than the brightness threshold, determining the brightness stretching weight of the first pixel as a first value;

[0010] If the brightness value of the first pixel is less than or equal to the brightness threshold, the brightness stretching weight of the first pixel is determined to be the second value.

[0011] The second value is less than the first value.

[0012] Optionally, determining the type of the defocus blur kernel of the initial image includes: performing binarization processing on the defocus blur kernel to obtain a discrete defocus kernel; and determining the type of the defocus blur kernel of the initial image based on the non-zero regions in the discrete defocus kernel.

[0013] Optionally, determining the type of defocus blur kernel of the initial image based on the non-zero regions in the discrete defocus kernel includes: if each row of the non-zero regions in the discrete defocus kernel is a single rectangle, and no column of the non-zero regions is a single rectangle, then the type of the defocus blur kernel is determined to be a first type of defocus blur kernel; if each column of the non-zero regions in the discrete defocus kernel is a single rectangle, and no row of the non-zero regions is a single rectangle, then the type of the defocus blur kernel is determined to be a second type of defocus blur kernel; if each row of the non-zero regions in the discrete defocus kernel is a single rectangle, and each column of the non-zero regions is a single rectangle, then the type of the defocus blur kernel is determined to be a third type of defocus blur kernel; and if no row of the non-zero regions in the discrete defocus kernel is a single rectangle, no column of the non-zero regions is a single rectangle, and the discrete defocus kernel is an axisymmetric structure, then the type of the defocus blur kernel is determined to be a fourth type of defocus blur kernel.

[0014] Optionally, determining the mapping relationship based on the brightness stretching weight and the type of the defocus blur kernel includes: determining the target integration direction based on the type of the defocus blur kernel; and determining the mapping relationship based on the brightness stretching weight along the target integration direction.

[0015] Optionally, determining the target integration direction based on the type of the defocus blur kernel includes: when the type of the defocus blur kernel is the first type of defocus blur kernel, determining that the target integration direction includes a row integration direction; when the type of the defocus blur kernel is the second type of defocus blur kernel, determining that the target integration direction includes a column integration direction; when the type of the defocus blur kernel is the third type of defocus blur kernel, determining that the target integration direction includes either a row integration direction or a column integration direction; and when the type of the defocus blur kernel is the fourth type of defocus blur kernel, dividing the fourth type of defocus blur kernel along the axis of symmetry, and determining the target integration direction based on the divided fourth type of defocus blur kernel.

[0016] Optionally, the step of processing the initial image to obtain the target image through the mapping relationship and the defocusing blur kernel includes: obtaining the unidirectional edge of the discrete defocusing kernel corresponding to the defocusing blur kernel; and processing the initial image to obtain the target image through the elements enclosed inside the unidirectional edge of the discrete defocusing kernel and the mapping relationship.

[0017] Optionally, the method further includes:

[0018] In response to the user's selection operation of the defocus blur kernel, the defocus blur kernel is determined;

[0019] or,

[0020] The depth image corresponding to the initial image, the coordinate information of the focus target in the initial image, and the degree of blur are obtained. The blur radius corresponding to the first pixel is calculated based on the depth image, the coordinate information, and the degree of blur. The defocus blur kernel corresponding to the first pixel is determined based on the blur radius. The degree of blur is proportional to the aperture value.

[0021] Using the method described above, considering that the defocus blur kernel can be used to blur the depth of field of an image, and that the brightness stretching weight is related to the light spot, this application can process the initial image by using the defocus blur kernel and the brightness stretching weight to obtain effects such as light spot rendering and blur rendering. Furthermore, this application can improve the efficiency of image processing through mapping relationships. In addition, the shape of the light spot is determined by the type of defocus blur kernel; therefore, by selecting the defocus blur kernel, various types of light spot rendering are achieved, resulting in diverse light spot effects.

[0022] Secondly, this application provides an image processing apparatus, comprising:

[0023] The determination module is used to determine the brightness stretching weight corresponding to the first pixel of the initial image and to determine the type of the defocus blur kernel of the initial image;

[0024] The processing module is used to process the initial image according to the brightness stretching weight and the type of the defocus blur kernel to obtain the target image.

[0025] Thirdly, this application provides an image processing apparatus, including a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method as described in the first aspect or any alternative method of the first aspect.

[0026] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method as described in the first aspect or any alternative manner of the first aspect.

[0027] Fifthly, this application provides a computer program product that, when run on an image processing device, causes the image processing device to perform the steps of the method described in the first aspect or any optional method of the first aspect.

[0028] It is understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here. Attached Figure Description

[0029] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0030] Figure 1 This is a schematic flowchart of an image processing method provided in an embodiment of this application;

[0031] Figure 2 This is a schematic diagram of the interface of a mobile terminal provided in an embodiment of this application;

[0032] Figure 3 This is a schematic diagram of the interface of another mobile terminal provided in an embodiment of this application;

[0033] Figure 4 This is a schematic diagram of the interface of another mobile terminal provided in an embodiment of this application;

[0034] Figure 5 This is a schematic diagram of a defocus blur kernel processing procedure provided in an embodiment of this application;

[0035] Figure 6 A schematic diagram illustrating another defocus blur kernel processing procedure provided in an embodiment of this application;

[0036] Figure 7 This is a schematic diagram of another defocus blur kernel processing procedure provided in an embodiment of this application;

[0037] Figure 8 This is a schematic diagram of the structure of an image processing device provided in an embodiment of this application;

[0038] Figure 9This is a schematic diagram of the structure of an image processing device provided in an embodiment of this application. Detailed Implementation

[0039] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.

[0040] It should be understood that the term "and / or" as used in this application specification and the appended claims refers to any combination of one or more of the associated listed items, as well as all possible combinations, and includes such combinations. Furthermore, in the description of this application specification and the appended claims, the terms "first," "second," "third," etc., are used only for distinguishing descriptions and should not be construed as indicating or implying relative importance.

[0041] It should also be understood that references to "one embodiment" or "some embodiments" in this specification mean that one or more embodiments of this application include the specific features, structures, or characteristics described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of 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 "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0042] The image processing method provided in this application will be described by way of specific embodiments below.

[0043] Please see Figure 1 , Figure 1 This is a flowchart illustrating an image processing method provided in this application. In this embodiment, the executing entity of the image processing method can be a mobile terminal, such as an Android phone, iOS phone, watch, bracelet, or other device with a camera function. Figure 1 As shown, the image processing method may include:

[0044] S101, determine the brightness stretching weight corresponding to the first pixel of the initial image and determine the type of defocus blur kernel of the initial image.

[0045] The initial image can be an image taken by the user using the mobile terminal, an image stored locally on the mobile terminal, or an image downloaded by the user using the mobile terminal (such as an image downloaded from a webpage or an image downloaded from chat history), and so on.

[0046] It is understandable that the first pixel is any pixel in the initial image.

[0047] In this embodiment of the application, determining the brightness stretching weight corresponding to the first pixel of the initial image may include: determining the brightness stretching weight corresponding to the first pixel based on the relationship between the brightness value of the first pixel and a preset brightness threshold. The brightness threshold can be determined empirically.

[0048] Furthermore, if the brightness value of the first pixel is greater than the brightness threshold, the brightness stretching weight of the first pixel is determined to be a first value; if the brightness value of the first pixel is less than or equal to the brightness threshold, the brightness stretching weight of the first pixel is determined to be a second value; wherein the second value is less than the first value. For example, the second value is 1, and the first value is a value greater than 1.

[0049] In some embodiments of this application, when the brightness value of the first pixel is greater than a brightness threshold, the brightness stretching weight corresponding to the first pixel may be determined in ways including but not limited to the following:

[0050] Method 1: An exponential function relating pixel brightness values ​​and pixel brightness stretching weights can be pre-constructed. The larger the pixel brightness value, the greater the brightness stretching weight; conversely, the smaller the pixel brightness value, the smaller the brightness stretching weight. Thus, the brightness value of the first pixel can be input into the pre-constructed exponential function to obtain the brightness stretching weight of the first pixel.

[0051] Method 2: A pre-defined correspondence between brightness ranges and brightness stretching weights can be established. A brightness range is a range of brightness values. If the brightness values ​​in one brightness range are all greater than the brightness values ​​in another brightness range, then the brightness stretching weight corresponding to the first brightness range is greater than the brightness stretching weight corresponding to the other brightness range. This allows determination of the target brightness range where the brightness value of the first pixel lies, and the determination of the brightness stretching weight corresponding to the target brightness range as the brightness stretching weight of the first pixel. The brightness range includes the target brightness range.

[0052] Method 3: A pre-defined correspondence between brightness difference intervals and brightness stretching weights can be established. The brightness difference interval is the range of differences between the brightness value and the brightness threshold. If the brightness difference in one interval is greater than the brightness difference in another interval, then the brightness stretching weight corresponding to the first interval is greater than the brightness stretching weight corresponding to the other interval. In this way, the difference between the brightness value of the first pixel and the brightness threshold can be calculated to obtain the target brightness difference value. The target brightness difference interval can then be determined, and the brightness stretching weight corresponding to the target brightness difference interval can be set as the brightness stretching weight of the first pixel. The brightness difference interval includes the target brightness difference interval.

[0053] Therefore, in methods one to three above, the brightness stretching weight of a pixel is determined based on the corresponding brightness value, making brighter pixels even brighter, thus better matching the visual effect.

[0054] Similarly, for pixels with brightness values ​​less than or equal to the brightness threshold, the brightness stretching weight can also be determined based on the corresponding brightness value, making darker pixels even darker.

[0055] In an optional embodiment of this application, if the initial image is a grayscale image, the brightness value of the first pixel can be determined based on the grayscale value; wherein, the larger the grayscale value of the first pixel, the larger the corresponding brightness value, and conversely, the smaller the grayscale value of the first pixel, the smaller the corresponding brightness value.

[0056] If the initial image is an RGB image, one approach is to convert the RGB image (where R represents the red color component, G represents the green color component, and B represents the blue color component) into a YUV image (where Y represents luminance, and U and V represent chrominance), and obtain the luminance value of the first pixel from the YUV image; another approach is to use the maximum luminance value of the first pixel in the RGB image with respect to the three color components as the luminance value of the first pixel; yet another approach is to use the average luminance value of the first pixel in the RGB image with respect to the three color components as the luminance value of the first pixel. The above examples are merely illustrative, and this application does not impose any special limitations on them.

[0057] In some embodiments of this application, determining the type of the defocus blur kernel of the initial image may include: binarizing the defocus blur kernel to obtain a discrete defocus kernel; and determining the type of the defocus blur kernel of the initial image based on the non-zero regions in the discrete defocus kernel.

[0058] It is understandable that, since the discrete defocus kernel is a convolution kernel obtained by binarizing the defocus blur kernel, the pixel value of each pixel in the discrete defocus kernel is either 0 or 1. Therefore, the non-zero region in the discrete defocus kernel includes the region composed of pixels with a pixel value of 1.

[0059] Optionally, the defocus blur kernel can be a grayscale image.

[0060] Furthermore, determining the type of defocus blur kernel for the initial image based on the non-zero regions in the discrete defocus kernel can include: if each row of the non-zero regions in the discrete defocus kernel is a single rectangle, and no column of the non-zero regions is a single rectangle, then the type of defocus blur kernel includes a first type of defocus blur kernel; if each column of the non-zero regions in the discrete defocus kernel is a single rectangle, and no row of the non-zero regions is a single rectangle, then the type of defocus blur kernel includes a second type of defocus blur kernel; if each row of the non-zero regions in the discrete defocus kernel is a single rectangle, and every column of the non-zero regions is a single rectangle, then the type of defocus blur kernel includes a third type of defocus blur kernel; and if no row of the non-zero regions in the discrete defocus kernel is a single rectangle, no column of the non-zero regions is a single rectangle, and the discrete defocus kernel has an axisymmetric structure, then the type of defocus blur kernel includes a fourth type of defocus blur kernel.

[0061] In other embodiments of this application, the type of defocus blur kernel can be directly classified according to the specific shape of the defocus blur kernel selected by the user. For example, the types of defocus blur kernels may include: circular defocus blur kernel, rhomboid defocus blur kernel, triangular defocus blur kernel, regular polygonal defocus blur kernel (e.g., regular hexagonal defocus blur kernel, etc.), heart-shaped defocus blur kernel, pentagonal defocus blur kernel, etc.

[0062] It is understood that the type of defocus blur kernel in this application determines the shape of the light spot. For example, if the defocus blur kernel is circular, the light spot shape is a symmetrical circular light spot; if the defocus blur kernel is heart-shaped, the light spot shape is heart-shaped; and if the defocus blur kernel is pentagonal, the light spot shape is pentagonal. Therefore, different light spot shapes can be generated by selecting the defocus blur kernel, thus diversifying the light spot shapes and improving the rendering effect.

[0063] In optional embodiments of this application, the defocusing blur kernel selected by the user can be determined by, but is not limited to, the following methods.

[0064] Method 1: Respond to the user's selection of the defocus blur kernel and determine the defocus blur kernel.

[0065] In some embodiments, the mobile terminal displays a list of defocus blur kernels in the interface showing the initial image. This list includes identifiers of multiple candidate defocus blur kernels. Thus, the selection operation involves the user choosing the identifier of a defocus blur kernel from among the identifiers of the multiple candidate defocus blur kernels.

[0066] For example, Figure 2A schematic diagram of a mobile terminal interface is shown. This application uses a mobile terminal, including a mobile phone, as an example for illustration. Figure 2 As shown, the interface displaying the initial image may include a display area 21, and the display area 21 may include a defocus blur kernel list 22, i.e. Figure 2 The system includes four defocusing blur kernel markers: 221 (circular), 222 (hexagonal), 223 (pentagonal), 224 (diamond), and 225 (heart-shaped). Users can trigger actions on these markers, such as long presses (pressing for longer than a preset time), double-clicks, or dragging along a specific path. Figure 2 The example below illustrates this by dragging the circular defocus blur kernel identifier 221.

[0067] Furthermore, considering that users may want to render different light spots in different areas of the initial image, in this embodiment, the mobile terminal can respond to the user's segmentation operation of the initial image, dividing the initial image into multiple image regions; and respond to the user's selection operation of the defocus blur kernel for each different image region, obtaining the defocus blur kernel corresponding to each image region. Thus, it is possible to render multiple light spots for a single image, resulting in more diverse rendering effects.

[0068] For example, Figure 3 A schematic diagram of a mobile terminal interface is shown, wherein the interface displaying the initial image may include: a first area 32 of a defocus blur kernel list 31, and a second area 33 displaying the initial image; the defocus blur kernel list 31 includes an identifier 311 for a circular defocus blur kernel, an identifier 312 for a regular hexagonal defocus blur kernel, an identifier 313 for a pentagonal defocus blur kernel, an identifier 314 for a rhombus-shaped defocus blur kernel, and an identifier 315 for a heart-shaped defocus blur kernel.

[0069] Thus, when the user is detected performing a segmentation operation on the initial image in the second region 33 (i.e. Figure 3 During the segmentation operation (indicated by the dashed arrow from top to bottom), the mobile terminal responds to the segmentation operation by dividing the initial image into multiple image regions, i.e. Figure 3The image contains a first image region 331 and a second image region 332. Next, the user can select a corresponding defocus blur kernel for each image region. For example, the user can first perform a first trigger operation on the first image region 321. In response to the first trigger operation, the mobile terminal displays the first image region 321 according to a preset display mode (e.g., grayscale display, highlight display, etc.). At this time, the user can perform a second trigger operation on the defocus blur kernel identifier in the first region 32, causing the mobile terminal to obtain the defocus blur kernel of the first image region in response to the second trigger operation. The first trigger operation and the second trigger operation can be different operations or the same operation, such as a long press operation, a double-click operation, or a drag operation along a certain trajectory.

[0070] In other embodiments, when displaying the initial image, the mobile terminal can output multiple candidate defocus blur kernels via voice. This allows the user to select a defocus blur kernel based on multiple candidate kernels by voice input; alternatively, the user can input the identifier of the defocus blur kernel via touch on the interface displaying the initial image, for example, by drawing the shape of the defocus blur kernel or writing its name.

[0071] For example, Figure 4 A schematic diagram of a mobile terminal interface is shown. For example... Figure 4 As shown, after the user hears multiple candidate defocus blur kernels from the voice output, the shape of the selected defocus blur kernel can be drawn on the interface displaying the initial image. Figure 4 The example used in this paper is a circular defocusing blur kernel, and this application does not impose any special restrictions on it.

[0072] It should be noted that the size of the candidate defocus blur kernel is fixed in Method 1; or, the size of the candidate defocus blur kernel can be adjusted. For example, a size selection control can be set near each candidate defocus blur kernel so that the user can select the size of the defocus blur kernel to use.

[0073] Method 2: Obtain the depth image corresponding to the initial image, the coordinate information of the focus target in the initial image, and the degree of blur. Calculate the blur radius corresponding to the first pixel based on the depth image, coordinate information, and degree of blur. Determine the defocus blur kernel corresponding to the first pixel based on the blur radius.

[0074] It is understandable that the degree of blur can be a parameter that the user can adjust, and the degree of blur is proportional to the aperture value, that is, a parameter related to the aperture value; the focus target can be the main subject in the image, for example, if the initial image is an image about a portrait, then the focus target is the portrait.

[0075] In one optional embodiment, the calculation process of the blur radius can be as follows: obtaining the depth value of the focus target from the depth image based on the focus coordinates, obtaining the target depth value based on the depth value of the focus target, calculating the absolute value of the difference between the depth value of each pixel in the depth image and the target depth value, and calculating the blur radius of each pixel in the depth image based on the absolute value and the degree of blur. The blur radius of each pixel in the depth image is the blur radius of the pixel at the corresponding position in the initial image. The specific calculation process is shown in Formula 1.

[0076] r(x i,j )=kmax(0,|d(x i,j Formula 1 (-d1|-d2)

[0077] Where, x i,j r(x) represents the pixel in the i-th row and j-th column of the depth image; i,j ) represents the blur radius of the pixel in the i-th row and j-th column of the depth image; d(x i,j ) represents the depth value of the pixel in the i-th row and j-th column of the depth image; d1 represents the target depth value; d2 represents the preset depth compensation value, so that objects within a certain depth range before and after the focused target are not blurred; k represents the degree of blurring. 'c' represents the aperture value, allowing users to adjust the aperture value to select the degree of bokeh. The larger the aperture value, the greater the bokeh, and vice versa.

[0078] In the embodiments of this application, obtaining the target depth value based on the depth value of the focus target may include: using the depth value of the focus target as the target depth value; or, obtaining the depth values ​​of other pixels within a preset distance range of the focus target, excluding the focus target, and calculating the average depth between the depth values ​​of the other pixels and the depth value of the focus target, and using the average depth as the target depth value. The above examples are only illustrative, and this application does not impose any special limitations on them.

[0079] After obtaining the blur radius of the first pixel in the initial image, this application can determine the defocus blur kernel selected by the user, and determine the size of the defocus blur kernel corresponding to the first pixel based on the blur radius of the first pixel. Therefore, it can be seen that, using this method, the corresponding spot size can be different for different pixel locations. The mobile terminal can display different types of defocus blur kernels using the method described in Method 1 above, in order to obtain the defocus blur kernel selected by the user; further details are omitted here.

[0080] It should be noted that this application does not impose any restrictions on the timing of determining the brightness stretching weight and the defocus blur kernel.

[0081] S102, the initial image is processed according to the brightness stretching weight and the type of defocus blur kernel to obtain the target image.

[0082] In this application, considering that the defocus blur kernel can be used to blur the depth of field of the initial image, and the brightness stretching weight can be used to render light spots on the initial image, and that the type of defocus blur kernel determines the shape of the light spots, it can be seen that the target image in this application is an image obtained by blurring and rendering light spots on the initial image.

[0083] Considering that mobile terminals can accelerate defocus blurring and achieve depth-of-field blurring effects using integral tables or integral images (commonly known as summarized area tables or integral images), which is simpler to implement than methods such as ray tracing and reduces the processor load on mobile terminals, this application embodiment can also use integral tables to achieve the effects of spot rendering and blur rendering, thus improving image processing efficiency. Furthermore, considering that rendering spots separately increases computational time and that the rendered spot features (such as the color, brightness, shape, and transparency of the spot edges) cannot be naturally integrated with the initial image, this application combines spot rendering and blur rendering to achieve a more natural rendering effect.

[0084] In summary, this application can determine the mapping relationship based on the brightness stretching weight and the type of defocus blur kernel; the target image is obtained by processing the initial image through the mapping relationship and the defocus blur kernel. This application does not limit the form of the mapping relationship; for example, it can be an integral table or integral image as described above.

[0085] It is understandable that existing integral tables (or integral images) typically accumulate pixel values ​​within different rectangular regions of the initial image. However, the defocusing blur kernel used in this application can be a non-rectangular defocusing blur kernel such as a circular defocusing blur kernel, a heart-shaped defocusing blur kernel, a pentagonal defocusing blur kernel, or a rhombus defocusing blur kernel. Therefore, during image processing, after obtaining the discrete defocusing kernel corresponding to the defocusing blur kernel, this application treats the discrete defocusing kernel as a concatenation of multiple single-row or single-column rectangular regions, and then performs convolution processing on the initial image using these multiple single-row or single-column regions. Thus, the mapping relationship in this application is obtained by accumulating single rows or columns in the initial image, as detailed in Equations 2 and 3 below.

[0086] In this embodiment of the application, the mobile terminal can determine the target integration direction according to the type of defocus blur kernel; and determine the mapping relationship according to the brightness stretching weight in the target integration direction.

[0087] It is understood that the target integration direction involved in this application can be the direction of integration over the initial image. Specifically, if integration is performed on each row of the initial image, the target integration direction includes the row integration direction; if integration is performed on each column of the initial image, the target integration direction includes the column integration direction. Optionally, if the target integration direction is the row integration direction, the mapping relationship can be called the row-direction integration mapping relationship; if the target integration direction is the column integration direction, the mapping relationship can be called the column-direction integration mapping relationship.

[0088] It should also be understood that since the light spot is related to the brightness, the mapping relationship of the initial image is determined by the brightness stretching weight, thus realizing the light spot rendering process.

[0089] In some embodiments, if the type of defocus blur kernel includes: circular defocus blur kernel, rhomboid defocus blur kernel, triangular defocus blur kernel, regular polygonal defocus blur kernel (e.g., regular hexagonal defocus blur kernel), heart-shaped defocus blur kernel, pentagonal defocus blur kernel, etc., then this application can obtain a preset integration direction correspondence. The preset integration direction correspondence includes the correspondence between different candidate defocus blur kernels and integration directions. Thus, the target integration direction corresponding to the defocus blur kernel can be obtained according to the preset integration direction correspondence, and the candidate defocus blur kernels include the defocus blur kernel itself.

[0090] For example, the preset integration direction correspondence may include: the target integration direction of a circular defocus blur kernel includes either a row integration direction or a column integration direction; the target integration direction of a rhombus defocus blur kernel includes either a row integration direction or a column integration direction; the target integration direction of a heart-shaped defocus blur kernel includes a column integration direction; and the target integration direction of a pentagonal defocus blur kernel includes: both sides of the axis of symmetry of the pentagonal defocus blur kernel are row integration directions.

[0091] In some embodiments, the defocus blur kernel type may also include: a first type of defocus blur kernel, a second type of defocus blur kernel, a third type of defocus blur kernel, and a fourth type of defocus blur kernel. Thus, when the defocus blur kernel type is a first type of defocus blur kernel, the target integration direction is determined to include the row integration direction; when the defocus blur kernel type is a second type of defocus blur kernel, the target integration direction is determined to include the column integration direction; when the defocus blur kernel type is a third type of defocus blur kernel, the target integration direction is determined to include either the row integration direction or the column integration direction; and when the defocus blur kernel type is a fourth type of defocus blur kernel, the fourth type of defocus blur kernel is divided along the axis of symmetry, and the target integration direction is determined based on the divided fourth type of defocus blur kernel.

[0092] Furthermore, this application can determine the defocusing blur kernel type of the fourth defocusing blur kernel after segmentation, and determine the corresponding target integration direction based on the defocusing blur kernel type of the fourth defocusing blur kernel after segmentation.

[0093] Optionally, if the target integration direction is the row integration direction, the calculation process of the integral image value in the i-th row and j-th column of the mapping relationship is as shown in Formula 2:

[0094]

[0095] Where SUT(i,j) represents the integral image value in the i-th row and j-th column of the mapping relationship, SUT(i,j-1) represents the integral image value in the i-th row and (j-1)-th column of the mapping relationship, I(i,j) represents the pixel value of the i-th row and j-th column of the initial image, and W(i,j) represents the brightness stretching weight of the i-th row and j-th column of the initial image.

[0096] Optionally, if the target integration direction is the column integration direction, the calculation process of the integral image value in the i-th row and j-th column of the mapping relationship is as shown in Formula 3:

[0097]

[0098] Where SUT(i,j) represents the integral image value in the i-th row and j-th column of the mapping relationship, SUT(i-1,j) represents the integral image value in the (i-1)-th row and j-th column of the mapping relationship, I(i,j) represents the pixel value of the pixel in the i-th row and j-th column of the initial image, and W(i,j) represents the brightness stretching weight of the pixel in the i-th row and j-th column of the initial image.

[0099] It is understood that the I(i,j) mentioned above can be a three-channel (i.e., RGB channel) or a four-channel (i.e., RGB channel and a first brightness stretching channel, and each pixel of the first brightness stretching channel is assigned the same value, such as 1); SUT(i,j) can also be a three-channel (i.e., RGB channel) or a four-channel (i.e., RGB channel and a second brightness stretching channel, and each pixel of the second brightness stretching channel is assigned the brightness accumulation value of the corresponding brightness stretching weight).

[0100] After obtaining the integral image values ​​using the method described above, a mapping relationship can be constructed based on the integral image values. In summary, this application determines the mapping relationship corresponding to the initial image in the target integration direction based on the brightness stretching weights and the pixel values ​​of each pixel in the initial image.

[0101] Optionally, the discrete defocus kernel includes a first element (i.e., an element with a pixel value of 1) for convolution processing of the initial image, and also includes a second element (i.e., an element with a pixel value of 0) that is not used. In order to quickly use the first element to perform convolution processing on the initial image, in this embodiment of the application, the unidirectional edge of the discrete defocus kernel corresponding to the defocus blur kernel can be obtained, and the initial image can be processed to obtain the target image through the elements enclosed inside the unidirectional edge of the discrete defocus kernel (i.e., the first element mentioned above) and the mapping relationship.

[0102] It should be noted that, in order to distinguish between the units in the image (i.e., the initial image and the target image in this application) and the convolution kernel (i.e., the discrete defocus kernel and the defocus blur kernel in this application), this application refers to the units in the image as pixels and the units in the convolution kernel as elements.

[0103] It is understood that in this application, the target integration direction is the same as the direction corresponding to the unidirectional edge. For example, if the direction corresponding to the unidirectional edge is a column direction, then the target integration direction is the column integration direction; if the direction corresponding to the unidirectional edge is a row direction, then the target integration direction is the row integration direction.

[0104] The direction corresponding to the unidirectional edge can be understood as follows: the column direction edge is obtained by subtracting the pixel values ​​of two adjacent rows in the defocus blur kernel; the row direction edge is obtained by subtracting the pixel values ​​of two adjacent columns in the defocus blur kernel.

[0105] The following explanation uses a circular defocusing blur kernel as an example. A circular discrete defocusing kernel corresponding to the circular defocusing blur kernel can be obtained. The difference between the elements in two adjacent rows of the circular discrete defocusing kernel is then calculated to obtain the column-direction edge of the circular discrete defocusing kernel; alternatively, the difference between the elements in two adjacent columns of the circular discrete defocusing kernel is calculated to obtain the row-direction edge of the circular discrete defocusing kernel.

[0106] Optionally, if the difference between the element in the (n+1)th row and the element in the (n)th row and the element in the (n)th row and the element in the (j)th column of the circular discrete defocus kernel is calculated, n and j can be positive integers. Specifically, if the difference between the element in the (n+1)th row and the element in the (n)th row and the element in the (j)th column is 0, then the element in the (n+1)th row and the element in the (j)th column is determined not to belong to a column-direction edge; if the pixel difference between the element in the (n+1)th row and the element in the (n)th row and the element in the (j)th column is not 0, then the element in the (n+1)th row and the element in the (j)th column is determined to belong to a column-direction edge.

[0107] For example, Figure 5 A schematic diagram of the processing procedure for a circular defocus blur kernel is shown. Figure 5 Figure (a) shows the circular defocusing blur kernel. Figure 5 Figure (b) shows a circular discrete defocusing kernel. Figure 5 Figure (c) shows a circular discrete defocusing kernel marked with column direction edges.

[0108] The following explanation uses a defocusing blur kernel, including a heart-shaped defocusing blur kernel, as an example. The heart-shaped discrete defocusing kernel corresponding to the heart-shaped defocusing blur kernel can be obtained. Since each column of the non-zero region in the heart-shaped discrete defocusing kernel is a single rectangle, and several rows of the non-zero region in the heart-shaped discrete defocusing kernel are not single rectangles, the difference between the elements of two adjacent rows in the heart-shaped discrete defocusing kernel is performed to obtain the column-direction edges of the heart-shaped discrete defocusing kernel.

[0109] For example, Figure 6 A schematic diagram of the processing procedure for the cardioid defocus blur kernel is shown. Figure 6 Figure (a) shows a heart-shaped discrete defocusing kernel. Figure 6 Figure (b) shows a heart-shaped discrete defocusing kernel marked with column direction edges.

[0110] The following explanation uses a pentagram-shaped defocusing blur kernel as an example. A pentagram-shaped discrete defocusing kernel can be obtained. Since several columns of the non-zero regions in the pentagram-shaped discrete defocusing kernel are not single rectangles, and several rows of the non-zero regions in the pentagram-shaped discrete defocusing kernel are not single rectangles, and the pentagram-shaped discrete defocusing kernel has an axisymmetric structure, the pentagram-shaped discrete defocusing kernel is divided along the axis of symmetry. For the divided pentagram-shaped discrete defocusing kernel, the corresponding row-directed edges are obtained according to the row direction.

[0111] For example, Figure 7 A schematic diagram of the processing procedure for a pentagonal defocus blur kernel is shown. Figure 7 Figure (a) shows the segmented pentagonal discrete defocusing kernel. Figure 7 Figure (b) shows the segmented pentagram discrete defocusing kernel marked with the row direction edges.

[0112] Optionally, the calculation process for the initial pixel value of the pixel in the i-th row and j-th column of the target image is shown in Formula 4:

[0113]

[0114] Where B(i,j) represents the initial pixel value of the pixel in the i-th row and j-th column of the target image; I(i+Δi,j+Δj) represents the pixel value of the pixel in the (i+Δi)-th row and (j+Δj)-th column of the initial image; W(i+Δi,j+Δj) represents the brightness stretching weight of the pixel in the (i+Δi)-th row and (j+Δj)-th column of the initial image; K(Δi,Δj) represents the value of the element in the Δi-th row and Δj-th column obtained with the center position of the element inside the unidirectional edge of the discrete defocus kernel as the reference; Δi represents the row offset of the pixel coordinate; Δj represents the column offset of the pixel coordinate, and the magnitudes of Δi and Δj are related to the number of elements enclosed inside the unidirectional edge of the discrete defocus kernel.

[0115] It is understandable that the discrete defocus kernel is a convolution kernel obtained by binarizing the defocus blur kernel. Therefore, the pixel value of a pixel in the discrete defocus kernel is either 0 or 1. That is, the elements enclosed inside the unidirectional edge of the discrete defocus kernel are 1, and the elements outside the unidirectional edge of the discrete defocus kernel are 0. Thus, the calculation of Formula 4 can be simplified to the cumulative value of the region product between the pixel value of each pixel in the target area and the corresponding brightness stretching weight. The target area is the area where the pixel in the i-th row and j-th column of the initial image is located, and it is the area where the elements inside the unidirectional edge of the discrete defocus kernel are convolved. Therefore, the target area and the area formed by the unidirectional edge of the discrete defocus kernel have the same shape. Then, the ratio between the cumulative value of the region and the cumulative value of the brightness of the target area is calculated to obtain the final pixel value of the pixel in the i-th row and j-th column of the target image. By calculating this ratio, the brightness stretching weight of the pixels in the target image is normalized, avoiding problems such as excessive brightness in the target image.

[0116] It should also be understood that the target region described above can be decomposed into multiple single-row or single-column rectangular regions. Specifically, if the integration direction of the mapping relationship is the row integration direction, the target region can be decomposed into multiple single-row rectangular regions; if the integration direction of the mapping relationship is the column integration direction, the target region can be decomposed into multiple single-column rectangular regions. In this way, the integrated image value of each pixel within each rectangular region can be quickly looked up and calculated using the mapping relationship, and the integrated image values ​​of all rectangular regions can be accumulated to obtain the region-accumulated value of the target region.

[0117] It should also be understood that when the integral image value in the mapping relationship is four channels, since the integral image value includes RGB channels and a second brightness stretching channel, and each pixel in the second brightness stretching channel is assigned the brightness accumulation value of the corresponding brightness stretching weight, this application can directly and quickly obtain the brightness accumulation value corresponding to the target area from the mapping relationship; when the integral image value in the mapping relationship is three channels, this application can obtain the brightness accumulation value by calculating the accumulation value of the brightness stretching weight of each pixel in the target area.

[0118] Using the image processing method described above, considering that the defocus blur kernel can be used to blur the depth of field of an image, and that the brightness stretching weight is related to the light spot, this application can process the initial image by using the defocus blur kernel and the brightness stretching weight to obtain effects such as light spot rendering and bokeh rendering. Furthermore, this application can quickly achieve bokeh rendering and light spot rendering through mapping relationships, avoiding the problems of long computation time and poor light spot effect caused by rendering light spots separately. In addition, the shape of the light spot is determined by the type of defocus blur kernel; therefore, by selecting the defocus blur kernel, multiple types of light spot rendering are achieved, resulting in diverse light spot effects.

[0119] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0120] Based on the image processing method provided in the above embodiments, the present invention further provides an apparatus embodiment for implementing the above method embodiments.

[0121] Please see Figure 8 , Figure 8 This is a schematic diagram of an image processing apparatus provided in an embodiment of this application. The included modules are used to perform... Figure 1 The steps in the corresponding embodiments. Please refer to the details. Figure 1 The relevant descriptions in the corresponding embodiments are shown below. For ease of explanation, only the parts relevant to this embodiment are shown. See also... Figure 8 The image processing device 8 includes:

[0122] The determination module 81 is used to determine the brightness stretching weight corresponding to the first pixel of the initial image and to determine the type of the defocus blur kernel of the initial image;

[0123] The processing module 82 is used to process the initial image according to the brightness stretching weight and the type of the defocus blur kernel to obtain the target image.

[0124] Optionally, the processing module 82 is further configured to determine a mapping relationship based on the brightness stretching weight and the type of the defocus blur kernel; and to process the initial image using the mapping relationship and the defocus blur kernel to obtain the target image.

[0125] Optionally, the determining module 81 is further configured to determine the brightness stretching weight corresponding to the first pixel based on the relationship between the brightness value of the first pixel and a preset brightness threshold.

[0126] Optionally, the determining module 81 is further configured to determine the brightness stretching weight of the first pixel as a first value when the brightness value corresponding to the first pixel is greater than the brightness threshold.

[0127] If the brightness value corresponding to the first pixel is less than or equal to the brightness threshold, the brightness stretching weight of the first pixel is determined to be the second value.

[0128] The second value is less than the first value.

[0129] Optionally, the determining module 81 is further configured to perform binarization processing on the defocus blur kernel to obtain a discrete defocus kernel; and determine the type of defocus blur kernel of the initial image based on the non-zero regions in the discrete defocus kernel.

[0130] Optionally, the determining module 81 is further configured to determine that the type of the defocus blur kernel includes a first type of defocus blur kernel when each row of the non-zero region in the discrete defocus kernel is a single rectangle and any column of the non-zero region is not a single rectangle;

[0131] If each column of the non-zero region in the discrete defocus kernel is a single rectangle, and any row of the non-zero region is not a single rectangle, then the type of the defocus blur kernel is determined to include a second type of defocus blur kernel.

[0132] If each row of the non-zero region in the discrete defocus kernel is a single rectangle, and each column of the non-zero region is a single rectangle, then the type of the defocus blur kernel is determined to include a third type of defocus blur kernel.

[0133] If any row of the non-zero region in the discrete defocus kernel is not a single rectangle, any column of the non-zero region is not a single rectangle, and the discrete defocus kernel is an axisymmetric structure, then the type of the defocus blur kernel is determined to include a fourth type of defocus blur kernel.

[0134] Optionally, the processing module 82 is further configured to determine the target integration direction according to the type of the defocus blur kernel; and determine the mapping relationship according to the brightness stretching weight in the target integration direction.

[0135] Optionally, the processing module 82 is further configured to determine that the target integration direction includes the line integration direction when the type of the defocus blur kernel is the first type of defocus blur kernel;

[0136] When the type of the defocus blur kernel is the second type of defocus blur kernel, the target integration direction is determined to include the column integration direction;

[0137] When the type of the defocus blur kernel is the third type of defocus blur kernel, the target integration direction is determined to include either the row integration direction or the column integration direction;

[0138] When the type of the defocus blur kernel is the fourth type of defocus blur kernel, the fourth type of defocus blur kernel is divided along the axis of symmetry, and the target integration direction is determined based on the divided fourth type of defocus blur kernel.

[0139] Optionally, the processing module 82 is further configured to obtain the unidirectional edge of the discrete defocus kernel corresponding to the defocus blur kernel;

[0140] The target image is obtained by processing the initial image using the elements enclosed within the unidirectional edge of the discrete defocus kernel and the mapping relationship.

[0141] Optionally, the determining module 81 is further configured to determine the defocus blur kernel in response to the user's selection operation of the defocus blur kernel;

[0142] or,

[0143] The depth image corresponding to the initial image, the coordinate information of the focus target in the initial image, and the degree of blur are obtained. The blur radius is calculated based on the depth image, the coordinate information, and the degree of blur. The defocus blur kernel is determined based on the blur radius. The degree of blur is proportional to the aperture value.

[0144] It should be noted that the information interaction and execution process between the above modules are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, which will not be repeated here.

[0145] Figure 9 This is a schematic diagram of the image processing device provided in an embodiment of this application. Figure 9 As shown, the image processing device 9 of this embodiment includes: a processor 90, a memory 91, and a computer program 92, such as an image processing program, stored in the memory 91 and executable on the processor 90. When the processor 90 executes the computer program 92, it implements the steps in the various image processing method embodiments described above, for example... Figure 1 S101 and S102 are shown. Alternatively, when the processor 90 executes the computer program 92, it implements the functions of each module / unit in the above-described device embodiments, for example... Figure 8 The functions of modules 81 and 82 are shown.

[0146] For example, the computer program 92 can be divided into one or more modules / units, which are stored in the memory 91 and executed by the processor 90 to complete this application. The one or more modules / units can be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program 92 in the image processing device 9. For example, the computer program 92 can be divided into an acquisition module, a fusion module, and a detection module; please refer to the specific functions of each module. Figure 1 The relevant descriptions in the corresponding embodiments are not repeated here.

[0147] The image processing device may include, but is not limited to, a processor 90 and a memory 91. Those skilled in the art will understand that... Figure 9This is merely an example of the image processing device 9 and does not constitute a limitation on the image processing device 9. It may include more or fewer components than shown, or combine certain components, or different components. For example, the image processing device may also include input / output devices, network access devices, buses, etc.

[0148] The processor 90 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.

[0149] The memory 91 can be an internal storage unit of the image processing device 9, such as a hard disk or memory of the image processing device 9. The memory 91 can also be an external storage device of the image processing device 9, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the image processing device 9. Furthermore, the memory 91 can include both internal and external storage units of the image processing device 9. The memory 91 is used to store the computer program and other programs and data required by the image processing device. The memory 91 can also be used to temporarily store data that has been output or will be output.

[0150] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, can implement the above-described image processing method.

[0151] This application provides a computer program product that, when run on an image processing device, enables the image processing device to implement the above-described image processing method.

[0152] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0153] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0154] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0155] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. An image processing method, characterized in that, include: Determine the brightness stretching weight corresponding to the first pixel of the initial image and determine the type of defocus blur kernel of the initial image; The initial image is processed to obtain a target image based on the brightness stretching weight and the type of the defocus blur kernel, including: determining a mapping relationship based on the brightness stretching weight and the type of the defocus blur kernel; obtaining the unidirectional edge of the discrete defocus kernel corresponding to the defocus blur kernel; and processing the initial image to obtain the target image using the elements enclosed inside the unidirectional edge of the discrete defocus kernel and the mapping relationship. The step of determining the mapping relationship based on the brightness stretching weight and the type of the defocus blur kernel includes: The target integration direction is determined based on the type of the defocus blur kernel; The mapping relationship is determined according to the brightness stretching weight in the target integration direction.

2. The method according to claim 1, characterized in that, Determining the brightness stretching weight corresponding to the first pixel of the initial image includes: The brightness stretching weight corresponding to the first pixel is determined based on the relationship between the brightness value of the first pixel and the preset brightness threshold.

3. The method according to claim 2, characterized in that, The step of determining the brightness stretching weight corresponding to the first pixel based on the relationship between the brightness value of the first pixel and a preset brightness threshold includes: If the brightness value of the first pixel is greater than the brightness threshold, the brightness stretching weight of the first pixel is determined to be a first value; If the brightness value of the first pixel is less than or equal to the brightness threshold, the brightness stretching weight of the first pixel is determined to be the second value. The second value is less than the first value.

4. The method according to claim 1, characterized in that, Determining the type of defocus blur kernel of the initial image includes: The defocusing blur kernel is binarized to obtain a discrete defocusing kernel; The type of defocus blur kernel of the initial image is determined based on the non-zero regions in the discrete defocus kernel.

5. The method according to claim 4, characterized in that, The step of determining the type of defocus blur kernel for the initial image based on the non-zero regions in the discrete defocus kernel includes: If each row of the non-zero region in the discrete defocus kernel is a single rectangle, and any column of the non-zero region is not a single rectangle, then the type of the defocus blur kernel is determined to include a first type of defocus blur kernel. If each column of the non-zero region in the discrete defocus kernel is a single rectangle, and any row of the non-zero region is not a single rectangle, then the type of the defocus blur kernel is determined to include a second type of defocus blur kernel. If each row of the non-zero region in the discrete defocus kernel is a single rectangle, and each column of the non-zero region is a single rectangle, then the type of the defocus blur kernel is determined to include a third type of defocus blur kernel. If any row of the non-zero region in the discrete defocus kernel is not a single rectangle, any column of the non-zero region is not a single rectangle, and the discrete defocus kernel is an axisymmetric structure, then the type of the defocus blur kernel is determined to include a fourth type of defocus blur kernel.

6. The method according to claim 5, characterized in that, Determining the target integration direction based on the type of the defocus blur kernel includes: When the type of the defocus blur kernel is the first type of defocus blur kernel, the target integration direction is determined to include the line integration direction; When the type of the defocus blur kernel is the second type of defocus blur kernel, the target integration direction is determined to include the column integration direction; When the type of the defocus blur kernel is the third type of defocus blur kernel, the target integration direction is determined to include either the row integration direction or the column integration direction; When the type of the defocus blur kernel is the fourth type of defocus blur kernel, the fourth type of defocus blur kernel is divided along the axis of symmetry, and the target integration direction is determined based on the divided fourth type of defocus blur kernel.

7. The method according to claim 1, characterized in that, The method further includes: In response to the user's selection operation of the defocus blur kernel, the defocus blur kernel is determined; or, The depth image corresponding to the initial image, the coordinate information of the focus target in the initial image, and the degree of blur are obtained. The blur radius corresponding to the first pixel is calculated based on the depth image, the coordinate information, and the degree of blur. The defocus blur kernel corresponding to the first pixel is determined based on the blur radius. The degree of blur is proportional to the aperture value.

8. An image processing apparatus, characterized in that, include: The determination module is used to determine the brightness stretching weight corresponding to the first pixel of the initial image and to determine the type of the defocus blur kernel of the initial image; The processing module is used to process the initial image to obtain a target image based on the brightness stretching weight and the type of the defocus blur kernel, including: determining a mapping relationship based on the brightness stretching weight and the type of the defocus blur kernel; obtaining the unidirectional edge of the discrete defocus kernel corresponding to the defocus blur kernel; and processing the initial image to obtain the target image through the elements enclosed inside the unidirectional edge of the discrete defocus kernel and the mapping relationship. The step of determining the mapping relationship based on the brightness stretching weight and the type of the defocus blur kernel includes: The target integration direction is determined based on the type of the defocus blur kernel; The mapping relationship is determined according to the brightness stretching weight in the target integration direction.

9. An image processing apparatus, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Image processing method and apparatus

    CN105279727A

  • Light spot blurring method and device, storage medium and computer equipment

    CN111583104A