# Image Magnification Based on Bicubic Approximation with Edge as Constraint
## 3 Constructing Quadratic Sampling Patches
### Calculating the Coefficients of Quadratic Term  
Since \(a_{3}\) and \(a_{4}\) are computed, there are 9 equations with four unknowns in Equation (5): \(a_{0}\), \(a_{1}\), \(a_{2}\), and \(a_{5}\). The third group of coefficients for \(a_{0},a_{1}\), and \(a_{2}\) can be determined based on 9 equations. In order to improve the accuracy of interpolation, two sets of values of \(a_{0},a_{1}\), and \(a_{2}\) are determined. The final values of \(a_{0},a_{1}\), and \(a_{2}\) are calculated using the weighted averages of the two sets of values. The following discusses how to determine the first set of values for \(a_{0}\), \(a_{1}\), and \(a_{2}\). Using the 9 equations in Equation (5), we have the following 8 difference equations:  
\[P_{i+l,j+k}-P_{i,j}=a_{0}l^{2}+a_{1}lk+a_{2}k^{2}+a_{3}l+a_{4}k,\,l,k=-1,0,1,|l|+| k|\geq 1.\]  
In these 8 equations, there are 3 unknowns: \(a_{0}\), \(a_{1}\), and \(a_{2}\). Using the weighted least squares method, the 3 unknowns are determined by minimizing the objective function \(G(a_{0},a_{1},a_{2})\) defined by the following:  
\[G(a_{0},a_{1},a_{2})=\sum\limits_{l=-1}^{1}\sum\limits_{k=-1}^{1}w_{i,k}(a_{0 }l^{2}+a_{1}lk+a_{2}k^{2}-\sigma_{i+l,j+k})^{2},\,\,|l|+|k|\geq 1 \tag{10}\]  
where \(\sigma_{i+l,j+k}=P_{i+l,j+k}-P_{i,j}-a_{3}l-a_{4}k,l,k=-1,0,1,w_{l,k}\) is the weight function. How to determine the weight function in Equation (10) is discussed below. Edge features and distance play an important role in determining \(a_{3}\) and \(a_{4}\) and should also play an important role in determining \(a_{0},a_{1},a_{2}\), and \(a_{5}\). Therefore, based on the discussion of Equation (9), the weight function can be defined as follows:  
\[ \begin{array}{l}w_{0,-1}=w_{0,1}=w_{1},\\ w_{-1,0}=w_{1,0}=w_{3},\\ w_{-1,-1}=w_{1,1}=w_{2},\\ w_{-1,1}=w_{1,-1}=w_{4}.\end{array}  \tag{11}\]  
where \(w_{i}\), \(i=1,2,3,4\) are defined by Equation (9). The 9 pixels shown in Figure 1 are in horizontal, vertical, and two diagonal directions. For each pixel, it is unreasonable to simply assign the same weight to the two pixels on an edge in the same direction. For example, for horizontal \(P_{i-1,j},P_{i,j}\), and \(P_{i+1,j}\), if \(P_{i-1,j}\) and \(P_{i,j}\) are sampling points on the same object and \(P_{i+1,j}\) is sampling point on another object, it is reasonable to assign relatively large weights to \(P_{i-1,j}\) and \(P_{i,j}\) and to assign a relatively small weight to \(P_{i+1,j}\), while according to Equation (11), \(P_{i-1,j}\) and \(P_{i+1,j}\) are assigned the same weight. For this reason, the new weights are defined as follows:  
\[w_{l,k}=w_{l,k}/(1+0.5|P_{i,j}-P_{i+l,j+k}|),\,\,\,l,k=-1,0,1. \tag{12}\]  
where \(w_{l,k},l,k=-1,0,1\) on the right side of Equation (12) is defined by Equation (11). For the convenience of the following discussion, the first set of values for \(a_{0}\), \(a_{1}\), and \(a_{2}\) computed by Equations (10)-(12) are denoted as \(a_{0}^{A}\), \(a_{1}^{A}\), and \(a_{2}^{A}\). In the following, we discuss how to determine the second set of values for \(a_{0},a_{1}\), and \(a_{2}\). From Equation (5), one gets the following three equations:  
\[ \begin{array}{l}P_{i+1,j}-P_{i,j}=a_{0}+a_{3}\\ P_{i+1,j+1}-P_{i,j}=a_{0}+a_{1}+a_{2}+a_{3}+a_{4}\\ P_{i,j+1}-P_{i,j}=a_{2}+a_{4}.\end{array}  \tag{13}\]  
These three equations correspond to the four pixels, \(P_{i,j},P_{i+1,j},P_{i,j+1}\), and \(P_{i+1,j+1}\), which form a square in Figure 1. When \(a_{3}\) and \(a_{4}\) are determined, \(a_{0},a_{1},a_{2}\) can be calculated from Equation (13) and denoted as \(a_{0}^{0},a_{1}^{0},a_{2}^{0}\). Similarly, the other three sets of values for \(a_{0}\), \(a_{1}\), and \(a_{2}\) can be calculated from the pixels forming the other three square in Figure 1, which are denoted as \(a_{0}^{1},a_{1}^{1},a_{2}^{1},a_{0}^{2},a_{1}^{2},a_{2}^{2}\), and \(a_{0}^{3},a_{1}^{3},a_{2}^{3}\), respectively. Let us consider how to determine the second set of values for \(a_{0},a_{1},a_{2}\) by \(a_{0}^{k},a_{1}^{k},a_{2}^{k}\), \(k=0,1,2,3\).