CN-116309654-B - Upsampling method, upsampling device, electronic device and storage medium
Abstract
The application discloses an up-sampling method, an up-sampling device, electronic equipment and a computer readable storage medium based on multi-type edge detection. The up-sampling method comprises the steps of carrying out edge detection on an input image by adopting a plurality of different types of edge detection modes to obtain detection results, determining a weight value corresponding to each original pixel of the input image in an interpolation range according to the detection results, determining an interpolation mode for carrying out interpolation processing on the input image according to the detection results, and carrying out interpolation processing on the input image according to the interpolation mode and the weight value corresponding to each original pixel to obtain a target image. According to the up-sampling method, the up-sampling device, the electronic equipment and the computer readable storage medium based on multi-type edge detection, which are disclosed by the embodiment of the application, the input image is subjected to edge detection in a plurality of different types of edge detection modes, so that the accuracy of the edge detection can be improved, and fewer artifacts are generated in the image after up-sampling.
Inventors
- SHU WENTING
Assignees
- OPPO广东移动通信有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20220907
Claims (17)
- 1. An up-sampling method based on multi-type edge detection for outputting a target image from an input image, the up-sampling method comprising: Performing edge detection on the input image by adopting a plurality of different types of edge detection modes to obtain detection results, wherein the edge detection is performed on the input image by adopting a first edge detection mode to obtain an edge type; Determining a weight value corresponding to each original pixel of the input image in an interpolation range according to the detection result, wherein the weight value corresponding to each original pixel is determined according to the first image gradient and the second image gradient; determining an interpolation mode for carrying out interpolation processing on the input image according to the detection result, wherein the interpolation mode is determined according to the edge type; And carrying out interpolation processing on the input image according to the interpolation mode and the weight value corresponding to each original pixel to obtain the target image.
- 2. The up-sampling method according to claim 1, wherein the target image includes a plurality of target pixels, corresponding positions of the target pixels in the input image are center pixels, and the edge detection is performed on the input image by using a first edge detection method to obtain an edge type, including: determining a first local area within a first predetermined range around the center pixel; calculating the current gradient amplitude of the first local area; calculating the current edge direction of the first local area; and determining the edge type according to the current gradient amplitude and the current edge direction.
- 3. The upsampling method of claim 2, wherein the first local area comprises a plurality of local sub-areas, the calculating a current gradient magnitude of the first local area comprising: respectively calculating a subarea horizontal gradient amplitude value and a subarea vertical gradient amplitude value of each local subarea according to a preset image gradient algorithm and pixel values of a plurality of original pixels in each local subarea; Determining the subarea gradient amplitude of the local subarea according to the subarea horizontal gradient amplitude and the subarea vertical gradient amplitude, and taking the subarea gradient amplitudes of a plurality of local subareas as the current gradient amplitude; the calculating the current edge direction of the first local area includes: determining the sub-region edge direction of the local sub-region according to the sub-region horizontal gradient amplitude and the sub-region vertical gradient amplitude, and taking the sub-region edge directions of a plurality of local sub-regions as the current edge direction; the determining the edge type according to the current gradient amplitude and the current edge direction comprises the following steps: and determining the edge type according to the subarea gradient amplitude values of the local subareas and the subarea edge directions.
- 4. The upsampling method of claim 3, wherein said determining said edge type from said sub-region gradient magnitudes and said sub-region edge directions for a plurality of said local sub-regions comprises: comparing the gradient amplitude of the subarea with a gradient amplitude threshold; when the gradient amplitude value of the subarea is larger than the gradient amplitude threshold value, taking the local subarea corresponding to the gradient amplitude value of the subarea as an edge pixel; judging an edge region and/or an extension region, to which the edge direction of the sub-region corresponding to the edge pixel belongs; counting the number of the edge pixels in each edge region and/or the extension region to obtain the edge region and/or the extension region with the largest number of the edge pixels; Determining the pixel ratio of the edge area and/or the extension area with the largest number of the edge pixels; and when the pixel ratio of the edge area is larger than a first proportion threshold value and/or the pixel ratio of the extension area is larger than a second proportion threshold value, judging that the edge type is the edge direction type corresponding to the edge area and/or the extension area.
- 5. The up-sampling method according to claim 1, wherein the target image includes a plurality of target pixels, corresponding positions of the target pixels in the input image are center pixels, and the edge detection of the input image by using the second edge detection method to obtain the first image gradient includes: determining a first local area within a first predetermined range around the center pixel; selecting a local direction region in the first local region towards a plurality of different directions respectively; determining first-direction image gradients corresponding to the local-direction regions in each direction respectively, and taking the first-direction image gradients corresponding to the local-direction regions in a plurality of different directions as the first image gradients; the edge detection of the input image by adopting the third edge detection mode to obtain a second image gradient includes: Determining a second local area within a second predetermined range around the center pixel, wherein the second predetermined range is smaller than the first predetermined range; determining second-direction image gradients of the second local area facing a plurality of different directions respectively, and taking the second-direction image gradients of the plurality of different directions as the second image gradients; The determining the weight value corresponding to each original pixel according to the first image gradient and the second image gradient includes: and determining the weight value corresponding to the original pixel in each direction according to the first direction image gradient and the second direction image gradient corresponding to a plurality of different directions.
- 6. The upsampling method according to claim 4, wherein said determining the interpolation scheme according to the edge type comprises: After the edge type is determined, determining the current confidence corresponding to the edge type according to the pixel duty ratio of the edge area and/or the pixel duty ratio of the extension area; When the current confidence coefficient is in a first confidence coefficient interval, adopting an interpolation mode of a bicubic interpolation algorithm; when the current confidence coefficient is in a second confidence coefficient interval, adopting an interpolation mode of interpolation along a plurality of different directions; when the current confidence coefficient is in a third confidence coefficient interval, an interpolation mode of interpolation is adopted along the edge direction determined by the edge type; the confidence degrees corresponding to the first confidence coefficient interval, the second confidence coefficient interval and the third confidence coefficient interval are sequentially increased.
- 7. The up-sampling method according to claim 5, wherein the edge detection is performed on the input image by using a plurality of different types of edge detection methods to obtain a detection result, further comprising: determining an edge degree according to the second direction image gradients of the second local area facing a plurality of different directions; The interpolating the input image according to the interpolation mode and the weight value corresponding to each original pixel to obtain the target image includes: Performing interpolation processing on the input image by adopting an interpolation mode of a bicubic interpolation algorithm and a weight value corresponding to each original pixel to obtain a first interpolation result so as to output the target image, or Interpolation is carried out on the input image by adopting an interpolation mode of interpolation along a plurality of different directions and a weight value corresponding to each original pixel to obtain a second initial interpolation result; Determining a second interpolation result based on the second initial interpolation result, the edge degree, and the first interpolation result to output the target image, or Interpolation is carried out on the input image by adopting an interpolation mode of interpolation along the edge direction determined by the edge type and a weight value corresponding to each original pixel to obtain a third initial interpolation result; And determining a third interpolation result according to the third initial interpolation result, the edge degree and the first interpolation result so as to output the target image.
- 8. The upsampling method of claim 1, wherein the target image comprises a plurality of target pixels, corresponding locations of the target pixels in the input image being center pixels, the upsampling method further comprising: determining a first local area within a first predetermined range around the center pixel; Performing pixel statistical analysis on the first local area to obtain pixel information; The determining the weight value corresponding to each original pixel of the input image in the interpolation range according to the detection result comprises the following steps: And determining a weight value corresponding to each original pixel according to the detection result and the pixel information.
- 9. The up-sampling method according to claim 5, wherein the determining the weight value corresponding to each of the original pixels according to the first image gradient and the second image gradient further comprises: after determining the weight value corresponding to the original pixel in each direction according to the first direction image gradient and the second direction image gradient corresponding to the plurality of different directions, adjusting the weight value corresponding to the original pixel in each direction according to the pixel information of the first local area.
- 10. The up-sampling method according to claim 7, wherein the performing edge detection on the input image by using a plurality of different types of edge detection methods to obtain a detection result comprises: Determining an attenuation factor of the edge degree according to the pixel information of the first local area; adjusting the edge degree according to the attenuation factor; the determining a second interpolation result according to the second initial interpolation result, the edge degree and the first interpolation result comprises: Determining the second interpolation result according to the second initial interpolation result, the adjusted edge degree and the first interpolation result; The determining a third interpolation result according to the third initial interpolation result, the edge degree and the first interpolation result comprises: And determining the third interpolation result according to the third initial interpolation result, the adjusted edge degree and the first interpolation result.
- 11. The upsampling method according to any one of claims 8-10, wherein the pixel information comprises any one or more of a pixel value mean, a pixel value variance, a pixel value difference of a plurality of the original pixels within the first local area.
- 12. The up-sampling method according to claim 1, wherein the target image includes a plurality of target pixels, corresponding positions of the target pixels in the input image are center pixels, and the edge detection is performed on the input image by using a first edge detection method to obtain an edge type, including: Determining a third local area within a third predetermined range around the central pixel, wherein the third local area comprises a central area, and the central pixel is positioned in the central area; Respectively selecting a plurality of reference areas from the central area towards a plurality of different directions in the third local area; calculating a plurality of absolute difference sums in a plurality of different directions according to pixel values of a plurality of original pixels in the central area and pixel values of a plurality of original pixels in a plurality of reference areas respectively; The edge type is determined from a plurality of the sum of absolute differences in a plurality of different directions.
- 13. The up-sampling method according to claim 1, wherein the performing edge detection on the input image by using a plurality of different types of edge detection modes to obtain a detection result comprises: Performing edge detection on the input image based on the brightness value by adopting a plurality of different types of edge detection modes to obtain a first detection result; The determining the weight value corresponding to each original pixel of the input image in the interpolation range according to the detection result comprises the following steps: and determining a weight value corresponding to each original pixel in the interpolation range according to the first detection result.
- 14. The up-sampling method according to claim 1, wherein the performing edge detection on the input image by using a plurality of different types of edge detection modes to obtain a detection result comprises: Performing edge detection on the input image based on the brightness value by adopting a plurality of different types of edge detection modes to obtain a first detection result; Performing edge detection on the input image based on the chromaticity value to obtain a second detection result; The determining the weight value corresponding to each original pixel of the input image in the interpolation range according to the detection result comprises the following steps: And determining a weight value corresponding to each original pixel in the interpolation range according to the first detection result and the second detection result.
- 15. An upsampling apparatus based on multi-type edge detection for outputting a target image based on an input image, the upsampling apparatus comprising: The edge detection module is used for carrying out edge detection on the input image by adopting a plurality of different types of edge detection modes to obtain detection results, and comprises a first edge detection mode, a second edge detection mode, a third edge detection mode, a first image gradient and a second image gradient, wherein the first edge detection mode is used for carrying out edge detection on the input image to obtain an edge type; The weight determining module is used for determining a weight value corresponding to each original pixel of the input image in an interpolation range according to the detection result, and comprises determining the weight value corresponding to each original pixel according to the first image gradient and the second image gradient; The interpolation selecting module is used for determining an interpolation mode for carrying out interpolation processing on the input image according to the detection result, and comprises the step of determining the interpolation mode according to the edge type; And the interpolation processing module is used for carrying out interpolation processing on the input image according to the interpolation mode and the weight value corresponding to each original pixel to obtain the target image.
- 16. An electronic device comprising one or more processors and a memory storing a computer program that, when executed by the processor, implements the multi-type edge detection based upsampling method of any of claims 1-14.
- 17. A computer readable storage medium having stored thereon a computer program, wherein the program, when executed by a processor, implements the multi-type edge detection based upsampling method of any of claims 1-14.
Description
Upsampling method, upsampling device, electronic device and storage medium Technical Field The present application relates to the field of image processing technologies, and in particular, to an upsampling method, upsampling apparatus, electronic device, and computer readable storage medium based on multi-type edge detection. Background Image upsampling is widely used in various image processing processes, such as digital zooming or image magnification to a specified size. In current image processing, the up-sampling method commonly used in the industry increases the number of pixels of an image, so that the sampling frequency of the image increases, and the up-sampled image generates image content which does not exist, and the image is easy to generate artifacts (artifacts), such as jaggies in the edge direction. Disclosure of Invention The embodiment of the application provides an up-sampling method, an up-sampling device, electronic equipment and a computer readable storage medium based on multi-type edge detection. An up-sampling method based on multi-type edge detection according to an embodiment of the present application is used for outputting a target image according to an input image, and includes: Performing edge detection on the input image by adopting a plurality of different types of edge detection modes to obtain detection results; Determining a weight value corresponding to each original pixel of the input image in the interpolation range according to the detection result; determining an interpolation mode for carrying out interpolation processing on the input image according to the detection result; And carrying out interpolation processing on the input image according to the interpolation mode and the weight value corresponding to each original pixel to obtain the target image. An up-sampling device based on multi-type edge detection according to an embodiment of the present application is configured to output a target image from an input image, and includes: the edge detection module is used for carrying out edge detection on the input image by adopting a plurality of different types of edge detection modes so as to obtain detection results; the weight determining module is used for determining a weight value corresponding to each original pixel of the input image in the interpolation range according to the detection result; The interpolation selecting module is used for determining an interpolation mode for carrying out interpolation processing on the input image according to the detection result; And the interpolation processing module is used for carrying out interpolation processing on the input image according to the interpolation mode and the weight value corresponding to each original pixel to obtain the target image. The electronic device of the embodiment of the application comprises one or more processors and a memory, wherein the memory stores a computer program, and the computer program realizes the upsampling method based on the multi-type edge detection of the embodiment of the application when being executed by the processor. The computer-readable storage medium of the embodiment of the present application has stored thereon a computer program that, when executed by a processor, implements the upsampling method based on multi-type edge detection of the embodiment of the present application. According to the up-sampling method, the up-sampling device, the electronic equipment and the computer readable storage medium based on multi-type edge detection, which are disclosed by the embodiment of the application, the input image is subjected to edge detection in a plurality of different types of edge detection modes, so that the accuracy of the edge detection can be improved, and fewer artifacts are generated in the image after up-sampling. Additional aspects and advantages of embodiments of the application will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of embodiments of the application. Drawings The foregoing and/or additional aspects and advantages of the present application will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings, in which: FIG. 1 is a flow diagram of an upsampling method based on multi-type edge detection according to some embodiments of the present application; FIG. 2 is a block diagram of an upsampling apparatus based on variable filter kernel sizes according to some embodiments of the present application; FIG. 3 is a schematic diagram of an upsampling method based on multi type edge detection according to some embodiments of the present application; FIG. 4 is a flow diagram of an upsampling method based on multi type edge detection according to some embodiments of the present application; FIG. 5 is a flow diagram of an upsampling method based on multi type edge detection acco