views:

41

answers:

3

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?

+2  A: 

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://opencv.willowgarage.com/documentation/cpp/geometric_image_transformations.html#resize

MusiGenesis
+2  A: 

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.

Federico Cristina
A: 

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

Martin Beckett