Raster graphics. Raster graphics, general information - lecture The concept of a raster image

In order to have a discussion about graphics programs, you first need to understand the concepts and differences between the two main types of 2D graphics: raster and vector images. This is a very important lesson, especially if you intend to work with graphics.

The concept of a raster image

Raster images are images that are made up of tiny rectangular dots of individual color - pixels - strung together. Each pixel has its own special location in the picture and its own individual color value.

Each image has a fixed number of pixels. You can see them on your monitor screen, most of which display approximately 70 to 100 pixels per inch (the actual number depends on your monitor and the settings of the screen itself).

To illustrate this, let's take a look at a typical desktop icon, My Computer, which is typically 32 pixels wide by 32 pixels tall. In other words, there are 32 points of color in each direction that combine to form the image of such an icon.

When you enlarge this drawing as in the example, you will be able to clearly see each individual square of a specific color. Note that the white areas in the background are also individual pixels, although they represent one solid color.

Image size and resolution

Raster images are resolution dependent. Image resolution is the number of pixels in an image per unit length. It is a measure of the clarity of detail in a raster image and is usually referred to as dpi (dots per inch) or ppi (pixels per inch). These terms are somewhat synonymous, only ppi refers to images and dpi refers to output devices. This is why you can find dpi in the description of monitors, digital cameras, etc.

The higher the resolution, the smaller the pixel size and the more of them there are per 1 inch, and accordingly, the better the picture quality.

The resolution is selected for each image individually and depends on where you plan to use it:

  • if you plan to use it for posting on the Internet, then the resolution is selected at 72 ppi, since the main criterion for the Internet is the speed of loading images, and not their amazing quality, which is why appropriate file saving formats are selected, where quality is not in the first place.
  • if you want to print an image, the resolution should be much higher than 72 ppi. So, in order to print an image in good quality, its resolution should be in the range of 150-300 ppi. This is the main requirement for photo printing houses that print magazines, catalogs and small-format products (booklets, flyers, advertising leaflets).

As mentioned above, raster images are very dependent on their resolution. That is why, when scaling, due to their pixel nature, such images always lose quality. However, if you still decide to increase the image size, then it is best to use the interpolation method, with which you can achieve very good results. ABOUT this method we'll talk about it in the next lesson.

The size of an image in raster graphics is physical size file in which this image is stored. It is proportional to the size of the image in pixels.

Photoshop shows the relationship between image size and resolution. This can be viewed by opening the Image Size dialog box found in the Image menu. When changes are made to one of these values, all others will automatically be adjusted in accordance with the changed value.

To sum up, we can say that main characteristics of raster images speakers:

  • image size in pixels
  • bit depth
  • color space
  • image resolution

An example of a raster image is any photograph or picture created by scanning, photographing or drawing in a raster editor, or created by converting a vector image to a raster image.

Raster image formats

The most common raster image formats include:

  • JPEG, JPG

Converting between raster image formats is very easy, using the “Save As ...” command, in the menu of which, after the file name, you select the format in which you want to save the image.

Some formats, namely GIF and PNG, support background transparency. At the same time, one should not forget that transparent background will not be so if the GIF or PNG image is saved in any other format or copied and pasted into another image.

Programs for working with raster graphics

The most popular programs for working with raster graphics:

  • Adobe Photoshop
  • Adobe Fireworks
  • Corel Photo-Paint
  • Corel Paint Shop Pro
  • Corel Painter
  • Paint

As for me, the Adobe Photoshop editor is the best of the programs.

Compared to this type of graphics, Vector graphics also has many advantages. Let's look at them.

What are vector images

Vector is an image, consisting of many individual, scalable objects (lines and curves) that are defined using mathematical equations.

Objects can consist of lines, curves, and shapes. In this case, changing the attributes of a vector object does not affect the object itself, i.e. You can freely change any number of object attributes without destroying the main object.

In vector graphics, image quality does not depend on resolution. This is all explained by the fact that vector objects are described by mathematical equations, so when scaling they are recalculated and, accordingly, do not lose quality. Based on this, you can increase or decrease the size to any extent, and your image will remain as clear and sharp, it will be visible both on the monitor screen and when printing. Thus, the vector is the best choice for illustrations that are displayed on various media and the size of which must be changed frequently, such as logos.

Another advantage of images is that they are not limited to a rectangular shape like raster images. Such objects can be placed on other objects (placement in the foreground or background is chosen by you personally).

For clarity, I have provided a drawing in which a circle is drawn in vector format and a circle in raster format. Both are placed on white backgrounds. But when you place a raster circle on top of another similar circle, you will see that this circle has a rectangular frame, which, as you see in the picture, is not present in the vector.

Today, vector images are becoming more and more photorealistic, this is due to the constant development and implementation of various tools in programs, for example, such as a gradient mesh.

Vector images are typically created using special programs. You cannot scan an image and save it as a vector file without using conversion by tracing the image in Adobe Illustrator.

On the other hand, a vector image can be converted to a raster image quite easily. This process is called rasterization. Also, during conversion, you can specify any resolution of the future raster image.

Vector formats

The most common vector formats include:

  • AI (Adobe Illustrator);
  • CDR (CorelDRAW);
  • CMX (Corel currency);
  • SVG (scalable vector graphics);
  • CGM Computer Graphics Metafile;
  • DXF AutoCAD.

The most popular programs for working with vectors : Adobe Illustrator, CorelDRAW and Inkscape.

So what is the difference between vector and raster images?

Summing up the article about raster and vector images, we can say with confidence that vector images have many advantages over raster images, namely.

In this material we will look at the main differences between raster and vector images. We will learn all the advantages of vector and raster graphics, as well as where it is best to use such graphics for your purposes. So, you have probably asked yourself this question more than once: “What does the picture that is displayed on my computer screen consist of?” You may be surprised, but in fact there is no such thing as a photo!

What is a raster image?

In reality, we only see electronic version pictures on the monitor. If we talk about raster image, then it is stored in the computer memory in the form of numbers and symbols. They are already with a certain sequence describe a specific area (element) the image itself. This element is rendered as a pixel (cells of a certain color). Let's see what kind of pixel this is.

To do this, you can simply take a photo and enlarge it. You will notice that special squares have appeared (picture below). The image began to split into squares of different colors. These squares are pixels.

This is how any raster image obtained from a camera, from a mobile phone camera, or downloaded from the Internet turns out to be. Each pixel, as I said, is described by a certain sequence of numbers and symbols. How do you find out what this sequence is? Yes, very simple! Select the tool " Pipette» (any graphics editor has it) and point at the desired pixel. If you are checking in Photoshop, then you will additionally need to go to the color palette.

So, what follows from what we discussed above. If pixels are represented as a sequence of numbers and letters, then they can be easily changed. By changing the numbers and letters of each pixel, we can change its color, that is, edit the pixel itself. When performing any global correction operation (for example, adjust the brightness) changes numeric value several thousand image pixels.

Now let's get acquainted with the concept vector image. To demonstrate a visual example, I'll try to create new document. Let's go to the menu " File» —> « Create". Let's use it to create vector graphics. For example, I'll take the tool " Feather» (2) . It is imperative that the setting “ Shape layer» (3) . After that I place the dots in the right places (4) . The result is a certain figure. You can do it at your own discretion.

After we have connected all the dots, a shape is formed and a miniature vector mask is attached to the layer. (5) . This indicates that this is a vector shape and not a raster one.It can be increased and decreased many times and the quality will not suffer in any way. Naturally, various glow effects, strokes, and so on can be applied to this layer.

So what are the differences between a raster image and a vector image? Vector images, unlike raster ones, are described by mathematical formulas rather than Latin symbols. Therefore, they can be increased or decreased without loss of quality. The formula remains the same, only the scale changes. The formula, as a rule, describes a smooth curve and at any value this curve will remain smooth.

If you try to enlarge the picture with vector graphics, then you will notice that the pixels are almost invisible, that is, the quality remains at the same level. If you enlarge an image with raster graphics, it will noticeably lose quality.

This way, vector images can be enlarged without losing quality. In any size they are described by mathematical formulas. A raster image is a sequence of pixels. When you enlarge a fragment, quality losses begin to be observed. Loss can also be observed when the image is reduced in size.

Vector images are good to use where you need a large image enlargement without loss of quality. For example, this could include various business cards, logos, website banners and much more. Adobe program Although Photoshop allows you to work with vector images, it is still a raster editor. CorelDraw or Adobe Illustrator are much better suited for working with vector images.

So, we have become acquainted with the concept of raster and vector images. As I said, the main difference: a vector image is described by mathematical formulas and can be enlarged as much as you like without losing quality, which cannot be said about a raster image.

Although, despite this, many web designers, and not only them, often use raster graphics on their sites. This is understandable, because such graphics look much more attractive. However, there are cool examples of vector graphics. In addition, such work weighs much less. In general, study and implement!

Rasters, pixels, sampling, resolution

Like all types of information, images in a computer are encoded as binary sequences. They use two fundamentally different encoding methods, each of which has its own advantages and disadvantages.

Both the line and the region consist of an infinite number of points. We need to code the color of each of these dots. If there are an infinite number of them, we immediately come to the conclusion that this requires an infinite amount of memory. Therefore, it will not be possible to encode the image in a “point-by-point” way. However, this idea can still be used.

Let's start with a black and white drawing. Let's imagine that a grid is superimposed on the image of a rhombus, which divides it into squares. This grid is called a raster. Now for each square we determine the color (black or white). For those squares in which part is painted black and part white, choose a color depending on which part (black or white) is larger.

Picture 1.

We have a so-called raster image consisting of pixel squares.

Definition 1

Pixel(eng. pixel = picture element, picture element) is the smallest element of the picture for which you can set your own color. Having divided the “ordinary” drawing into squares, we performed its discretization - we divided a single object into separate elements. Indeed, we had a single and indivisible drawing - the image of a rhombus. As a result, we received a discrete object - a set of pixels.

The binary code for the black and white image obtained as a result of sampling can be constructed as follows:

  • replace white pixels with zeros and black pixels with ones;
  • We write out the rows of the resulting table one after another.

Example 1

Let's show this with a simple example:

Figure 2.

The width of this figure is $8$ pixels, so each row of the table consists of $8$ binary digits - bits. In order not to write a very long chain of zeros and ones, it is convenient to use the hexadecimal number system, encoding $4$ adjacent bits (tetrad) with one hexadecimal digit.

Figure 3.

For example, for the first line we get the code $1A_(16)$:

and for the entire figure: $1A2642FF425A5A7E_(16)$.

Note 1

It is very important to understand what we have gained and what we have lost as a result of discretization. The most important thing is that we were able to encode the drawing in binary code. However, the drawing was distorted - instead of a diamond, we got a set of squares. The reason for the distortion is that in some squares parts of the original picture were painted with different colors, but in the encoded image each pixel necessarily has one color. Thus, some of the original information was lost during encoding. This will manifest itself, for example, when the picture is enlarged - the squares become larger, and the picture becomes even more distorted. To reduce information loss, you need to reduce the pixel size, that is, increase the resolution.

Definition 2

Permission is the number of pixels per inch of image size.

Resolution is usually measured in pixels per inch (using the English notation $ppi$ = pixels per inch). For example, a resolution of $254$ppi$ means that there are $254$pixels per inch ($25.4$mm), so that each pixel "contains" a square of the original image measuring $0.1x0.1$mm. The higher the resolution, the more accurately the image is encoded (less information is lost), but at the same time the volume also increases file.

Color coding

What to do if the drawing is colored? In this case, one bit is no longer enough to encode the color of a pixel. For example, in the image of the Russian flag $4$ shown in the picture, the colors are black, blue, red and white. It takes $2$ bits to encode one of the four options, so the code for each color (and the code for each pixel) will consist of two bits. Let $00$ represent black, $01$ red, $10$ blue, and $11$ white. Then we get the following table:

Figure 4.

The only problem is that when displayed on the screen, you need to somehow determine which color corresponds to this or that code. That is, color information must be expressed as a number (or set of numbers).

A person perceives light as a multitude of electromagnetic waves. Certain wavelength correspond to a certain color. For example, wavelengths of $500-565 nm are green. So-called “white” light is actually a mixture of wavelengths that span the entire visible range.

According to the modern concept of color vision (the Young-Helmholtz theory), the human eye contains three types of sensitive elements. Each of them perceives the entire flow of light, but the first are most sensitive in the red region, the second in the green region, and the third in the blue region. Color is the result of stimulation of all three types of receptors. Therefore, it is considered that any color (i.e. Feel a person perceiving waves of a certain length) can be simulated using only three light beams (red, green and blue) of different brightness. Consequently, any color is approximately decomposed into three components - red, green and blue. By changing the strength of these components, you can create any colors. This color model is called RGB after the initial letters of the English words red, green and blue.

In the RBG model, the brightness of each component (or, as they say, each channel) is most often encoded as an integer from $0$ to $255$. In this case, the color code is a triple of numbers (R, G, B), the brightness of individual channels. The color ($0,0,0$) is black and ($255,255,255$) is white. If all components have equal brightness, shades of gray are obtained, from black to white.

Figure 5.

To make a light red (pink) color, you need to increase the brightness of the green and blue channels equally in the red color ($255,0,0$), for example, the color ($255, 150, 150$) is pink. Uniformly reducing the brightness of all channels makes a dark color, for example, the color with code ($100,0,0$) is dark red.

In total there are $256$ brightness options for each of the three colors. This allows us to encode $256^3= $16,777,216 shades, which is more than enough for a human. Since $256 = 2^8$, each of the three components takes up $8$ bits or $1$ bytes in memory, and all the information about a certain color takes up $24$ bits (or $3$ bytes). This value is called color depth.

Definition 3

Color depth is the number of bits used to encode the color of a pixel.

$24$-bit color encoding is often called true color mode. To calculate the volume of a picture in bytes with this encoding, you need to determine the total number of pixels (multiply the width and height) and multiply the result by $3$, since the color of each pixel is encoded in three bytes. For example, a picture of $20×30$ pixels encoded in true color would take up $20×30×3 = 1800$ bytes.

In addition to the true color mode, $16$-bit coding is also used (English: High Color), when $5$ bits are allocated to the red and blue components, and $6$ bits are allocated to the green component, to which the human eye is more sensitive. High Color mode can encode $2^(16) = $65,536 different colors. IN mobile phones$12$-bit color encoding ($4$ bits per channel, $4096$ colors).

Coding with palette

As a general rule, the fewer colors used, the more distorted the color image will be. Thus, when encoding color, there is also an inevitable loss of information, which is “added” to the losses caused by sampling. Very often (for example, in diagrams, diagrams and drawings) the number of colors in the image is small (no more than $256$). In this case, palette coding is used.

Definition 4

Color palette is a table in which each color, specified as components in the RGB model, is associated with a numerical code.

Coding with a palette is done as follows:

  • select the number of colors $N$ (usually no more than $256$);
  • from the true color palette ($16,777,216 colors) we select any $N$ colors and for each of them we find the components in the RGB model;
  • each color is assigned a number (code) from $0$ to $N–1$;
  • We create a palette by first writing down the RGB components of the color with code $0$, then the components of the color with code $1$, etc.

The color of each pixel is encoded not as RGB component values, but as a color number in the palette. For example, when image encoding Russian flag (see above) $4$ colors were chosen:

  • black: RGB code ($0,0,0$); binary code $002$;
  • red: RGB code ($255,0,0$); binary $012$;
  • blue: RGB code ($0,0,255$); binary $102$;
  • white: RGB code ($255,255,255); binary code $112$.

Therefore, the palette, which is usually written to a special service area at the beginning of the file (called the file header), consists of four three-byte blocks:

Figure 6.

The code for each pixel takes only two bits.

Palettes with a color quantity of more than $256$ are not used in practice.

Advantages and disadvantages of raster coding

Raster coding has dignity:

  • universal method (any image can be encoded);
  • The only method for encoding and processing blurry images that do not have clear boundaries, such as photographs.

AND flaws:

  • there is always a loss of information during sampling;
  • when changing the size of an image, the color and shape of objects in the picture are distorted, since when increasing the size, you need to somehow restore the missing pixels, and when decreasing, you need to replace several pixels with one;
  • The file size does not depend on the complexity of the image, but is determined only by the resolution and color depth.

As a rule, raster images have a large volume.

If you are an experienced designer, you do not need this article, you probably know the difference between a raster and a vector, and you came here by accident. For all beginners, this difference is not only unclear, they don’t even suspect that the difference exists.

Let's try to figure it out. A raster and vector image is in any case a graphic object.

Raster graphics.

Photo printcnx.com

The peculiarity of a raster image is that, like a mosaic, it is made up of small cellular pieces - pixels. And the higher the resolution, the large quantity pixels fit per unit area.

Example: resolution 600x800px.

Literally this means the following: your picture contains 600 pixels vertically and 800 horizontally. If this image is not enlarged and viewed on the screen, then most likely the human eye will not notice the cellularity.

If you start enlarging or printing on paper, for example A4, you will see a mosaic. The picture will look like a cross stitch pattern.

Raster images are used to convey a smooth transition of colors and many shades. The most common application is photo processing, creating collages, etc. The most popular raster graphics editor is Photoshop.

A raster image takes up more disk space than the same image, but executed in a vector. But, here it is very important to remember that this is true if you “drew the text”, and if you photographed your beloved girl against the background of a red Ferrari, the vector is powerless here, only a raster.

Vector graphics.


Photo printcnx.com

Unlike a raster image, a vector image does not consist of individual points - pixels. The logic of a vector image is completely different. In vector graphic objects there are so-called anchor points, with curves between them. The curvature of these curves is described mathematical formula. This does not mean that the designer should be a guru of higher mathematics and remember the formulas of all kinds of hyperbolas and parabolas; you don’t even have to describe a sine wave. Does all this for you graphics editor. The designer, you know, places points and “drags” the curve with the mouse in order to achieve the desired shape.

The most popular vector graphics editors are CorelDrow and Adobe Illustrator.

Vector graphics are often used in printing: booklets, leaflets, business cards, etc. Ie. products that contain text, a logo, ornamental patterns - everything that does not require an accurate representation of all 18 shades of peach color, and can be described using curves. Vector images are often called “in curves”.

The biggest advantage of vector images is that even with high magnification graphic object, the image quality does not change. The picture will be equally good if you print it from a vector onto a business card or print the same business card the size of a billboard.

As a result we have:

Raster image:
pros: very clearly and subtly conveys the change-flow of colors, shades, shadows.
Minuses: loss of quality when enlarging: the picture crumbles into colored squares - pixels; in high resolution it takes up a lot of space.
Scope of application: photo processing, creating website layouts, creating graphic objects with a wide range of colors

Vector image:
pros: Easy to scale - the image does not lose quality even at very high magnifications.
Minuses: It is impossible to convey smooth color transitions, as in raster.
Scope of application: printing, design of leaflets, booklets, advertising materials, business cards, logos, etc.

How do you plan to use your logo: online or on printed materials?

You don't have to choose anymore. After all, the Logaster online service offers to create several logo files at once, which perfectly adapt to any media.