The disclosure relates to an image technology, and in particular to an image processing method and an image processing device.
Guided filter is a filtering technology used in the fields of image processing and computer vision. The guided filter is mainly used for image smoothing operation, which can not only remove noise in the image, but also retain important edge information.
Conventional filtering technology (such as Gaussian filtering) treats the entire image as a whole, while the guided filter uses an auxiliary image referred to as a “guided image” to help the filtering process. The guided image is usually some kind of conversion of the original image, such as a grayscale image, a gradient image, or other feature maps. The guided image has the same size as the original image, but reflects the structural information in the original image to some extent.
The guided filters are used in many computer vision tasks, including, for example, image noise reduction and image enhancement. Since the guided filter can smooth the image while retaining important features, the guided filter performs better than the conventional filtering method in many scenarios.
However, most of the existing guided filter technologies require the use of at least two neural networks, which results in high computational complexity and cost. In addition, some guided filter technologies require higher computation accuracy to be implemented, and the difficulty of implementation is increased.
In view of the above, the disclosure provides an image processing method and an image processing device, which can be used to solve the above technical problems.
An embodiment of the disclosure provides an image processing method, suitable for an image processing device. The method includes the following. A first image is obtained, and the first image is down-sampled into a second image. The first image includes multiple first pixels, and the second image includes multiple second pixels. A first resolution parameter combination of each second pixel in the second image is obtained. A target pixel among the plurality of first pixels is selected, and a plurality of second pixels corresponding to the target pixel among the plurality of second pixels are accordingly obtained. A comparison result between the target pixel and each second pixel corresponding to the target pixel is determined, and at least one candidate pixel among the plurality of second pixels corresponding to the target pixel is accordingly selected. A second resolution parameter combination of the target pixel is obtained based on the first resolution parameter combination of each candidate pixel. The target pixel is converted into an output pixel based on the second resolution parameter combination.
An embodiment of the disclosure provides an image processing device, including a storage circuit and a processor. The storage circuit stores a program code. The processor is coupled to the storage circuit and accesses the program code to perform the following. A first image is obtained, and the first image is down-sampled into a second image. The first image includes multiple first pixels, and the second image includes multiple second pixels. A first resolution parameter combination of each second pixel in the second image is obtained. A target pixel among the plurality of first pixels is selected, and a plurality of second pixels corresponding to the target pixel among the plurality of second pixels are accordingly obtained. A comparison result between the target pixel and each second pixel corresponding to the target pixel is determined, and at least one candidate pixel among the plurality of second pixels corresponding to the target pixel is accordingly selected. A second resolution parameter combination of the target pixel is obtained based on the first resolution parameter combination of each candidate pixel. The target pixel is converted into an output pixel based on the second resolution parameter combination.
Please refer to
In
The processor 104 is coupled to the storage circuit 102 and may be a general purpose processor, a special purpose processor, a conventional processor, a digital signal processor, multiple microprocessors, one or more microprocessors combined with a digital signal processor core, a controller, a microcontroller, an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), any other kinds of integrated circuits, a state machine, an advanced RISC machine (ARM)-based processor, and similar devices.
In an embodiment of the disclosure, the processor 104 may access the modules and program codes recorded in the storage circuit 102 to implement an image processing method proposed by the disclosure, and the details are described in detail below.
Please refer to
Noted that the method shown in
In step S210, the processor 104 obtains a first image INHR and down-samples the first image INHR into a second image INLR, in which the first image INHR includes multiple pixels, and the second image INLR includes multiple pixels. In an embodiment, the first image INHR is, for example, any image to be used for guided filtering, but the disclosure is not limited thereto. The multiple pixels of the first image INHR have their own pixel values, and the multiple pixels of the second image INLR also have their own pixel values. For convenience of description, the multiple pixels of the first image INHR described below are referred to as first pixels, and the multiple pixels of the second image INLR are referred to as second pixels.
In an embodiment, the processor 104 may down-sample the first image INHR into the second image INLR based on a desired down-sample coefficient or scaling ratio (characterized by S).
Please refer to
When S is 2, the processor 104 may convert every 4 first pixels in the first image INHR into 1 second pixel in the second image INLR.
For example, the processor 104 may be configured to perform: converting the 4 first pixels located in a range 311 into a second pixel 321 in the second image INLR; converting the 4 first pixels located in a range 312 into a second pixel 322 in the second image INLR; converting the 4 first pixels located in a range 313 into a second pixel 323 in the second image INLR; converting the 4 first pixels located in a range 314 into a second pixel 324 in the second image INLR. Based on a similar principle, the processor 104 may also convert the 4 first pixels located in a range 315 into a second pixel 325 in the second image INLR, and convert the 4 first pixels located in a range 316 into a second pixel 326 in the second image INLR.
Other second pixels in the second image INLR may also be derived based on the above description, so details will not be repeated herein.
It should be understood that each first pixel in the first image INHR and each second pixel in the second image INLR have a corresponding numerical value, but these numerical values are not shown for maintaining the simplicity of
In an embodiment, since the second image INLR is down-sampled from the first image INHR, the image resolution of the first image INHR may be higher than the image resolution of the second image INLR. From another point of view, the second image INLR may also be understood as a thumbnail of the first image INHR, but the disclosure is not limited thereto.
In step S220, the processor 104 obtains a first resolution parameter combination PARLR of each second pixel in the second image INLR.
Please also refer to
In different embodiments, designers may determine the network model and/or deep learning model used to implement the neural network NN1 according to various requirements, such as the convolutional neural network or the like, but the disclosure is not limited thereto.
In some embodiments, the implementation of the neural network NN1 may also refer to, for example, related art literatures such as “Google HDRnet”, “Fast End-to-End Trainable Guided Filter”, and “Fast Guided Filter”, and the details will not be repeated herein.
In an embodiment, a first pixel located at coordinates (i, j) in the first image INHR may be characterized by INi,jHR, and a second pixel located at coordinates (m, n) in the second image INLR may be characterized by INm,nLR, but the disclosure is not limited thereto. In addition, in an embodiment, a first resolution parameter combination PARLR of the second pixel INm,nLR in the second image INLR may be characterized by, for example, (Am,nLR, bm,nLR) but the disclosure is not limited thereto. In this embodiment, parameters A and b in the representation of PARLR may be, for example, computed by the neural network NN1, but the disclosure is not limited thereto.
In step S230, the processor 104 selects a first pixel among the plurality of first pixels as a target pixel, and obtains a plurality of second pixels corresponding to the target pixel among the plurality of second pixels accordingly. For example, the target pixel of this embodiment in the first image INHR is located at the coordinates (i, j), so the target pixel may be characterized by INi,jHR. In the disclosure, for example, the second pixels corresponding to the target pixel are defined as specific pixels and reference pixels. Regarding the definitions of the specific pixels and the reference pixels, details will be described below in the disclosure. In this embodiment, for example, a relationship between the target pixel in the first image INHR and the corresponding second pixels in the second image INLR is obtained based on the step S210, but the disclosure is not limited thereto.
In detail, in an embodiment of the disclosure, the processor 104, for example, regards the first pixels as target pixels one by one, and performs steps S230 to S260 accordingly. After step S260 is performed, an output pixel corresponding to a selected target pixel may be obtained. Regarding steps S240 to S260, details will be described below in the disclosure.
Based on above, each first pixel has a corresponding output pixel, and the processor 104 may correspondingly combine each first pixel selected with the corresponding output pixel, so as to generate an output image OUTHR. In an embodiment, the output image OUTHR may be understood as a result image generated by the processor 104 via performing the guided filtering based on the first image INHR, but the disclosure is not limited thereto.
For better understanding, the concept of the disclosure will be described below by taking several first pixels among the first pixels as the examples of the target pixel, but this implementation manner is merely used as an example, and is not intended to limit possible implementations of the disclosure.
In an embodiment, the processor 104 may select a second pixel corresponding to the target pixel among multiple second pixels in a down-sampled second image INLR, and the second pixel is defined as the specific pixel in this disclosure. The processor 104 may also obtain multiple second pixels surrounding the specific pixel, and assign the second pixels surrounding the specific pixel as the reference pixels corresponding to the target pixel. The second image INLR after down-sampling is, for example, an image with a size of 5×5.
Please refer to
Following the above, in step S230, the processor 104 may obtain multiple second pixels surrounding the specific pixel (e.g., the second pixel 324) in the second image INLR (e.g., other second pixels in a range 324a except for the second pixel 324). The processor 104 also assigns the second pixels surrounding the specific pixel (e.g., the second pixel 324) as reference pixels corresponding to the first pixel 411 (that is, the target pixel), but the disclosure is not limited thereto. In a preferred embodiment, coordinates of the specific pixel and the plurality of reference pixels may be obtained according to
In the formula, (m, n) are, for example, the coordinates of the specific pixel and the multiple reference pixels, (i, j) are, for example, the coordinates of the first pixel 411 (the target pixel) in the first image INHR, and S is, for example, the scaling ratio. The scaling ratio is, for example, the image scaling ratio between the first image and the second image, but the disclosure is not limited thereto. Furthermore, based on the coordinates of the first pixel 411 in the first image INHR being (3, 2), the result of
may be obtained. In other words, the coordinates (m, n) of the specific pixel and the plurality of reference pixels are, for example, located at coordinates (0,0), (0,1), (0,2), (1, 0), (1, 1), (1, 2), (2,0), (2,1), and (2, 2). In this way, this embodiment may obtain the coordinates of the specific pixel and the multiple reference pixels in the second image INLR. The specific pixel and the plurality of reference pixels (the second pixels) may be, for example characterized by INm,nLR.
Afterward, in step S240, the processor 104 determines a comparison result between the target pixel and each second pixel corresponding to the target pixel, and selects at least one candidate pixel among the second pixels corresponding to the target pixel accordingly. In detail, in this embodiment, the processor 104 determines the comparison result between the numerical value of the target pixel in the first image INHR and the numerical values of the specific pixel and the surrounding reference pixels in the second image INLR. Furthermore, the candidate pixel may be selected by comparing the specific pixel and the surrounding reference pixels in the second image INLR with the target pixel in the first image INHR. Regarding the definition of the candidate pixel, details will be described below in the disclosure.
For example, in the embodiment of
In
Next, in step S250, the processor 104 obtains a second resolution parameter combination PARHR of the target pixel (that is, the first pixel 411) based on the first resolution parameter combination PARLR of each candidate pixel (that is, the second pixel 324b).
In the embodiment of the disclosure, the coordinates of the target pixel in the first image INHR are, for example, (i, j), then the target pixel may be characterized by INi,jHR, and the second resolution parameter combination PARHR of the target pixel may be characterized by (Ai,jHR, bi,jHR), but the disclosure is not limited thereto.
Based on the above, in the implementation of determining that the candidate pixel is the one with the smallest numerical value among the numerical values corresponding to the specific pixel and the plurality of reference pixels, the processor 104 may assign the first resolution parameter combination PARLR of the candidate pixel (that is, the second pixel 324b) as the second resolution parameter combination PARHR of the target pixel.
Next, in step S260, the processor 104 converts the target pixel into an output pixel based on the second resolution parameter combination PARHR.
In an embodiment of the disclosure, the output pixel may be characterized by “OUTi,jHR=Ai,jHR·INi,jHR+bi,jHR”. In this embodiment, based on the implementation manner that the first resolution parameter combination PARLR is assigned as the second resolution parameter combination PARHR of the target pixel, accordingly, “Ax,yLR=Ai,jHR”, and “bx,yLR=bi,jHR”. In other words, the output pixel of this embodiment may be characterized by “OUTi,jHR=Ax,yLR. INi,jHR+bx,yLR”, in which in this embodiment, “Ax,yLR=A1,2LR”, and “bx,yLR=b1,2LR”.
In the embodiment of
Similar to the above embodiment, in this embodiment, the processor 104 may also select a second pixel corresponding to the target pixel among multiple second pixels in the down-sampled second image INLR, and the second pixel is defined as the specific pixel corresponding to the first pixel 511 (the target pixel). The processor 104 may also obtain multiple second pixels surrounding the specific pixel, and assign the second pixels surrounding the specific pixel as the reference pixels corresponding to the target pixel. The second image INLR after down-sampling is, for example, an image with a size of 5×5.
Please refer to
Following the above, in step S230, the processor 104 may obtain multiple second pixels surrounding the specific pixel (e.g., the second pixel 325) in the second image INLR (e.g., other second pixels in a range 325a except for the second pixel 325). The processor 104 also assigns the second pixels surrounding the specific pixel (e.g., the second pixel 325) as reference pixels corresponding to the first pixel 511 (that is, the target pixel), but the disclosure is not limited thereto. In a preferred embodiment, coordinates of the specific pixel and the plurality of reference pixels may be obtained according to
In the formula, (m, n) are, for example, the coordinates of the specific pixel and the multiple reference pixels, (i, j) are, for example, the coordinates of the first pixel 511 (the target pixel) in the first image INHR, and S is, for example, the scaling ratio. The scaling ratio is, for example, the image scaling ratio between the first image and the second image, but the disclosure is not limited thereto. Furthermore, based on the coordinates of the first pixel 511 in the first image INHR being (4, 5), the result of
may be obtained. In other words, the coordinates (m, n) of the specific pixel and the plurality of reference pixels are, for example, located at the coordinates (1, 1), (1, 2), (1, 3), (2,1), (2, 2), (2,3), (3,1), (3,2), and (3,3). In this way, this embodiment may obtain the coordinates of the specific pixel and the multiple reference pixels in the second image INLR. The specific pixel and the plurality of reference pixels (the second pixels) may be, for example characterized by INm,nLR.
Afterward, in step S240, the processor 104 determines the comparison result between the target pixel and each second pixel corresponding to the target pixel, and selects at least one candidate pixel among the second pixels corresponding to the target pixel accordingly. In detail, in this embodiment, the processor 104 determines the comparison result between the numerical value of the target pixel in the first image INHR and the numerical values of the specific pixel and the surrounding reference pixels in the second image INLR. Furthermore, the candidate pixel may be selected by comparing the specific pixel and the surrounding reference pixels in the second image INLR with the target pixel in the first image INHR.
For example, in the embodiment of
In
Next, in step S250, the processor 104 obtains a second resolution parameter combination PARHR of the target pixel (that is, the first pixel 511) based on the first resolution parameter combination PARLR of each candidate pixel (that is, the second pixel 325b).
In the embodiment of the disclosure, the coordinates of the target pixel in the first image INHR are, for example, (i, j), then the target pixel may be characterized by INi,jHR, and the second resolution parameter combination PARHR of the target pixel may be characterized by (Ax,yHR, bx,yHR), but the disclosure is not limited thereto.
Based on the above, in the implementation of determining that the candidate pixel is the one with the largest numerical value among the numerical values corresponding to the specific pixel and the plurality of reference pixels, the processor 104 may assign the first resolution parameter combination PARLR of the candidate pixel (that is, the second pixel 325b) as the second resolution parameter combination PARHR of the target pixel.
Next, in step S260, the processor 104 converts the target pixel into an output pixel based on the second resolution parameter combination PARHR.
Similarly, in the embodiment of the disclosure, the output pixel may be characterized by “OUTi,jHR=Ai,jHR·INi,jHR+bi,jHR”. In this embodiment, based on the implementation manner that the first resolution parameter combination PARLR is assigned as the second resolution parameter combination PARHR of the target pixel, accordingly, “Ax,yLR=Ai,jHR”, and “bx,yLR=bi,jHR”. In other words, the output pixel of this embodiment may be characterized by OUTi,jHR=Ax,yLR·INi,jHR+bx,yLR, in which in this embodiment, “Ax,yLR=A2,1LR” and “bx,yLR=b2,1LR”.
In the embodiment of
Similar to the above embodiment, in this embodiment, the processor 104 may also select a second pixel corresponding to the target pixel among multiple second pixels in the down-sampled second image INLR, and the second pixel is defined as the specific pixel corresponding to the first pixel 611 (the target pixel). Afterward, the processor 104 may obtain multiple second pixels surrounding the specific pixel, and assign the second pixels surrounding the specific pixel as the reference pixels corresponding to the target pixel. The second image INLR after down-sampling is, for example, an image with a size of 5×5.
Please refer to
Following the above, in step S230, the processor 104 may obtain multiple second pixels surrounding the specific pixel (e.g., the second pixel 326) in the second image INLR (e.g., other second pixels in a range 326a except for the second pixel 326). The processor 104 also assigns the second pixels surrounding the specific pixel (e.g., the second pixel 326) as reference pixels corresponding to the first pixel 611 (that is, the target pixel), but the disclosure is not limited thereto.
Afterward, in step S240, the processor 104 determines the comparison result between the target pixel and each second pixel corresponding to the target pixel, and selects at least one candidate pixel among the second pixels corresponding to the target pixel accordingly. In detail, in this embodiment, the processor 104 determines the comparison result between the numerical value of the target pixel in the first image INHR and the numerical values of the specific pixel and the surrounding reference pixels in the second image INLR. That is, at least one candidate pixel is obtained by comparing the specific pixel and the reference pixels surrounding the specific pixel in the second image INLR with the target pixel in the first image INHR.
For example, in the embodiment of
Following the above, please continue to refer to
Regarding the selection of candidate pixels mentioned above, details will be further described below in the disclosure.
In this embodiment, the processor 104, for example, divides the specific pixel and the plurality of reference pixels into a first group and a second group, in which the numerical values of the specific pixel and the reference pixels in the first group are all greater than the target pixel, and the numerical values of the reference pixels in the second group are all smaller than the target pixel. As shown in
Afterward, the processor 104 may select a first candidate pixel among the reference pixels of the first group, and select a second candidate pixel among the reference pixels of the second group.
In this embodiment, the numerical value of the first candidate pixel selected by the processor 104 in the first group is, for example, a minimum numerical value, and the numerical value of the second candidate pixel selected in the second group is, for example, a maximum numerical value. In the scenario of
In other embodiments, the processor 104 may also select any reference pixel among the first group or select a reference pixel as the first candidate pixel according to an appropriate criterion. Correspondingly, the processor 104 may also select any reference pixel among the second group or select a reference pixel as the second candidate pixel according to an appropriate criterion.
In this embodiment, the first resolution parameter combination PARLR of the first candidate pixel may be characterized by (Ax1,y1LR, bx1,y1LR), in which (x1, y1) is, for example, coordinates of the first candidate pixel in the second image INLR. In addition, the first resolution parameter combination PARLR of the second candidate pixel may be characterized by (Ax2,y2LR, bx2,y2LR), in which (x2, y2) is, for example, coordinates of the second candidate pixel in the second image INLR, but the disclosure is not limited thereto. In this embodiment, the first candidate pixel is, for example, the second pixel 326b, and the second candidate pixel is, for example, the second pixel 326c.
Following the above, since the coordinates of the first candidate pixel (the second pixel 326b) in the second image INLR are (2, 4), the first candidate pixel (the second pixel 326b) may also be characterized by IN2,4LR, and the corresponding first resolution parameter combination PARLR is, for example, (A2,4LR, b2,4LR) (that is, (Ax1,y1LR, bx1,y1LR).
In addition, since the coordinates of the second candidate pixel (e.g., the second pixel 326c) in the second image INLR are (3, 4), the second candidate pixel (e.g., the second pixel 326c) may be characterized by IN3,4LR, and the corresponding first resolution parameter combination PARLR is, for example, (A3,4LR, b3,4LR) (that is, (Ax2,y2LR, bx2,y2LR).
Next, in step S250, the processor 104 obtains the second resolution parameter combination PARHR of the target pixel (that is, the first pixel 611) based on the first resolution parameter combination PARLR of each candidate pixel (that is, the second pixels 326b, 326c).
In an embodiment of the disclosure, assuming that the coordinates of the target pixel in the first image INHR are (i, j), the target pixel may be characterized by INi,jHR, and the second resolution parameter combination PARHR of the target pixel may be characterized by Ai,jHR, bi,jHR, but the disclosure is not limited thereto.
Based on the above, in the implementation of determining the first candidate pixel (e.g., the second pixel 326b) and the second candidate pixel (e.g., the second pixel 326c), the processor 104 may combine the first resolution parameter combination PARLR of the first candidate pixel and the first resolution parameter combination PARLR of the second candidate pixel into the second resolution parameter combination PARHR of the target pixel (e.g., the first pixel 611).
In this embodiment, the first resolution parameter combination PARLR after the aforementioned combination is characterized by (Ax,yLR, bx,yLR). Ax,yLR may be characterized by “Ax,yLR=w1·Ax1,y1LR+w2·Ax2,y2LR”, and bx,yLR may be characterized by “bx,yLR=w1·bx1,y1LR+w2·bx2,y2LR”. (x1, y1) is, for example, the coordinates of the first candidate pixel (the second pixel 326b) in the second image INLR, and (x2, y2) is, for example, the coordinates of the second candidate pixel (e.g., the second pixel 326c) in the second image INLR. In this embodiment, the coordinates (x1, y1) of the first candidate pixel are, for example, (2, 4), and the coordinates of the second candidate pixel are, for example, (3, 4).
In the embodiment of
In a preferred embodiment,
in which d1 is an absolute difference between the first candidate pixel and the target pixel, and d2 is an absolute difference between the second candidate pixel and the target pixel. In the implementation shown in
Based on the above, in
Next, in step S260, the processor 104 converts the target pixel into an output pixel based on the second resolution parameter combination PARHR.
Similarly, in an embodiment of the disclosure, the output pixel may be characterized by “OUTi,jHR=Ai,jHR·INi,jHR+bi,jHR”. In this embodiment, based on the implementation manner that the first resolution parameter combination PARLR after the aforementioned combination is assigned as the second resolution parameter combination PARHR of the target pixel, accordingly, “Ax,yLR=Ai,jHR”, and “bx,yLR=bi,jHR”. In other words, the output pixel of this embodiment may be characterized by “OUTx,yHR=Ax,yLR·INx,yHR+bx,yLR”.
In the embodiment of
Please refer to
In the embodiment of the disclosure, for each first pixel in the first image INHR, the processor 104 may convert the first pixel into the corresponding output pixel through implementation manners described in the first, second, or third embodiment. Afterward, the processor 104 may combine each first pixel with the corresponding output pixel to form the output image OUTHR.
Since the method proposed by embodiments of the disclosure does not require the use of at least two neural networks, the computational complexity and cost are both low.
In summary, the image processing method and the image processing device proposed by embodiments of the disclosure can realize the guided filter with low computational complexity, low cost, and low difficulty.
Although the disclosure has been disclosed above in the embodiments, the embodiments are not intended to limit the disclosure. Persons with ordinary skill in the technical field may make some changes and modifications without departing from the spirit and scope of the disclosure. Therefore, the protection scope of the disclosure shall be determined by the appended claims.
Number | Date | Country | Kind |
---|---|---|---|
113104382 | Feb 2024 | TW | national |
This application claims the priority benefits of U.S. provisional application Ser. No. 63/460,862, filed on Apr. 20, 2023, and Taiwan application serial no. 113104382, filed on Feb. 5, 2024. The entirety of each of the above-mentioned patent applications is hereby incorporated by reference herein and made a part of this specification.
Number | Date | Country | |
---|---|---|---|
63460862 | Apr 2023 | US |