Image sharpening method, device and equipment and computer readable storage medium
By traversing the image row by row and calculating the sharpened pixel value of the target pixel, and utilizing adjacent traversed pixels and preset compensation values, the problem of low image sharpening efficiency in the prior art is solved, and a highly efficient image sharpening effect is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
- Filing Date
- 2024-10-22
- Publication Date
- 2026-04-24
AI Technical Summary
Existing image sharpening methods require two scans and calculations, resulting in low computational efficiency.
By acquiring multiple pixels of the image to be processed, traversing row by row and calculating the sharpened pixel value of the target pixel, and using the original pixel values of adjacent traversed pixels and preset compensation values, the sharpened image can be obtained in just one traversal.
It improves the efficiency of image sharpening by enabling real-time calculation of sharpened pixel values during the traversal of each pixel, thus reducing computation time.
Smart Images

Figure CN121921203A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of image processing technology, and in particular to an image sharpening method, apparatus, device, and computer-readable storage medium. Background Technology
[0002] Sharpening is a common image processing technique that enhances the edges and details in an image, making it appear sharper and improving blurriness caused by limitations of the optical system or environmental factors such as insufficient light or camera shake.
[0003] In existing technologies, edge detection algorithms (such as the Sobel operator) are generally used to detect the contours or edges of objects in an image. Then, sharpening convolution kernels (such as the Laplacian operator) are used to enhance the brightness of the edges to improve the contrast at the edges of objects in the image, ultimately achieving a sharpening effect.
[0004] However, this sharpening method requires scanning and calculating the image twice, resulting in low computational efficiency. Summary of the Invention
[0005] To address the aforementioned technical problems, this disclosure provides an image sharpening method, apparatus, device, and computer-readable storage medium to improve the efficiency of image sharpening.
[0006] In a first aspect, embodiments of this disclosure provide an image sharpening method, including:
[0007] Acquire an image to be processed, the image to be processed comprising multiple pixels;
[0008] In the process of traversing the image to be processed row by row to obtain the original pixel value of each pixel, if the currently traversed pixel is the target pixel, the sharpened pixel value of the target pixel is calculated based on the original pixel values of the traversed pixels adjacent to the target pixel. The number of traversed pixels in the adjacent pixels of the target pixel accounts for at least half of the number of adjacent pixels.
[0009] When the traversal of the image to be processed is completed, the sharpened image corresponding to the image to be processed is obtained according to the sharpened pixel value of each target pixel.
[0010] In some embodiments, calculating the sharpened pixel value of the target pixel based on the original pixel value of the target pixel and the original pixel values of the traversed pixels adjacent to the target pixel includes:
[0011] Calculate the average of the original pixel value and the preset compensation value for each of the traversed pixels to obtain the environmental measurement value of the target pixel;
[0012] The difference between the original pixel value of the target pixel and the environmental measurement value is calculated to obtain the environmental difference value of the target pixel;
[0013] The sharpening compensation value of the target pixel is obtained by calculating the product of the environmental difference value and the preset sharpening intensity.
[0014] The sharpened pixel value of the target pixel is obtained by summing the original pixel value of the target pixel with the sharpening compensation value.
[0015] In some embodiments, the preset compensation value is the sum of preset compensation pixel values for each untraversed pixel adjacent to the target pixel.
[0016] In some embodiments, prior to acquiring the image to be processed, the method further includes:
[0017] The original image is segmented into multiple images to be processed;
[0018] The process of traversing the image to be processed row by row includes:
[0019] Create multiple traversal threads;
[0020] The multiple traversal threads are used to traverse the multiple images to be processed in parallel.
[0021] In some embodiments, the step of traversing the image to be processed row by row to obtain the original pixel value of each pixel includes:
[0022] A two-dimensional array is created in memory, wherein the number of rows and columns of the elements in the two-dimensional array is the same as the number of rows and columns of the pixels in the image to be processed;
[0023] When any pixel of the image to be processed is encountered, the original pixel value of the pixel is stored in the element corresponding to the pixel in the two-dimensional array.
[0024] In some embodiments, obtaining the sharpened image corresponding to the image to be processed based on the sharpened pixel value of each of the target pixels includes:
[0025] The sharpened image corresponding to the image to be processed is obtained based on the sharpened pixel value of each target pixel and the original pixel value of each boundary pixel, wherein the boundary pixels are the first row and first column pixels of the image to be processed.
[0026] In a second aspect, embodiments of this disclosure provide an image sharpening apparatus, comprising:
[0027] The first acquisition module is used to acquire an image to be processed, the image to be processed including multiple pixels;
[0028] The calculation module is used to calculate the sharpened pixel value of the target pixel based on the original pixel values of the traversed pixels adjacent to the target pixel during the process of traversing the image to be processed row by row to obtain the original pixel value of each pixel.
[0029] The second acquisition module is used to obtain the sharpened image corresponding to the image to be processed based on the sharpened pixel value of each target pixel when the traversal of the image to be processed is completed.
[0030] In some embodiments, the computing module is further configured to:
[0031] Calculate the average of the original pixel value and the preset compensation value for each of the traversed pixels to obtain the environmental measurement value of the target pixel;
[0032] The difference between the original pixel value of the target pixel and the environmental measurement value is calculated to obtain the environmental difference value of the target pixel;
[0033] The sharpening compensation value of the target pixel is obtained by calculating the product of the environmental difference value and the preset sharpening intensity.
[0034] The sharpened pixel value of the target pixel is obtained by summing the original pixel value of the target pixel with the sharpening compensation value.
[0035] Thirdly, embodiments of this disclosure provide an electronic device, including:
[0036] Memory;
[0037] Processor; and
[0038] Computer programs;
[0039] The computer program is stored in the memory and configured to be executed by the processor to implement the method as described in the first aspect.
[0040] Fourthly, embodiments of this disclosure provide a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the method described in the first aspect.
[0041] Fifthly, embodiments of this disclosure also provide a computer program product, which includes a computer program or instructions that, when executed by a processor, implement the image sharpening method described above.
[0042] The image sharpening method, apparatus, device, and computer-readable storage medium provided in this disclosure calculate the sharpened pixel value of the target pixel using only the pixel values of the preceding pixels. This enables real-time calculation of the sharpened pixel value of the target pixel during the traversal of each pixel, requiring only one traversal of the image to be processed to obtain the corresponding sharpened image, thus improving the efficiency of image sharpening. Attached Figure Description
[0043] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0044] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0045] Figure 1 This is a flowchart of an image sharpening method provided in an embodiment of the present disclosure;
[0046] Figure 2 This is a schematic diagram of multi-threaded traversal provided in an embodiment of the present disclosure;
[0047] Figure 3 This is a schematic diagram of the image to be processed provided in the embodiments of this disclosure;
[0048] Figure 4 A flowchart of an image sharpening method provided in another embodiment of this disclosure;
[0049] Figure 5 This is a schematic diagram of the structure of the image sharpening device provided in the embodiments of this disclosure;
[0050] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0051] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.
[0052] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.
[0053] This disclosure provides an image sharpening method, which will be described below with reference to specific embodiments.
[0054] Figure 1 This is a flowchart illustrating an image sharpening method provided in an embodiment of this disclosure. This method can be applied to any terminal device with image and data processing capabilities, such as smartphones, PDAs, tablets, wearable devices with displays, desktop computers, laptops, all-in-one computers, smart home devices, etc. It is understood that the image sharpening method provided in this disclosure can also be applied to other scenarios.
[0055] The following is about Figure 1 The image sharpening method shown is described below, and the specific steps of this method are as follows:
[0056] S101. Obtain the image to be processed, which includes multiple pixels.
[0057] The image to be processed is the image that needs to be sharpened, which includes multiple pixels, each with its own pixel value.
[0058] Specifically, the image to be processed can be a single frame image, or a portion of a single frame image; and a single frame image can also be a single frame image extracted from a video.
[0059] S102. In the process of traversing the image to be processed row by row to obtain the original pixel value of each pixel, if the currently traversed pixel is the target pixel, the sharpened pixel value of the target pixel is calculated based on the original pixel values of the traversed pixels adjacent to the target pixel. The number of traversed pixels among the adjacent pixels of the target pixel accounts for at least half of the number of adjacent pixels.
[0060] To obtain the original pixel value of each pixel in the image to be processed, each pixel needs to be traversed. Since pixels are stored row-by-row in memory, the rule of row-by-row traversal must also be followed when traversing each pixel.
[0061] During the process of traversing the pixels, if a target pixel is encountered, the sharpening pixel value of the target pixel is calculated.
[0062] A target pixel is a pixel whose neighboring pixels include more than half of the traversed pixels, and whose original pixel values are known. This target pixel can be used to calculate the sharpening pixel value. For example, if pixel A has eight neighboring pixels, including four traversed pixels (half the number of neighboring pixels), then pixel A is the target pixel.
[0063] Specifically, among the multiple pixels in the image to be processed, except for the first row and the first column, the remaining pixels will become target pixels one by one during the traversal. At the same time, each time a target pixel appears during the traversal, the sharpening pixel value of the target pixel is calculated, and then the next pixel is traversed.
[0064] S103. When the traversal of the image to be processed is completed, the sharpened image corresponding to the image to be processed is obtained according to the sharpened pixel value of each target pixel.
[0065] When the image to be processed has been traversed, the original pixel value of each pixel and the sharpened pixel value of each target pixel are obtained. Based on this, the sharpened image corresponding to the image to be processed can be obtained.
[0066] Specifically, the sharpened image corresponding to the image to be processed is obtained based on the sharpened pixel value of each target pixel and the original pixel value of each boundary pixel, wherein the boundary pixels are the first row and first column pixels of the image to be processed.
[0067] When boundary pixels are traversed, since less than half of their neighboring pixels have already been traversed, meaning that the values of most of their neighboring pixels are unknown, there is insufficient reference data for calculating the sharpened pixel values of boundary pixels. Therefore, their original pixel values are still used in the final sharpened image. However, for other pixels besides boundary pixels, their corresponding sharpened pixel values are calculated during the traversal process and can be directly applied to the sharpened image.
[0068] This embodiment of the disclosure acquires an image to be processed, which includes multiple pixels. During the process of traversing the image row-by-row to obtain the original pixel value of each pixel, if the currently traversed pixel is a target pixel, the sharpened pixel value of the target pixel is calculated based on its original pixel value and the original pixel values of the traversed pixels adjacent to it. The number of traversed pixels among the adjacent pixels of the target pixel is at least half the number of adjacent pixels. When the traversal of the image to be processed is complete, a sharpened image corresponding to the image to be processed is obtained based on the sharpened pixel value of each target pixel. By calculating the sharpened pixel value of the target pixel using only the pixel values of its preceding pixels, the sharpened pixel value of the target pixel can be calculated in real time during the traversal of each pixel. Only one traversal of the image to be processed is needed to obtain the corresponding sharpened image, thus improving the efficiency of image sharpening.
[0069] Based on the above embodiments, the step of calculating the sharpened pixel value of the target pixel based on the original pixel value of the target pixel and the original pixel values of the traversed pixels adjacent to the target pixel includes: calculating the average of the original pixel values of the traversed pixels and a preset compensation value to obtain the environmental measurement value of the target pixel; calculating the difference between the original pixel value of the target pixel and the environmental measurement value to obtain the environmental difference value of the target pixel; calculating the product of the environmental difference value and a preset sharpening intensity to obtain the sharpening compensation value of the target pixel; and calculating the sum of the original pixel value of the target pixel and the sharpening compensation value to obtain the sharpened pixel value of the target pixel.
[0070] Image sharpening essentially enhances the difference in pixel values between a pixel and its surrounding image area to improve contrast. In this embodiment, there are untraversed pixels among the neighboring pixels of the target pixel. The pixel values of these untraversed pixels are unknown and cannot provide a reference for the pixel values around the target pixel. Therefore, a preset compensation value is used to compensate for these untraversed pixels.
[0071] Specifically, the preset compensation value is the sum of the preset compensation pixel values of each untraversed pixel adjacent to the target pixel. That is, a preset compensation pixel value is set for each untraversed pixel adjacent to the target pixel. The preset compensation pixel value can be set to 50% of the maximum pixel value; for example, with an 8-bit pixel value of 0-255, the compensation pixel value would be 128. Alternatively, the preset compensation pixel value can be set to the average of the original pixel values of the traversed pixels adjacent to the target pixel.
[0072] Sharpening intensity defines the strength of the image sharpening effect. Optionally, the sharpening intensity value can be defined as 0-1, and the specific value can be configured according to the user's needs.
[0073] The sharpening pixel value for the target pixel can be calculated using the following formula:
[0074]
[0075] Where W represents the sharpened pixel value of the target pixel, S is the original pixel value of the target pixel, X is the sum of the original pixel values of the traversed pixels, Y is the preset compensation value, N is the number of adjacent pixels of the target pixel, and T is the sharpening intensity.
[0076] In some embodiments, a weight can be set between the sum of the original pixel values of the traversed pixels and a preset compensation value. The specific calculation formula is as follows:
[0077]
[0078] The weights a and b are positive numbers, and their sum is 1.
[0079] This embodiment calculates the sharpened pixel value of the target pixel using a sharpening calculation formula, and compensates the pixel value of the untraversed pixel using a preset compensation value, so as to make the evaluation of the pixel value around the target pixel more accurate and improve the sharpening effect of the image.
[0080] Meanwhile, the embodiments of this disclosure introduce sharpening intensity, allowing users to adjust the strength of the sharpening effect and further improve the flexibility of image sharpening.
[0081] In some embodiments, before acquiring the image to be processed, the method further includes: segmenting the original image into multiple images to be processed; the step of traversing the images to be processed row by row includes: establishing multiple traversal threads; and using the multiple traversal threads to traverse the multiple images to be processed in parallel.
[0082] Figure 2 This is a schematic diagram illustrating multi-threaded traversal provided in an embodiment of this disclosure. For example... Figure 2 As shown, the original image is divided into k images to be processed, which are denoted as image to be processed 1, image to be processed 2, and so on, up to image to be processed k. Correspondingly, at least k traversal threads are established, which are denoted as thread 1, thread 2, and so on, up to thread k.
[0083] Correspondingly, each traversal thread processes one image to be processed, and k traversal threads can process k images to be processed in parallel.
[0084] It is understood that the number of traversal threads can be the same as the number of images to be processed, or it can be any number, depending on the user's actual needs. This disclosure does not limit this.
[0085] This embodiment of the present disclosure obtains multiple images to be processed by segmenting the original image, and uses multiple traversal threads to sharpen each image to be processed, thereby further improving the efficiency of the image sharpening method.
[0086] In some embodiments, since pixels are stored contiguously in memory, fast calculation is not possible, and it is impossible to traverse previous historical data. Therefore, pixel values need to be stored in array form during traversal. Specifically, the step of traversing the image to be processed row by row to obtain the original pixel value of each pixel includes: creating a two-dimensional array in memory, wherein the number of rows and columns of the elements in the two-dimensional array is the same as the number of rows and columns of the pixels in the image to be processed; when traversing to any pixel in the image to be processed, storing the original pixel value of the pixel into the element corresponding to the pixel in the two-dimensional array.
[0087] Taking a 6*6 pixel image as an example, create a two-dimensional array a[6][6]. Figure 3 This is a schematic diagram of the image to be processed provided in the embodiments of this disclosure, such as... Figure 3 As shown, the image to be processed consists of six rows (1-6) and six columns (A-B), totaling 36 pixels. Figure 3 Each pixel is identified by coordinates, and the 36 pixels also correspond to the 36 elements in the two-dimensional array a[6][6].
[0088] When traversing the image to be processed row by row, start from pixel (0,0) to (5,0), then start from pixel (0,1), and so on, until pixel (5,5 is reached, thus completing the traversal of the image to be processed.
[0089] During this process, the pixels (0,0), (0,1)~(0,5), (1,0)~(5,0) are boundary pixels. When these pixels are traversed, their original pixel values are directly stored in the corresponding elements of the two-dimensional array a[6][6].
[0090] When the traversal reaches pixel (1,1), pixels (0,0), (1,0) to (5,0), and (0,1) have already been traversed. Their original pixel values are stored in the two-dimensional arrays a[0][0], a[1][0] to a[5][0], and a[0][1], respectively. At this time, the neighboring pixels of pixel (1,1) include the traversed pixels (0,0), (1,0), (2,0), and (0,1), whose pixel values are known; and the untraversed pixels (2,1), (0,2), (1,2), and (2,2). It can be seen that the number of traversed pixels reaches half the number of neighboring pixels of pixel (1,1), thus determining pixel (1,1) as the target pixel.
[0091] Correspondingly, while storing the pixel value of pixel (1,1) into a[1][1], the corresponding original pixel value can also be obtained from the two-dimensional arrays a[0][0], a[1][0], a[2][0], and a[0][1], and the sharpened pixel value of the target pixel (1,1) can be further calculated.
[0092] This process continues until pixel (5, 5) is reached.
[0093] Specifically, for pixel (5, 5), all of its neighboring pixels are already traversed pixels, so there is no need to calculate its sharpened pixel value using the preset compensation value.
[0094] The embodiments disclosed herein improve the efficiency of image sharpening methods by simultaneously calculating sharpening during the process of converting pixels into arrays.
[0095] Figure 4 This is a flowchart of an image sharpening method provided in another embodiment of this disclosure. Figure 4 As shown, the method includes the following steps:
[0096] S401. Divide the original image into multiple images to be processed.
[0097] S402. Create multiple traversal threads.
[0098] S403. The multiple traversal threads are used to traverse the multiple images to be processed in parallel.
[0099] S404. For each image to be processed, a two-dimensional array is created in memory, wherein the number of rows and columns of the elements in the two-dimensional array is the same as the number of rows and columns of the pixels in the image to be processed.
[0100] S405. When any pixel of the image to be processed is encountered, the original pixel value of the pixel is stored in the element corresponding to the pixel in the two-dimensional array.
[0101] S406. If the currently traversed pixel is the target pixel, then the sharpened pixel value of the target pixel is calculated based on the original pixel values of the traversed pixels adjacent to the target pixel.
[0102] Wherein, the number of traversed pixels among the neighboring pixels of the target pixel is at least half of the number of neighboring pixels.
[0103] The process of calculating the sharpened pixel value is as follows: calculate the average of the original pixel value and the preset compensation value of each of the traversed pixels to obtain the environmental measurement value of the target pixel; calculate the difference between the original pixel value and the environmental measurement value of the target pixel to obtain the environmental difference value of the target pixel; calculate the product of the environmental difference value and the preset sharpening intensity to obtain the sharpening compensation value of the target pixel; calculate the sum of the original pixel value and the sharpening compensation value of the target pixel to obtain the sharpened pixel value of the target pixel.
[0104] Specifically, the preset compensation value is the sum of the preset compensation pixel values of the untraversed pixels adjacent to the target pixel.
[0105] S407. Obtain the sharpened image corresponding to the image to be processed based on the sharpened pixel value of each target pixel and the original pixel value of each boundary pixel, wherein the boundary pixels are the first row pixels and the first column pixels of the image to be processed.
[0106] The embodiments disclosed herein use only the pixel values of the preceding pixels of the target pixel to calculate the sharpened pixel value of the target pixel. This enables the sharpened pixel value of the target pixel to be calculated in real time during the traversal of each pixel. Only one traversal of the image to be processed is required to obtain the corresponding sharpened image, thereby improving the efficiency of image sharpening.
[0107] Meanwhile, the embodiments of this disclosure calculate the sharpened pixel value of the target pixel using a sharpening calculation formula, and compensate the pixel value of the untraversed pixel using a preset compensation value, so as to make the evaluation of the pixel value around the target pixel more accurate and improve the sharpening effect of the image; the introduction of sharpening intensity allows the user to adjust the strength of the sharpening effect, further improving the flexibility of image sharpening.
[0108] In addition, the embodiments of this disclosure obtain multiple images to be processed by segmenting the original image, and use multiple traversal threads to sharpen each image to be processed, thereby further improving the efficiency of the image sharpening method.
[0109] Figure 5 This is a schematic diagram of the structure of an image sharpening device provided in an embodiment of this disclosure. The image sharpening device can be part of a terminal device with image and data processing functions as described in the above embodiments, or it can be a component or assembly within the terminal device. The image sharpening device provided in this embodiment can execute the processing flow provided in the image sharpening method embodiments, such as... Figure 5 As shown, the image sharpening device 50 includes: a first acquisition module 51, a calculation module 52, and a second acquisition module 53; wherein, the first acquisition module 51 is used to acquire an image to be processed, the image to be processed including multiple pixels; the calculation module 52 is used to calculate the sharpened pixel value of the target pixel based on the original pixel values of the traversed pixels adjacent to the target pixel when the current traversed pixel is a target pixel during the process of traversing the image to be processed row by row to obtain the original pixel value of each pixel; the number of traversed pixels in the adjacent pixels of the target pixel is at least half of the number of adjacent pixels; the second acquisition module 53 is used to obtain the sharpened image corresponding to the image to be processed based on the sharpened pixel value of each target pixel when the traversal of the image to be processed is completed.
[0110] Optionally, the calculation module 52 is specifically used to calculate the average of the original pixel value and the preset compensation value of each of the traversed pixels to obtain the environmental measurement value of the target pixel; calculate the difference between the original pixel value and the environmental measurement value of the target pixel to obtain the environmental difference value of the target pixel; calculate the product of the environmental difference value and the preset sharpening intensity to obtain the sharpening compensation value of the target pixel; and calculate the sum of the original pixel value and the sharpening compensation value of the target pixel to obtain the sharpened pixel value of the target pixel.
[0111] Optionally, the preset compensation value is the sum of the preset compensation pixel values of each untraversed pixel adjacent to the target pixel.
[0112] Optionally, the image sharpening device 50 includes a segmentation module 54 for segmenting the original image into multiple images to be processed; the calculation module 52 includes a traversal unit 521 for establishing multiple traversal threads; and the multiple traversal threads are used to traverse the multiple images to be processed in parallel.
[0113] Optionally, the calculation module 52 includes a storage unit 522 for creating a two-dimensional array in memory, wherein the number of rows and columns of the elements in the two-dimensional array is the same as the number of rows and columns of the pixels in the image to be processed; when traversing to any pixel in the image to be processed, the original pixel value of the pixel is stored in the element corresponding to the pixel in the two-dimensional array.
[0114] Optionally, the second acquisition module 53 is used to obtain the sharpened image corresponding to the image to be processed based on the sharpened pixel value of each target pixel and the original pixel value of each boundary pixel, wherein the boundary pixels are the first row pixels and the first column pixels of the image to be processed.
[0115] Figure 5 The image sharpening apparatus of the illustrated embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effect are similar, and will not be repeated here.
[0116] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. The electronic device can be a terminal device with image and data processing functions as described in the above embodiments. The electronic device provided in this embodiment can execute the processing flow provided in the image sharpening method embodiments, such as… Figure 6 As shown, the electronic device 60 includes: a memory 61, a processor 62, a computer program, and a communication interface 63; wherein the computer program is stored in the memory 61 and configured to be executed by the processor 62 using the image sharpening method described above.
[0117] In addition, this disclosure also provides a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the image sharpening method described in the above embodiments.
[0118] Furthermore, this disclosure also provides a computer program product, which includes a computer program or instructions that, when executed by a processor, implement the image sharpening method described above.
[0119] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0120] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0121] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
[0122] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0123] The above description is merely a specific embodiment of this disclosure, enabling those skilled in the art to understand or implement it. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not to be limited to the embodiments described herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An image sharpening method, characterized in that, The method includes: Acquire an image to be processed, the image to be processed comprising multiple pixels; In the process of traversing the image to be processed row by row to obtain the original pixel value of each pixel, if the currently traversed pixel is the target pixel, the sharpened pixel value of the target pixel is calculated based on the original pixel values of the traversed pixels adjacent to the target pixel. The number of traversed pixels in the adjacent pixels of the target pixel accounts for at least half of the number of adjacent pixels. When the traversal of the image to be processed is completed, the sharpened image corresponding to the image to be processed is obtained according to the sharpened pixel value of each target pixel.
2. The method according to claim 1, characterized in that, The process of calculating the sharpened pixel value of the target pixel based on the original pixel value of the target pixel and the original pixel values of the traversed pixels adjacent to the target pixel includes: Calculate the average of the original pixel value and the preset compensation value for each of the traversed pixels to obtain the environmental measurement value of the target pixel; The difference between the original pixel value of the target pixel and the environmental measurement value is calculated to obtain the environmental difference value of the target pixel; The sharpening compensation value of the target pixel is obtained by calculating the product of the environmental difference value and the preset sharpening intensity. The sharpened pixel value of the target pixel is obtained by summing the original pixel value of the target pixel with the sharpening compensation value.
3. The method according to claim 2, characterized in that, The preset compensation value is the sum of the preset compensation pixel values of each untraversed pixel adjacent to the target pixel.
4. The method according to claim 1, characterized in that, Prior to acquiring the image to be processed, the method further includes: The original image is segmented into multiple images to be processed; The process of traversing the image to be processed row by row includes: Create multiple traversal threads; The multiple traversal threads are used to traverse the multiple images to be processed in parallel.
5. The method according to claim 1, characterized in that, The process of traversing the image to be processed row by row to obtain the original pixel value of each pixel includes: A two-dimensional array is created in memory, wherein the number of rows and columns of the elements in the two-dimensional array is the same as the number of rows and columns of the pixels in the image to be processed; When any pixel of the image to be processed is encountered, the original pixel value of the pixel is stored in the element corresponding to the pixel in the two-dimensional array.
6. The method according to claim 1, characterized in that, The step of obtaining the sharpened image corresponding to the image to be processed based on the sharpened pixel value of each target pixel includes: The sharpened image corresponding to the image to be processed is obtained based on the sharpened pixel value of each target pixel and the original pixel value of each boundary pixel, wherein the boundary pixels are the first row and first column pixels of the image to be processed.
7. An image sharpening device, characterized in that, include: The first acquisition module is used to acquire an image to be processed, the image to be processed including multiple pixels; The calculation module is used to calculate the sharpened pixel value of the target pixel based on the original pixel values of the traversed pixels adjacent to the target pixel during the process of traversing the image to be processed row by row to obtain the original pixel value of each pixel. The second acquisition module is used to obtain the sharpened image corresponding to the image to be processed based on the sharpened pixel value of each target pixel when the traversal of the image to be processed is completed.
8. The apparatus according to claim 7, characterized in that, The computing module is also used for: Calculate the average of the original pixel value and the preset compensation value for each of the traversed pixels to obtain the environmental measurement value of the target pixel; The difference between the original pixel value of the target pixel and the environmental measurement value is calculated to obtain the environmental difference value of the target pixel; The sharpening compensation value of the target pixel is obtained by calculating the product of the environmental difference value and the preset sharpening intensity. The sharpened pixel value of the target pixel is obtained by summing the original pixel value of the target pixel with the sharpening compensation value.
9. An electronic device, characterized in that, include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and configured to be executed by the processor to implement the method as described in any one of claims 1-6.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-6.