Hello Patrickdang,
There are several good algorithms and/or source code implementations
for image magnification. You did not specify any constraints (such as
fixed magnification steps, allowing unequal X/Y zoom, speed, gray
scale / color, or licenses), so I will give you several examples that
you can choose from. If you have additional constraints - please make
a clarification request so I can find a solution that more closely
fits your project.
At the low end, there are methods such as pixel replication or pixel
decimation (eliminating "chosen" pixels) to generate larger and
smaller images respectively. These are fast but generally introduce a
number of artifacts that are visible to the viewer.
Slightly more complex methods include image averaging or
interpolation. There is a good summary of interpolation at
http://www.cambridgeincolour.com/tutorials/image-interpolation.htm
which has a number of images illustrating the differences in several methods.
More advanced methods are generally adaptive - attempting to detect
edges or other significant changes in an image to either speed up the
processing or to ensure the edges or other signficiant changes remain
sharp. The hq3x example below appears to be in this category.
For papers on these algorithms, I suggest
- your local university library
- the on line journals at IEEE or ACM (if a member)
- a search at Citeseer (http://citeseer.ist.psu.edu/cs)
For implementations and other information, here are a few good references.
hq3x Magnification Filter
http://www.hiend3d.com/hq3x.html
This is an interesting implementation of a fixed zoom (3x in this
case) solution. In brief, it examines the 8 adjacent pixels to each
pixel and based on the relative color difference to determine the mix
of colors to be used in the 9 destination pixels (the 3x zoom). There
is companion code for 2x and 4x zoom - if interested, I may be able to
suggest methods to adapt to other zoom factors.
Thumbnail.java
http://schmidt.devlib.org/java/save-jpeg-thumbnail.html
An implementation in Java using built in capabilities of Java to
convert a larger image into a "thumbnail" size. Size of the input
image is "automatic", you can set the size of the thumbnail &
"quality" settings for the output file.
ImageMagick
http://www.imagemagick.org/script/index.php
or
http://www.imagemagick.org/api/resize.php
ImageMagick can do a lot more than zoom an image and is callable from
a number of languages (C, C++, Java, Perl, Python, etc.).
Zoom
http://www.xmission.com/~legalize/zoom.html
Another general purpose package - includes support for several
different file formats and has complete source code (C).
Color Averaging
http://www.compuphase.com/graphic/scale3.htm
Some commentary and source code describing methods to average colors
(a method used frequently in image resizing algorithms). You may want
to look at the other articles posted here that may be helpful as well
(e.g., on perception of colors or "Color Metric").
Geometric Scaling Tutorial
http://www.cee.hw.ac.uk/hipr/html/scale.html
Part of the "Hypermedial Image Processing Reference" at
http://www.cee.hw.ac.uk/hipr/html/hipr_top.html
Has several good links / images that illustrate the basic concepts and
the differences in results.
For additional references, try searches using phrases like
source code image magnification
algorithm image magnification
image scale source code
image zoom source code
adaptive image interpolation algorithm
[algorithm name] image description
image processing tutorial
If any part of the answer is unclear or you need additional
information on some aspect of your question - please make a
clarification request. I would be glad to help.
Good luck with your project.
--Maniac |