How to Vectorize Using the Multi-Color Strategy

Introduction

This topic explains how to vectorize an image using BobART.The use of the Multi-Color Strategy is the main focus, but the Black and White strategy is also examined.Many useful tips and a few different approaches are provided.

Example File

If you are connected to the Internet, the part file for this example can be downloaded automatically by clicking the following link: Multi-Color Vectorization Example 1.bbcd

Once you download and saved the zip file, extract the files on your system in an easy place to remember.You can then open the file to use with this tutorial.All files for the tutorials in this help system available for download can be found by clicking on the following link: http://www.bobcad.com/helpfiles.

 

In this example, a color image of a car is used to create vector geometry.The image used is shown next.

 

 

This tutorials explains the following BobART functionality:

 

  • Loading an image using the BobART Manager

  • Selecting the image location

  • Hiding and showing images

  • Moving and scaling images

  • Using the Vectorize... dialog to vectorize an image

    • The 2-level black and white strategy

    • The multi-color strategy

  • Using Remove Chains Less Than

  • Editing the vectorization parameters

  • Exploring workflow methods and many helpful tips

Part 1) Open the Example File

  1. Click File > Open.

    The Open dialog is displayed.

  2. In the Opendialog, select the folder in which you saved the example files.

  3. Select Multi-Color Vectorization Example 1.bbcd, and click Open.

    The file is opened (the graphics area is empty).

  4. Click the BobART tab to access the BobArt Tree.

Part 2) Load the Image, Select Location, Size and Transparency

Note: For this example, we are simply vectorizing an image without using other geometry, so we can focus on the process of vectorizing the image.You may want to move or scale an image in order to use the resulting geometry with an existing model.This section shows you how to do so.You can use these steps before or after vectorizing an image, depending on how you prefer to work.

 

Loading the image

 

  1. In the BobARTtree, right-click Images, and click Load Image.If you do not make a selection, the Front plane of the SolidWorksworld coordinate system is automatically assigned.

  2. In the Opendialog, select the folder in which you saved the example files.

  3. At the bottom of the dialog, next to Files of Type, click the arrow and select All Files (at the bottom of the list).

    You can also go through the list to find the specific file type you need.

  4. Select Old Car.bmp, and click Open.

    The Load Image dialog opens and the image is loaded and displayed in the graphics area.



    Notice the Image-Old Car item is added to the BobART tree under Images.

Selecting a location

 

  1. By default the UCS is set to Top(X/Y) which is the desired UCS for this example.

  2. The bottom left of the image is placed at the Origin position.

    This can be adjusted by editing the values in the fields, or by placing your mouse over the image and dragging it into the desired position.



    For this example, we leave the origin at 0 for all values.

  3. If needed we can add a rotation angle to the image, but keeping the edges parallel with the X and Y axis is the desired result in this case, so this value is left to 0 as well.

Setting the size

 

  1. The current size of the image is listed as: 

    1. X Size = 11.9567

    2. Y Size = 8.5300

 

  1. These values can be updated by adjusting the values in the fields directly, or by using your mouse in the graphics area to pull the given points in the desired direction.



    In this case we will leave the size as it is, but adjusting one of these values with either method automatically adjusts the other to keep the aspect ration of the image.To adjust a single value independently, clear the Keep Aspect Ratio check box.

 

Setting the Transparency

 

  1. To adjust the transparency, in the Transparency group at the bottom of the dialog, select Full Image and either adjust the slider, or set the value between 0 and 1.

    In the images below you will see the a value of 0, followed by a value of 0.75.



    In this case we will leave the Transparency at 0.

  2. Ensure the Transparency is set to 0, and click OK.

 

Tip: When modifying the image this way, any previous vectorization result remains in the previous location.To update the results to the new location, you can simply open the Vectorize... dialog and click OK.Alternatively, you can use any standard CAD functionality to move or modify the vectorized geometry.Any vectorization performed after moving the geometry, automatically uses the new location.

Part 3) Hiding and Showing the Image

When vectorizing images, you need to hide and show the image in order to view and work with the geometry that is created.There are two ways to hide images, and it is important to understand how they work.

 

  1. Click anywhere in the graphics area (to give it key focus), and press I.

    The letter I is the keyboard shortcut to hide all images.

    Press I again and the image is shown.

  2. In the Quick Access Menu at the top of the BobART tab, click the icon.

    All images in the graphics area are hidden.

    Repeat the process and all images are shown.

  3. Right-click on Images and select Blank/Unblank All.

    All images in the graphics area are hidden.

    Repeat the process and all images are shown.

  4. Right-click Image-Old Car, and click Blank/Unblank.

    The image is hidden.This method is used to hide or show a single image.

    Repeat the process to show the image.

Note: For this example, you can use either method to hide and show the image, since we only have a single image.Notice when hiding the image, the blanked icon  displays next to the image icon in the BobART tree.

Part 4) Using the Vectorize... dialog

This section explains how the Vectorize... dialog is used to create and modify the vectorized geometry.

 

The Multi-Color Strategy

In this section we begin using the multi-color strategy to vectorize the image and begin exploring the various workflow options for creating and saving geometry.

 

  1. In the BobARTtree, right-click Image-Old Car, and click Vectorize.

    The Vector... dialog is displayed.

  2. In the Method group of the Strategy section, click Multi-Color Strategy.



    The image is shown divided into 64 specific colors.The multi-color strategy defaults the number of colors to 64, which allows you to target very specific colors or color ranges in the image in order to be more precise with the vectorization results.Experimentation with the number of colors is an important aspect of learning to vectorize images in an efficient manner.

  3. Next to # of Colors, click the down arrow and select 64.

  4. At the bottom of the Parameters group, under the color boxes, click Check All.

  5. Click Apply to vectorize the image in its current state.

    Img

  6. Next to # of Colors, click the down arrow and select 32.Notice the change in the preview.For example, the gradient of the image background is reduced from 6 unique colors to 5, and the yellow and orange colors are removed from the head lights and the exhaust.

    When you change the number of colors, the image is actually reduced to the selected number of colors, and the color boxes update under Colors to be Vectorized.



  7. Continue reducing the # of Colors (for example to 16, 8, and 4), and observe the change in the preview.







  8. Change the # of Colors to 24 and click Check All to automatically select the check box of all colors.



  9. Click OK to vectorize the image.



    The image is processed using all 24 colors to create the vectorized geometry.Notice the horizontal lines.This is a result of the gradient in the background of the image.The current settings separated the gradient into three unique colors.

    Although it is not the method used for this tutorial, you could decide that you are now done with the vectorization and simply edit the geometry.Depending on what you want to achieve, this may not be the most efficient method to use.When using this method, you are vectorizing many adjacent colors, which results in a large amount of entities.Regardless of how you choose to work, we explore another important parameter next, Remove Chains Less Than.

Remove Chains Less Than

 

  1. Next to Image-Old Car, click to expand the tree item.

    To edit the parameters, right-click Vectorization, and click Edit.

Note: You can also right-click Image-Old Car, and click Vectorize.

 

  1. In the Vectorize... dialog, set the # of Colors to 64.

  2. Click Uncheck All.

  3. Select the colors seen in the image below.

    Img

  4. Click the Blank Image button at the top-right to hide the image so we can better view the results.

  5. Click OK.

    Notice that the geometry from the first vectorization is removed and replaced with new geometry.

    Img

    When there is geometry that you want to keep, you copy it to a new layer.This allows you to vectorize the image more than once (in order to be more precise).

 

 

Part 5) Copy Geometry to a New Layer to Save It

  1. Right-click anywhere in the graphics area.

  2. Press Ctrl+Cto copy the entities.

  3. In the Layers Manager, right-click the layer name Grill and select Active Layer.

    Confirm that the Active Layer icon is displayed next to Grill.

    This sets the layer to the active drawing layer.

  4. Press Ctrl+Vto paste the entities onto the active layer.

  5. In the Layers window, right-click the Grill layer and select Show Only This Layer.

    Img

  6. Now that the geometry selection is confirmed to be correct, hide all but the CAD layer and set it as the active layer.

    It is important that only the CAD layer is visible (for the process that we are using).

    This assures that you are only seeing the results of the vectorization and not the copied geometry.

  7. To cancel selection mode, right-click anywhere in the graphics area, and clickCancel.

 

Tip: You can also pressEsc to cancel selection mode.

Part 6) Use the Black and White Strategy

The 2 Level Black and White Strategy

This section explains how the Vectorize... dialog is used to create and modify the vectorized geometry.We start by experimenting with the 2 Level Black and White strategy, as it is a viable option for vectorizing color images or black and white images.The strategy simply determine show the image is analyzed in order to create geometry.

 

  1. In the BobARTtree, right-click Image-Old Car, and click Vectorize.

    The Vectorize dialog displays and the image appears in blank and white with only portions visible.

    This is because in the Strategy section, the Method is set to 2 Level (Black/White) Strategy by default.

  2. In the Threshold Value field, update the value to 40.



    No noticeable change occurs.

  3. Update the value again, but this time, use 60.



    Notice the preview of the image updates each time that you change the value.

    You can also click and drag the Threshold Value slider, in small increments, and release (to accomplish the same task).

  4. Change the Threshold Valueto 140.



  5. Click OK to vectorize the image and update the original sketch feature.

    Hide the image to view the geometry.

    Img

    The resulting geometry is placed on the active layerautomatically adds to the SolidWorks Feature Manager design tree.It is important to understand that when you edit the Vectorization parameters in the Vectorize... dialog, the previous result is replaced.This allows you to experiment with the vectorization result without creating excessive features or geometry.

  6. To edit the vectorization we did, either: 

    1. Right-click Image-Old Car, and click Vectorize... to enter the dialog again.

    2. Under Image-Old Car, right-click Vectorization, and click Edit.

      The Vectorization item was added to the BobART tree after the first vectorization.

  7. Change the Threshold Value to 174 and clickOK to update the vectorization result.

    Img

    Notice that the geometry from the first vectorization is removed and replaced with new geometry.

 

For this part, you experiment with the Black and White strategy to get the profile of the car.

 

  1. In the document toolbar, click to enable selection mode.

    Press and hold Shift, and click to chain-select the profile of the car as shown next.

    ImgImg

  2. Press Ctrl+Cto copy the entities.

  3. In the Layers Manager,right-click the layer name Profile and select Active Layer.

    Confirm that the Active Layer icon is displayed next to Profile.

    This sets the layer to the active drawing layer.

  4. Pres Ctrl+V to Paste.

  5. To confirm the geometry is properly pasted, right-click the Profile layer and select Show Only This Layer.

    The geometry should appear as follows.

    Img

  6. Hide all but the CAD layer and set it as the active layer.

    Img

Part 7) Continue Using the Multi-Color Strategy

  1. Right-click Vectorization, and click Edit.

  2. Select Multi-Color Strategy.

  3. Click the # of Colors arrow, and click 32.

    Notice that the preview of the image changes based on the # of Colors selected.

    When you change the number of colors, the image is actually reduced to the selected number of colors, and the color check boxes are also updated under Colors to be Vectorized.

    Repeat this process of reducing the # of Colors (for example to 16, then 8, then 4, etc.) and observing the image preview.

    This process is very helpful when trying to vectorize only a certain area of the image.

  4. Set the # of Colors to 24.

    Click Uncheck All.

    Click to select the top check box in column 2 of Colors to be Vectorized.

    Img

    Click OK.

    Img

  5. When you zoom-in to view the front wheel, you can see that there are small unwanted entities as shown next.

 

Img

Part 8) Remove Chains Less Than

Remove Chains Less Than

The Remove Chains Less Than parameter is very important when vectorizing images, as it helps you to remove unnecessary geometry that may be created from the gradients in an image.

 

  1. Show the image, and zoom-in closely to different areas of the image and notice the geometry as compared to the selected colors (gradients). For example, the grill on the front of the car or the wheels are a great place to view how the geometry is created based on the colors.

    The following image shows the colors of the front grill zoomed in closely with the geometry hidden from view.You can see that there are actually three colors that make the vertical black and gray stripes.



    Because we have vectorized all 24 colors, the software created geometry for each color.The first point here is that you may not want to vectorize adjacent colors, as it results in what appears as duplicate geometry, although it isn’t. It may be better to vectorize only one of the colors.The second point is that the darker gray color results in very small entities that are most likely not needed.The geometry from our vectorization is shown next highlighted to make it easier to view.



    You can see the small rectangles are not needed, so now we use the Remove Chains Less Than parameters to remove them.

  2. Right-click Vectorization,and click Edit.

  3. Under Vectorize Parameters, change the Remove Chains Less Than value to 75(pixels), and click OK.



    You can see that the small groups of entities are now removed from the result.You can experiment with the Remove Chains Less Than value to make the vectorization result more efficient.Next we explore more ways to be efficient with vectorization.

    Img

  4. In the document toolbar, click to enable selection mode.

  5. In the graphics area, click and drag a window around the three wheels as shown next.

    ImgImg

  6. Copy the selected geometry, to the Wheels layer.(Use either method as explained earlier.)

  7. Hide all but the CAD layer and set it as the active layer.

 

 

 

Note: To get the other contours from the wheel, the following color is used.

Img

The Remove Chains Less Than value was changed to 100, to create the following result.

Img

Be sure to reduce the Remove Chains Less Than value(if needed) when moving on to vectorize a new area of the image.

Part 9) Edit the Vectorization Parameters

In this part, the seat is the target area from which you create geometry.

 

  1. Right-click Vectorization,and click Edit.

  2. Change the # of Colors to 20.

  3. Select the following colors.

    Img

  4. In the Remove Chains Less Thanbox, type 100.

  5. Click OK.

    Img

    The result appears as though some of the geometry is missing from these at.To confirm if this is correct, show the image, and compare the image and the geometry.You may want to hide and show the image a few times as you examine certain areas.You can see that the geometry from the seat is accurate (the steering wheel and the windshield cause the missing areas.)

    You could window select the (seat) geometry and copy it to a new layer, but you would get double entities that need to be cleaned up later.In the following steps, you edit the vectorization and get the seat geometry in two steps.This again helps you to get clean geometry that requires less editing later.

  6. Edit the vectorization, and click to clear the bottom-left check box.

    Img

  7. Click OK.

    Img

    You can see that now you have much cleaner results.

    Show and hide the image a few times to compare the image and the geometry.

    The result is grabbing mostly the brown areas of the seat.

  8. Use chain-selection to select the desired geometry, and copy it to the Seat Browns layer.

    Imgimg

  9. Use chain-selection to select the desired geometry, and copy it to the Seat Reds layer.

    Imgimg

  10. Edit the parameters, and select the following colors.

    Img

    Click OK.

    Imgimg

    This time mostly the red areas of the seat are vectorized.

    Show and hide the image to compare.

  11. Copy the desired geometry (remember to use the chain-selection method), and paste it to the Seat Reds layer.

    Imgimg

    The brown areas of the seat are copied to the Seat Brownslayer.

    Imgimg

    All of the geometry created so far is shown next.

    Img

  12. Continue this process until you have created all of the desired geometry from the image.

 

(Pick a target area.Adjust the Number of Colors to create the desired results.Copy the geometry to a new layer, and repeat.)

 

Img

Final Notes

Image Origin

You can change the location of the image in the graphics area using the Image Origin dialog.

 

To change the image location:

 

  • Right-click Image -name, and click Edit.

 

  • Set the Origin values (in relation to the WCS or world coordinate system). The Origin of the image is the lower-left corner.

 

  • Click OK.The image is moved.

 

  • To move any vectorized geometry to the new location, open the Vectorize... dialog, and click OK.

 

Warning: Only the original geometry associated to the image, and not copies of the geometry will be updated using this method.

 

Moving the image is helpful when you vectorize more than one image.

Image Size

In the Vectorize... dialog, the Image Size values are used to scale the vectorized geometry that is created.(The size of the image is not actually changed.)

Remove Arcs

If you want to create the vector geometry using only line segments, clear the With Arcs check box in the Vectorize... dialog.

Vectorize Parameters - Accuracy

The Accuracy parameter can be changed to create smoother or rougher contours.

 

High Accuracy (0.10 pixels)

 

Img

 

Low Accuracy (0.90 pixels)

 

Img

 

 

This concludes the tutorial.

Related Topics

BobART Overview