Image Filtering


Team Members


Introduction

Performs a variety of basic image processing tasks on a 128X128 bitmap image. Uses a modular convolution matrix which describes the transformation that needs to be applied to each individual pixel, then iterates through the bitmap array, applying the transformation to each pixel in succession. Changing the matrix allows us to rotate, sharpen, and blur the images.

Want a sample? The following was done with ImageJ, made by Wayne Rasband (National Institutes of Health), and released into the public domain. He used an algorithm substantially similar to the one we will be using, except his was implemented in Java (Java for graphics manipulation -- and you wonder why he works for the government).

Mario, prior to any algorithm being applied

Above, we have a portrait of our plucky plumber. (Copyright Nintendo 2002)

Mario, with the blurring algorithm applied three times

Perhaps Mario should lay off the vino... he seems to be getting a little hazy. (The blur algorithm has been applied three times).

Mario, deblurred

Luckily, the algorithm is reversible, if a little lossy (i.e. some data is lost in the process).


Problem Description

There are two difficulties in the program. The first is the convolution alorithm, which applies the matrix to the image. Designing it to operate efficiently will be the most technically challenging part of the project. Given that the images we are working on are fairly small, PIII machines won't have any difficulty working on them even with a fairly inefficient algorithm, but we'd like ours to scale well.

The second difficulty is designing the various convolution matricies to get the desired (and hopefully, impressive) effects.


Implementation

The images are read in from 256 color, 128X128 BMP format images and are stored internally as 128X128 byte arrays. The program will use a minimum of two buffers, and probably more, to store the images when working on them. Two images (before and after) will be shown on the screen for each transformation. String operations will be used as much as possible, in the interest of making the transformations fast. The palette of the graphics card will be modified to match the pallete of the BMP file.


Procedures


Convolve

Inputs:

kernel array byte, image _from array byte[128x128]

Outputs:

image _to array byte[128x128]

Function:

Applies specified kernel tranformation to the image, writes it to the _to array buffer.

Member in charge:

Jeremy, Eric(kernels)

DrawPic

Inputs:

BX = pointer to the image to draw, DX = top left corner on screen

Outputs:

writes to screen

Function:

Reads in image byte buffer, writes it to the screen.

Member in charge:

Tom

FileIn

Inputs:

DX = file name buffer, BX = destination image array

Outputs:

writes to image buffer pointed to in BX, sets screen palette

Function:

Reads in BMP file, sets palette to properly display it.

Member in charge:

Patrick

FileOut

Inputs:

DX = file name buffer, BX = source image array

Outputs:

writes to disk with file name specified.

Function:

Reads in BMP file, sets palette to properly display it.

Member in charge:

Patrick

CopyPic

Inputs:

SI = source image array, DI = destination image array

Outputs:

writes to image buffer pointed to in BX, sets screen palette

Function:

Copies an image array between two locations.

Member in charge:

Tom

UI

Inputs:

user banging away on keyboard

Outputs:

calls functions appropriate to the user's input

Function:

A loop which interprets what the user wants done, then does it.

Member in charge:

Ethan
Stuff we might do if we have time:

Zoom

Inputs:

BX = destination image, DX = array index of top left of "window"

Outputs:

writes new image to memory

Function:

Blows up a 64X64 "window" of a particular image, effectively a 4X zoom.

FindEdges

Inputs:

DX = file name buffer, BX = destination to write image to

Outputs:

writes to image buffer pointed to in BX

Function:

Uses as-yet-unspecified algorithm to identify the edges of an image, by reducing it to grayscale.

Rotate

Inputs:

DX = file name buffer, BX = destination to write image to, AL = degrees to rotate

Outputs:

writes to image buffer pointed to in BX

Function:

Reads in BMP file, rotates it (AL * 90) degrees right.

External Routines

The convolution algorithm we use was described by Wayne Rasband and [blah], but the implementation of it is our own. All other routines will be scratch-coded. kernels used were developed & tested by Eric Sigfried.