A direction adaptive filter kernel generation method and device, and a computer device

CN122948680APending Publication Date: 2026-10-20AIXIN YUANZHI SEMICONDUCTOR (CHONGQING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611323265.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-27
Publication Date
2026-10-20

AI Technical Summary

Technical Problem

然而,当图像中包含文字笔画拐角、小尺度折线边缘或非对称角点等复杂局部图像结构时,沿单一方向生成的直线带状的滤波核无法准确反映当前像素周围实际的局部图像结构,进而导致去噪、锐化、边缘检测或文字增强等操作效果较差

Benefits of technology

[0014]在本申请一些实施例中,从预设的基础滤波核中确定与每个候选路径对应的候选滤波核,包括:

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure FT_1
    Figure FT_1
  • Figure FT_2
    Figure FT_2
  • Figure FT_3
    Figure FT_3
Patent Text Reader

Abstract

This application provides a method, apparatus, and computer device for generating a direction-adaptive filter kernel. Based on the gradient information of pixels in the neighborhood of a target pixel in each preset direction, multiple candidate center directions and their corresponding confidence levels are determined. Positive and negative adjacent pixels are determined along both sides of each candidate center direction. Then, based on the gradient information of pixels in the neighborhood of each adjacent pixel in each preset direction, multiple positive and negative candidate directions and their corresponding confidence levels are determined. The candidate center directions, positive and negative candidate directions are then combined to obtain multiple candidate paths. Based on the confidence level of each candidate path, the candidate filter kernels corresponding to the candidate paths are weighted and summed to obtain a filter kernel that accurately represents the actual local image structure around the target pixel.
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 a method, apparatus, and computer device for generating a direction-adaptive filter kernel. Background Technology

[0002] In the field of image processing technology, it is often necessary to perform operations such as denoising, sharpening, edge detection, or text enhancement on images.

[0003] In related technologies, a main direction for the edge or line extension within a local window is typically determined first, and a linear band-shaped filter kernel is generated along this main direction. Convolution operations are then performed based on this filter kernel to achieve operations such as image denoising, sharpening, edge detection, or text enhancement. However, when the image contains complex local image structures such as the corners of text strokes, small-scale polyline edges, or asymmetrical corners, a linear band-shaped filter kernel generated along a single direction cannot accurately reflect the actual local image structure around the current pixel, resulting in poor performance in denoising, sharpening, edge detection, or text enhancement. Summary of the Invention

[0004] This application provides a method, apparatus, and computer device for generating a direction-adaptive filter kernel, which can obtain a filter kernel that accurately represents the actual local image structure around the target pixel, thereby improving the effects of operations such as denoising, sharpening, edge detection, or text enhancement.

[0005] According to a first aspect of the embodiments of this application, a method for generating a direction-adaptive filter kernel is provided, comprising: Acquire the target image; For each target pixel in the target image, based on the gradient information of the neighboring pixels of the target pixel in each preset direction, multiple candidate center directions of the target pixel and the confidence level of each candidate center direction are determined. Determine the neighboring pixels of the target pixel in each center candidate direction. The neighboring pixels include positive side neighboring pixels and negative side neighboring pixels. Based on the gradient information of the pixels in the neighborhood of each adjacent pixel in each preset direction, determine multiple positive candidate directions, multiple negative candidate directions, the confidence level of each positive candidate direction, and the confidence level of each negative candidate direction for the target pixel. Multiple candidate directions for the center, multiple candidate directions for the positive side, and multiple candidate directions for the negative side are combined to obtain multiple candidate paths. The candidate paths represent the overall orientation of the local image structure around the target pixel. The candidate filter kernel corresponding to each candidate path is determined from the preset basic filter kernel; for each candidate path, the confidence level of the candidate path is determined based on the confidence level of each candidate direction in the candidate path. Based on the confidence level of each candidate path, a weighted summation operation is performed on each candidate filter kernel to obtain the filter kernel corresponding to the target pixel.

[0006] In some embodiments of this application, for each target pixel in the target image, based on the gradient information of the neighboring pixels of the target pixel in each preset direction, multiple candidate center directions of the target pixel and the confidence level of each candidate center direction are determined, including: For each target pixel in the target image, calculate the sum of the absolute pixel differences between every two neighboring pixels in each preset direction within the neighborhood of the target pixel; The two preset directions with the smallest sum of absolute pixel differences are selected as the center candidate directions of the target pixel; For each candidate center direction, the confidence level of the candidate center direction is determined based on the sum of the absolute differences of the pixels corresponding to the candidate center direction. The confidence level of the candidate center direction is negatively correlated with the sum of the absolute differences of the pixels corresponding to the candidate center direction.

[0007] As can be seen, the above-mentioned direction-adaptive filter kernel generation method can determine the center candidate direction and the confidence level corresponding to the center candidate direction based on the absolute pixel difference of neighboring pixels in each preset direction. In this way, it can accurately determine the multiple possible extension directions of the image structure in the neighborhood of the target pixel and their confidence level, providing a reliable directional basis for the subsequent generation of candidate paths and filter kernels.

[0008] In some embodiments of this application, the preset directions include a horizontal direction, a vertical direction, a right-upper diagonal direction, and a right-lower diagonal direction; When the center candidate direction is horizontal, the positive adjacent pixel is the right adjacent pixel of the target pixel, and the negative adjacent pixel is the left adjacent pixel of the target pixel. When the center candidate direction is vertical, the positive adjacent pixels are the adjacent pixels below the target pixel, and the negative adjacent pixels are the adjacent pixels above the target pixel. When the direction of the center candidate is the upper right diagonal direction, the positive side adjacent pixel is the upper right adjacent pixel of the target pixel, and the negative side adjacent pixel is the lower left adjacent pixel of the target pixel. When the center candidate direction is the lower right slant direction, the positive side adjacent pixel is the lower right adjacent pixel of the target pixel, and the negative side adjacent pixel is the upper left adjacent pixel of the target pixel.

[0009] As can be seen, in the above-mentioned direction adaptive filter kernel generation method, each preset direction is set to the horizontal direction, the vertical direction, the upper right diagonal direction, and the lower right diagonal direction, so as to cover the common edge or line extension directions in the image.

[0010] In some embodiments of this application, based on the gradient information of the pixels in the neighborhood of each adjacent pixel in each preset direction, multiple positive candidate directions, multiple negative candidate directions, the confidence level of each positive candidate direction, and the confidence level of each negative candidate direction are determined for the target pixel, including: For each adjacent pixel, calculate the sum of the absolute pixel differences between every two neighboring pixels in each preset direction within the neighborhood of the adjacent pixel; select the two preset directions with the smallest sum of absolute pixel differences as candidate center directions for the adjacent pixels; For each candidate center direction of adjacent pixels, the confidence level of the candidate center direction of adjacent pixels is determined based on the sum of the absolute differences of the pixels corresponding to the candidate center directions of adjacent pixels. The confidence level of the candidate center direction of adjacent pixels is negatively correlated with the sum of the absolute differences of the pixels corresponding to the candidate center directions of adjacent pixels. The confidence scores of the center candidate directions of all adjacent pixels are accumulated according to the candidate direction category, and the two candidate directions with the highest confidence scores after accumulation are taken as the front and side candidate directions of the target pixel. The confidence scores of the center candidate directions of all negative adjacent pixels are accumulated according to the candidate direction category, and the two candidate directions with the highest confidence scores after accumulation are taken as the negative candidate directions of the target pixel.

[0011] As can be seen, in the aforementioned orientation adaptive filtering kernel generation method, the extension direction of the image structure at the location of each adjacent pixel is accurately captured by using the candidate center directions of adjacent pixels. Simultaneously, the reliability of the candidate center directions of each adjacent pixel is quantified by the negative correlation between confidence level and the sum of absolute pixel differences. Furthermore, the two candidate directions with the highest accumulated confidence levels from the candidate center directions of positive and negative adjacent pixels can be selected as the positive and negative candidate directions, respectively. By referencing the orientation information of multiple adjacent pixels, orientation misjudgment is avoided, effectively improving the accuracy of image structure orientation determination.

[0012] In some embodiments of this application, before determining the candidate filter kernel corresponding to each candidate path from the preset basic filter kernels, the method further includes: Choose any one of the preset directions as the center direction, any one of the preset directions as the positive side direction, and any one of the preset directions as the negative side direction; By combining the central direction, the positive side direction, and the negative side direction, multiple basic paths can be obtained; For each basic path, obtain the direction kernel for each direction in the basic path. The direction kernel is a weight matrix in which the weights are distributed along the corresponding direction. Based on the position information corresponding to each direction in the basic path, the direction kernel for each direction is superimposed on the initial filter kernel of a preset size to obtain the basic filter kernel corresponding to the basic path.

[0013] As can be seen, in the above-mentioned direction adaptive filter kernel generation method, multiple basic paths covering all possible direction combinations are generated by arbitrarily selecting the center direction, positive side direction and negative side direction from each preset direction, and a basic filter kernel corresponding to each basic path is constructed. Through these basic filter kernels, the orientation of the image structure around the target pixel in different directions can be completely characterized, ensuring the accuracy and comprehensiveness of candidate filter kernel matching.

[0014] In some embodiments of this application, determining the candidate filter kernel corresponding to each candidate path from a preset basic filter kernel includes: For each candidate path, determine the index value corresponding to the candidate path according to the preset index mapping relationship; The basic filter kernel corresponding to the index value in the preset basic filter kernel is used as the candidate filter kernel corresponding to the candidate path.

[0015] As can be seen, in the above-mentioned direction adaptive filter kernel generation method, the correspondence between the three directional combinations of the candidate path and the basic filter kernel can be established through the preset index mapping relationship. This allows for the rapid determination of the candidate filter kernel that matches the directional combination of the candidate path from multiple preset basic filter kernels, ensuring the consistency between the candidate filter kernel and the candidate path in terms of directional combination. This provides a reliable foundation for the subsequent weighted fusion to generate the filter kernel of the target pixel.

[0016] In some embodiments of this application, for each candidate path, the confidence level of the candidate path is determined based on the confidence level of each candidate direction within the candidate path, including: For each candidate path, the confidence scores of each candidate direction in the candidate path are multiplied to obtain the original confidence score of the candidate path; the original confidence score is then subjected to non-linear sharpening to obtain the intermediate confidence score of the candidate path. The intermediate confidence scores of each candidate path are normalized to obtain the confidence scores of each candidate path.

[0017] As can be seen, in the above-mentioned direction adaptive filter kernel generation method, the original confidence score is obtained by multiplying the confidence scores of multiple candidate directions in the candidate path. This allows the confidence score of the candidate path to comprehensively reflect the credibility of the center candidate direction, the positive side candidate direction, and the negative side candidate direction. Furthermore, by performing nonlinear sharpening processing on the original confidence score, the direction selectivity of the filter kernel is enhanced, and the accuracy of the filtering is improved.

[0018] According to a second aspect of the embodiments of this application, a direction-adaptive filter kernel generation apparatus is provided, comprising: The acquisition module is used to acquire the target image; The determination module is used to determine multiple candidate center directions of the target pixel and the confidence level of each candidate center direction for each target pixel in the target image, based on the gradient information of the pixels in the neighborhood of the target pixel in each preset direction. The determining module is also used to determine the neighboring pixels of the target pixel in each center candidate direction, including positive side neighboring pixels and negative side neighboring pixels; The determination module is also used to determine multiple positive candidate directions, multiple negative candidate directions, the confidence level of each positive candidate direction, and the confidence level of each negative candidate direction of the target pixel based on the gradient information of the pixels in the neighborhood of each adjacent pixel in each preset direction. The combination module is also used to combine multiple center candidate directions, multiple positive side candidate directions and multiple negative side candidate directions to obtain multiple candidate paths. The candidate paths represent the overall orientation of the local image structure around the target pixel. The determination module is also used to determine the candidate filter kernel corresponding to each candidate path from the preset basic filter kernels; and for each candidate path, determine the confidence level of the candidate path based on the confidence level of each candidate direction in the candidate path. The filter kernel generation module is used to perform a weighted summation operation on each candidate filter kernel based on the confidence level of each candidate path, so as to obtain the filter kernel corresponding to the target pixel.

[0019] According to a third aspect of the embodiments of this application, a computer device is provided, the computer device including a processor and a memory, the memory being used to store at least one program, the at least one program being loaded by the processor and executed by any of the above-described directional adaptive filter kernel generation methods.

[0020] According to a fourth aspect of the embodiments of this application, a computer-readable storage medium is provided, wherein at least one program is stored in the computer-readable storage medium, and the at least one program is loaded and executed by a processor to implement any of the above-described directional adaptive filter kernel generation methods.

[0021] As can be seen, in the above-mentioned direction-adaptive filter kernel generation method, multiple candidate center directions and their confidence levels can be determined based on the gradient information of the pixels in the neighborhood of the target pixel in each preset direction. Positive and negative adjacent pixels are determined on both sides of each candidate center direction. Then, multiple positive and negative candidate directions and their corresponding confidence levels are determined based on the gradient information of the pixels in the neighborhood of each adjacent pixel in each preset direction. The candidate center directions, positive and negative candidate directions and their corresponding confidence levels are then combined to obtain multiple candidate paths. The confidence level of each candidate path is determined based on the confidence level of each direction in the candidate path. Finally, the candidate filter kernels corresponding to the candidate paths are weighted and summed according to the confidence level of each candidate path to obtain the filter kernel corresponding to the target pixel.

[0022] Therefore, the above-mentioned adaptive filtering kernel generation method can obtain candidate paths that can not only represent straight lines, but also complex directions such as corners, broken lines, and asymmetrical corners by combining the central candidate direction, positive side candidate direction, and negative side candidate direction. This improves the accuracy of image structure direction description. Furthermore, by performing a weighted summation operation on the candidate filtering kernel based on the confidence of each candidate path, the obtained filtering kernel can more accurately represent the actual local image structure around the target pixel, thereby improving the effects of operations such as denoising, sharpening, edge detection, or text enhancement. Attached Figure Description

[0023] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying 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.

[0024] Figure 1 A flowchart illustrating a direction-adaptive filter kernel generation method provided in an embodiment of this application; Figure 2 A schematic diagram illustrating a candidate orientation provided in an embodiment of this application; Figure 3 This is a schematic diagram of the structure of a direction-adaptive filter kernel generation device provided in an embodiment of this application; Figure 4 This is a schematic diagram of the structure of a terminal provided in an embodiment of this application; Figure 5 This is a schematic diagram of the structure of a server provided in an embodiment of this application. Detailed Implementation

[0025] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0026] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application.

[0027] In this application, the terms "first," "second," etc., are used to distinguish identical or similar items that have essentially the same function. It should be understood that there is no logical or temporal dependency between "first," "second," and "nth," nor does it limit the quantity or execution order. It should also be understood that although the following description uses the terms "first," "second," etc., to describe various objects, these objects should not be limited by the terms.

[0028] These terms are simply used to distinguish one object from another. For example, without departing from the various examples, a first action can be called a second action, and similarly, a second action can be called a first action. Both the first and second actions can be actions, and in some cases, they can be separate and distinct actions.

[0029] "At least one" refers to one or more actions. For example, at least one action can be one action, two actions, three actions, or any integer number of actions greater than or equal to one. "Multiple" refers to two or more actions. For example, multiple actions can be two actions, three actions, or any integer number of actions greater than or equal to two.

[0030] In the field of image processing technology, it is often necessary to perform operations such as denoising, sharpening, edge detection, or text enhancement on images. In related techniques, a main direction for the edge or line extension within a local window is typically determined first, and a linear band-shaped filter kernel is generated along this main direction. Then, convolution operations are performed based on this filter kernel to achieve operations such as denoising, sharpening, edge detection, or text enhancement. However, when the image contains complex local image structures such as the corners of text strokes, small-scale polyline edges, or asymmetrical corners, a linear band-shaped filter kernel generated along a single direction cannot accurately reflect the actual local image structure around the current pixel, resulting in poor performance in denoising, sharpening, edge detection, or text enhancement operations.

[0031] To address the aforementioned technical problems, this application provides a method for generating a direction-adaptive filter kernel, which can obtain a filter kernel that accurately represents the actual local image structure around the target pixel, thereby improving the effects of operations such as denoising, sharpening, edge detection, or text enhancement.

[0032] Figure 1 This is a flowchart illustrating a direction-adaptive filter kernel generation method provided in an embodiment of this application. The following is a summary of the process. Figure 1The method for generating a directional adaptive filter kernel is described in detail below. The execution subject of this method can be a terminal device with image processing capabilities, such as a smartphone, tablet computer, or digital camera, or a server that communicates with these terminal devices. The method for generating a directional adaptive filter kernel is described below with the terminal device as the execution subject. The method for generating a directional adaptive filter kernel can include steps S101 to S107, as detailed below.

[0033] S101, acquire the target image.

[0034] The target image can be any image that requires operations such as denoising, sharpening, edge detection, or text enhancement. For example, the target image can be an original image obtained by an image acquisition device, or an image that has undergone preprocessing such as demosaicing, white balance, and gamma correction. This application embodiment does not limit this.

[0035] S102, for each target pixel in the target image, based on the gradient information of the pixels in the neighborhood of the target pixel in each preset direction, determine multiple candidate center directions of the target pixel and the confidence level of each candidate center direction.

[0036] The target pixel is the pixel currently being processed. In this embodiment, by traversing each target pixel in the target image, a filter kernel corresponding to each target pixel is generated. Then, a convolution operation is performed on the target image based on the filter kernel to achieve operations such as denoising, sharpening, edge detection, or text enhancement of the target image.

[0037] The neighborhood of a target pixel refers to a local region centered on the target pixel. The size of this neighborhood can be set according to actual needs, and is usually 3×3.

[0038] The preset direction is a pre-defined set of directions. For example, the preset direction may include four directions: horizontal, vertical, upper right diagonal, and lower right diagonal. It may also include more granular direction divisions, which are not limited in this embodiment.

[0039] Gradient information is used to characterize the intensity and direction of pixel value changes along preset directions. For example, gradient information can be calculated using the Sobel operator, Prewitt operator, or difference method, and this application embodiment does not limit this method.

[0040] Since there may be multiple edges or lines with different directions around a target pixel, gradient information in different directions can reflect the intensity of changes in the image structure in that direction. Directions with weaker gradient information (i.e., smaller gradient magnitudes) indicate that the pixel value changes more gently in that direction, and are more likely to correspond to the extension direction of the image structure.

[0041] Therefore, based on the gradient information in each preset direction, multiple possible extension directions of the image structure in the neighborhood of the target pixel can be determined as center candidate directions. Based on the gradient information in the corresponding direction, the confidence level of each center candidate direction can be determined. This confidence level can characterize the degree of credibility of the existence of image structure in the corresponding direction.

[0042] S103, determine the neighboring pixels of the target pixel in each center candidate direction, including positive side neighboring pixels and negative side neighboring pixels.

[0043] For each candidate center direction, the terminal device can determine the positive adjacent pixels along one side of that direction and the negative adjacent pixels along the other side. The positive and negative adjacent pixels are located on either side of the target pixel along the candidate center direction, respectively. By determining the positive and negative adjacent pixels, the terminal device can obtain information about the extension direction of the image structure over a wider range.

[0044] S104, based on the gradient information of the pixels in the neighborhood of each adjacent pixel in each preset direction, determine multiple positive candidate directions, multiple negative candidate directions, the confidence level of each positive candidate direction, and the confidence level of each negative candidate direction for the target pixel.

[0045] The neighborhood of adjacent pixels is the same size as the neighborhood of the target pixel, and the preset direction here is also the same as the preset direction mentioned above.

[0046] Since there may be multiple edges or lines with different orientations within the neighborhood of adjacent pixels, multiple positive and negative candidate directions can be determined based on the gradient information of pixels in each neighboring pixel's neighborhood in each preset direction, in order to cover the various image structure orientations that may exist within the neighborhood of adjacent pixels.

[0047] Positive candidate directions characterize the extension direction of the image structure within the neighborhood of positively adjacent pixels, while negative candidate directions characterize the extension direction of the image structure within the neighborhood of negatively adjacent pixels. Each positive candidate direction corresponds to a confidence level, which characterizes the degree of confidence that an image structure exists in that direction; the same applies to each negative candidate direction.

[0048] Furthermore, the confidence level of each positive candidate direction and each negative candidate direction can be determined based on the gradient information in the corresponding direction.

[0049] S105 combines multiple center candidate directions, multiple positive side candidate directions, and multiple negative side candidate directions to obtain multiple candidate paths. The candidate paths represent the overall orientation of the local image structure around the target pixel.

[0050] The terminal device can traverse all combinations of multiple central candidate directions, multiple positive side candidate directions, and multiple negative side candidate directions to obtain multiple candidate paths.

[0051] Specifically, the terminal device can select one central candidate direction from multiple central candidate directions, one positive side candidate direction from multiple positive side candidate directions, and one negative side candidate direction from multiple negative side candidate directions. Then, these three selected directions are combined to obtain a candidate path. That is, a candidate path is a directional path composed of a central candidate direction, one positive side candidate direction, and one negative side candidate direction.

[0052] The center candidate direction represents the extension direction of the image structure within the neighborhood of the target pixel itself, the positive candidate direction represents the extension direction of the image structure within the neighborhood of the positive adjacent pixels, and the negative candidate direction represents the extension direction of the image structure within the neighborhood of the negative adjacent pixels. These three candidate directions, when combined, form a candidate path that represents the overall trend of the local image structure surrounding the target pixel.

[0053] For example, if the central candidate direction, multiple positive side candidate directions, and multiple negative side candidate directions each include two directions, then there are a total of 8 combinations, resulting in 8 candidate paths.

[0054] As can be seen, by combining these three candidate directions, multiple different candidate paths can be obtained to cover various complex structural orientations that may exist around the target pixel. When the three directions are consistent, the candidate path is a straight line, which can represent the edge of a straight line. When the three directions are not completely consistent, the candidate path forms a broken line, which can represent complex structures such as corners and broken lines.

[0055] S106, determine the candidate filter kernel corresponding to each candidate path from the preset basic filter kernel; for each candidate path, determine the confidence level of the candidate path based on the confidence level of each candidate direction in the candidate path.

[0056] The basic filter kernel consists of multiple pre-defined filter kernel templates. The size of the basic filter kernel can typically be 5×5, and each basic filter kernel corresponds to a possible path.

[0057] For example, if the center candidate direction, the positive side candidate direction, and the negative side candidate direction each have four possibilities, namely: horizontal, vertical, upper right diagonal, and lower right diagonal, then the combination of these three candidate directions can form 64 possible direction paths. Therefore, 64 basic filter kernels can be preset, and each basic filter kernel corresponds to one possible path.

[0058] The terminal device can determine a candidate filter kernel corresponding to each candidate path from a preset base filter kernel. The size of the candidate filter kernel is the same as the size of the base filter kernel. The weight distribution of the candidate filter kernel corresponding to the candidate path matches the image structure direction represented by the candidate path. For example, when the candidate path is a straight line, the weight of the corresponding candidate filter kernel is distributed along the straight line direction. When the candidate path is a broken line, the weight of the corresponding candidate filter kernel is distributed along the broken line direction.

[0059] Furthermore, for each candidate path, the terminal device can also determine the confidence level of the candidate path based on the confidence level of each candidate direction in the candidate path. This confidence level is used to characterize the credibility of the image structure orientation corresponding to the candidate path.

[0060] S107. Based on the confidence level of each candidate path, perform a weighted summation operation on each candidate filter kernel to obtain the filter kernel corresponding to the target pixel.

[0061] After determining the confidence level of each candidate path, a weighted summation can be performed on each candidate filter kernel. Specifically, a weighted summation operation can be performed on the weight values ​​at the same position in each candidate filter kernel to obtain the filter kernel corresponding to the target pixel.

[0062] During the weighted summation operation on each candidate filter kernel, the confidence level of the candidate path can be used as the weight coefficient of the corresponding candidate filter kernel to perform the weighted summation operation and obtain the filter kernel corresponding to the target pixel, as shown in the following formula.

[0063]

[0064] in, Indicates position The filter kernel for the target pixel at that location. Indicates position The confidence score of the i-th candidate path for the target pixel at the given location. Indicates position The candidate filter kernel corresponding to the i-th candidate path of the target pixel at the given location.

[0065] By using a weighted summation method, candidate filter kernels corresponding to candidate paths with higher confidence levels occupy a larger weight proportion in the final filter kernel, while candidate filter kernels corresponding to candidate paths with lower confidence levels occupy a smaller weight proportion. In this way, the final filter kernel can comprehensively reflect the information of various image structure orientations around the target pixel, while highlighting image structure orientations with higher confidence levels, thereby better preserving the detailed information of image structure in subsequent filtering processes.

[0066] After determining the filter kernel corresponding to each target pixel in the target image, the target pixels in the target image can be filtered based on the filter kernel corresponding to each target pixel to obtain the filtered image, thereby realizing operations such as noise reduction, sharpening, edge detection or text enhancement of the target image.

[0067] As can be seen, in the above-mentioned direction-adaptive filter kernel generation method, multiple candidate center directions and their confidence levels can be determined based on the gradient information of the pixels in the neighborhood of the target pixel in each preset direction. Positive and negative adjacent pixels are determined on both sides of each candidate center direction. Then, multiple positive and negative candidate directions and their corresponding confidence levels are determined based on the gradient information of the pixels in the neighborhood of each adjacent pixel in each preset direction. The candidate center directions, positive and negative candidate directions and their corresponding confidence levels are then combined to obtain multiple candidate paths. The confidence level of each candidate path is determined based on the confidence level of each direction in the candidate path. Finally, the candidate filter kernels corresponding to the candidate paths are weighted and summed according to the confidence level of each candidate path to obtain the filter kernel corresponding to the target pixel.

[0068] Therefore, the above-mentioned adaptive filtering kernel generation method can obtain candidate paths that can not only represent straight lines, but also complex directions such as corners, broken lines, and asymmetrical corners by combining the central candidate direction, positive side candidate direction, and negative side candidate direction. This improves the accuracy of image structure direction description. Furthermore, by performing a weighted summation operation on the candidate filtering kernel based on the confidence of each candidate path, the obtained filtering kernel can more accurately represent the actual local image structure around the target pixel, thereby improving the effects of operations such as denoising, sharpening, edge detection, or text enhancement.

[0069] In some embodiments of this application, S102 relates to a process where, for each target pixel in a target image, the terminal device can determine multiple candidate center directions and the confidence level of each candidate center direction based on the gradient information of the neighboring pixels of the target pixel in each preset direction. S102 may include S1021 to S1023, as follows: S1021, for each target pixel in the target image, calculate the sum of the absolute pixel differences between every two neighboring pixels in each preset direction within the neighborhood of the target pixel.

[0070] For each preset direction, the terminal device can traverse the pixels in the neighborhood of the target pixel along that direction, calculate the absolute difference between the pixel values ​​of every two neighboring pixels in that direction, and sum all the absolute differences to obtain the sum of the absolute differences of pixels corresponding to that preset direction.

[0071] The smaller the sum of absolute pixel differences, the more gradual the change in pixel value along that direction, and the more likely that direction is the extension direction of image structure (e.g., edges or lines). The larger the sum of absolute pixel differences, the more drastic the change in pixel value along that direction, and the more likely that direction is perpendicular to the extension direction of image structure.

[0072] S1022, select the two preset directions with the smallest sum of absolute pixel differences as the center candidate directions of the target pixel.

[0073] Then, the two preset directions with the smallest sum of absolute pixel differences can be selected as candidate center directions. For example, if the sum of absolute pixel differences corresponding to the four preset directions is as follows: the sum of absolute pixel differences for the horizontal direction is 10, the sum of absolute pixel differences for the vertical direction is 3, the sum of absolute pixel differences for the upper right diagonal direction is 5, and the sum of absolute pixel differences for the lower right diagonal direction is 15, the two directions with the smallest sum of absolute pixel differences are the vertical direction and the upper right diagonal direction, and the vertical direction and the upper right diagonal direction are selected as candidate center directions for the target pixel.

[0074] S1023, for each candidate center direction, determine the confidence level of the candidate center direction based on the sum of the absolute differences of the pixels corresponding to the candidate center direction, wherein the confidence level of the candidate center direction is negatively correlated with the sum of the absolute differences of the pixels corresponding to the candidate center direction.

[0075] The smaller the sum of the absolute pixel differences, the more likely that direction is an extension of the image structure. Therefore, the confidence level is negatively correlated with the sum of the absolute pixel differences. That is, the smaller the sum of the absolute pixel differences, the higher the confidence level; the larger the sum of the absolute pixel differences, the lower the confidence level.

[0076] For example, the sum of absolute pixel differences can be converted into a corresponding confidence level by taking the reciprocal of the sum of absolute pixel differences, taking the opposite of the sum, and then normalizing. This application does not limit the specific conversion method. Continuing with the previous example, the candidate center directions of the target pixel are the vertical direction and the upper right diagonal direction, respectively. The confidence level of the vertical direction is 0.4, and the confidence level of the upper right diagonal direction is 0.5.

[0077] As can be seen, the above-mentioned direction-adaptive filter kernel generation method can determine the center candidate direction and the confidence level corresponding to the center candidate direction based on the absolute pixel difference of neighboring pixels in each preset direction. In this way, it can accurately determine the multiple possible extension directions of the image structure in the neighborhood of the target pixel and their confidence level, providing a reliable directional basis for the subsequent generation of candidate paths and filter kernels.

[0078] In some embodiments of this application, the preset directions include a horizontal direction, a vertical direction, a right-upper diagonal direction, and a right-downper diagonal direction. When the center candidate direction is horizontal, the positive adjacent pixel is the pixel to the right of the target pixel, and the negative adjacent pixel is the pixel to the left of the target pixel. When the center candidate direction is vertical, the positive adjacent pixel is the pixel below the target pixel, and the negative adjacent pixel is the pixel above the target pixel. When the center candidate direction is right-upper diagonal, the positive adjacent pixel is the pixel to the upper right of the target pixel, and the negative adjacent pixel is the pixel to the lower left of the target pixel. When the center candidate direction is right-downper diagonal, the positive adjacent pixel is the pixel to the lower right of the target pixel, and the negative adjacent pixel is the pixel to the upper left of the target pixel.

[0079] It should be noted that the above definition of positive and negative sides is only an example, and the specific definition of positive and negative sides in this application embodiment is not limited. For example, in other embodiments, the positive side in the horizontal direction can also be defined as the left side and the negative side as the right side.

[0080] As can be seen, in the above-mentioned direction adaptive filter kernel generation method, each preset direction is set to the horizontal direction, the vertical direction, the upper right diagonal direction, and the lower right diagonal direction, so as to cover the common edge or line extension directions in the image.

[0081] In some embodiments of this application, S104 is involved. The terminal device can determine multiple positive candidate directions, multiple negative candidate directions, the confidence level of each positive candidate direction and the confidence level of each negative candidate direction based on the gradient information of the pixels in the neighborhood of each adjacent pixel in each preset direction. S104 may include: S1041 to S1044, as follows.

[0082] S1041, for each adjacent pixel, calculate the sum of the absolute pixel differences between every two neighboring pixels in each preset direction within the neighborhood of the adjacent pixel; and select the two preset directions with the smallest sum of absolute pixel differences as the candidate center directions of the adjacent pixels.

[0083] S1042, for each candidate center direction of adjacent pixels, the confidence level of the candidate center direction of adjacent pixels is determined based on the sum of the absolute differences of the pixels corresponding to the candidate center directions of adjacent pixels. The confidence level of the candidate center direction of adjacent pixels is negatively correlated with the sum of the absolute differences of the pixels corresponding to the candidate center directions of adjacent pixels.

[0084] Similar to the processing logic for the target pixel, for each adjacent pixel, the terminal device can calculate the sum of the absolute pixel differences between every two neighboring pixels in each preset direction within the neighborhood of that adjacent pixel, and select the two preset directions with the smallest sum of absolute pixel differences as the candidate center directions for that adjacent pixel. The smaller the sum of absolute pixel differences, the more gradual the change in pixel value along that direction, and the more likely that direction is the extension direction of the image structure at the location of that adjacent pixel.

[0085] Then, for each candidate center direction of each adjacent pixel, the terminal device can determine the confidence level based on the sum of the absolute differences between the pixels corresponding to that candidate center direction. The smaller the sum of the absolute differences between pixels, the higher the confidence level; the larger the sum of the absolute differences between pixels, the lower the confidence level. The confidence level can characterize the degree of confidence that an image structure exists at the location of the adjacent pixel along the corresponding direction.

[0086] S1043, the confidence scores of the center candidate directions of all adjacent pixels are accumulated according to the candidate direction category, and the two candidate directions with the highest confidence scores after accumulation are taken as the front and side candidate directions of the target pixel.

[0087] S1044: The confidence scores of the center candidate directions of all negative adjacent pixels are accumulated according to the candidate direction category, and the two candidate directions with the highest confidence scores after accumulation are taken as the negative candidate directions of the target pixel.

[0088] For example, such as Figure 2 As shown, Figure 2 This is a schematic diagram of a candidate orientation provided in an embodiment of this application.

[0089] like Figure 2 As shown, the target pixel is pixel A. The candidate center directions of pixel A are the vertical direction and the upper right diagonal direction. The adjacent pixels of pixel A in the vertical direction include the positive adjacent pixel D and the negative adjacent pixel E. The adjacent pixels of pixel A in the upper right diagonal direction include the positive adjacent pixel B and the negative adjacent pixel C.

[0090] The candidate center directions for the adjacent pixel D are vertical (confidence 0.2) and upper right diagonal (confidence 0.5), while the candidate center directions for the adjacent pixel B are horizontal (confidence 0.7) and upper right diagonal (confidence 0.6). Then, the candidate directions are accumulated according to their categories. The confidence level for the vertical direction is 0.2, for the horizontal direction it is 0.7, and for the upper right diagonal it is 1.1. The horizontal and upper right diagonal directions with the highest accumulated confidence are selected as the candidate center directions for the target pixel.

[0091] The candidate center directions for the negative adjacent pixel E are the vertical direction (confidence 0.8) and the lower right slant direction (confidence 0.3). The candidate center directions for the negative adjacent pixel C are the vertical direction (confidence 0.4) and the upper right slant direction (confidence 0.7). Then, the candidate directions are accumulated according to their categories. The confidence level after accumulation is 1.2 for the vertical direction, 0.3 for the lower right slant direction, and 0.7 for the upper right slant direction. The vertical direction and the upper right slant direction with the highest accumulated confidence are selected as the negative candidate directions for the target pixel.

[0092] As can be seen, in the aforementioned orientation adaptive filtering kernel generation method, the extension direction of the image structure at the location of each adjacent pixel is accurately captured by using the candidate center directions of adjacent pixels. Simultaneously, the reliability of the candidate center directions of each adjacent pixel is quantified by the negative correlation between confidence level and the sum of absolute pixel differences. Furthermore, the two candidate directions with the highest accumulated confidence levels from the candidate center directions of positive and negative adjacent pixels can be selected as the positive and negative candidate directions, respectively. By referencing the orientation information of multiple adjacent pixels, orientation misjudgment is avoided, effectively improving the accuracy of image structure orientation determination.

[0093] In some embodiments of this application, S106 is involved. Before determining the candidate filter kernel, the terminal device can also pre-generate the basic filter kernel. Based on this, before S106, S108 to S1010 can also be included, as follows.

[0094] S108, arbitrarily select one direction from each preset direction as the center direction, arbitrarily select one direction as the positive side direction, and arbitrarily select one direction as the negative side direction.

[0095] S109 combines the center direction, positive side direction, and negative side direction to obtain multiple basic paths.

[0096] The preset directions are the same as those in the steps above. The terminal device can arbitrarily select one of the preset directions as the center direction, one as the positive side direction, and one as the negative side direction. The selection of the three directions is independent of each other. Then, the center direction, positive side direction, and negative side direction can be combined to obtain multiple basic paths.

[0097] With the preset directions including horizontal, vertical, upper right diagonal, and lower right diagonal, 64 combinations can be formed. By traversing all possible combinations, it is possible to cover all possible orientations of the image structure surrounding the target pixel in different directions, providing a complete set of basic filter kernels for subsequent candidate path matching.

[0098] S1010: For each basic path, obtain the direction kernel for each direction in the basic path. The direction kernel is a weight matrix in which the weights are distributed along the corresponding direction. Based on the position information corresponding to each direction in the basic path, superimpose the direction kernel of each direction onto the initial filter kernel of a preset size to obtain the basic filter kernel corresponding to the basic path.

[0099] The directional kernel is a weight matrix where weights are distributed along a corresponding direction. This distribution means that only positions along that direction have non-zero weight values, while the weights at other positions are zero. The directional kernel is typically a 3×3 weight matrix, with weights distributed only along the corresponding direction. The initial filter kernel is typically a 5×5 zero matrix centered at the target pixel.

[0100] For each basic path, the terminal device can obtain three direction kernels: the direction kernel for the center direction, the direction kernel for the positive side direction, and the direction kernel for the negative side direction in the basic path.

[0101] Then, the terminal device can superimpose the direction kernel of each direction onto the initial filter kernel of a preset size based on the position information corresponding to each direction in the basic path, so as to obtain the basic filter kernel corresponding to the basic path.

[0102] Specifically, the center-direction direction kernels can be anchored at the target pixel location (i.e., the center of the initial filter kernel) and superimposed. Specifically, the center element of the center-direction direction kernels can be aligned with the center of the initial filter kernel for superposition, thus representing the filtering response at the target pixel along the center direction. The positive-side direction kernels can be anchored at the positive-side adjacent pixel locations along the center direction and superimposed, thus representing the filtering response of the target pixel's positive-side adjacent region along the positive-side direction. The negative-side direction kernels can be anchored at the negative-side adjacent pixel locations along the center direction and superimposed, thus representing the filtering response of the target pixel's negative-side adjacent region along the negative-side direction.

[0103] For example, suppose the center direction of a certain basic path is vertical, the positive side direction is horizontal, and the negative side direction is upper right diagonal. Then, the vertical direction kernel is a 3×3 matrix, with weights distributed along the vertical direction and anchored at the center position of the initial filter kernel (i.e., row 3, column 3) for superposition. The horizontal direction kernel is a 3×3 matrix, with weights distributed along the horizontal direction and anchored at the adjacent positive position in the vertical direction (i.e., the adjacent position below the center position, row 4, column 3) for superposition. The upper right diagonal direction kernel is a 3×3 matrix, with weights distributed along the upper right diagonal direction and anchored at the adjacent negative position in the vertical direction (i.e., the adjacent position above the center position, row 2, column 3) for superposition.

[0104] It should be noted that if some weights exceed the range of the initial filter kernel during the superposition process, the excess weights can be discarded directly. After superposition, the terminal device can also normalize the entire basic filter kernel so that the sum of all weight values ​​in the basic filter kernel is 1, ensuring the numerical stability of the filtering operation.

[0105] As can be seen, in the above-mentioned direction adaptive filter kernel generation method, multiple basic paths covering all possible direction combinations are generated by arbitrarily selecting the center direction, positive side direction and negative side direction from each preset direction, and a basic filter kernel corresponding to each basic path is constructed. Through these basic filter kernels, the orientation of the image structure around the target pixel in different directions can be completely characterized, ensuring the accuracy and comprehensiveness of candidate filter kernel matching.

[0106] In some embodiments of this application, S106 is involved, in which the terminal device can determine the candidate filter kernel corresponding to each candidate path from the preset basic filter kernel. S106 may include S1061 and S1062, as follows.

[0107] S1061, For each candidate path, determine the index value corresponding to the candidate path according to the preset index mapping relationship.

[0108] S1062, the basic filter kernel corresponding to the index value in the preset basic filter kernel is used as the candidate filter kernel corresponding to the candidate path.

[0109] A candidate path is composed of a candidate center direction, a positive side candidate direction, and a negative side candidate direction. A basic path is composed of a center direction, a positive side direction, and a negative side direction. A preset index mapping relationship is used to map the three directions in the candidate path and the basic path to an index value.

[0110] For example, the preset directions, including the horizontal direction, vertical direction, upper right diagonal direction, and lower right diagonal direction, can be numbered as 0, 1, 2, and 3 respectively, and the preset index mapping relationship is as follows:

[0111]

[0112] in, The number indicating the center direction or candidate center direction. The number indicates the positive or side direction or a candidate positive or side direction. The number indicating the negative side direction or negative side candidate direction. Indicates the index value of the base path or candidate path.

[0113] When generating the basic filter kernel corresponding to each basic path, the terminal device can calculate the index value of the basic path according to the above index mapping relationship, and store the basic filter kernel according to the index value, so that the basic filter kernel and the index value correspond one-to-one.

[0114] For each candidate path, the terminal device can determine the index value corresponding to that candidate path based on the aforementioned preset index mapping relationship. After determining the index value of each candidate path, the terminal device can retrieve the basic filter kernel corresponding to that index value from the stored basic filter kernels and use it as the candidate filter kernel for that candidate path.

[0115] As can be seen, in the above-mentioned direction adaptive filter kernel generation method, the correspondence between the three directional combinations of the candidate path and the basic filter kernel can be established through the preset index mapping relationship. This allows for the rapid determination of the candidate filter kernel that matches the directional combination of the candidate path from multiple preset basic filter kernels, ensuring the consistency between the candidate filter kernel and the candidate path in terms of directional combination. This provides a reliable foundation for the subsequent weighted fusion to generate the filter kernel of the target pixel.

[0116] In some embodiments of this application, S106 is involved, whereby the terminal device can determine the confidence level of each candidate path based on the confidence level of each candidate direction in the candidate path. S106 may include S1061 and S1062, as follows.

[0117] S1061, for each candidate path, multiply the confidence scores of each candidate direction in the candidate path to obtain the original confidence score of the candidate path; perform non-linear sharpening processing on the original confidence score to obtain the intermediate confidence score of the candidate path.

[0118] Each candidate path consists of a candidate center direction, a positive side candidate direction, and a negative side candidate direction, each with its own confidence level. The terminal device can multiply the confidence levels of the candidate center direction, the positive side candidate direction, and the negative side candidate direction in the candidate path to obtain the original confidence level of the candidate path.

[0119] Then, the original confidence score can be non-linearly sharpened to obtain the intermediate confidence score of the candidate path, which is given by the following formula.

[0120]

[0121] in, This represents the initial confidence level of the candidate path. Indicates taking The maximum value in, This indicates the preset sharpening intensity control parameter. This parameter is a positive number, for example, it can be 2.0, or it can be set to other positive numbers depending on the application scenario. This represents the intermediate confidence level of the candidate path. That is, the terminal device can first take the maximum value between the original confidence level and zero, and then perform a power operation on the result after taking the maximum value, where the exponent of the power operation is a preset sharpening intensity control parameter.

[0122] The nonlinear sharpening process described above can widen the confidence difference between different candidate paths, thereby highlighting the contribution of the main path while suppressing the interference of the secondary path and enhancing the directional selectivity of the filter kernel.

[0123] S1062, normalize the intermediate confidence scores of each candidate path to obtain the confidence score of each candidate path.

[0124] Then, the terminal device can normalize the intermediate confidence scores of all candidate paths for the target pixel so that the sum of the confidence scores of all candidate paths is 1, and finally obtain the confidence score of each candidate path.

[0125] As can be seen, in the above-mentioned direction adaptive filter kernel generation method, the original confidence score is obtained by multiplying the confidence scores of multiple candidate directions in the candidate path. This allows the confidence score of the candidate path to comprehensively reflect the credibility of the center candidate direction, the positive side candidate direction, and the negative side candidate direction. Furthermore, by performing nonlinear sharpening processing on the original confidence score, the direction selectivity of the filter kernel is enhanced, and the accuracy of the filtering is improved.

[0126] Therefore, the above-mentioned adaptive filtering kernel generation method can obtain candidate paths that can not only represent straight lines, but also complex directions such as corners, broken lines, and asymmetrical corners by combining the central candidate direction, positive side candidate direction, and negative side candidate direction. This improves the accuracy of image structure direction description. Furthermore, by performing a weighted summation operation on the candidate filtering kernel based on the confidence of each candidate path, the obtained filtering kernel can more accurately represent the actual local image structure around the target pixel, thereby improving the effects of operations such as denoising, sharpening, edge detection, or text enhancement.

[0127] Embodiments of this application also provide a direction-adaptive filter kernel generation device, such as... Figure 3 As shown, Figure 3 This is a schematic diagram of a direction-adaptive filter kernel generation device provided in an embodiment of this application. The direction-adaptive filter kernel generation device 300 can be deployed on terminal devices with image processing capabilities, such as smartphones, tablets, and digital cameras, or on a server communicatively connected to these terminal devices. The direction-adaptive filter kernel generation device 300 includes: Acquisition module 301 is used to acquire the target image; The determination module 302 is used to determine multiple candidate center directions of the target pixel and the confidence level of each candidate center direction for each target pixel in the target image, based on the gradient information of the pixels in the neighborhood of the target pixel in each preset direction. The determining module 302 is further configured to determine the neighboring pixels of the target pixel in each center candidate direction, the neighboring pixels including positive side neighboring pixels and negative side neighboring pixels; The determining module 302 is further configured to determine multiple positive candidate directions, multiple negative candidate directions, the confidence level of each positive candidate direction, and the confidence level of each negative candidate direction of the target pixel based on the gradient information of the pixels in the neighborhood of each adjacent pixel in each preset direction. The combination module 303 is used to combine multiple center candidate directions, multiple positive side candidate directions and multiple negative side candidate directions to obtain multiple candidate paths. The candidate paths represent the overall orientation of the local image structure around the target pixel. The determining module 302 is further configured to: determine the candidate filter kernel corresponding to each candidate path from the preset basic filter kernels; and for each candidate path, determine the confidence level of the candidate path based on the confidence level of each candidate direction in the candidate path. The filter kernel generation module 304 is used to perform a weighted summation operation on each candidate filter kernel according to the confidence level of each candidate path to obtain the filter kernel corresponding to the target pixel.

[0128] In some embodiments of this application, the determining module 302 is specifically used to: calculate, for each target pixel in the target image, the sum of absolute pixel differences between every two neighboring pixels in each preset direction within the neighborhood of the target pixel; select the two preset directions with the smallest sum of absolute pixel differences as candidate center directions for the target pixel; and for each candidate center direction, determine the confidence level of the candidate center direction based on the sum of absolute pixel differences corresponding to the candidate center direction, wherein the confidence level of the candidate center direction is negatively correlated with the sum of absolute pixel differences corresponding to the candidate center direction.

[0129] In some embodiments of this application, each preset direction includes a horizontal direction, a vertical direction, a right-upper diagonal direction, and a right-lower diagonal direction. When the center candidate direction is horizontal, the positive adjacent pixel is the adjacent pixel to the right of the target pixel, and the negative adjacent pixel is the adjacent pixel to the left of the target pixel. When the center candidate direction is vertical, the positive adjacent pixel is the adjacent pixel below the target pixel, and the negative adjacent pixel is the adjacent pixel above the target pixel. When the center candidate direction is right-upper diagonal, the positive adjacent pixel is the adjacent pixel to the upper right of the target pixel, and the negative adjacent pixel is the adjacent pixel to the lower left of the target pixel. When the center candidate direction is right-lower diagonal, the positive adjacent pixel is the adjacent pixel to the lower right of the target pixel, and the negative adjacent pixel is the adjacent pixel to the upper left of the target pixel.

[0130] In some embodiments of this application, the determining module 302 is specifically configured to: calculate, for each adjacent pixel, the sum of absolute pixel differences between every two neighboring pixels in each preset direction within the neighborhood of the adjacent pixel; select the two preset directions with the smallest sum of absolute pixel differences as candidate center directions for the adjacent pixels; for each candidate center direction of the adjacent pixels, determine the confidence level of the candidate center direction of the adjacent pixels based on the sum of absolute pixel differences corresponding to the candidate center directions of the adjacent pixels, wherein the confidence level of the candidate center direction of the adjacent pixels is negatively correlated with the sum of absolute pixel differences corresponding to the candidate center directions of the adjacent pixels; accumulate the confidence levels of the candidate center directions of all positive adjacent pixels according to the candidate direction category, and select the two candidate directions with the highest confidence after accumulation as the positive candidate directions of the target pixel; accumulate the confidence levels of the candidate center directions of all negative adjacent pixels according to the candidate direction category, and select the two candidate directions with the highest confidence after accumulation as the negative candidate directions of the target pixel.

[0131] In some embodiments of this application, the combination module 303 is further configured to: arbitrarily select one direction from each preset direction as the center direction, arbitrarily select one direction as the positive side direction, and arbitrarily select one direction as the negative side direction; combine the center direction, the positive side direction, and the negative side direction to obtain multiple basic paths; for each basic path, obtain the direction kernel of each direction in the basic path, where the direction kernel is a weight matrix with weights distributed along the corresponding direction; and according to the position information corresponding to each direction in the basic path, superimpose the direction kernel of each direction onto an initial filter kernel of a preset size to obtain the basic filter kernel corresponding to the basic path.

[0132] In some embodiments of this application, the determining module 302 is specifically used to determine the index value corresponding to each candidate path according to a preset index mapping relationship; and to use the basic filter kernel corresponding to the index value in the preset basic filter kernel as the candidate filter kernel corresponding to the candidate path.

[0133] In some embodiments of this application, the determining module 302 is specifically used to: for each candidate path, multiply the confidence scores of each candidate direction in the candidate path to obtain the original confidence score of the candidate path; perform nonlinear sharpening processing on the original confidence scores to obtain the intermediate confidence scores of the candidate paths; and perform normalization processing on the intermediate confidence scores of each candidate path to obtain the confidence scores of each candidate path.

[0134] Embodiments of this application also provide a computer device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement any of the above-described directional adaptive filter kernel generation methods.

[0135] Taking computer devices as terminals as an example, Figure 4 A schematic diagram of the structure of a terminal provided in an embodiment of this application is shown below. Figure 4 In some embodiments of this application, terminal 400 may be a smartphone, tablet computer, MP3 player (Moving Picture Experts Group Audio Layer III), MP4 player (Moving Picture Experts Group Audio Layer IV), laptop computer, or desktop computer. Terminal 300 may also be referred to as user equipment, portable terminal, laptop terminal, desktop terminal, or other names.

[0136] Typically, terminal 400 includes a processor 401 and a memory 402.

[0137] In some embodiments of this application, processor 401 may include one or more processing cores, such as a quad-core processor, a penta-core processor, etc. Processor 401 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). Processor 401 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 401 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 401 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.

[0138] The memory 402 may include one or more computer-readable storage media, which may be non-transitory. The memory 402 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 402 are used to store at least one program code, which is executed by the processor 401 to implement the process of terminal execution in the method embodiments of this application.

[0139] In some embodiments, the terminal 400 may also optionally include a peripheral device interface 403 and at least one peripheral device. The processor 401, memory 402, and peripheral device interface 403 can be connected via a bus or signal line. Each peripheral device can be connected to the peripheral device interface 403 via a bus, signal line, or circuit board. Specifically, the peripheral device includes at least one of a display screen 404, a camera assembly 405, an audio circuit 406, and a power supply 407.

[0140] Peripheral device interface 403 can be used to connect at least one I / O (Input / Output) related peripheral device to processor 401 and memory 402. In some embodiments, processor 401, memory 402 and peripheral device interface 403 are integrated on the same chip or circuit board; in some other embodiments, any one or two of processor 401, memory 402 and peripheral device interface 403 can be implemented on separate chips or circuit boards, and this application embodiment does not limit this.

[0141] Display screen 404 is used to display a UI (User Interface). This UI may include graphics, text, icons, videos, and any combination thereof. When display screen 404 is a touch display screen, it also has the ability to collect touch signals on or above its surface. These touch signals can be input as control signals to processor 401 for processing. In this case, display screen 404 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there may be one display screen 404, disposed on the front panel of terminal 400; in other embodiments, there may be at least two display screens, disposed on different surfaces of terminal 400 or in a folded design; in other embodiments, display screen 404 may be a flexible display screen, disposed on a curved or folded surface of terminal 400. Furthermore, display screen 404 may be configured as a non-rectangular, irregular shape, i.e., a non-rectangular screen. Display screen 404 may be made of materials such as LCD (Liquid Crystal Display) or OLED (Organic Light-Emitting Diode).

[0142] The camera assembly 405 is used to acquire images or videos. In some embodiments, the camera assembly 405 includes a front-facing camera and a rear-facing camera. Typically, the front-facing camera is located on the front panel of the terminal, and the rear-facing camera is located on the back of the terminal. In some embodiments, there are at least two rear-facing cameras, which are any one of a main camera, a depth-sensing camera, a wide-angle camera, and a telephoto camera, to achieve background blurring by fusion of the main camera and the depth-sensing camera, panoramic shooting by fusion of the main camera and the wide-angle camera, VR (Virtual Reality) shooting, or other fusion shooting functions. In some embodiments, the camera assembly 405 may also include a flash. The flash can be a single-color temperature flash or a dual-color temperature flash. A dual-color temperature flash is a combination of a warm-light flash and a cool-light flash, which can be used for light compensation at different color temperatures.

[0143] The audio circuit 406 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals which are then input to the processor 401 for processing. For stereo sound acquisition or noise reduction purposes, multiple microphones may be used, each positioned at a different location on the terminal 400. The microphone may also be an array microphone or an omnidirectional microphone. The speaker is used to convert the electrical signals from the processor 401 into sound waves. The speaker may be a conventional diaphragm speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can convert electrical signals not only into audible sound waves but also into inaudible sound waves for purposes such as distance measurement. In some embodiments, the audio circuit 406 may also include a headphone jack.

[0144] Power supply 407 is used to power the various components in terminal 400. Power supply 407 can be AC ​​power, DC power, a disposable battery, or a rechargeable battery. When power supply 407 includes a rechargeable battery, the rechargeable battery can support wired or wireless charging. The rechargeable battery can also be used to support fast charging technology.

[0145] Those skilled in the art will understand that Figure 4 The structure shown does not constitute a limitation on terminal 400 and may include more or fewer components than shown, or combine certain components, or use different component arrangements.

[0146] Taking computer equipment as a server as an example, Figure 5 This is a schematic diagram of a server structure provided in an embodiment of this application. The server 500 can vary significantly due to different configurations or performance. It may include one or more processors 501 (Central Processing Units, CPUs) and one or more memories 502. The one or more memories 502 store at least one computer program, which is loaded and executed by the one or more processors 501 to implement the aforementioned image noise reduction method. Of course, the server 500 may also have wired or wireless network interfaces, a keyboard, and input / output interfaces for input and output. The server 500 may also include other components for implementing device functions, which will not be elaborated upon here.

[0147] Embodiments of this application also provide a computer-readable storage medium, which includes a stored computer program, wherein the computer program, when running, controls the device where the computer-readable storage medium is located to perform the method described above. Optionally, the computer-readable storage medium may be read-only memory (ROM), random access memory (RAM), compact-disc read-only memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device, etc.

[0148] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0149] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A method for generating a directional adaptive filter kernel, characterized in that, include: Acquire the target image; For each target pixel in the target image, based on the gradient information of the neighboring pixels of the target pixel in each preset direction, multiple candidate center directions of the target pixel and the confidence level of each candidate center direction are determined. The neighboring pixels of the target pixel in each center candidate direction are determined, and the neighboring pixels include positive side neighboring pixels and negative side neighboring pixels; Based on the gradient information of the pixels in the neighborhood of each adjacent pixel in each preset direction, determine multiple positive candidate directions, multiple negative candidate directions, the confidence level of each positive candidate direction, and the confidence level of each negative candidate direction for the target pixel. The multiple center candidate directions, the multiple positive side candidate directions, and the multiple negative side candidate directions are combined to obtain multiple candidate paths, and the candidate paths represent the overall orientation of the local image structure around the target pixel; Determine the candidate filter kernel corresponding to each candidate path from the preset basic filter kernels; For each candidate path, the confidence level of the candidate path is determined based on the confidence level of each candidate direction in the candidate path. Based on the confidence level of each candidate path, a weighted summation operation is performed on each candidate filter kernel to obtain the filter kernel corresponding to the target pixel.

2. The method according to claim 1, characterized in that, For each target pixel in the target image, determining multiple candidate center directions and the confidence level of each candidate center direction based on the gradient information of neighboring pixels in each preset direction includes: For each target pixel in the target image, calculate the sum of the absolute pixel differences between every two neighboring pixels in every preset direction within the neighborhood of the target pixel; The two preset directions with the smallest sum of the absolute differences between the pixels are selected as the center candidate directions of the target pixel; For each candidate center direction, the confidence level of the candidate center direction is determined based on the sum of the absolute differences of the pixels corresponding to the candidate center direction, wherein the confidence level of the candidate center direction is negatively correlated with the sum of the absolute differences of the pixels corresponding to the candidate center direction.

3. The method according to claim 1, characterized in that, The preset directions include the horizontal direction, the vertical direction, the upper right diagonal direction, and the lower right diagonal direction; When the center candidate direction is the horizontal direction, the positive side adjacent pixel is the pixel to the right of the target pixel, and the negative side adjacent pixel is the pixel to the left of the target pixel; When the center candidate direction is the vertical direction, the positive side adjacent pixel is the adjacent pixel below the target pixel, and the negative side adjacent pixel is the adjacent pixel above the target pixel; When the center candidate direction is the upper right diagonal direction, the positive side adjacent pixel is the adjacent pixel to the upper right of the target pixel, and the negative side adjacent pixel is the adjacent pixel to the lower left of the target pixel; When the center candidate direction is the lower right slant direction, the positive side adjacent pixel is the adjacent pixel to the lower right of the target pixel, and the negative side adjacent pixel is the adjacent pixel to the upper left of the target pixel.

4. The method according to claim 1, characterized in that, The step of determining multiple positive candidate directions, multiple negative candidate directions, the confidence level of each positive candidate direction, and the confidence level of each negative candidate direction based on the gradient information of the neighboring pixels of each adjacent pixel in each preset direction includes: For each adjacent pixel, calculate the sum of absolute pixel differences between every two neighboring pixels in each preset direction within the neighborhood of the adjacent pixel; select the two preset directions with the smallest sum of absolute pixel differences as candidate center directions for the adjacent pixels; For each candidate center direction of adjacent pixels, the confidence level of the candidate center direction of adjacent pixels is determined based on the sum of the absolute differences of the pixels corresponding to the candidate center directions of adjacent pixels. The confidence level of the candidate center direction of adjacent pixels is negatively correlated with the sum of the absolute differences of the pixels corresponding to the candidate center directions of adjacent pixels. The confidence scores of the center candidate directions of all adjacent pixels on the front and side are accumulated according to the candidate direction category, and the two candidate directions with the highest confidence scores after accumulation are taken as the front and side candidate directions of the target pixel. The confidence scores of the center candidate directions of all negatively adjacent pixels are accumulated according to the candidate direction category, and the two candidate directions with the highest confidence scores after accumulation are taken as the negatively adjacent candidate directions of the target pixel.

5. The method according to claim 1, characterized in that, Before determining the candidate filter kernel corresponding to each candidate path from the preset basic filter kernels, the method further includes: Choose any one of the preset directions as the center direction, any one of the preset directions as the positive side direction, and any one of the preset directions as the negative side direction; By combining the central direction, the positive side direction, and the negative side direction, multiple basic paths are obtained; For each basic path, obtain the direction kernel for each direction in the basic path. The direction kernel is a weight matrix in which the weights are distributed along the corresponding direction. Based on the position information corresponding to each direction in the basic path, superimpose the direction kernel of each direction onto an initial filter kernel of a preset size to obtain the basic filter kernel corresponding to the basic path.

6. The method according to claim 1, characterized in that, The step of determining the candidate filter kernel corresponding to each candidate path from the preset basic filter kernels includes: For each candidate path, an index value corresponding to the candidate path is determined according to a preset index mapping relationship; The basic filter kernel corresponding to the index value in the preset basic filter kernel is used as the candidate filter kernel corresponding to the candidate path.

7. The method according to claim 1, characterized in that, For each candidate path, determining the confidence level of the candidate path based on the confidence level of each candidate direction within the candidate path includes: For each candidate path, the confidence scores of each candidate direction in the candidate path are multiplied to obtain the original confidence score of the candidate path; the original confidence score is then subjected to non-linear sharpening to obtain the intermediate confidence score of the candidate path. The intermediate confidence scores of each candidate path are normalized to obtain the confidence scores of each candidate path.

8. A direction-adaptive filter kernel generation device, characterized in that, include: The acquisition module is used to acquire the target image; The determination module is used to determine, for each target pixel in the target image, multiple candidate center directions of the target pixel and the confidence level of each candidate center direction based on the gradient information of the neighboring pixels of the target pixel in each preset direction. The determining module is further configured to determine the neighboring pixels of the target pixel in each center candidate direction, wherein the neighboring pixels include positive side neighboring pixels and negative side neighboring pixels; The determining module is further configured to determine multiple positive candidate directions, multiple negative candidate directions, the confidence level of each positive candidate direction, and the confidence level of each negative candidate direction of the target pixel based on the gradient information of the pixels in the neighborhood of each adjacent pixel in each preset direction. The combination module is used to combine the multiple center candidate directions, the multiple positive side candidate directions, and the multiple negative side candidate directions to obtain multiple candidate paths, wherein the candidate paths represent the overall orientation of the local image structure around the target pixel; The determining module is further configured to determine a candidate filter kernel corresponding to each candidate path from a preset basic filter kernel; For each candidate path, the confidence level of the candidate path is determined based on the confidence level of each candidate direction in the candidate path. The filter kernel generation module is used to perform a weighted summation operation on each candidate filter kernel based on the confidence level of each candidate path to obtain the filter kernel corresponding to the target pixel.

9. A computer device, characterized in that, The computer device includes a processor and a memory, the memory being used to store at least one program, the at least one program being loaded by the processor and executed as described in any one of claims 1 to 7, the directional adaptive filter kernel generation method.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one program, which is loaded and executed by a processor to implement the directional adaptive filter kernel generation method as described in any one of claims 1 to 7.