CN109934785B - Image sharpening method and device - Google Patents

Image sharpening method and device Download PDF

Info

Publication number
CN109934785B
CN109934785B CN201910186224.9A CN201910186224A CN109934785B CN 109934785 B CN109934785 B CN 109934785B CN 201910186224 A CN201910186224 A CN 201910186224A CN 109934785 B CN109934785 B CN 109934785B
Authority
CN
China
Prior art keywords
value
target pixel
image
target
pixel point
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910186224.9A
Other languages
Chinese (zh)
Other versions
CN109934785A (en
Inventor
何琦
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hunan Goke Microelectronics Co Ltd
Original Assignee
Hunan Goke Microelectronics Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hunan Goke Microelectronics Co Ltd filed Critical Hunan Goke Microelectronics Co Ltd
Priority to CN201910186224.9A priority Critical patent/CN109934785B/en
Publication of CN109934785A publication Critical patent/CN109934785A/en
Application granted granted Critical
Publication of CN109934785B publication Critical patent/CN109934785B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Image Processing (AREA)

Abstract

The invention relates to the technical field of image processing, and provides an image sharpening method and device, wherein the method comprises the following steps: obtaining a first sharpening strength of a target pixel point based on a pixel value according to the image pixel average value and the target pixel average value; obtaining a second sharpening strength of the target pixel point based on the gradient value according to the image gradient value and the target gradient value; adjusting the pixel value of the target pixel point according to the first sharpening strength and the second sharpening strength to obtain a target pixel value corresponding to the target pixel point; and updating the pixel value of each target pixel point to a target pixel value corresponding to each target pixel point, and generating a sharpened image. Compared with the prior art, the image sharpening method and the image sharpening device provided by the invention solve the problems that in the prior art, the sharpened image has saw teeth at a strong edge and the sharpening strength of a weak edge is insufficient.

Description

Image sharpening method and device
Technical Field
The invention relates to the technical field of image processing, in particular to an image sharpening method and device.
Background
The image shot by the camera is affected by shooting conditions such as insufficient illumination, non-optimal angle and the like, and the obtained image scene is rich and various, and various boundaries such as rich textures, edges with obvious black-white contrast and weak edges of a low-brightness area exist in the image. Common algorithms adopt the same sharpening processing to the boundary types, so that the sharpened image has the problems of saw teeth at strong edges and insufficient sharpening strength at weak edges.
Disclosure of Invention
The invention aims to provide an image sharpening method and device to solve the problems that in the prior art, sharpened images have saw teeth at strong edges and have insufficient sharpening strength at weak edges.
In order to achieve the above purpose, the embodiment of the present invention adopts the following technical solutions:
in a first aspect, an embodiment of the present invention provides an image sharpening method, where the method includes: obtaining a first sharpening strength according to an image pixel mean value and a target pixel mean value, wherein the image pixel mean value is a pixel mean value of all pixel points in an image to be processed, the target pixel mean value is a pixel mean value in a preset window range with a target pixel point as a center, the target pixel point is any pixel point in the image to be processed, and the first sharpening strength is a sharpening strength of the target pixel point based on a pixel value; obtaining a second sharpening strength according to an image gradient value and a target gradient value, wherein the image gradient value is a gradient average value of all pixel points in the image to be processed, the target gradient value is the gradient value of the target pixel point, and the second sharpening strength is the sharpening strength of the target pixel point based on the gradient value; adjusting the pixel value of the target pixel point according to the first sharpening strength and the second sharpening strength to obtain a target pixel value corresponding to the target pixel point; and updating the pixel value of each target pixel point to a target pixel value corresponding to each target pixel point, and generating a sharpened image.
In a second aspect, an embodiment of the present invention provides an image sharpening device, where the device includes: the processing module is used for obtaining a first sharpening strength according to an image pixel mean value and a target pixel mean value, wherein the image pixel mean value is a pixel mean value of all pixel points in an image to be processed, the target pixel mean value is a pixel mean value in a preset window range with a target pixel point as a center, the target pixel point is any pixel point in the image to be processed, and the first sharpening strength is a sharpening strength of the target pixel point based on a pixel value; obtaining a second sharpening strength according to an image gradient value and a target gradient value, wherein the image gradient value is a gradient average value of all pixel points in the image to be processed, the target gradient value is the gradient value of the target pixel point, and the second sharpening strength is the sharpening strength of the target pixel point based on the gradient value; adjusting the pixel value of the target pixel point according to the first sharpening strength and the second sharpening strength to obtain a target pixel value corresponding to the target pixel point; and the generating module is used for updating the pixel value of each target pixel point to a target pixel value corresponding to each target pixel point, and generating a sharpened image.
Compared with the prior art, the embodiment of the invention has the following beneficial effects:
according to the image sharpening method and device provided by the embodiment of the invention, the first sharpening strength of the target pixel point based on the pixel value is obtained through the image pixel mean value and the target pixel mean value, the second sharpening strength of the target pixel point based on the gradient value is obtained through the image gradient value and the target gradient value, the pixel value of the target pixel point is adjusted according to the first sharpening strength and the second sharpening strength to obtain the target pixel value corresponding to the target pixel point, and the pixel value of each target pixel point in the image to be processed is updated to be the target pixel value so as to generate the sharpened image. The method comprises the steps of sharpening pixel points in an image to be processed to different degrees based on pixel values and gradient values so as to solve the problems that in the prior art, sharpened images have saw teeth at strong edges and weak edges have insufficient sharpening strength.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention, and therefore should not be considered as limiting the scope, and for a user of ordinary skill in the art, other related drawings can be obtained according to these drawings without creative efforts.
Fig. 1 shows a schematic structural diagram of a part of an electronic device provided by an embodiment of the present invention.
Fig. 2 shows a flowchart of an image sharpening method according to an embodiment of the present invention.
Fig. 3 is a flowchart illustrating another image sharpening method according to an embodiment of the present invention.
Fig. 4 is a block diagram illustrating an image sharpening device according to an embodiment of the present invention.
Icon: 100-an electronic device; 101-a processor; 102-a memory; 103-a bus; 104-a communication interface; 105-a display screen; 300-image sharpening means; 301-a processing module; 302-generation module.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be obtained by a user skilled in the art without inventive work based on the embodiments of the present invention, are within the scope of protection of the present invention.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. Meanwhile, in the description of the present invention, the terms "first", "second", and the like are used only for distinguishing the description, and are not to be construed as indicating or implying relative importance.
The images shot by the monitoring camera are affected by shooting conditions, such as insufficient illumination, non-optimal angles and the like, detail information in the images is often not optimal, the difficulty of adjusting lens focusing by non-professionals is increased, and meanwhile, subsequent processing such as edge detection is also affected.
A common sharpening algorithm usually selects a two-dimensional template to perform convolution on the whole frame of image, extracts and increases the high-frequency component, and then adds the amplified high-frequency component to the low-frequency image to achieve the effect of enhancing the edge. The actually acquired image scenes are rich and various, and various boundaries exist in the image, such as rich textures, edges with obvious black-white contrast, and weak edges of areas with low brightness. Common algorithms adopt the same processing for the boundary types, so that the sharpened image has the problems of saw teeth at strong edges and insufficient sharpening strength at weak edges.
When the video monitoring image is enhanced, one or more statistical characteristics can be referred to, so that the enhancement of noise is effectively avoided, and a better visual effect is provided. Automatic sharpening can be achieved by specifying the relationship between brightness and sharpening intensity in a light box. However, there is a great difference between the actual environment for acquiring the monitored image and the light box, and the relationship between the brightness and the sharpening intensity cannot be accurately described by the calibrated data. Secondly, the perception of the sharpening strength by the human eye is caused by contrast, and the perception of the gradient information of various strengths in the image is not linear, so that the gradient information of the image also needs to be considered when the sharpening is carried out automatically.
The technical problem to be solved by the present invention is to provide an image sharpening method, which has a core improvement point in that pixel points in an image to be processed are sharpened to different degrees based on pixel values and gradient values, so as to solve the problems that in the prior art, sharpened images have saw teeth at strong edges and weak edges have insufficient sharpening strength.
The image sharpening method provided by the embodiment of the present invention is applied to the electronic device 100, and the electronic device 100 may be, but is not limited to, a smart phone, a tablet computer, a personal computer, an in-vehicle computer, a Personal Digital Assistant (PDA), and the like. Referring to fig. 1, fig. 1 is a schematic diagram illustrating a partial structure of an electronic device according to an embodiment of the present invention, where the electronic device 100 includes a processor 101, a memory 102, a bus 103, a communication interface 104, and a display screen 105. The processor 101, the memory 102, the communication interface 104 and the display screen 105 are connected by a bus 103, and the processor 101 is configured to execute executable modules, such as computer programs, stored in the memory 102.
The processor 101 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the image sharpening method may be performed by integrated logic circuits of hardware or instructions in the form of software in the processor 101. The Processor 101 may be a general-purpose Processor 101, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
The Memory 102 may comprise a high-speed Random Access Memory (RAM) and may also include a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. The Memory 102 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Read-Only Memory (EPROM), an electrically Erasable Read-Only Memory (EEPROM), and the like.
The bus 103 may be an ISA (Industry Standard architecture) bus, a PCI (peripheral Component interconnect) bus, an EISA (extended Industry Standard architecture) bus, or the like. Only one bi-directional arrow is shown in fig. 1, but this does not indicate only one bus 103 or one type of bus 103.
The electronic device 100 implements a communication connection between the electronic device 100 and an external device through at least one communication interface 104 (which may be wired or wireless). Memory 102 is used to store programs, such as image sharpening device 300. Image sharpening device 300 includes at least one software functional module that may be stored in memory 102 in the form of software or firmware (firmware) or solidified in an Operating System (OS) of electronic device 100. The processor 101 executes the program to implement the image sharpening method after receiving the execution instruction.
The display screen 105 is used to display an image, which may be the result of some processing by the processor 101. The display screen 105 may be a touch display screen, a display screen without interactive functionality, or the like. The display screen 105 can display the image to be processed and the sharpened image.
It should be understood that the configuration shown in fig. 1 is merely a schematic application of the configuration of the electronic device 100, and that the electronic device 100 may also include more or fewer components than shown in fig. 1, or have a different configuration than shown in fig. 1. The components shown in fig. 1 may be implemented in hardware, software, or a combination thereof.
Based on the electronic device 100, a possible implementation manner of an image sharpening method is given below, an execution subject of the method may be the electronic device 100, please refer to fig. 2, and fig. 2 shows a flowchart of an image sharpening method according to an embodiment of the present invention. The image sharpening method comprises the following steps:
s110, obtaining a first sharpening strength according to the image pixel average value and the target pixel average value.
The image pixel mean value is the pixel mean value of all pixel points in the image to be processed, the target pixel mean value is the pixel mean value in a preset window range with the target pixel point as the center, the target pixel point is any pixel point in the image to be processed, and the first sharpening strength is the sharpening strength of the target pixel point based on the pixel value;
s210, obtaining a second sharpening strength according to the image gradient value and the target gradient value.
The image gradient value is the average gradient value of all pixel points in the image to be processed, the target gradient value is the gradient value of the target pixel point, and the second sharpening strength is the sharpening strength of the target pixel point based on the gradient value;
s310, adjusting the pixel value of the target pixel point according to the first sharpening strength and the second sharpening strength to obtain a target pixel value corresponding to the target pixel point;
and S410, updating the pixel value of each target pixel point to a target pixel value corresponding to each target pixel point, and generating a sharpened image.
According to the image sharpening method provided by the embodiment of the invention, the first sharpening strength of the target pixel point based on the pixel value is obtained through the image pixel mean value and the target pixel mean value, the second sharpening strength of the target pixel point based on the gradient value is obtained through the image gradient value and the target gradient value, the pixel value of the target pixel point is adjusted according to the first sharpening strength and the second sharpening strength, the target pixel value corresponding to the target pixel point is obtained, and the pixel value of each target pixel point in the image to be processed is updated to be the target pixel value, so that a sharpened image is generated. The sharpening of different degrees is carried out on the pixel points in the image to be processed based on the pixel values and the gradient values, so that the problems that in the prior art, the sharpened image has saw teeth at a strong edge and the sharpening strength of a weak edge is insufficient are solved.
In order to execute step S110 to obtain the first sharpening strength according to the image pixel mean value and the target pixel mean value, a possible implementation manner for obtaining the image pixel mean value of the image to be processed and the target pixel mean value of the target pixel point is given below:
the image to be processed may be obtained by shooting through a camera, may be pre-stored in the memory 102 of the electronic device 100, or may be an image sent by another external device received by the communication interface 104. The image pixel mean value may be an average pixel value of all pixel points in the image to be processed, the target pixel mean value may be an average pixel value of all pixel points within a preset window range with the target pixel point as a center, and the target pixel point may be any pixel point in the image to be processed, which may be understood as a currently processed pixel point.
The step of obtaining the image pixel mean value of the image to be processed may be understood as adding the pixel values of each pixel point in the image to be processed, and then dividing the sum by the number of all pixel points in the image to be processed to obtain the image pixel mean value of the image to be processed.
The step of obtaining the target pixel mean value of the target pixel point may be understood as obtaining pixel values of all pixel points within a preset window range with respect to the center of the target pixel point, and then processing the number of all pixel points within the preset window range, so as to obtain the target pixel mean value of the target pixel point. The preset window is a rectangular window with a target pixel point as the center, and the size of the preset window can be customized, for example, a 3 × 3 window, a 5 × 5 window, and can also be other (2N +1) × (2N +1) windows.
S110, obtaining a first sharpening strength according to an image pixel mean value and a target pixel mean value, wherein the image pixel mean value is a pixel mean value of all pixel points in the image to be processed, the target pixel mean value is a pixel mean value in a preset window range with the target pixel point as a center, the target pixel point is any pixel point in the image to be processed, and the first sharpening strength is a sharpening strength of the target pixel point based on a pixel value.
In the embodiment of the present invention, the first sharpening strength may be a sharpening strength of the target pixel point based on a pixel value, and the step of obtaining the first sharpening strength is performed according to the image pixel mean value and the target pixel mean value, which may be understood as obtaining a first intensity value corresponding to the image pixel mean value according to the image pixel mean value and a corresponding relationship between the image pixel mean value and the first intensity value, and then obtaining the first sharpening strength corresponding to the target pixel mean value according to the target pixel mean value and a gaussian function, where an input parameter of the gaussian function includes the first intensity value, and the gaussian function represents the corresponding relationship between the target pixel mean value and the first sharpening strength.
Further, a sharpened image is generated from an image to be processed, a possible implementation manner is provided in this application, and on the basis of fig. 2, fig. 3 is a flowchart of another image sharpening method provided in an embodiment of the present invention:
referring to fig. 3, step S110 may specifically include the following sub-steps:
s111, obtaining a first intensity value corresponding to the image pixel mean value according to the image pixel mean value and the corresponding relation between the image pixel mean value and the first intensity value.
In the embodiment of the present invention, a corresponding relationship between the image pixel mean value and the first intensity value is stored in the electronic device 100 in advance, and the corresponding relationship between the image pixel mean value and the first intensity value may be an exponential relationship, specifically, the image pixel mean value and the first intensity value may be fitted by using an exponential function, so as to determine the first intensity value corresponding to the image pixel mean value, where the first intensity value may be the maximum sharpening intensity based on the pixel value.
And S112, obtaining a first sharpening strength corresponding to the target pixel mean value according to the target pixel mean value and the Gaussian function.
The parameter of the Gaussian function comprises a first intensity value, and the Gaussian function represents the corresponding relation between the target pixel mean value and the first sharpening intensity.
In the embodiment of the present invention, the parameter is an input parameter, the parameter of the gaussian function includes a, b, and c, where a is a first intensity value, b is a central coordinate of a peak, c is a standard deviation, the first sharpening intensity is a sharpening intensity of a target pixel point based on a pixel value, and the gaussian function to be determined as the parameter a is pre-stored in the electronic device 100:
Figure BDA0001992955200000091
where a is the first intensity value, b is the center coordinate of the peak, c is the standard deviation, x is the target pixel mean, f (x) is the first sharpening intensity, and b and c are preset in the electronic device 100.
Step S111 may determine the parameter a of the gaussian function, that is, may obtain the determined gaussian function, and bring the target pixel mean value into the gaussian function, that is, may obtain the first sharpening strength corresponding to the target pixel mean value. The sharpening intensity is adjusted through the pixel points in the image to be processed based on the pixel values, and the lower sharpening intensity is used for the low-brightness area in the image to be processed, so that the signal to noise ratio of the image to be processed can be effectively improved, and the whole sharpening of the image to be processed is not influenced because the sensitivity of human eyes to the low-illumination area is low.
In order to execute step S220 to obtain the second sharpening strength according to the image gradient value and the target gradient value, a possible implementation manner for obtaining the image gradient value of the image to be processed and the target gradient value of the target pixel point is provided below, and specifically includes the following sub-steps:
s201, neighborhood pixel points within a preset window range are obtained according to the target pixel points, and the preset window takes the target pixel points as centers.
In the embodiment of the present invention, the preset window is a rectangular window centered on one target pixel, and the size of the preset window may be user-defined, for example, a 3 × 3 window, a 5 × 5 window, or another (2N +1) × (2N +1) window. The neighborhood pixels can be all pixels except the target pixel at the central point position in the preset window range. The step of obtaining the neighborhood pixels within the preset window range may be understood as obtaining all neighborhood pixels within the preset window centered on the target pixel.
S202, calculating a target gradient value of the target pixel point according to the pixel value of the neighborhood pixel point, the pixel value of the target pixel point and a preset gradient operator.
In the embodiment of the present invention, the target gradient value may be a gradient value of a target pixel, and the preset gradient Operator may be an Operator for calculating a gradient value of a pixel, for example, a sobel Operator, a laplacian Operator (Laplace Operator), and the like. And according to the pixel values of the neighborhood pixel points and the pixel value of the target pixel point, the pixel values of all the pixel points in the preset window range can be formed, and the gradient value of the target pixel point, namely the target gradient value, can be obtained by calculating with a preset gradient operator.
As an implementation manner, the preset window range is a 3 × 3 window with the target pixel point as the center, the preset gradient operator is a sobel operator, and the sobel operator respectively represents the target pixel point from the horizontal direction and the vertical direction.
Figure BDA0001992955200000101
Wherein, A represents a preset window, and Gx and Gy represent the detection of transverse and longitudinal edges, respectively. The target gradient value (G) expression is as follows:
Figure BDA0001992955200000102
s203, averaging the target gradient values of all target pixel points in the image to be processed to obtain the image gradient value of the image to be processed.
In the embodiment of the present invention, the image gradient value may be an average gradient value of all pixel points in the image to be processed, and the step of obtaining the image gradient value of the image to be processed may be performed by averaging the target gradient values of all target pixel points in the image to be processed, and may be understood as a step of obtaining the target gradient value of the target pixel point through sub-step S201 and sub-step S202, performing the same processing on each pixel point in the image to be processed to obtain the gradient values of all pixel points in the image to be processed, summing the gradient values of all pixel points, and dividing by the number of all pixel points in the image to be processed to obtain the image gradient value of the image to be processed.
S210, obtaining a second sharpening strength according to the image gradient value and the target gradient value, wherein the image gradient value is a gradient average value of all pixel points in the image to be processed, the target gradient value is a gradient value of the target pixel point, and the second sharpening strength is a sharpening strength of the target pixel point based on the gradient value.
In the embodiment of the present invention, the second sharpening strength is a sharpening strength of the target pixel point based on the gradient value, and the step of obtaining the second sharpening strength is performed according to the image gradient value and the target gradient value, which may be understood as obtaining a second strength value corresponding to the image gradient value according to the image gradient value and a corresponding relationship between the image gradient value and the second strength value, and obtaining a second sharpening strength corresponding to the target gradient value according to the target gradient value and a growth function, where an entry parameter of the growth function includes the second strength value, and the growth function represents the corresponding relationship between the target gradient value and the second sharpening strength.
Step S210 may specifically include the following sub-steps:
s211, obtaining a second intensity value corresponding to the image gradient value according to the image gradient value and the corresponding relation between the image gradient value and the second intensity value.
In the embodiment of the present invention, the electronic device 100 stores a corresponding relationship between the image gradient value and the second intensity value in advance, where the corresponding relationship between the image gradient value and the second intensity value may be a direct proportion relationship, and specifically, the image gradient value and the second intensity value may be fitted by using a direct proportion function, so as to determine the second intensity value corresponding to the image gradient value.
S212, according to the target gradient value and the growth function, a second sharpening strength corresponding to the target gradient value is obtained.
And the parameter of the growth function comprises a second intensity value, and the growth function represents the corresponding relation between the target gradient value and the second sharpening intensity.
In the embodiment of the present invention, the input parameter is an input parameter, the input parameter of the growth function includes M and d, where M is a second intensity value, d is a preset base number, the second sharpening intensity is a sharpening intensity of the target pixel point based on the gradient value, and the growth function to be determined for the input parameter M is pre-stored in the electronic device 100:
Figure BDA0001992955200000121
wherein d is a predetermined base number, y is a target gradient value, f (y) is a second sharpening strength, and M is a second intensity value.
Step S211 may determine the parameter M of the growth function, that is, may obtain the determined growth function, and bring the target gradient value into the growth function, that is, may obtain the second sharpening strength corresponding to the target gradient value. The sharpening strength is adjusted through pixel points in the image to be processed based on the gradient values, low-strength sharpening processing is conducted on a flat area in the image to be processed, slightly low-strength sharpening processing is conducted on a strong edge area in the image to be processed, the highest-strength sharpening processing is conducted on an area with the middle edge strength, and the sharpness improvement of the image to be processed and the balance of the signal-to-noise ratio are guaranteed. The sharpening strength of a strong edge area with a large gradient amplitude is limited to a certain extent, and the sawtooth effect is inhibited. It should be noted that, in other embodiments of the present invention, the execution order of step S110 and step S210 may be exchanged, or step S110 and step S210 may be executed simultaneously, which is not limited herein.
S310, adjusting the pixel value of the target pixel point according to the first sharpening strength and the second sharpening strength to obtain a target pixel value corresponding to the target pixel point.
In the embodiment of the present invention, the target pixel value may be a pixel value obtained by adjusting a pixel value of the target pixel point. Adjusting the pixel value of the target pixel point according to the first sharpening strength and the second sharpening strength to obtain a target pixel value corresponding to the target pixel point, wherein the first sharpening strength and the second sharpening strength are used for calculating the target sharpening strength corresponding to the target pixel point, the second sharpening strength and the second sharpening strength are used for obtaining a neighborhood pixel point within a preset window according to the target pixel point, the preset window takes the target pixel point as the center, the high-frequency component corresponding to the target pixel point is obtained according to the pixel value of the neighborhood pixel point and the pixel value of the target pixel point, the high-frequency component is the measurement of the edge and the contour of the target pixel point in an image to be processed, the high-frequency component is amplified according to the target sharpening strength to obtain a sharpened pixel value, and finally the pixel value of each target pixel point is updated to be the target pixel value corresponding to each target pixel point, and generating a sharpened image.
Step 310 may specifically include the following sub-steps:
s311, calculating the target sharpening intensity corresponding to the target pixel point according to the first sharpening intensity and the second sharpening intensity.
In the embodiment of the present invention, the target sharpening strength may be a sharpening strength of the target pixel point based on the gradient value and the pixel value. And calculating the target sharpening intensity corresponding to the target pixel point according to the first sharpening intensity and the second sharpening intensity, where it is understood that the target sharpening intensity is the first sharpening intensity plus the second sharpening intensity, and the target sharpening intensity corresponding to the target pixel point is obtained by adding the first sharpening intensity obtained in step S110 and the second sharpening intensity obtained in step S210.
S312, neighborhood pixel points within a preset window range are obtained according to the target pixel points, and the preset window takes the target pixel points as centers.
In the embodiment of the present invention, the preset window is a rectangular window centered on one target pixel, and the size of the preset window may be user-defined, for example, a 3 × 3 window, a 5 × 5 window, or another (2N +1) × (2N +1) window. The neighborhood pixels can be all pixels except the target pixel at the central point position in the preset window range. The step of obtaining the neighborhood pixels within the preset window range may be understood as obtaining all neighborhood pixels within the preset window centered on the target pixel.
S313, according to the pixel values of the neighborhood pixel points and the pixel value of the target pixel point, high-frequency components corresponding to the target pixel point are obtained.
And the high-frequency component is the measurement of the edge and the outline of the target pixel point in the image to be processed.
In the embodiment of the invention, the pixel values of all the pixel points in the preset window range can be formed according to the pixel values of the neighborhood pixel points and the target pixel point, and the high-frequency component corresponding to the target pixel point is obtained according to the pixel values of the neighborhood pixel points and the target pixel point. The fuzzy processing is performed on all the pixel points within the preset window range, and the fuzzy processing can be performed by adopting, but not limited to, gaussian fuzzy or mean fuzzy.
The following steps of performing fuzzy processing on all pixel points in a preset window to obtain fuzzy components corresponding to target pixel points are explained by taking gaussian fuzzy as an example:
firstly, obtaining a weight matrix (comprising a plurality of weight values) corresponding to all pixel points in a preset window range, multiplying each pixel point in the preset window by the corresponding weight value to obtain a weight component of each pixel point in the preset window range, and adding all the weight components to obtain a fuzzy component corresponding to a target pixel point.
And S314, amplifying the high-frequency component according to the target sharpening intensity to obtain a sharpened pixel value.
In the embodiment of the present invention, the sharpened pixel value may be a pixel value obtained by amplifying a high-frequency component corresponding to the target pixel point. The step of amplifying the high frequency component according to the target sharpening intensity to obtain the sharpened pixel value may be understood as that, the sharpened pixel value is the high frequency component and the target sharpening intensity, and the sharpened pixel value corresponding to the target pixel point may be obtained by multiplying the target sharpening intensity obtained in the substep S311 and the high frequency component obtained in the substep S313.
And S315, adding the sharpened pixel value and the pixel value of the target pixel point to obtain a target pixel value corresponding to the target pixel point.
In the embodiment of the present invention, the target pixel value may be a pixel value obtained by adjusting a pixel value of the target pixel point. And adding the sharpened pixel value and the pixel value of the target pixel point to obtain a target pixel value corresponding to the target pixel point, wherein the target pixel value is sharpened pixel value + the pixel value of the target pixel point. For example, when the sharpened pixel value is 5 and the pixel value of the target pixel point is 156, the target pixel value is 5+ 156-161.
And S410, updating the pixel value of each target pixel point to a target pixel value corresponding to each target pixel point, and generating a sharpened image.
In the embodiment of the present invention, the sharpened image may be an image generated after sharpening the pixel value of each pixel point in the image to be processed. The step of updating the pixel value of each target pixel point to a target pixel value corresponding to each target pixel point, and generating the sharpened image may be understood as performing the same processing on each (target) pixel point in the image to be processed according to steps S110 to S310 to obtain a target pixel value of each (target) pixel point, and updating the pixel value of each target pixel point in the image to be processed to a target pixel value corresponding to the target pixel value, so as to generate the sharpened image.
The sharpening of different degrees is carried out on the pixel points in the image to be processed based on the pixel values and the gradient values, so that the problems that in the prior art, the sharpened image has saw teeth at a strong edge and the sharpening strength of a weak edge is insufficient are solved.
With reference to the method flows of fig. 2 to fig. 3, a possible implementation manner of an image sharpening device 300 is given below, where the image sharpening device 300 may be implemented by using a device structure of the electronic device 100 in the foregoing embodiment, or implemented by using the processor 101 in the electronic device 100, please refer to fig. 4, and fig. 4 shows a block schematic diagram of the image sharpening device provided in the embodiment of the present invention. Image sharpening device 300 includes a processing module 301 and a generating module 302.
The processing module 301 is configured to obtain a first sharpening strength according to an image pixel mean value and a target pixel mean value, where the image pixel mean value is a pixel mean value of all pixel points in an image to be processed, the target pixel mean value is a pixel mean value within a preset window range with the target pixel point as a center, the target pixel point is any pixel point in the image to be processed, and the first sharpening strength is a sharpening strength of the target pixel point based on a pixel value; obtaining a second sharpening strength according to the image gradient value and the target gradient value, wherein the image gradient value is a gradient average value of all pixel points in the image to be processed, the target gradient value is the gradient value of the target pixel point, and the second sharpening strength is the sharpening strength of the target pixel point based on the gradient value; and adjusting the pixel value of the target pixel point according to the first sharpening strength and the second sharpening strength to obtain a target pixel value corresponding to the target pixel point.
In this embodiment of the present invention, the processing module 301 is further configured to: acquiring neighborhood pixel points within a preset window range according to the target pixel points, wherein the preset window takes the target pixel points as centers; calculating a target gradient value of the target pixel point according to the pixel value of the neighborhood pixel point, the pixel value of the target pixel point and a preset gradient operator; and solving the mean value of the target gradient values of all target pixel points in the image to be processed to obtain the image gradient value of the image to be processed.
The processing module 301 executes a step of obtaining a first sharpening strength according to the image pixel average value and the target pixel average value, and is specifically configured to: obtaining a first intensity value corresponding to the image pixel mean value according to the image pixel mean value and the corresponding relation between the image pixel mean value and the first intensity value; and obtaining a first sharpening strength corresponding to the target pixel mean value according to the target pixel mean value and a Gaussian function, wherein the parameter of the Gaussian function comprises a first intensity value, and the Gaussian function represents the corresponding relation between the target pixel mean value and the first sharpening strength. Specifically, the gaussian function is:
Figure BDA0001992955200000161
where a is the first intensity value, b is the center coordinate of the peak, c is the standard deviation, x is the target pixel mean, and f (x) is the first sharpening intensity.
The processing module 301 executes a step of obtaining a second sharpening strength according to the image gradient value and the target gradient value, and is specifically configured to: obtaining a second intensity value corresponding to the image gradient value according to the image gradient value and the corresponding relation between the image gradient value and the second intensity value; and obtaining a second sharpening strength corresponding to the target gradient value according to the target gradient value and the growth function, wherein the parameter of the growth function comprises a second strength value, and the growth function represents the corresponding relation between the target gradient value and the second sharpening strength. Specifically, the growth function is:
Figure BDA0001992955200000162
wherein d is a predetermined base number, y is a target gradient value, f (y) is a second sharpening strength, and M is a second intensity value.
The processing module 301 executes a step of adjusting the pixel value of the target pixel point according to the first sharpening strength and the second sharpening strength to obtain a target pixel value corresponding to the target pixel point, and is specifically configured to: calculating a target sharpening intensity corresponding to the target pixel point according to the first sharpening intensity and the second sharpening intensity; acquiring neighborhood pixel points within a preset window range according to the target pixel points, wherein the preset window takes the target pixel points as centers; obtaining a high-frequency component corresponding to a target pixel point according to the pixel value of the neighborhood pixel point and the pixel value of the target pixel point, wherein the high-frequency component is the measurement of the edge and the contour of the target pixel point in the image to be processed; amplifying the high-frequency component according to the target sharpening intensity to obtain a sharpened pixel value; and adding the sharpened pixel value and the pixel value of the target pixel point to obtain a target pixel value corresponding to the target pixel point.
The processing module 301 performs a step of obtaining a high-frequency component corresponding to the target pixel point according to the pixel value of the neighborhood pixel point and the pixel value of the target pixel point, and is specifically configured to: according to the pixel values of the neighborhood pixel points and the target pixel point, fuzzy processing is carried out on the target pixel point to obtain fuzzy components corresponding to the target pixel point; and subtracting the pixel value of the target pixel point from the fuzzy component corresponding to the target pixel point to obtain a high-frequency component corresponding to the target pixel point.
A generating module 302, configured to update the pixel value of each target pixel point to a target pixel value corresponding to each target pixel point, and generate a sharpened image.
In summary, an embodiment of the present invention provides an image sharpening method and an image sharpening device, where the method includes: obtaining a first sharpening strength of a target pixel point based on a pixel value according to the image pixel average value and the target pixel average value; obtaining a second sharpening strength of the target pixel point based on the gradient value according to the image gradient value and the target gradient value; adjusting the pixel value of the target pixel point according to the first sharpening strength and the second sharpening strength to obtain a target pixel value corresponding to the target pixel point; and updating the pixel value of each target pixel point to a target pixel value corresponding to each target pixel point, and generating a sharpened image. Compared with the prior art, the invention has the following advantages: the sharpening of different degrees is carried out on the pixel points in the image to be processed based on the pixel values and the gradient values, so that the problems that in the prior art, the sharpened image has saw teeth at a strong edge and the sharpening strength of a weak edge is insufficient are solved.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present invention may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes. It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.

Claims (9)

1. A method of image sharpening, the method comprising:
obtaining a first intensity value corresponding to the image pixel mean value according to the image pixel mean value and the corresponding relation between the image pixel mean value and the first intensity value; obtaining a first sharpening strength corresponding to a target pixel mean value according to the target pixel mean value and a Gaussian function; the input parameter of the gaussian function comprises the first intensity value, the gaussian function represents the corresponding relation between the target pixel mean value and the first sharpening intensity, the image pixel mean value is the pixel mean value of all pixel points in the image to be processed, the target pixel mean value is the pixel mean value in a preset window range with a target pixel point as the center, the target pixel point is any pixel point in the image to be processed, and the first sharpening intensity is the sharpening intensity of the target pixel point based on the pixel value;
obtaining a second sharpening strength according to an image gradient value and a target gradient value, wherein the image gradient value is a gradient average value of all pixel points in the image to be processed, the target gradient value is the gradient value of the target pixel point, and the second sharpening strength is the sharpening strength of the target pixel point based on the gradient value;
adjusting the pixel value of the target pixel point according to the first sharpening strength and the second sharpening strength to obtain a target pixel value corresponding to the target pixel point;
and updating the pixel value of each target pixel point to a target pixel value corresponding to each target pixel point, and generating a sharpened image.
2. The method of claim 1, wherein prior to the step of deriving a second sharpening strength from the image gradient value and the target gradient value, the method further comprises:
acquiring neighborhood pixel points within a preset window range according to a target pixel point, wherein the preset window takes the target pixel point as a center;
calculating a target gradient value of the target pixel point according to the pixel value of the neighborhood pixel point, the pixel value of the target pixel point and a preset gradient operator;
and solving the mean value of the target gradient values of all the target pixel points in the image to be processed to obtain the image gradient value of the image to be processed.
3. The method of claim 1, wherein the gaussian function is:
Figure FDA0002802104400000021
where a is the first intensity value, b is the center coordinate of the peak, c is the standard deviation, x is the target pixel mean, and f (x) is the first sharpening intensity.
4. The method of claim 1, wherein the deriving the second sharpening strength from the image gradient value and the target gradient value comprises:
obtaining a second intensity value corresponding to the image gradient value according to the image gradient value and the corresponding relation between the image gradient value and the second intensity value;
and obtaining a second sharpening strength corresponding to the target gradient value according to the target gradient value and a growth function, wherein the parameter of the growth function comprises the second strength value, and the growth function represents the corresponding relation between the target gradient value and the second sharpening strength.
5. The method of claim 4, wherein the growth function is:
Figure FDA0002802104400000022
wherein d is a predetermined base number, y is a target gradient value, f (y) is a second sharpening strength, and M is a second intensity value.
6. The method of claim 1, wherein the step of adjusting the pixel value of the target pixel point according to the first sharpening strength and the second sharpening strength to obtain the target pixel value corresponding to the target pixel point comprises:
calculating a target sharpening intensity corresponding to the target pixel point according to the first sharpening intensity and the second sharpening intensity;
acquiring neighborhood pixel points within a preset window range according to the target pixel points, wherein the preset window takes the target pixel points as centers;
obtaining a high-frequency component corresponding to the target pixel point according to the pixel value of the neighborhood pixel point and the pixel value of the target pixel point, wherein the high-frequency component is the measurement of the edge and the contour of the target pixel point in the image to be processed;
amplifying the high-frequency component according to the target sharpening strength to obtain a sharpened pixel value;
and adding the sharpened pixel value and the pixel value of the target pixel point to obtain a target pixel value corresponding to the target pixel point.
7. The method according to claim 6, wherein the step of obtaining the high frequency component corresponding to the target pixel point according to the pixel values of the neighborhood pixel points and the target pixel point comprises:
according to the pixel values of the neighborhood pixel points and the pixel value of the target pixel point, carrying out fuzzy processing on the target pixel point to obtain a fuzzy component corresponding to the target pixel point;
and subtracting the pixel value of the target pixel point from the fuzzy component corresponding to the target pixel point to obtain a high-frequency component corresponding to the target pixel point.
8. An image sharpening apparatus, the apparatus comprising:
the processing module is used for obtaining a first intensity value corresponding to the image pixel mean value according to the image pixel mean value and the corresponding relation between the image pixel mean value and the first intensity value; obtaining a first sharpening strength corresponding to a target pixel mean value according to the target pixel mean value and a Gaussian function; the input parameter of the gaussian function comprises the first intensity value, the gaussian function represents the corresponding relation between the target pixel mean value and the first sharpening intensity, the image pixel mean value is the pixel mean value of all pixel points in the image to be processed, the target pixel mean value is the pixel mean value in a preset window range with a target pixel point as the center, the target pixel point is any pixel point in the image to be processed, and the first sharpening intensity is the sharpening intensity of the target pixel point based on the pixel value; obtaining a second sharpening strength according to an image gradient value and a target gradient value, wherein the image gradient value is a gradient average value of all pixel points in the image to be processed, the target gradient value is the gradient value of the target pixel point, and the second sharpening strength is the sharpening strength of the target pixel point based on the gradient value; adjusting the pixel value of the target pixel point according to the first sharpening strength and the second sharpening strength to obtain a target pixel value corresponding to the target pixel point;
and the generating module is used for updating the pixel value of each target pixel point to a target pixel value corresponding to each target pixel point, and generating a sharpened image.
9. The apparatus of claim 8, wherein the processing module is further to:
acquiring neighborhood pixel points within a preset window range according to a target pixel point, wherein the preset window takes the target pixel point as a center;
calculating a target gradient value of the target pixel point according to the pixel value of the neighborhood pixel point, the pixel value of the target pixel point and a preset gradient operator;
and solving the mean value of the target gradient values of all the target pixel points in the image to be processed to obtain the image gradient value of the image to be processed.
CN201910186224.9A 2019-03-12 2019-03-12 Image sharpening method and device Active CN109934785B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910186224.9A CN109934785B (en) 2019-03-12 2019-03-12 Image sharpening method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910186224.9A CN109934785B (en) 2019-03-12 2019-03-12 Image sharpening method and device

Publications (2)

Publication Number Publication Date
CN109934785A CN109934785A (en) 2019-06-25
CN109934785B true CN109934785B (en) 2021-03-12

Family

ID=66986856

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910186224.9A Active CN109934785B (en) 2019-03-12 2019-03-12 Image sharpening method and device

Country Status (1)

Country Link
CN (1) CN109934785B (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110298858B (en) * 2019-07-01 2021-06-22 北京奇艺世纪科技有限公司 Image clipping method and device
CN111340715B (en) * 2019-09-19 2024-02-06 杭州海康慧影科技有限公司 Grid pattern weakening method and device of image and electronic equipment
CN110660031B (en) * 2019-09-19 2023-12-05 广州酷狗计算机科技有限公司 Image sharpening method and device and storage medium
CN111028182B (en) * 2019-12-24 2024-04-26 北京金山云网络技术有限公司 Image sharpening method, device, electronic equipment and computer readable storage medium
CN113643190B (en) * 2020-04-27 2024-07-16 北京金山云网络技术有限公司 Image sharpening method and device
CN112950491B (en) * 2021-01-26 2024-02-13 上海视龙软件有限公司 Video processing method and device
CN113096014B (en) * 2021-03-31 2023-12-08 咪咕视讯科技有限公司 Video super processing method, electronic device and storage medium
CN113674272B (en) * 2021-09-06 2024-03-15 上海集成电路装备材料产业创新中心有限公司 Image detection method and device
CN114298936A (en) * 2021-12-29 2022-04-08 上海宇思微电子有限公司 Noise reduction and sharpening combined processing method and device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1892696A (en) * 2005-07-08 2007-01-10 深圳迈瑞生物医疗电子股份有限公司 Supersonic image edge-sharpening and speck-inhibiting method
CN103489167A (en) * 2013-10-21 2014-01-01 厦门美图网科技有限公司 Automatic image sharpening method
CN105894459A (en) * 2015-12-10 2016-08-24 乐视云计算有限公司 Gradient value and direction based image sharpening method and device
CN108038833A (en) * 2017-12-28 2018-05-15 福州瑞芯微电子股份有限公司 A kind of the image adaptive sharpening method and storage medium of gradient correlation detection

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7088474B2 (en) * 2001-09-13 2006-08-08 Hewlett-Packard Development Company, Lp. Method and system for enhancing images using edge orientation

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1892696A (en) * 2005-07-08 2007-01-10 深圳迈瑞生物医疗电子股份有限公司 Supersonic image edge-sharpening and speck-inhibiting method
CN103489167A (en) * 2013-10-21 2014-01-01 厦门美图网科技有限公司 Automatic image sharpening method
CN105894459A (en) * 2015-12-10 2016-08-24 乐视云计算有限公司 Gradient value and direction based image sharpening method and device
CN108038833A (en) * 2017-12-28 2018-05-15 福州瑞芯微电子股份有限公司 A kind of the image adaptive sharpening method and storage medium of gradient correlation detection

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
工业X射线图像锐化技术算法研究;刘艳莉;《中国博士学位论文全文数据库信息科技辑》;20150715;第I138-105页 *

Also Published As

Publication number Publication date
CN109934785A (en) 2019-06-25

Similar Documents

Publication Publication Date Title
CN109934785B (en) Image sharpening method and device
CN109741287B (en) Image-oriented filtering method and device
US11501428B2 (en) Method, apparatus and system for detecting fundus image based on machine learning
CN112200771B (en) Height measurement method, device, equipment and medium
CN108230333B (en) Image processing method, image processing apparatus, computer program, storage medium, and electronic device
CN109711508B (en) Image processing method and device
CN105933589A (en) Image processing method and terminal
US8520953B2 (en) Apparatus and method for extracting edges of image
CN108764139B (en) Face detection method, mobile terminal and computer readable storage medium
CN110736610B (en) Method and device for measuring optical center deviation, storage medium and depth camera
CN107748882B (en) Lane line detection method and device
CN113592776A (en) Image processing method and device, electronic device and storage medium
CN106919883B (en) QR code positioning method and device
CN106506982B (en) method and device for obtaining photometric parameters and terminal equipment
CN108074238B (en) Hough transform and Gaussian fitting-based in-plane mura detection method and detection system
CN113920022A (en) Image optimization method and device, terminal equipment and readable storage medium
CN111311481A (en) Background blurring method and device, terminal equipment and storage medium
CN112351271A (en) Camera shielding detection method and device, storage medium and electronic equipment
CN109360167B (en) Infrared image correction method and device and storage medium
CN109886864B (en) Privacy mask processing method and device
CN107945186A (en) Method, apparatus, computer-readable recording medium and the terminal device of segmentation figure picture
CN110830728A (en) Exposure adjusting method and device
CN115937324B (en) Assembly quality evaluation method, device, equipment and storage medium
CN109523564B (en) Method and apparatus for processing image
CN117058022A (en) Depth image denoising method and device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant