# Revision history [back]

### cv::resize() incorrect interpolation with INTER_NEAREST

I am trying to 'enlarge' pixels - i.e. apply resize() to increase the dimensions of an image with nearest neighbour interpolation. However I am not getting expected results.

Input image (2 x 2 pixels):

Code:

  resize(_inputImage, outImage,  Size(256,256),INTER_NEAREST);
imshow(_windowName, outImage);


Expected result (256 x 256 pixels):

Actual result (256 x 256 pixels):

What am I doing wrong?

### cv::resize() incorrect interpolation with INTER_NEAREST

I am trying to 'enlarge' pixels - i.e. apply resize() to increase the dimensions of an image with nearest neighbour interpolation. However I am not getting expected results.

Input image (2 x 2 pixels):

Code:

  resize(_inputImage, outImage,  Size(256,256),INTER_NEAREST);
imshow(_windowName, outImage);


Expected result (256 x 256 pixels):

Actual result (256 x 256 pixels):

What am I doing wrong?

_update_
Thanks to the numerous comments and answers, it transpires that I had omitted some params. The correct call is:

      resize(_inputImage, outImage,  Size(256,256),0,0,INTER_NEAREST);


The 4th, 5th and 6th params are optional with defaults. I was omitting #4 (fx) and #5 (fy), so INTER_NEAREST was getting interpreted as fx (int 0), fy was defaulting to 0, and interpolation was defaulting to INTER_LINEAR( bilinear interpolation) which gave the unexpected result.