Question

The image resizing function provided by Emgu (a .net wrapper for OpenCV) can use any one of four interpolation methods:

  1. CV_INTER_NN (default)
  2. CV_INTER_LINEAR
  3. CV_INTER_CUBIC
  4. CV_INTER_AREA

I roughly understand linear interpolation, but can only guess what cubic or area do. I suspect NN stands for nearest neighbour, but I could be wrong.

The reason I'm resizing an image is to reduce the amount of pixels (they will be iterated over at some point) whilst keeping them representative. I mention this because it seems to me that interpolation is central to this purpose - getting the right type ought therefore be quite important.

My question then, is what are the pros and cons of each interpolation method? How do they differ and which one should I use?

Was it helpful?

Solution

Nearest neighbor will be as fast as possible, but you will lose substantial information when resizing.

Linear interpolation is less fast, but will not result in information loss unless you're shrinking the image (which you are).

Cubic interpolation (probably actually "Bicubic") uses one of many possible formulas that incorporate multiple neighbor pixels. This is much better for shrinking images, but you are still limited as to how much shrinking you can do without information loss. Depending on the algorithm, you can probably reduce your images by 50% or 75%. The primary con of this approach is that it is much slower.

Not sure what "area" is - it may actually be "Bicubic". In all likelihood, this setting will give your best result (in terms of information loss / appearance), but at the cost of the longest processing time.

Update: this link gives more details (including a fifth type not included in your list):

http://docs.opencv.org/modules/imgproc/doc/geometric_transformations.html?highlight=resize#resize

OTHER TIPS

The interpolation method to use depends on what you are trying to achieve:

CV_INTER_LINEAR or CV_INTER_CUBIC apply a lowpass filter (average) in order to achieve a trade-off between visual quality and edge removal (lowpass filters tend to remove edges in order to reduce aliasing in images). Between these two, i'd recommend you CV_INTER_CUBIC.

CV_INTER_NN method actually is Nearest neighbour, it's the most basic method and you'll get sharper edges (no lowpass filter will be applied). However this method simply is like "zooming" the image, no visual enhancement.

The algorithms are: (descriptions are from the OpenCV documentation)

  • INTER_NEAREST - a nearest-neighbor interpolation
  • INTER_LINEAR - a bilinear interpolation (used by default)
  • INTER_AREA - resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire’-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method.
  • INTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood
  • INTER_LANCZOS4 - a Lanczos interpolation over 8x8 pixel neighborhood

If you want more speed use Nearest Neighbor method.

If you want to preserve quality of Image after downsampling, you can consider using INTER_AREA based interpolation, but again it depends on image content.

You can find detailed analysis of speed comparison here

Below is the speed comparison on 400*400 px image taken from the above link

Speed comparison

They all lose information, which you use depends on the speed you need, how much information you can afford to lose and the nature of your image.

Sorry there is no correct answer - that's why there is a choice

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top