
nanoCAD 4.5: raster editing

One of the brightest innovations of nanoCAD 4.5 is the work with raster images. What is it? What for? And what gives users? Let's try to figure it out ...
What is fuss about? Raster versus vector
Before telling what the “goodness” of the raster editing function in nanoCAD is, you need to dive a little into the basic concepts - the world of raster and vector.I think that the difference between a raster and a vector should already be clear to any modern person. This difference is best illustrated by the image shown in fig. 1.

Рис. 1. Растровое (справа) и векторное изображение
Vector is a mathematical description, raster is a set of points. If you paint the difference in more detail, a lot of details will come up (pluses / minuses?). Try to answer the questions: how easy it is to make changes to the vector and raster drawing: mirror, change the type of line, its thickness? Is it easy to enlarge the drawing three times? what size is a drawing of the A0 format in raster format? .. It is clear that a vector drawing is much easier to edit.
And the raster seems to have a bunch of flaws; it seems that the vector format is more promising ... But the raster also has several undeniable advantages. For example, the complexity of making changes to a bitmap drawing is also a plus: imagine that you have finished working on the drawing and you need to protect it from changes. Drawings of equipment are often stored on manufacturers' websites in a raster format. And, finally, it’s easiest to return the printed drawing back to the computer by scanning, and a scan is a raster ... It is because of the simplicity of converting paper drawings into electronic format using a scanner and due to the maximum correspondence of the original to the original, the archives of drawings in enterprises are created in raster format.
In general, a raster is one of the formats for storing working documentation. And that means you need to be able to work with him. But raster raster discord ...
A bit about the quality of the bitmap
A raster has a fundamental characteristic that directly affects its quality - resolution. Considering that a raster image is a set of points, the answer to the question “How many raster points are placed in a certain segment?” Is the resolution of the raster. An inch is usually taken as a segment. A resolution of 300 dpi (dot per inch or dpi) means 300 dots by 2.54 centimeters. A resolution of 72 dpi is horrible, it is impossible to work with it, 1200 dpi is, in general, a good full-color image with very high quality. An example of the same image with different resolutions is shown in Fig. 2.
Рис. 2. Разрешение растра напрямую зависит от качества изображения
If we talk about drawings in a raster format, then for work it is desirable to have a drawing with a resolution of 300-600 dpi. Less - vectorization and binding functions will not work correctly, more - redundant, the drawing will take up too much space in memory and on the hard disk.
An equally important characteristic of a drawing in a raster format is the color of the image. Let's look at the pic. 3.

Рис. 3. Монохромное и grayscale изображение
There is only one color in the image on the left - black (white is the background), that is, the image is monochrome. It absolutely correctly conveys most of the standard drawings. When vectorizing, working with a monochrome drawing is much easier - in contrast to the gray shaded drawing shown in the same figure (on the right). When there are halftones in the image, it is very difficult to programmatically determine which point belongs to the line and which is the background.
The latter requires clarification. Along with the concept of raster quality, there is also the concept of drawing quality. If you print a print and immediately scan it, it will have a fairly high quality. Such a protein drawing requires minimal tools to improve quality. But if copies were taken from the drawing several times, he lay in the storage for a long time, his paper turned yellow and deformed - the quality of the drawing begins to be lost. And if the drawing used is very old and is a copy on photosensitive paper (blue), then there is no way to do it without restoration (Fig. 4, drawings are taken from RasterArts.ru and from Wikipedia ).


Рис. 4. Растровые чертежи часто требуют восстановления и реставрации – особенно старые чертежи-синьки
During restoration, many methods are used - from removing the background (that is, actually removing raster spots of a certain size) to binarization, in which a certain color is highlighted in a separate monochrome image. With all these methods, Raster Arts series software products are superbly managed (we recommend those interested in the site www.rasterarts.ru , where the entire series is presented in detail). The main task of the restoration tools is to save the old paper drawing, translate it into electronic format and put it in the archive, providing it with an information card.
And then you need to work with these bitmap drawings and release new documentation on their basis. Here is a set of such tools and appeared in nanoCAD 4.5 ...
NanoCAD 4.5 Raster Drawing Toolkit
So, in one way or another, you received a raster drawing: either from the enterprise’s archive, or from the NormaCS regulatory documents database, or from the Internet, or you yourself scanned from a textbook. What to do with it now?
Рис. 5. Функции для работы с растром
In general, the list of functions for working with the raster is shown in Fig. 5, but let's look at them with a real example.
Image Insertion
To place a raster drawing in a * dwg-document, just use the OPEN command ( Insert -> Link to raster ... ). You can insert any raster image (at least monochrome, at least color) into the drawing field and in any of five formats (TIFF, JPG, PNG, PCX and BMP). According to experience, the best format is TIFF. It can store multi-page raster images without loss of quality. And monochrome rasters will also occupy the minimum volume - an A4 format drawing and medium saturation will require at a resolution of 300 dpi about 50 Kb.As an example, we take a working drawing from the standard documentation stored in the NormaCS database (Fig. 6).

Рис. 6. Один из чертежей серии 1.100.3-6, утвержденный Госстроем в 1988 году. Еще действующий! Взят из базы нормативных документов NormaCS
Bitmap Correction
Outwardly, the document is almost flawless: the text is read perfectly, good resolution. But if an ideal vector dimensional frame is applied to the inserted drawing, we will see that the paper drawing does not coincide with it. Why?In the process of storing and scanning a paper drawing, both its quality and dimensions (paper compression) were affected. This means that there is no need to talk about any accuracy yet: if we just simply “chopped” the documentation, we will get an incorrect vector drawing. The raster document must first be adjusted.
We call the command Correction by 4 points ( Framing ), specify the format to which the raster should correspond, then four corner points on the raster that correspond to the ideal frame, click OK - and we get a aligned raster image (Fig. 7).

Рис. 7. Операция Коррекция по 4-м точкам позволяет выправить бумажный чертеж и получить более точную подоснову
The image correction functions also include the Rotate / Display raster commands (exists in any graphics editor, but in our case it will not be necessary to upload the raster to an external application), Eliminate Skew, and Trim the raster to a rectangle . The last two are very important. The original is often scanned with a slight skew, and nanoCAD can not only eliminate this skew - by analyzing the lines, the program is able to independently determine the skew angle and eliminate distortions in automatic mode.
Bitmap Editing
Let's say that now the document inserted from NormaCS needs to be attached to our project. To do this, remove some of the information from the drawing (stamp data, product code, number 30 in the upper right corner, etc.). Well, write your own data on top of the bitmap drawing. An ideal tool for the first part of this task is the Eraser . We call the RastrEraser command ( Raster -> Eraser ), set the size of the eraser and carefully erase the excess from the document (Fig. 8).
Рис. 8. Универсальные инструменты Ластик, Карандаш и Заливка позволяют быстро привязать документ к нашему проекту
There is also a reverse command - Pencil , which, on the contrary, will allow you to finish the data. Of course, to draw with a pencil the entire document does not make sense, but to restore the line erased by the eraser is very helpful. There are also the Fill and Erase fill commands : they allow you to fill the closed area with a new color. The last command is especially convenient when you need to remove a complex area from a drawing - say, letters or an isolated part. Click in the letter or the black part of the drawing and the area disappears ...
When the raster drawing is clean, all further work on the document is standard: over the raster data we enter vector ones - texts, lines, arcs, hatching.
Raster snap
Drawing on top of the bitmap is easy enough - you put lines on the eye and gradually draw what you need. But nanoCAD provided automation here as well: starting with version 4.0, it is possible to snap to raster objects and catch typical snaps (end point, circle center, nearest, etc.).In fact, this is a temporary vectorization. While the user moves the cursor over the raster drawing, the program analyzes the structure of the raster and tries to find a vector that is as close as possible to the raster “spot” under the cursor. If the "spot" is elongated, then this is most likely a line, if closed - a circle, if rounded - an arc. It looks absolutely fantastic and very convenient to use (Fig. 9).

Рис. 9. Работая над растровым чертежом, nanoCAD проводит векторизацию документа на лету, что позволяет использовать растровые и векторные привязки
Work with color image
Despite the fact that initially the raster editing teams were conceived for working with drawings, nanoCAD still has the ability to work with color images. The Rotate , Mirror , Eraser , Pencil , and Crop commands are applicable to any raster. At the same time, a number of commands ( Correcting skew in automatic mode , Raster Snap ) only works with monochrome drawings. This must be borne in mind.Printing documentation
When working in nanoCAD, the user receives a hybrid drawing that contains both raster and vector data. How will this drawing look on paper? Surprisingly, it’s almost the same as a regular vector one. If the quality of the original raster is good (read, the resolution of the raster is at least 300 dpi), then on paper the human eye will not be able to distinguish raster lines from vector ones. On the right side of fig. 10 vector data is highlighted in blue.
Рис. 10. Технологии работы с растровым изображением позволяют работать в среде nanoCAD с гибридными чертежами, содержащими как вектор, так и растр
This technology significantly reduces the time spent on documentation. Thanks to nanoCAD there is no need to redraw the entire document: you only correct the part that needs to be changed. And you print the finished drawing. Profit!