Increasing the megapixel count of your image, or enlarging your image using MATLAB

Is The above statement true enough to be believed?
Well well the answer is yes as, there are many softwares on the earth that can do so. They are backed by many powerful image processing algorithm that allows you to do nearly perfect image enlargement. Some of them are 'bilinear', 'bicubic', or even much advanced like 'spline'. They work on the same principle, that is they take account for the neighboring pixels of the pixel they are processing in. Then they produce some value, depending on the coefficient in their equation are set, and that value is got to replaced in liu of the older one. Simple isn't it? But for the processor (who did all the calculation part), its a heavy task.But what where the MATLAB came from in this process.

Well the answer lies in the Image Processing Toolbox Of MATLAB, it contains a large set of functions from that we can perform various function related to image processing. And the above mentioned task can be easily and efficiently preformed by the MATLAB software (its a beauty of this software, isn't it?).
This operation would be in the category of "Spatial Transformation", of image processing.

The function is "imresize" with the syntax:
#x = imresize(a, scale) [here scale is any number like 0.5 (for shirking) or 4 (for zooming)
**any number less that one will shrink the image & greater than 1 will zoom the image, if equal to 1 it will keep the image as it is]

#x = imresize(A, [numrows numcols]) [yes we can directly set the number of columns & rows of the resultant image]

[x newmap] = imresize(y, map, scale) [This function syntax is particularly for indexed type of image, like .gif[Graphics interchange format] format or .tif[tagged image format]]

[...] = imresize(..., method) [here default method is bicubic] [ here method may be 'nearest', 'bilinear' or 'bicubic' we have to enter them as a text string]
**apart from the methods we can say to the MATLAB interpreter/compiler that we are actually applying a Structuring element on that image, by typing there name as, 'box'(for Box-shaped kernel), 'triangle'(Triangular kernel (that is nearly equivalent to 'bilinear')), 'cubic' kernel (that is also same as 'bicubic'), 'lanczos2' Lanczos-2 kernel, 'lanczos3' Lanczos-3 kernel[Some advanced kernel]

[...] = imresize(..., parameter, value, ...)

**In this format, a parameter can be,
->'Antialiasing':- The default value of this depends on the interpolation method we have choosen. If the method is nearest-neighbor ( that is 'nearest'), the default is false & for all other interpolation methods, the default is true.
->'OutputSize':-A two-element vector, [numrows numcols], that specifies the size of the output image.

For example let us take an internally available image of MATLAB:

i = imread('peppers.png','bilinear');
j = imresize(i, 5);
figure, imshow(i), figure, imshow(j)

Now the j is containing the zoomed image of peppers.png, that is scaled by a factor of 5. That is if your image is of 1 Mega pixel it is now of 5 mega pixel, now just save it and enjoy.
In order to save it, type imwrite(j,'newname.jpg','jpg');
Your new zoomed image will be known as "newname.jpg" or whatever you want to know it as.

Resizing an indexed image
[x, map] = imread('xxx.tif');
[y, n_map] = imresize(x, map, 5);
imshow(y, n_map)

the last command will show an image, that is 5 time larger than the original one, this option is performed by bilinear transformation, that is by default applied, as we havn't mentioned any of the techniques.

Resizing by specifying number of rows & number of columns
t = imread('peppers.png');
l = imresize(t, [64 64]);

the resultant image will be an 64x64 image, resized offcourse by the bilinear transformation.

See the result of all the three techniques available in the MATLAB by this code:
i1 = imresize(i,0.5,’nearest’);
i2 = imresize(i,0.5,’bilinear’);
i3 = imresize(i,0.5,’bicubic’);
subplot(1,3,1), imshow(I_sm2), title(’Nearest-neighbor Interpolation’);
subplot(1,3,2), imshow(I_sm3), title(’Bilinear Interpolation’);
subplot(1,3,3), imshow(I_sm4), title(’Bicubic Interpolation’);