Skip to content

← Blog

How to vectorize a scanned drawing and convert it to DWG

· Guides

The screenshots show the Spanish interface; commands and options are given as they appear in the English version of the program.

A scanned drawing is a picture: pixels, not lines. You can trace over it by hand, but on a long drawing that takes hours. The other route is to vectorize it: turn the ink in the image into polylines, circles and arcs, and recognize the labels with OCR so they become editable text. In LinceCAD both are done inside the program, with VECTORIZAR and OCRIMAGE, and the result is saved as DWG.

If your drawing is not a scan but a PDF exported from a CAD program, there is no need to vectorize: it contains the vectors and PDFIMPORT converts them directly. We explain it in how to convert a PDF to DWG.

LinceCAD demo: a scanned floor plan is attached as an image, VECTORIZAR in outline mode turns it into lines and arcs, and OCRIMAGE converts its labels into text (26 s, no sound). The video shows the Spanish interface: OCRIMAGEN is OCRIMAGE in English.

Which scans give the best results

The image can be PNG, JPEG, BMP, TIFF, GIF or WebP.

Step by step

1. Attach the image on its own layer

Create one layer for the scan and another for the vectorized result (for example SCAN and VECTOR): that way you can later turn the image off and see only the entities. With the scan layer current, type IMAGEATTACH (or click the button on the Insert tab, Image and tracing group), choose the file and specify the insertion point, scale and rotation. The image is not copied into the drawing: its path is saved.

Scanned floor plan of a home, with walls, doors, a round column and the labels SALON, COCINA, ASEO, DORMITORIO and TERRAZA, attached as an image on the ESCANEO layer in LinceCAD (Spanish interface).
The scan attached with IMAGEATTACH, before vectorizing.

2. Clean up the image if needed

IMAGEEDIT retouches the pixels without touching the original file (it saves a copy <name>-ed.png and relinks the image to it). The most useful operations before vectorizing:

If the drawing was photographed at an angle, IMAGEPERSP uses four corners to straighten what should be rectangular. To remove margins or the title block, use IMAGECROP.

3. Bring the image to its real scale

Vectorized entities are created where the image is and at its size, so it is best to scale it first. With GEOREFIMAGE you pick two or three recognizable points on the scan (the ends of a known dimension, a grid line intersection) and give them their real position; the image is moved, rotated and scaled without being distorted. If you prefer to do it afterwards, SCALE with the Reference option, or ALIGN, does the same with the entities.

4. Vectorize

Make the VECTOR layer current, type VECTORIZAR (or click Vectorize image) and select the image. Before running it you can adjust the parameters; Enter runs it with the current ones:

ParameterWhat it does
ThresholdBinarization limit (0-255): a pixel darker than the threshold counts as ink.
Fit (tolerance)How far an outline can deviate, in pixels, and still be a line, circle or arc, and how much polylines are simplified.
MinimumDiscards strokes shorter than this size in pixels (8 by default). Useful for removing noise.
CenterlineThins strokes to one pixel and follows their center, instead of going around the outline. Intended for line drawings with thick strokes.
JoinJoins broken strokes whose ends almost touch.

Each outline is fitted by least squares: if it is nearly circular you get a circle or an arc, if it is nearly straight a line, and otherwise a polyline. The entities take the current layer and color.

5. Recognize the text with OCR

Switch to a layer for the text and type OCRIMAGE (or RECOGNIZETEXT), select the image and press Enter. One text (TEXT) is created for each recognized line, at its position, with the height measured from the pixels and the rotation of the line, on the current layer and text style. The OCR engine is built into the program: the first time, it downloads its two models (about 12 MB) to the configuration folder and then reuses them. Offline, if you have tesseract installed, it is used as a fallback.

The same plan in LinceCAD after VECTORIZAR and OCRIMAGE: the walls, doors and column vectorized in red over the image, and the labels recognized as blue text; the command line (Spanish interface) reads “OCR terminado: 9 líneas de texto creadas” (OCR finished: 9 text lines created).
The vectorized geometry (red) and the OCR text (blue) over the scan.

6. Check and save

Turn off the SCAN layer to see only the entities, erase what is not needed and check the measurements against a known dimension. Then save the drawing as DWG (or DXF) with SAVEAS.

A real example

For the screenshots we used a floor plan of a home that we drew ourselves: a 1600 × 1000 pixel image with noise, specks and a slight rotation, so that it looks like a scan. With the default parameters, VECTORIZAR created 95 entities (71 polylines and 24 circles). OCRIMAGE read all six labels correctly (SALON, COCINA, ASEO, DORMITORIO, TERRAZA and “PLANTA BAJA ESCALA 1:100”) and created three extra texts: it read the round column as a “C” and two stray strokes as “6” and “RO”. Always check what comes out of the OCR.

The letters in the scan are vectorized too, as outlines, and overlap the OCR text. Raising Minimum to 120 pixels brought the vectorization down to 28 entities and left the letters out; on the other hand, a high value can lose small details, so it is best to try it on a copy.

Limitations

Frequently asked questions

Do I need another program for the OCR? No. The OCR is built into LinceCAD; tesseract is only used as an offline fallback, if you already have it installed.

What if the drawing is of a land parcel? Before vectorizing a scanned cadastral plan, check whether the official mapping will do: how to import the Spanish cadastral map and the PNOA orthophoto into a DWG.

Can it be automated for many drawings? LinceCAD has AutoLISP, scripts and a local API; we cover them in how to automate DWG drawings with Python.

Does it work on Linux? Yes, the same as on Windows: how to open and edit DWG files on Linux.

Vectorization, OCR and PDF to DWG come as standard in LinceCAD, with a perpetual license. Download · See pricing · Images and all other features.