Exercise P6: Converting Grayscale Images to Bitonal Images

In this exercise you convert a grayscale image to bitonal (black and white) images and clean up the converted image:

By converting the grayscale image to a bitonal (black and white) image, inverting the image, and removing speckles, you make the soil boundaries in the image easier to identify. The resulting map can be readily converted to vector using the AutoCAD Raster Design toolset Vectorization Tools.

In this lesson, you also export the modified image with a world correlation file.

Related Exercises

Before doing this exercise, ensure that AutoCAD Raster Design toolset options are set as described in the exercise Exercise A1: Setting AutoCAD Raster Design Toolset Options.

Exercise

  1. In the ..\Program Files\Autodesk\ApplicationPlugins\RasterDesign2024.Bundle\Contents\Tutorials\Tutorial5 folder, open the drawing file Map_06.dwg. In the next few steps, you will change the background color of the Model space to black.
  2. Right-click in the drawing window and choose Options to open the Options dialog box.
  3. Click the Display tab.
  4. Click the Colors button. The Drawing Window Colors dialog box opens.
  5. In the Interface Element list, select Uniform Background.
  6. In the Color list, select Black.
  7. Click Apply & Close in the Drawing Window Colors dialog box, then click OK in the Options dialog box.

    Convert the grayscale image to bitonal

  8. On the ribbon, click Raster Tools tab Edit panel Process Image drop-down menu Histogram . Press Enter to edit the entire image.
  9. In the Histogram dialog box, on the Threshold tab, use the slider to determine which pixels will be black and which will be white after you convert the image. The shades of gray to the left of the slider become black, and those to the right become white.
  10. Move the slider to 82, observing the effect on the image in the preview window.

    This exercise uses one image. However, if you select multiple images, you can select the image name below the preview to observe the effect of the threshold value on that image. The selected images convert to black and white when you click Apply and Close.

  11. Click Apply and Close to convert the image.

    The following example shows how the image of the soils map should appear after you convert it to a bitonal (black and white) image. The image has a light background and dark line work that is difficult to read. The image also contains large speckles.

    Export the image

  12. On the ribbon, click Raster Tools tab Insert & Write panel Image Export .
  13. In the Export dialog box, enter Soilsmap_world_03.cal for the filename, select CALS Type 1 for the file type, and click Export.
  14. In the Export Options dialog box, select Maintain Drawing Link to Image and under Correlation, select World File.
  15. Click Finish.

    Invert the image

  16. On the ribbon, click Raster Tools tab Edit panel Cleanup drop-down menu Invert .

    The following example shows how the image of the soils map should appear after you invert the light and dark areas of the image. The image still contains many large speckles.

    Remove speckles from the image

  17. On the ribbon, click Raster Tools tab Edit panel Cleanup drop-down menu Despeckle .
  18. Press Enter to process the entire image.

    You are prompted to continue or to respecify the pixel size.

  19. Pick one of the small to medium speckles in the image.

    The pixels about to be removed are highlighted. In a real project, this is when you can zoom in to inspect the image and ensure that essential data is not highlighted for removal. You can specify pixels to exclude from the removal set in a variety of ways.

  20. Press Enter to remove the highlighted speckles.

    The following example shows how the image of the soils map should appear after you remove the speckles.

  21. Repeat the Despeckle process as needed.
  22. Close the drawing without saving changes.