# Image Magnification Based on Bicubic Approximation with Edge as Constraint
## 3 Constructing Quadratic Sampling Patches
### Calculating the Coefficients of First Term  
Based on Equation (5), the following four equations can be obtained [18]:  
\[a_{3}=e_{1},\ a_{3}+a_{4}=e_{2},\ a_{4}=e_{3},\ a_{3}-a_{4}=e_{4}. \tag{6}\]  
where,  
\[\begin{array}{l}e_{1}=(P_{i,j+1}-P_{i,j-1})/2,\ e_{2}=(P_{i+1,j+1}-P_{i-1,j-1}) /2\\ e_{3}=(P_{i+1,j}-P_{i-1,j})/2,\ e_{4}=(P_{i+1,j-1}-P_{i-1,j+1})/2\end{array}\]  
Equation (6) has four equations with two unknowns \(a_{3}\) and \(a_{4}\). Using the weighted least squares method, \(a_{3}\) and \(a_{4}\) are determined by minimizing the objective function \(G(a_{3},a_{4})\) defined by  
\[G(a_{3},a_{4})=w_{1}(a_{3}-e_{1})^{2}+w_{2}(a_{3}+a_{4}-e_{2})^{2}+w_{3}(a_{4}- e_{3})^{2}+w_{4}(a_{3}-a_{4}-e_{4})^{2}. \tag{7}\]  
where \(w_{k},k=1,2,3,4\) is the weight function.  
Let us consider how to define the weight function in Equation (7). If 9 pixels \(P_{i+l,j+k},l,k=-1,0,1\) are sampling points on the same object, we could set \(w_{1}=w_{3}=1,w_{2}=w_{4}=1/\sqrt{2}\), considering the relative positions of the other 8 pixels and \(P_{i,j}\). \(w_{2}\) and \(w_{4}\) take smaller weights because their corresponding first-order differences \(e_{2}\) and \(e_{4}\) are on the diagonal (as shown in Figure 1). The points relatively far away from \(P_{i,j}\) should be assigned a smaller weight. If the 9 pixels are sampling points on the different objects, there are edges in the 9 pixels; that is, at least three pixels are on an edge. To simplify the complexity of the problem, we assume that there are up to four edges in a block of 9 pixels, which are on the horizontal, vertical, and diagonal lines of Figure 1. For ensuring the edge features of the magnified image, the pixels on an edge should play a relatively large role in the determination of \(a_{3}\) and \(a_{4}\), which is equivalent to assigning a relatively large value to the corresponding weight in Equation (7). For example, if \(P_{i-1,j-1}\), \(P_{i,j}\), and \(P_{i+1,j+1}\) are on the diagonal edge, \(w_{2}\) should give a relatively large weight. Note \(\delta_{k},k=1,2,3,4\) is a second-order difference along four directions.  
\[\begin{array}{l}\delta_{1}=P_{i+1,j}-2P_{i,j}+P_{i-1,j}\\ \delta_{2}=P_{i+1,j+1}-2P_{i,j}+P_{i-1,j-1}\\ \delta_{3}=P_{i,j+1}-2P_{i,j}+P_{i,j-1}\\ \delta_{4}=P_{i+1,j-1}-2P_{i,j}+P_{i-1,j+1}.\end{array} \tag{8}\]  
The feature of \(P_{i-1,j-1}\), \(P_{i,j}\), and \(P_{i+1,j+1}\) on the edge is that \(|\delta_{2}|\) in Equation (8) has a relatively small value. Therefore, assigning a relatively large weight to \(w_{2}\) is equivalent to \(w_{2}\) being inversely proportional to \(|\delta_{2}|\). If \(P_{i-1,j-1}\), \(P_{i,j}\), and \(P_{i+1,j+1}\) are on the edge, the corresponding \(|\delta_{4}|\) in Equation (8) of the edge's normal direction is usually relatively large, and then, giving a relatively large weight to \(w_{2}\) is equivalent to \(w_{2}\) being proportional to \(|\delta_{4}|\). Based on the above discussion, the weight \(w_{k},k=1,2,3,4\) can be defined as follows:  
\[\begin{array}{l}w_{1}=\frac{1+\delta\delta_{3}}{1+\delta\delta_{4}^{2}},w_{ 2}=\frac{\sqrt{2}(1+\delta\delta_{4})}{2(1+\delta\delta_{4}^{2})},\\ w_{3}=\frac{1+\delta\delta_{1}}{1+\delta\delta_{3}^{2}},w_{4}=\frac{\sqrt{2}(1 +\delta\delta_{2})}{2(1+\delta\delta_{4}^{2})}.\end{array} \tag{9}\]  
where \(\delta_{k},k=1,2,3,4\) are defined in Equation (8). Experimental results show that \(\beta=0.2,\ \alpha=0.5\) is preferable in Equation (9).