The raster principle for representing graphics was invented many centuries before the advent of computers – it was used in such types of applied art as mosaic, stained glass and embroidery. In them, the image is built from separate elements independent of each other.
Digital images that have adopted the same principle are also a mosaic of very small discrete (individual) elements – pixels, described by the position in the bitmap (table, matrix) and color characteristics.
Pixels, like colored stones in a mosaic, are independent of each other.
In this case, one or more video pixels or points can be used for the image of one pixel, depending on the image display scale.
The display screen is divided into a fixed number of video pixels, which form a graphic grid (raster) of a fixed number of rows and columns. The graphic grid size is usually represented in the form N * M, where N is the number of video pixels in the horizontal direction and M is in the vertical direction.
On modern displays, for example, such graphic grid sizes are used: 640 * 480, 800 * 600, etc. Video pixels are very small (less than 0.3 mm) and are located close to each other. In order for an image to be perceived by the eye, it must be composed of thousands or millions of video pixels, each of which must have its own color tint. An enlarged video pixel is a square or rectangle.
Each little bitmap square in the bottom image is an enlarged pixel.
Vector graphics consist of reference (nodal) points, which are connected by curved lines (Bernstein-Bezier curves). These lines form paths that can contain strokes and fills.
In order to compare these two types of graphics, we list their advantages and disadvantages.
Advantages and disadvantages of this type of graphics
Advantages of raster (pixel) graphics:
- Hardware feasibility, which ensures the ease of obtaining such images. Unlike vector images created by an artist or designer, raster images can be obtained automatically using a camera or scanner.);
- Versatility of formats – jpeg can be seen in any OS, opened in any editor, and immediately posted on the Internet;
- Photorealistic and photodocumentary.
Disadvantages of raster (pixel) graphics:
- Large file size. The bitmap file stores the color information of each video pixel as a combination of bits. The simplest type of image has only two colors. In this case, 2 values are required to encode the color of each video pixel, which means that one bit of memory is enough – two values: 0 and 1. If the color of a video pixel is determined by two bits, then we have 4 possible combinations of 0 and 1: 00, 01, 10, 11 , which means that 4 colors can already be encoded. Four bits of memory allow you to encode 16 colors, 8 bits – 256 colors, 24 bits 16,777,216 different colors.
- Simple raster images occupy a small amount of memory (several tens or hundreds of kilobytes). Photo quality images often require several megabytes. For example, if the graphic grid size is 1240 x 1024, and the number of colors used is 16,777,216, then the size of the bitmap file is about 4 MB. because information about the color of video pixels in the file takes
1240 *1024 * 24 = 30474240 (bits), or
30 474 240 / 8 = 3 809 280 (bytes), or
3 809 280 / 1024 = 3720 (Kb), or
3720 / 1024 = 3.63 (Mb)
- When using 16-bit color depth, we can already talk about hundreds of megabytes.
Thus, bitmaps require a large amount of memory to store.
A simple solution to the problem
The simplest solution to the bitmap storage problem is to increase the computer’s storage capacity. Modern hard drives and optical drives provide significant amounts of storage for data. The downside to this solution is cost, although the prices of these storage devices have been coming down noticeably lately.
Another way to solve the problem is to compress graphic files, that is, use programs that reduce the size of raster graphics files by changing the way the data is organized. There are several methods for compressing graphic data.
In the simplest of them, a sequence of repeating values (in our case, a set of bits for representing video pixels) is replaced by a pair of values - a repeating value and the number of its repetitions.
This compression method is called RLE. The RLE method works best with images that contain large areas of solid shading, but it compresses photographs much worse, since there are almost no long lines of pixels of the same color. Highly patterned images are well compressed using the LZW method.
The problem with transformations and distortions.
A bitmap after scaling or rotating may lose its appeal. For example, areas of solid color may take on a strange pattern; curves and straight lines that looked smooth can suddenly become sawtooth. If you reduce and then enlarge a bitmap image to its original size, it will become fuzzy and jagged, and filled areas may be distorted.
The reason is that resizing a bitmap is done in one of two ways:
– all pixels of the picture change their size
— Pixels are added to or removed from the picture.
In the first method, scaling the image does not change the number of pixels included in it, but the number of elements needed to build a pixel changes, and as the picture is enlarged, the “stepping” becomes more and more noticeable – each point turns into a square.
The sampling of pixels in an image can be done in two ways. First, you can simply duplicate or remove the required number of pixels. Secondly, with the help of certain calculations, the program can create pixels of a different color, determined by the original pixel and its surroundings. In this case, the disappearance of small details and thin lines from the picture, as well as a decrease in the sharpness of the image, is possible.
So, raster images have limited possibilities for scaling, rotation and other transformations.
Hardware dependence on the type of technology used and problems with moiré.