Image operations

A digital image is basically a two dimensional discrete number matrix,where all the information of an image is stored in matrix elements. One element contains data for a single pixel. An unlimited number of different calculations, which modify the image someway, can be performed with this matrix. This is the main advantage of digital images compared to analog pictures. The basic operations include operations like image resizing, cutting, thresholding, copying, pasting, rotating, pixelizing, changing pixel values and image filtering. More advanced operations might include warping, morphing and color keying. These pages just skim the surface.

1. Basic operations

The best way to learn what kind of operations can be done with an image, is to run some kind of a graphic tool, like xv, photoshop or xpaint and try experimenting with an image. Here are a few basic examples of elementary operations :

Resizing

The user sets the new parameters either by typing the new height and width or by typing procent values for these two. In this operation, the pixel size on the screen is modified : One image pixel no longer consumes only one screen pixel, but 2 * 2 screen pixels, thus making the picture 4 times larger. If the resizing parameters are for example 132 % * 140 %, then new pixel values have to be calculated by averaging the old ones.

Copy-and-paste

Area of w * h starting from (x , y) is copied from tje original image matrix to a new image matrix:

Rotating

In rotation every pixel has to be rotated the wanted angle and put in a new place in the matrix and the matrix dimensions also have to be modified. Otherwise pixels that fall out of the current image matrix are left out. In the latter case, the matrix elements, which are now empty, have to be filled with black or white color.

Rotating 36 degrees counterclockwise.

Pixelizing

Calculate a mean value for a block of pixels (like 4 *4) and replace ALL pixel values inside that block with this mean value. These calculations are done for every BLOCK of pixels in an image. Blocks at the border of the image are either averaged with fewer pixels or alternatively the missing pixel values for averaging are taken "mirrored" from the opposite side of the image.