# Image Magnification Based on Bicubic Approximation with Edge as Constraint
## 4 Constructing the Whole Sampling Surface
### Constructing the Initial Whole Sampling Surface  
In Section 3, a patch \(f_{i,j}(x,y),i,j=2,3,4,\cdots,n-1\) is constructed on each of the neighborhoods centered on \(P_{i,j}\). For pixels on the boundary, \(P_{j,1}\), \(P_{j,n}\), \(P_{1,j}\) and \(P_{n,j},j=1,2,3,\cdots,n\), the corresponding patches \(f_{j,1}(x,y),f_{j,n}(x,y),f_{1,j}(x,y)\) and \(f_{n,j}(x,y)\), \(j=2,3,4,\cdots,n-1\) are defined as follows:  
\[\begin{array}{l}f_{1,j}(x,y)=f_{2,j}(x,y),\ \ \ \ \ f_{n,j}(x,y)=f_{n-1,j}(x,y),\\ f_{j,1}(x,y)=f_{j,2}(x,y),\ \ \ \ f_{j,n}(x,y)=f_{j,n-1}(x,y),\\ f_{1,1}(x,y)=f_{2,2}(x,y),\ \ \ f_{n,n}(x,y)=f_{n-1,n-1}(x,y),\\ f_{n,1}(x,y)=f_{n-1,2}(x,y),\ \ f_{1,n}(x,y)=f_{2,n-1}(x,y).\end{array} \tag{18}\]  
On each unit square area \([i,i+1]\times[j,j+1],i,j=1,2,3,\cdots,n-1\), a bicubic sampling surface patch \(F_{i,j}(x,y),i,j=1,2,3\cdots,n-1\) can be generated from the weighted combination of \(f_{i,j}(x,y),f_{i+1,j}(x,y)\), \(f_{i+1,j+1}(x,y)\), and \(f_{i,j+1}(x,y)\). All \(F_{i,j}(x,y)\) are put together to form an initial whole sampling surface \(F(x,y)\). The definition of \(F_{i,j}(x,y)\) is as follows:  
\[\begin{array}{l}F_{i,j}(x,y)=f_{i,j}(u,v)w_{i,j}(u,v)+f_{i,j+1}(u,v)w_{i,j+1 }(u,v)+\\ f_{i+1,j+1}(u,v)w_{i+1,j+1}(u,v)+f_{i+1,j}(u,v)w_{i+1,j}(u,v).\end{array} \tag{19}\]  
where \(u=x-i,v=y-j\), and \(w_{i+k,j+l}(u,v)\), \(k,l=0,1\) are the weight functions.  
In general, the weight functions can be defined by the following bilinear basis functions:  
\[\begin{array}{l}w_{i,j}(u,v)=(1-u)(1-v),\ \ \ \ w_{i,j+1}(u,v)=(1-u)v,\\ w_{i+1,j+1}(u,v)=uv,\ \ \ \ \ \ w_{i+1,j}(u,v)=u(1-v)\end{array}\]  
In the unit square area \([i,i+1]\times[j,j+1]\), if the approximation accuracy of the four patches, \(f_{i,j}(x,y),f_{i+1,j}(x,y)\), \(f_{i+1,j+1}(x,y)\), and \(f_{i,j+1}(x,y)\) is about the same, the ideal result can be obtained with the weight function defined by the above equation. If the approximation accuracy of the four patches is significantly different, it is more reasonable to define the weight functions with the following rational functions.  
\[\begin{array}{l}w_{i,j}(u,v)=\alpha_{0,0}(1-u)(1-v)/w,\\ w_{i,j+1}(u,v)=\alpha_{0,1}(1-u)v/w,\\ w_{i+1,j+1}(u,v)=\alpha_{1,1}uv/w,\\ w_{i+1,j}(u,v)=\alpha_{1,0}u(1-v)/w,\\ w=\alpha_{0,0}(1-u)(1-v)+\alpha_{0,1}(1-u)v+\alpha_{1,1}uv+\alpha_{1,0}u(1-v).\end{array} \tag{20}\]  
where \(\alpha_{i,k},l,k=0,1\) is the parameter, which determines the importance of the corresponding weight \(w_{i+l,j+k}(u,v)\).  
If the approximation accuracy of \(f_{i,j}(x,y)\) is better than the approximation accuracy of \(f_{i+1,j}(x,y),f_{i+1,j+1}(x,y)\), and \(f_{i,j+1}(x,y)\), \(\alpha_{0,0}\) in \(w_{i,j}(u,v)\) (Equation (20)) should be given a maximum value and similarly for the others. The average value of the four surface patches is  
\[s(u,v)=(f_{i,j}(u,v)+f_{i,j+1}(u,v)+f_{i+1,j+1}(u,v)+f_{i+1,j}(u,v))/4,\]  
Then, \(\alpha_{0,0},\alpha_{0,1},\alpha_{1,1}\), and \(\alpha_{1,0}\) in Equation (20) are defined as follows:  
\[\begin{array}{l}\alpha_{l,k}=1/(1+\sqrt{3}e_{l,k}^{2}),l,k=0,1\\ e_{l,k}=f_{i+l,j+k}(u,v)-s(u,v).\end{array} \tag{21}\]  
Equation (21) shows that the definition principle of \(\alpha_{0,0},\alpha_{0,1},\alpha_{1,1}\), and \(\alpha_{1,0}\) is that \(f_{i+k,j+l}(x,y),l,k=0,1\) with a large deviation from \(s(u,v)\) corresponds to small \(\alpha_{k,l}\).