Artifact in Bicubic interpolation I wrote an algorithm to do bicubic interpolation of an image.
I used the method desribed in the wikipedia page.
On simple images, the result looks good, but on more complex ones, I got strange artifacts in non-smooth zones.

What could be a probable source of those artifacts, and what can I try to get rid of them ?

My code is on github, but I checked it several times, so I don't think the problem comes from it but rather from the simple implementation suggested in wikipedia

I'm using this particular equation (3rd-order Hermite polynomial interpolation) to do the interpolation (in one dimension):

$$x(n+t)=\frac{1}{2}
\begin{bmatrix}
1 &amp; t &amp; t^2 &amp; t^3 \\
\end{bmatrix}
\begin{bmatrix}
0 &amp; 2 &amp; 0 &amp; 0 \\
-1 &amp; 0 &amp; 1 &amp; 0 \\
2 &amp; -5 &amp; 4 &amp; -1 \\
-1 &amp; 3 &amp; -3 &amp; 1 \\
\end{bmatrix}
\begin{bmatrix}
x[n-1] \\
x[n] \\
x[n+1] \\
x[n+2] \\
\end{bmatrix}$$

where $x[n-1]$, ... $x[n+2]$, .. are the values of the surrounding pixels (in one dimension), and $t$ is the fractional coordinate (where $0 \le t &lt; 1$) of the interpolated pixel between the adjacent pixels $x[n]$, $x[n+1]$. $n$ is an integer and $x(n)=x[n]$ for any integer $n$.

The expected output:



My result, look closely at the bird head,a lot of white pixels have appeared.



---EDIT---
To show that my code does produce coherent results, here is the example of my scaling up on simple image with 16 red pixels.



And here is the ouput of the library (which also use 3rd-order Hermite polynomial interpolation):

 

And here is my results:



In this case the difference are IMO totally acceptable, but it shows that my interpolation does something legit.
What you're seeing is acutance, as described in the wikipedia article on bicubic interpolation. 

However, for downsampling an image, cubic interpolation is perhaps not the ideal choice, but makes more sense for upsampling.

Note that if you're downsampling by more than a facor of 4, there will be many pixels in the original image that are simply never used in the downsampled version.

The easiest way to get around this is to downsample by iteratively taking the mean value of 4 neighbouring pixels, until you're within a factor of 2 of the desired image size. Then you can do the last part by cubic interpolation.

If you're want high quality resampling, try taking a look at the ImageMagik documentation for inspiration. In particular they recommend using windowed filters for downsampling, such as Lanczos or Sinc.