Categories
Raster to Vector Guides

Mending Breaks in Raster Lines for Successful Raster to Vector Conversion

CAD software packages have eased vectorization – at least ideally – by reducing the steps to uploading a raster image whose outline the software then traces automatically, clicking the conversion button or icon, and, voila, a vector image is created. But, it’s not as straightforward as it sounds. There’s a lot you should do to correct some problems, thereby optimizing your vector conversion. Indeed, you have to put in some effort into your output file to be as good as possible.

Some of the necessary corrections you should do include:

  • Smoothing edges by removing what the CAD world calls hairs
  • Removing holes – these are gaps present within solid objects
  • Reducing colors – a perfect conversion requires a monochrome raster image
  •  Adding borders

For a complete list of the corrective measures you should undertake, do take time and read our detailed article on the subject.

Breaks in Raster Lines

The list recommends the removal of holes. Holes mainly feature solid raster objects. However, when these solid objects happen to be raster lines – presenting a situation whereby the holes are concentrated in one region along each of the solid lines or just a single one – then breaks in the raster lines form.

You shouldn’t confuse broken lines with dithered lines, though. The latter occurs when the holes are distributed evenly along the line, creating faint, dotted lines. In such cases, you can easily tell the lines’ outline or path, always. In some broken lines, however, telling the outline could prove impossible. To differentiate between broken and dithered lines, take a look at the images below.

Dithered Line
Dithered Line Source
Broken Line
Broken Line Source

The breaks or holes arise because of poor image quality or image compression, particularly in scanned drawings or linework. For one, scanning is dependent on the settings you’ve chosen and the equipment you’re using. You’re likely to realize the best result when you use the recommended settings or if the equipment you’re using supports high-quality scanning. A combination of these two factors is likely to yield the best results.

Resolution

On the settings’ front, one preferred setting is a high dots per inch (dpi) resolution – because raster images are highly dependent on the resolution. The higher the resolution, the better your raster image will look. For drawings, a scan resolution of between 200 to 400 dpi is desirable because lines are at a size that the scanner can easily identify.

In the same breath, the quality of the raster image obtained through scanning is also dependent on the content contained in the scanned document, i.e., the thickness of the lines. If this document contains very thin lines, perhaps because you’ve drawn using a 0.03-micron mechanical pencil, then the fine lines on your drawing will appear broken in the digitized piece. In such cases, a higher scan resolution setting of above 1800 dpi is recommended.

Grayscale

When scanning black and white images, selecting grayscale as the capture technique is preferred to bitonal or monochrome because it catches even the finest of details. Grayscale consists of a total of 256 tones or shades of gray. Each tone is assigned to a different shade of black and white in addition to lines of varying thicknesses.

The principle of line thickness in grayscale, therefore, means that very thin lines do not have a grayscale value because they don’t have an assigned tone. As such, they won’t appear on the scanned raster image.

Nevertheless, although grayscale captures more information than monochrome, it’s not preferred in vectorization. This is because while vectorizing raster images scanned through the grayscale option you’ll be required to:

  • Change the scale and resolution
  • Do away with deformations
  •  Change the saturation, hue, contrast, and brightness
  • Improve the quality of the image

And much more because vectorization works best if the raster image contains a reduced number of colors.

But, to ensure that the scanned raster image has captured all details, you can choose grayscale and then convert the image to black and white using Scan2CAD’s in-built functions.

Mending Breaks in Raster Lines

Before converting your raster image to a vector image, you should mend breaks, fill the holes, and undertake other measures listed above. This is the only sure way to have a successful raster to vector conversion. Otherwise, you’ll finalize the vectorization process only to realize that the output image is of an extremely low quality. Conversion software packages, such as our in-house Scan2CAD, attempt to correct about 80% of the issues post-conversion. The remaining 20% is always left to you, the user.

While tidying up the converted image is a post-conversion exercise, the scope of work you engage in during this period could be reduced if you make changes before converting. And this is why fixing issues, such as breaks, is crucial before converting – it makes the post-conversion period less taxing. But this is not to say that you can eliminate all issues beforehand such that your converted vector image is 100% perfect. That can’t happen.

Notably, if you want to use your vectorized image for CAD purposes, you need to fix all issues, including mending breaks. The computer-aided design relies on the accurate representation of plans because some software design packages such as Autodesk’s Fusion 360 and CATIA allow extrusion of the plans to form 3D images. If there’s an undesired break in a line within the plan, then the extrusion becomes inaccurate or impossible.

Mending Tools

Mending tools within conversion software come two-fold. There are:

  •  Automatic mending tools
  •  Manual mending tools

Converting raster images to vectors requires the software to overlay lines, curves, texts, and shapes on the raster image in a process called tracing. Two tracing methods exist, the manual and automatic. The former is preferred when you have plenty of time and would like to test your skills. The latter, on the other hand, is available on many conversion software thanks to advances in technology. In some conversion packages, the automation is so advanced that the output file is near perfect. Automatic tracing reduces the conversion time.

The advances in automatic tracing have gone hand in hand with the development of automated mending tools. Still, manual mending tools exist, particularly when the automation cannot achieve the desired results.

Automatic mending tools

The broken lines in an unconverted raster file can be mended by:

  • Thickening the line
  • Thickening the pixels
  • Gap-jumping

The former two are necessary because the lines may appear broken because they are too faint to be picked by the human eye. Thickening the lines or the pixels that form the line, therefore, makes them visible.

In some cases, the conversion software picks the lines during tracing, but because they were too faint in the raster image, the software allocates fewer pixels to the line. As such, thickening the line or the pixels mends the breaks in the lines.

It is important to emphasize that the effectiveness of conversion software and the inbuilt automatic tracing is dependent on the quality of the image. To the human eye, the faint lines on the scanned raster image may be visible, but the software may fail to pick them up because the image’s resolution doesn’t make this possible. The result is an image that contains broken lines. This is where gap-jumping comes in.

Gap-jumping is an automatic mending tool in Scan2CAD. Do note that you should utilize this tool prior to vectorizing the raster image. Otherwise, it’ll be useless post-conversion. Gap-jumping works when the user specifies the number of pixels the software should jump. Scan2CAD then jumps over the breaks whose pixel distance is less than the figure that you as the user has set. This creates a continuous line. 

Gap-jumping settings on Scan2CAD
Gap-jumping settings on Scan2CAD

Manual mending tools

In some raster images, the lines might be too broken to be mended automatically. Or, the raster image may be too low-quality for the conversion software to detect any line, curve, or shape. In such cases, the only remaining technique to mend the broken lines is to draw new raster lines, curves, and other geometric primitives over the broken ones. Like the automatic mending tools, fixing the broken raster lines using these manual drawing methods is also done before the conversion.

Upon conversion, however, you might realize that the resultant vector image has some broken lines as well, even though the raster image didn’t feature any broken line. In such cases, stretching the broken vector line is the preferred manual mending method, as shown in the image below.

Fixing a broken vector line using Scan2CAD by stretching
Fixing a broken vector line using Scan2CAD by stretching

People with programming knowledge can also mend broken lines using code such as Python or OpenCV. However, this method only works with tables or regular shapes because it relies on coordinates and object dimensions. Still, it’s a manual tool for mending broken lines because the programmer writes the lines of code manually. Also, it’s more complicated.

Conversion software packages attempt to make vectorization as simple as possible. But the simplification, through the development of advanced mending tools, is not 100% successful. For the most desired results, you, as the user, have a crucial role to play to ensure that the vector image is perfect. Use your keen eye for detail throughout the vectorization process to pick out any broken lines, which you should then mend the breaks in the raster lines using the tools described in this article for successful raster to vector conversion.