Image Mask Quickstart

The Image Mask GUI application processes coin images for publication. The program automatically finds the edges of the coin, masks out the background to your choice of color. This version of Image Mask is used for interactive processing of images. The command line version provides the same functionality in a scriptable form.

Installation instructions for Image Mask.

Examples

Example 1 - Load A Source Image
Example 2 - Resize Image To Fit Tab (Or to Full Size)
Example 3 - Automatically Find A Round Coin
Example 4 - Automatically Find A Non-Round Coin
Example 5 - Handle Renegade Points
Example 6 - Crop, Mask Out Background, Change Background Color
Example 7 - Rotate Coin
Example 8 - Draw A Grid Over The Output Image
Example 9 - Draw An Arrow To Highlight A Feature
Example 10 - Create Garyscale Output Image
Example 11 - Change The Size Of The Output Image
Example 12 - Save The Final Image

Example Source Images

A round coin with a background that offers no significant noise that we must deal with.

A non-round coin.

Background with problematic edges.


Example 1 - Load A Source Image

Use the menu selection File -> Open. The Open dialog is displayed. Navigate to the directory with your source image. Select the source image and click the Save button.

Your source image will be opened in the Original tab. The result image will be displayed in the Final tab. If you haven't made any changes to the Options (on the left side of the window) the Final image is a small version of the original.

File -> Open

Example 2 - Resize Image To Fit Tab (Or to Full Size)

  • Use Fit and Full buttons under each image
  • Pressing the Fit button causes the image to be scaled to fit entirely on the tab.
  • Pressing the Full button causes the image to be scakked to 100%.

When a new image is loaded it is displayed at its full size. If the image is larger than the display area you will see only the top left part of the image. This will prabably be only a small part of the background. Press the Fit button to resize the image to fit entirely in the window.

When scaled to Fit the image is displayed at a low resolution. To see the original, higher resolution press the Full button. Drag the scroll bars to move the hidden parts of the image into view.

Full
Fit

Example 3 - Automatically Find A Round Coin

  • Select Find Circle from the Search Options - Type listbox.

There are several ways to find (or specify) the edge of the coin. The easiest is usually the Find Circle option. This tool will search for multiple points around the edge of the coin, then calculate a circle that passes through each of those points. Of course this only works on round coins. The Find Irregular option is used for coins that are not round (perhaps square or oval).

When using the Find Circle option there are several parameters to improve the identification of points around the edge of the coin.

Threshold
The contrast level that tells the application an edge was found. Increase this value if small defects in the background are mistakenly interpreted as the edge of the coin. Decrease this value if the edge is mistakenly detected inside the coin.
Points
The number of points to be detected along the edge of the coin. On round coins using 8 points is usually sufficient. This option is usually only increased when using Filter Options.
Border Left
This option specifies how wide a buffer to ignore on the left side of the image. This is useful if the background does not reach the edge of the image.
Border Right
This option specifies how wide a buffer to ignore on the right side of the image. This is useful if the background does not reach the edge of the image.
Border Top
This option specifies how wide a buffer to ignore on the top side of the image. This is useful if the background does not reach the edge of the image.
Border Bottom
This option specifies how wide a buffer to ignore on the bottom side of the image. This is useful if the background does not reach the edge of the image.

Find Circle
Edge Mistakenly Detected
Border Left and Right Ignored

Example 4 - Automatically Find A Non-Round Coin

  • Select Find Irregular from the Search Options - Type listbox
  • Increase the number of points found along the edge of the coin to smooth out the edge.

The edge of a coin that is not round can be found automatically. The application finds a bunch of points along the edge of the coin and joins them by a straight line. If a small number of points is used a course outline results that cuts off corners. Increase the number of points to get a better result.

When using the Find Irregular option there are several parameters to improve the identification of points around the edge of the coin.

Threshold
The contrast level that tells the application an edge was found. Increase this value if small defects in the background are mistakenly interpreted as the edge of the coin. Decrease this value if the edge is mistakenly detected inside the coin.
Points
The number of points to be detected along the edge of the coin. On non-round coins many points are required to get a smooth edge. This option is often increased when using Filter Options.
Border Left
This option specifies how wide a buffer to ignore on the left side of the image. This is useful if the background does not reach the edge of the image.
Border Right
This option specifies how wide a buffer to ignore on the right side of the image. This is useful if the background does not reach the edge of the image.
Border Top
This option specifies how wide a buffer to ignore on the top side of the image. This is useful if the background does not reach the edge of the image.
Border Bottom
This option specifies how wide a buffer to ignore on the bottom side of the image. This is useful if the background does not reach the edge of the image.

A Non-Round Coin
More Points

Example 5 - Handle Renegade Points

  • Filter out points that aren't actually on the edge of the coin.

Often points are erroneously detected far from the edge of the coin. These points can be filted out before the edge of the coin is calculated. There are two filters available. The first is very simple. It ignores any point that is too far from its neighbors. This works pretty well as long as none of the erroneous points are next to each other.

If there are small clusters of erroneous points use the Point Run filter type. You can specify a number of points that must be in a cluster (or run of points). Smaller runs of points will not be included in the calculated edge.

Erroneous Points
Ignore Isolated Points

Example 6 - Crop, Mask Out Background, Change Background Color

  • View the output image.
  • Crop the coin out from the background.
  • Mask out the background, setting it to a solid color.
  • Change the color of the background.

Click on the Final tab to see the output image. If you haven't change any options yet the image will look the same as the original image.

To crop the edges of the images to the edge of the coin select "Crop To Coin" from the Image Process - Cropping listbox.

To mask out the background select "yes" from the Image Process - Mask listbox.

To change the color of the background change the color name in the Output - Background text box. If an invalid color name is entered the text will be red. When a valid color is entered the text turns black the background color changes. The color name can be any recognized english color name or a hex value.

Hex color values are written with a hash then the value. For example:

  • "#000000" is black
  • "#FFFFFF" is white
  • "#FF0000" is Red
  • "#00FF00" is Green
  • "#0000FF" is Blue

Crop, Mask, and Background Color

Example 7 - Rotate Coin

  • Rotate the image of the coin to correctly orient it.

In the Image Process - Rotate option enter the degrees to rotate the coin. Positive values rotate the coin clockwise, negitive values rotate counter clockwise. The example here rotates a coin by 90 degrees. Usually, this is used to adjust a coin that was photographed just slightly rotated to make it appear completely level.

Rotated by 90°

Example 8 - Draw A Grid Over The Output Image

  • Draw a grid over the output image.
  • Helpful to guide rotating the coin.
  • Helpful to identify the location for a highlight arrow.
  • Usually used only when working with the image. You can then turn this option off (select "no" from the option listbox) before saving the image.

Select "yes" on the Output Decoration - Grid option to display the grid. The grid is drawn in blue. At this time the color of the grid can not be changed.

The number of grid columns is changed by setting the value in the Output Decoration - Grid Width option.

The number of grid rows is changed by setting the value in the Output Decoration - Grid Height option.

10 x 10 Grid

Example 9 - Draw An Arrow To Highlight A Feature

  • Draw a Highlight Arrow over the output image.
  • Highlight a feature of the coin.
  • Set the location to which the arrow points.
  • Set the direction in which the arrow points.

To draw a white arrow on the output image select "yes" on the Output Decoration - Highlight Arrow listbos.

Set the location to which the arrow points in the fields labeled Point To X and Point To Y. Valid values are from 0.0 (left or top sides) to 1.0 (right or bottom sides).

Set the direction in which the arrow points by selecting a value from the Direction listbox.

Highlight Arrow

Example 10 - Create Grayscale Output Image

  • Create a grayscale (shades of gray) output image.

Select "8 bit Grayscale" on the Output - Output Type listbox.

Set the black point and white point by changing the values in Black Point and White Point. Values range from 0.0 (Black) to 100.0 (White).

Source

Example 11 - Change The Size Of The Output Image

  • Set the size of the actual coin.
  • Set the resolution of the output image.

The size of the output image is controlled by the size of the actual coin and the resolution. The output resolution is in Dots Per Inch (DPI). For example, to create an output image of 900 x 900 pixels:

  • Assume a round coin and selection of "Crop To Coin" to create a sqaure output image.
  • Set Coin Options - Diameter to 3.00 and Units to "in".
  • Set Output Resolution (DPI) to 300.00.
  • The Output Image is created with a size of 900 x 900 pixels. That is calculated as 3 inchs times 300 dots per inch.

Diameter
Resolution (DPI)

Example 12 - Save The Final Image

  • Use the menu selection File -> Save

Use the menu selection File -> Save. If this is the first time you've saved your final image the Open dialog is displayed. Navigate to the directory where you want to save your Final Image. Enter the name of your Final Image and click the Save button.

Your Final Image will be saved in the selected file.

File -> Save