
- Computer Graphics - Home
- Computer Graphics Basics
- Computer Graphics Applications
- Graphics APIs and Pipelines
- Computer Graphics Maths
- Sets and Mapping
- Solving Quadratic Equations
- Computer Graphics Trigonometry
- Computer Graphics Vectors
- Linear Interpolation
- Computer Graphics Devices
- Cathode Ray Tube
- Raster Scan Display
- Random Scan Device
- Phosphorescence Color CRT
- Flat Panel Displays
- 3D Viewing Devices
- Images Pixels and Geometry
- Color Models
- Line Generation
- Line Generation Algorithm
- DDA Algorithm
- Bresenham's Line Generation Algorithm
- Mid-point Line Generation Algorithm
- Circle Generation
- Circle Generation Algorithm
- Bresenham's Circle Generation Algorithm
- Mid-point Circle Generation Algorithm
- Ellipse Generation Algorithm
- Polygon Filling
- Polygon Filling Algorithm
- Scan Line Algorithm
- Flood Filling Algorithm
- Boundary Fill Algorithm
- 4 and 8 Connected Polygon
- Inside Outside Test
- 2D Transformation
- 2D Transformation
- Transformation Between Coordinate System
- Affine Transformation
- Raster Methods Transformation
- 2D Viewing
- Viewing Pipeline and Reference Frame
- Window Viewport Coordinate Transformation
- Viewing & Clipping
- Point Clipping Algorithm
- Cohen-Sutherland Line Clipping
- Cyrus-Beck Line Clipping Algorithm
- Polygon Clipping Sutherland–Hodgman Algorithm
- Text Clipping
- Clipping Techniques
- Bitmap Graphics
- 3D Viewing Transformation
- 3D Computer Graphics
- Parallel Projection
- Orthographic Projection
- Oblique Projection
- Perspective Projection
- 3D Transformation
- Rotation with Quaternions
- Modelling and Coordinate Systems
- Back-face Culling
- Lighting in 3D Graphics
- Shadowing in 3D Graphics
- 3D Object Representation
- Represnting Polygons
- Computer Graphics Surfaces
- Visible Surface Detection
- 3D Objects Representation
- Computer Graphics Curves
- Computer Graphics Curves
- Types of Curves
- Bezier Curves and Surfaces
- B-Spline Curves and Surfaces
- Data Structures For Graphics
- Triangle Meshes
- Scene Graphs
- Spatial Data Structure
- Binary Space Partitioning
- Tiling Multidimensional Arrays
- Color Theory
- Colorimetry
- Chromatic Adaptation
- Color Appearance
- Antialiasing
- Ray Tracing
- Ray Tracing Algorithm
- Perspective Ray Tracing
- Computing Viewing Rays
- Ray-Object Intersection
- Shading in Ray Tracing
- Transparency and Refraction
- Constructive Solid Geometry
- Texture Mapping
- Texture Values
- Texture Coordinate Function
- Antialiasing Texture Lookups
- Procedural 3D Textures
- Reflection Models
- Real-World Materials
- Implementing Reflection Models
- Specular Reflection Models
- Smooth-Layered Model
- Rough-Layered Model
- Surface Shading
- Diffuse Shading
- Phong Shading
- Artistic Shading
- Computer Animation
- Computer Animation
- Keyframe Animation
- Morphing Animation
- Motion Path Animation
- Deformation Animation
- Character Animation
- Physics-Based Animation
- Procedural Animation Techniques
- Computer Graphics Fractals
Raster Methods for Transformation in Computer Graphics
So far in this tutorial, we have explored transformation matrices to perform transformations on points or vectors to be specific. To display images, we need rasterizations. We can apply these transformations on raster images as well.
Raster graphics are made up of tiny pixels arranged in a grid, and transformations are applied to these pixels to manipulate the images. We can apply the same rotate, scale, translate, or skew the image, among other operations. In this chapter, we will have a detailed explanation of how transformations work on raster images.
Basics of Raster Graphics
Raster graphics are images composed of a grid of pixels. Each pixel representing a small piece of the image. They are commonly used for photographs and complex images due to their ability to handle a wide range of colors and details.
Raster transformations are more challenging than vector graphics, because they use mathematical equations to define objects, but they are easier to apply due to the fixed grid of pixels.
Raster Transformation Methods
Like vectors, we also use raster transformations using mathematical operations on the pixel grid. Some common raster transformations are:
- Translation − Moving the entire image by shifting all its pixels by the same amount.
- Rotation − Rotating the image around a specific point.
- Scaling − Enlarging or shrinking the image by adjusting the distance between pixels.
- Shearing − Slanting the image in a particular direction.
- Reflection − Flipping the image across an axis.
All these transformations involve adjusting the position or values of the pixels in the raster grid. The most common approach is to apply a transformation matrix to the pixel coordinates
In the following sections of this chapter, we will see the transformation applied on an image. The input image is −

For raster images, since it is an array of pixels, the (0, 0) coordinate is the top left corner of the image.
Translation of Raster Images
Translation is the simplest raster transformation. It performs shifting all the pixels in the image by the same amount along the x-axis, y-axis, or both. For example, if we want to move an image 50 pixels to the right and 70 pixels down, we add 50 to the x-coordinate of each pixel and 70 to the y-coordinate.

Rotation of Raster Images
The next operation is rotating a raster image. It is is more complex than translation because we must adjust the position of each pixel based on the rotation angle. When we rotate an image, each pixel moves to a new position, and we need to calculate the new coordinates for every pixel.
This matrix is applied to the coordinates of each pixel, rotating them around the origin of the image. However, when we rotate an image, we often encounter a problem called aliasing, where the rotated pixels do not align perfectly with the grid, resulting in jagged edges or distorted shapes. To reduce aliasing, techniques like bilinear interpolation or bicubic interpolation can be used to smooth out the transitions between pixels.

Here, the pivot is at (0, 0), then it is rotated 45.
Scaling of Raster Images
Scaling is another common transformation applied to raster images. It is just enlarging or reducing the image by adjusting the distance between pixels.
In the following figure, we are applying scaling factor of 1.5 and 1.5 for X and Y respectively.

Where sx and sy are the scaling factors along the X and Y axes. Scaling an image can sometimes result in pixelation, where the individual pixels become visible, especially when enlarging the image by a large factor. To avoid this, smoothing techniques like anti-aliasing can be used.
Shearing of Raster Images
Shearing is a transformation that slants the image along the X or Y-axis. This creates a skewed effect. For example, horizontal shearing moves each pixel horizontally by an amount proportional to its y-coordinate.

Here it is sheared on X-axis with ratio 0.5

Here it is sheared on the Y-axis with ratio 0.5
Interpolation Methods for Raster Transformation
Let us see the idea of interpolation. It is one of the most challenges while we are using transformation on raster images. Sometimes we deal with pixels that do not align perfectly with the transformed grid. This happens during rotation, scaling, and shearing. To handle this, interpolation methods are used to estimate the color values of new pixels based on the surrounding pixels.
The most common interpolation methods are −
- Nearest-Neighbour Interpolation − This is the simplest method, where each new pixel is assigned the color of the closest pixel in the original image. While fast, it often results in blocky or pixelated images.
- Bilinear Interpolation − This method calculates the color of each new pixel by taking the weighted average of the four nearest pixels. It produces smoother images than nearest-neighbour interpolation.
- Bicubic Interpolation − This method uses the eight nearest pixels to calculate the color of each new pixel. It produces even smoother results, making it ideal for high-quality transformations.
Interpolation is needed in maintaining the quality of an image during transformation. Without it, transformed images may appear jagged, pixelated, or distorted.
Conclusion
In this chapter, we explained the basics of raster graphics and covered key transformations like translation, rotation, scaling, and shearing. We also looked at interpolation methods that help maintain image quality during transformations. There are several methods including nearest neighbour method, bilinear method and the bi-cubic method.