File Exchange

image thumbnail


version 1.2 (2.69 KB) by

Increases the resolution of an image by interpolation



View License

IIR Increases the size of an image by interpolation
B= IIR(inputfile,f) returns the image stored in file 'inputfile' with resolution increased by factor f in both dimensions. 'filename' must be a valid graphic file (jpg, gif, tiff, etc.). It can be grayscale or color.
Parameter 'f' is the size increase ratio, so to increase by 50%
use f= 1.5, to double size (in each dimension) use f= 2.
Additional parameters:
B= IIR(A,f,'Display','off') eliminates display of both images, the original and the modified. Deafult 'on'
B= IIR(A,f,'Method',method) Allows to choose between five methods of interpolation: linear, spline, pchip, cubic or v5cubic. 'method' must be a string character. Default 'linear'

B= iir('myimage.jpg',2);

The screenshot shows the effect of increasing resolution by 3. Original size: 600x402. After: 2400x1608.
(I took the photo myself. No copyright problems).

Comments and Ratings (13)

Oza San, you need to provide more details. How do you call the function?

oza san

dear fransisco how can i run this code i stack with an error "Error using iir (line 25)Not enough input arguments."
please help me!!!

dai zhengguo

dai zhengguo (view profile)

The best way to increase the resolution of the image is a ill-posed problem. Please refer to the reconstruction methods for super-resolution image from single image only.

Magnus: The short answer: no, IIR cannot do that. I don't have plans right now to introduce that, but you are welcome to try.


Magnus (view profile)

This is a very nice function, but I need to increase resolution by different amounts in the x and y directions. For example I would like to be able to convert a 4:3 image to a 16:9 image. Is that possible with IIR?

Malcolm: Of course I'm not cheating (but I'm a bit offended, actually). Besides, it's not only the teeth, the whole image improves in definition (let's stay away from semantic subtleties). It can be appreciated best in all borders between light and dark areas (i.e. eye sockets). Anybody can try for himself: download the example image, crop the left part and use the function on it.

Malcolm McLean

Cris: that's sort of true. You can't create information out of nowhere. However if I have a curve specified by several points, and the curve represents the true underlying data, I can improve the representation of the data by taking more points.

If you look at Fransisco's images, he's clearly improved the definition of the teeth. Unless he's cheating, the image quality has been improved.

Resolution (definition)
Webster: b : a measure of the [...] fineness with which a device [...] can produce or record an image, usually expressed as the total number or density of pixels in the image <a resolution of 1200 dots per inch>
Oxford English Dictionary: the process or capability of rendering distinguishable the component parts of an object or image; a measure of this, expressed [...] as the number of pixels that form an image.

Thus, given that the function changes the number of pixels in the image, according to Webster and OED, it changes its resolution.

On the other hand, the sampling density or sampling rate is the number of recorded samples (PiXels) per unit distance *when converting from an analog signal to digital*.

When the image is read (with imread) it actually stores it as a 2 or 3 dimensional array, and the interpolation is done on that array. You may try to change the instruction where the image is read to make it suitable for your arrays, the rest of the code "should" work, although if the array representing the font is B&W (0 & 1) I'm not sure about the results.

Cris Luengo

Cris Luengo (view profile)

You cannot change the resolution of an image by interpolation. You'll change the sampling density, but not the resolution. Please get your terminology straight!

Malcolm McLean

THis could be incorporated into my sequence logo program to scale the fonts (see my recent contribution). But for that I'd need it to work on arrays - presumably not a big change to the function.

The function works equally in grayscale as well as in color images.

sheena k.

can this be implement on grayscale images?
currently im doing for grayscale images



change description slightly


Interpolation in two domensions at once.


IIR now reads the graphics file directly.
More interpolation methods added
Improved display of grayscale images

MATLAB Release
MATLAB 7.4 (R2007a)

MATLAB Online Live Editor Challenge

Win cash prizes and have your live script featured on our website

Learn more

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video