Raster editing commands

 

The following raster editing commands are available for use in a Command File.

 

Negate

No arguments.

Negates the currently loaded raster image. See Negate.

 

MirrorVert

No arguments.

Mirrors the currently loaded raster image vertically.

 

MirrorHoriz

No arguments.

Mirrors the currently loaded raster image horizontally.

 

Rotate or RotateRaster

Degrees

One argument.

Rotate the currently loaded raster image by the number of Degrees you specify. If you enter a positive angle, the image will be rotated in a clockwise direction. If you enter a negative angle, it will be rotated in an anti clockwise direction.

The following example code rotates the raster image clockwise by 90 degrees:

ROTATE

90

 

AutoDeskew

No arguments.

Automatically deskews the currently loaded raster image.

Only 1 Bit (black and white) images are affected by this command. You can ensure that an image is 1 Bit by using the ReduceColorDepth1Bit command before using AutoDeskew.

 

Scale or ScaleNearest

XScaleFactor If set to 1, the scale in the X direction will not be changed.
YScaleFactor If set to 1, the scale in the Y direction will not be changed.

Two arguments.

Scales the currently loaded raster image vertically and/or horizontally.

The following example code scales the image by a factor of 2 in both the X and Y directions:

SCALE

2

2

 

ScaleTile

XScaleFactor The scale in the X direction which should always be set to 2,
YScaleFactor The scale in the Y direction which should always be set to 2,

Two arguments.

Scales the currently loaded raster image vertically and/or horizontally.

The following example code scales the image by a factor of 2 in both the X and Y directions:

SCALETILE

2

2

 

ScaleBicubic

XScaleFactor If set to 1, the scale in the X direction will not be changed.
YScaleFactor If set to 1, the scale in the Y direction will not be changed.

Two arguments.

Scales the currently loaded raster image vertically and/or horizontally.

The following example code scales the image by a factor of 2 in both the X and Y directions:

SCALEBICUBIC

2

2

 

ScaleBilinear

XScaleFactor If set to 1, the scale in the X direction will not be changed.
YScaleFactor If set to 1, the scale in the Y direction will not be changed.

Two arguments.

Scales the currently loaded raster image vertically and/or horizontally.

The following example code scales the image by a factor of 2 in both the X and Y directions:

SCALEBILINEAR

2

2

 

ScaleBspline

XScaleFactor If set to 1, the scale in the X direction will not be changed.
YScaleFactor If set to 1, the scale in the Y direction will not be changed.

Two arguments.

Scales the currently loaded raster image vertically and/or horizontally.

The following example code scales the image by a factor of 2 in both the X and Y directions:

SCALEBSPLINE

2

2

 

ThresholdSimple

SimpleThresholdLimit Threshold value between 1 and 255.

One argument.

Uses a simple threshold to threshold the currently loaded raster image. All pixels with a color value less that the threshold value are set to black. All pixels with a color value greater that the threshold value are set to white.

Only 4 Bit (16 color) and 8 Bit (256 color and grayscale) images are affected by this command. 24 Bit (16.7 million color) images are automatically converted to grayscale before thresholding.

After the threshold, you may want to reduce the color depth of the thresholded image to 1 Bit (black and white) using the ReduceColorDepth1Bit command.

The following example thresholds the image then reduces its color depth.

THRESHOLDSIMPLE

127

REDUCECOLORDEPTH1BIT

 

ThresholdAdaptive

AdaptiveThresholdWindow Window value between 4 and 400.
AdaptiveThresholdBackground Background value between 1 and 100.

Two arguments.

Uses an adaptive threshold to threshold the currently loaded raster image

Only 4 Bit (16 color) and 8 Bit (256 color and grayscale) images are affected by this command. 24 Bit (16.7 million color) images are automatically converted to grayscale before thresholding.

After the threshold, you may want to reduce the color depth of the thresholded image to 1 Bit (black and white) using the ReduceColorDepth1Bit command.

The following example thresholds the image then reduces its color depth.

THRESHOLDADAPTIVE

20

17

REDUCECOLORDEPTH1BIT

 

DetectEdges

No arguments.

Deletes solid areas of color, leaving just the boundaries between them. See Detect Color Edges.

The following example code detects the edges between white and colored areas of the image:

DETECTEDGES

 

The following example code detects the edges between all the colors on the image:

* Reduce the color depth of the raster image to 256 colors

REDUCECOLORDEPTH8BIT

* Detecting the edges between hundreds of colors will probably

* give meaningless results, so reduce the palette to a sensible level

REDUCECOLORSAUTO16

* Activate Layer Colors

COLORLAYERSON

* Smooth the edges between the colors

SMOOTH

* Detect the edges between the colors

DETECTEDGES

* Remove speckles from the detected edges

REMOVESPECKLES

6

 

RemoveSpeckles

SpeckleSize Pixels, 1 to 63

One argument.

Cleans the currently loaded raster image by removing speckles from it. See Remove Speckles.

The following example code removes speckles of any color if they are smaller than 6 pixels in size and completely surrounded by white:

REMOVESPECKLES

6

 

The following example code removes speckles of any color if they are smaller than 6 pixels in size, regardless of the background color they are on:

* Reduce the color depth of the raster image to 256 colors

REDUCECOLORDEPTH8BIT

* Activate Layer Colors

COLORLAYERSON

* Remove speckles

REMOVESPECKLES

6

 

RemoveHoles

HoleSize Pixels, 1 to 63

One argument.

Cleans the currently loaded raster image by removing white holes from it. See Remove Holes.

The following example code removes white holes if they are smaller than 6 pixels in size:

REMOVEHOLES

6

 

ThinStandard

NumberOfThinnings Pixels

One argument.

Thins the currently loaded raster image with a bias towards retaining curves. See Thin Standard.

The following example code thins the raster image by 9 pixels:

THINSTANDARD

9

 

ThinOrtho

NumberOfThinnings Pixels

One argument.

Thins the currently loaded raster image with a bias towards retaining orthogonal lines. See Thin Ortho.

The following example code thins the raster image by 9 pixels:

THINORTHO

9

 

ThickenLines

No arguments.

Thickens the currently loaded raster image. See Thicken Lines.

 

ThickenPixels

MinimumProximityPixels Pixels, 2 to 8

One argument.

Fills white pixels that are surrounded by a user-defined number of colored pixels. See Thicken Pixels.

The following example code fills white pixels if they are surrounded by at least 2 colored pixels:

THICKENPIXELS

2

 

Smooth

No arguments.

Smooths the currently loaded raster image by removing “hairs” from it. If you are going to rotate the image, you should use Smooth before you rotate it. See Smooth.

The following example code smooths entities that are on a white background:

SMOOTH

 

The following example code smooths entities regardless of their background color:

* Reduce the color depth of the raster image to 256 colors

REDUCECOLORDEPTH8BIT

* Activate Layer Colors

COLORLAYERSON

* Smooth

SMOOTH

 

Outline

OutlineThickness Pixels

One argument.

Deletes solid colored areas of pixels from the raster image to leave a raster outline. See Outline.

The following example code deletes solid colored areas of pixels leaving an outline 2 pixels thick:

OUTLINE

2

 

ForceToWhite

RangePercentage

One argument.

Makes the paper background white by forcing colors within a percentage range of white to white.

You should always use ForceToWhite before converting a grayscale or color raster image to vectors unless you are converting a color image to color vectors using ColorLayersOn (see below).

The RangePercentage value will be different depending on the raster image you are converting. To choose a suitable RangePercentage value you need to experiment with raster images similar to the ones you intend to convert using the Command File, as follows:

1. Load a raster image into Scan2CAD.
2. Selete Palette Menu > View/Edit Palette.

The Reduce Colors dialog appears.

3. Type a percentage into the Select Range box.
4. Click on the button to the right of the Select Range box.
5. Click on white in the palette (always the bottom right color).

All the colors within the percentage range you have chosen are selected.

6. Select the White Change To option
7. Click OK.

The selected colors are made white.

8. Look at the image.

If parts of the image have disappeared the percentage you typed was too high. Return to Step 1 and try again with a lower percentage.

9. Click on the VEC icon and see whether sensible vectors appear on the image.

If no vectors appear on the image, or a single straight line vector appears along the edge(s) of the image, or vectors appear over the paper area of the image, the percentage you typed was too low. Return to Step 1 and try again with a higher percentage.

The following example code converts a grayscale or color raster image to vectors, ignoring color:

* Make the paper background white

FORCETOWHITE

15

* Select suitable vectorization settings

TYPECONTOUR

* Vectorize the image

RUNVECTOR

 

ReduceColorsAuto256

No arguments.

Automatically reduces the number of colors used on the currently loaded raster image to 256. See Reduce colors automatically.

 

ReduceColorsAuto128

No arguments.

Automatically reduces the number of colors used on the currently loaded raster image to 128.

 

ReduceColorsAuto64

No arguments.

Automatically reduces the number of colors used on the currently loaded raster image to 64.

 

ReduceColorsAuto32

No arguments.

Automatically reduces the number of colors used on the currently loaded raster image to 32.

 

ReduceColorsAuto16

No arguments.

Automatically reduces the number of colors used on the currently loaded raster image to 16.

 

ReduceColorsAuto8

No arguments.

Automatically reduces the number of colors used on the currently loaded raster image to 8.

 

ReduceColorsAuto4

No arguments.

Automatically reduces the number of colors used on the currently loaded raster image to 4.

 

ReduceColorsAuto2

No arguments.

Automatically reduces the number of colors used on the currently loaded raster image to 2.

 

LoadPalette

PaletteFileName

One argument.

Loads a palette. See Change the palette.

The following example code loads the AutoCAD palette and maps the colors in the currently loaded raster image to their nearest AutoCAD equivalents.

LOADPALETTE

c:\program files\scan2cadv8\palettes\autocad.pal

 

ReduceColorDepth8Bit

No arguments.

Reduces the color depth of the currently loaded raster image to 8 Bit (256 colors).

 

ReduceColorDepth4Bit

No arguments.

Reduces the color depth of the currently loaded raster image to 4 Bit (16 colors).

 

ReduceColorDepth1Bit

No arguments.

Reduces the color depth of the currently loaded raster image to 1 Bit (2 colors –

� black and white).

 

ColorLayersOn (replaces ColorSeparationOn)

ColorSeparationOn

No arguments.

Activates Color Layers.

All colors on the currently loaded raster image are automatically selected as Layer Colors – it is not currently possible to select individual Layer Colors from the Command File.

ColorLayersOn does not work on 24 Bit images. Before using ColorLayersOn you must use one of the ReduceColorDepth commands to reduce color depth to 8 Bit or less.

For sensible results you should also use one of the ReduceColorsAuto commands to reduce the number of colors used on the image to the minimum that is appropriate for the images.

The following example code converts a color raster image to color vectors:

* Load the raster image map.tif

LOADRASTER

c:\users\username\documents\scan2cadv8\samples\map.tif

* Reduce the color depth of the raster image to 256 colors

REDUCECOLORDEPTH8BIT

* Reduce the number of colors used on the image to a level suitable for that image

REDUCECOLORSAUTO4

* Activate Layer Colors

COLORLAYERSON

* Select suitable vectorization settings

TYPECONTOUR

* Vectorize the image

RUNVECTOR

* Save the vectors as map.dxf

SAVEVECTOR

* Exit Scan2CAD

EXIT

 

ColorLayersOff (replaces ColorSeparationOff)

ColorSeparationOff

No arguments.

Deactivates Layer Colors.

 

Have questions on this topic? Talk to us