Vectorizing scanned templates for CNC work

Turn a scanned template or a photograph of a part into a DXF outline for a laser cutter or 3D printer.

Automatic vectorization of CNC templates

A CNC machine, laser cutter, or 3D printer may be available even when the original part has no CAD file. This example shows how to turn a scanned template or photograph into an editable DXF outline using automatic vectorization.

The starting point

The template is cut from white cardboard and was made by measuring a full-size sample. We need a DWG or DXF outline to send to a cutting plotter.

Prepare the scan

Choose a scanner that can accommodate the size and thickness of the template, or use a camera if the template is too large. For the large patterns in this example, a 300 dpi scan provides sufficient detail. Protect the template with a clear A2, A1, or A0 sleeve, or a sheet of transparent film for larger originals. Scan in grayscale.

Figure 1. Scanned template
Figure 1. Scanned template

Prepare the scan

Use Insert Image to place the scan in nanoCAD Raster model space. Scale it so the dimensions in the drawing match the actual part.

Figure 2. Adaptive Binarization command
Figure 2. Adaptive Binarization command

Use Adaptive Binarization to convert the grayscale image to black and white. Adjust the settings in the preview until the outline is continuous and as few stray pixels as possible remain.

Figure 2. Image after binarization
Figure 2. Image after binarization

Use Crop by Rectangle to remove the unused part of the image. Then run Speckle Remover to remove isolated marks before tracing.

Figure 3. Speckle Remover
Figure 3. Speckle Remover

Use Measure Size to measure the largest speck you want the filter to remove.

Figure 4. Image after speckle removal
Figure 4. Image after speckle removal

Vectorize the outline

Open the R2V conversion options. On the Recognition tab, select the geometry you want the software to create. This template needs only polylines.

Figure 5. Geometry recognition options
Figure 5. Geometry recognition options

On the Options tab, set the tracing accuracy, line width, and maximum gap the vectorizer should bridge.

Figure 5. Geometry recognition options
Figure 6. Vectorization settings

Run Raster to Vectors and compare the resulting outline with the scan. Remove the raster image from the drawing and save the vector geometry as a DXF file.

Figure 7. Vectorized outline
Figure 7. Vectorized outline

Conclusion

The scanned template or photograph now has an editable DXF outline for downstream CNC, laser cutting, or 3D printing workflows.

With nanoCAD Raster, you can do the image cleanup and tracing in the drawing itself.

Figure 8. Editing the resulting geometry
Figure 8. Editing the resulting geometry

Edit scanned drawings in nanoCAD

Use nanoCAD Raster to calibrate, clean up and vectorize scanned drawings.

Explore the Raster module

Related articles

View all articles