29-09-2016, 10:54 AM
1456738572-INTER.pdf (Size: 218.97 KB / Downloads: 7)
Introduction
The aim of computer graphics these days is headed toward the third dimension; companies
are focusing their assets on creating more realistic 3-d graphics, applying physics and real
life observations to their projects. However, with all attention on the third dimension,
many forget about the aspects of the second dimension that have yet to be touched upon
or mastered.
It is my view the computer entertainment industry has become lazy in the use of twodimensional
graphics. Capcom, and many other leading software companies, consistently
come out with software with noticeable pixelation. Obviously the aesthetic quality of a
program is very important in order for it to appeal to the masses.
However, with the application of a simple graphical filter, the resolution and quality
of the images that appear on the screen are greatly increased. In this case, one can
possibly even port software from 1980s and have them appear in a marketable, somewhat
presentable fashion. Thus, time and money can be saved since graphics do not need to
be completely redrawn.
Additionally, image interpolation can be especially useful when one needs to reduce
file size or increase the amount of image data sent at one time. With the image size
reduced, the image quality does not have to be significantly reduced as well.
This tech-lab project bravely ventures into the fields of image processing and computer
graphics. It is my aim to explore the boundaries of 2D graphics and animation and
research the application of image filters and processing.
2 Background
Interpolation is way through which images are enlarged. There are many different types
of interpolation methods, each resulting in a different ?look? to the final picture. Thus,
it is best if the quality, or visible distinction for each pixel, is retained throughout the
enlargement process.
Thus, one cannot simply have a number of pixels directly represent a single original
pixel; this is not sufficient for commercial use. Conspicuous blocks of single color will be
visible, and depending on size of enlargement, the original image will be unrecognizable.
Older methods of linear interpolation somewhat addressed this problem. By finding
a mean pixel value between neighboring pixels, one was able to produce an effect of
blurred edges and smoothed details. Bilinear re-sampling uses the values from the four
surrounding pixels, and new pixel values are calculated by weighting the averages of the
four closest pixels based on distance. The new pixel value is determined by calculating
a weighted average of the four closest pixels (2x2 array) based on distance. However,
bilinear interpolation seems to work better for image reduction rather than image enlargement.
Linear interpolation methods can only go so far, and it has been found that nonlinear
methods are superior. Some non-linear interpolation methods include Bi-Cubic,
Soft Directional, and non-linear interpolation through extended permutation filters. Bicubic
interpolation uses the nearest sixteen pixels (4x4 array) based on distance, which
produces a much better effect than linear interpolation.
Most high-end image manipulation and viewing programs today have some sort of
interpolation process used when resizing an image. Such include ACDSee, Adobe Photoshop,
IfranView, and even Internet Explorer. They implement many commercial interpolation
methods. For instance Lanczos Interpolation, standard Kneson, and pxl
SmartScale.
3 Blitters
Typically blitters are, quite simply, used to display graphics. However, it is not uncommon
for many blitters to implement special video modes that manipulate the original screen
output.
The Super2XSai blitter is an existing interpolation engine use primarily in the PC
emulation of arcade machines and video game consoles. It increases the size of the original
video output by twice-fold, and applies a unique interpolation filter onto each frame.
There are many other interpolation video blitters for emulation use, such as SuperEagle,
Zoom 2X Software, and various scanlined video blitters. However, the effects that
these blitters produce are very stylized and significantly change the look of the original
video.
Developmental Resources
For this project, the main coding languages used were C and C++. Additionally, SDL
(Simple DirectMedia Layer) and OpenGL have been used to display the interpolated
images and graphical statistical representation of pixel data. The SDL graphical library
was learned specifically for this project.
5 Image Filetype
Although there have been forays into researching bitmap header and RAW image filetypes,
as of now the official image filetype of this project is the PPM (Portable PixMap),
due to its ease of use.
A PPM can be read quite with little difficulty. After a very simple file header with
select information such as P identifier, resolution, and maximum pixel value, all the pixel
data is listed. Being able to view a PPM directly in a text editor, since all of the data is
encoded in ASCII, allows for easy debugging of code and exact results.
A typical PPM goes like this:
P3 (identifier) 200 300 (width height) 255 (max pixel value)
0 0 121 1 2 4 242 0 1 etc. etc. etc. (image data)
However, as time passes, the Bitmap has become crucial to this project as well,
especially when graphical libraries such as SDL are involved. Typical Bitmap header
types are as follows:
Bytes_Per_Raster = (X2 - X1 + 1) * 3;
If ((Bytes_Per_Raster % 4) == 0)
4
Raster_Pad = 0;
Else Raster_Pad = 4 - (Bytes_Per_Raster % 4);
Bytes_Per_Raster = Bytes_Per_Raster + Raster_Pad;
Long int bfSize = 0; //(* Size of File, Computed below *)
int bfReserved1 = 0; //(* Always Zero *)
int bfReserved2 = 0; //(* Always Zero *)
int bfOffbits = SizeOf(Header); //(* Pointer to Image Start *)
int biSize = 40; //(* Bytes in bi Section *)
int biWidth = X2 - X1 + 1; //(* Width of Image *)
int biHeight = Y2 - Y1 + 1; //(* Height of Image *)
int biPlanes = 1; //(* One Plane (all colors packed)*)
int biBitCount = 24; //(* Bits per Pixel *)
int biCompression = 0; //(* No Compression *)
int biSizeImage = Bytes_Per_Raster * biHeight; //(* Size of Image *)
int biXPelsPerMeter = 0; //(* Always Zero *)
int biYPelsPerMeter = 0; //(* Always Zero *)
int biClrUsed = 0; //(* No Palette in 24 bit mode *)
int biClrImportant = 0; //(* No Palette in 24 bit mode *)
int bfSize = SizeOf(Header) + biSizeImage;
Since BITMAP is more or less the STANDARD, it was crucial to be able to use it in
this project.
5
6 Nearest Neighbor
Probably the most basic form of interpolation. As the actual pixels are proportionally
copied to their new locations, their position in relation to one another remains the same.
Since the image is enlarged, filler pixels must be placed in between the actual pixels.
With the most basic nearest neighbor interpolation, just copy the exact same pixel
values over to the filler pixel closest to the pixel. Since my images have been initialized
with the pixel at 0,0 being the same pixel in the original and enlarged image, I choose
the pixel to the right or the pixel below, dependant on where the filler pixel is placed.
DIAGRAM
AB
CD
For 2X Turns into
AABB
AABB
CCDD
CCDD