You are here: Technology Image processing Mask filtering

Mask filtering

Rate this item
(4 votes)

Mask filtering is a powerful tool for processing black and white raster. Proper use of mask filters can solve a huge range of tasks, from preparing a raster terrain contour lines to highlight the marshes.

This tool enables you to create new filtering strategies and modify existing ones. Its dialog box consists of 4 zones: list of filters, list of masks, mask editing zone and control & preview zone.

The essence of mask filtering

Tracing tools of Easy Trace process what they "see" in the image, so it should be clean and clear. Far from being true at real work! Thus, the image should be preliminarily prepared for digitizing. It may take several hours at the worst (several minutes more likely) but saves days of operator's labour.

At that, adjacency filtering and other primitive methods of noise deletion don't cope with the task well. Individual approach to every local situation in the image is much more desirable. It sounds fantastically but it is possible indeed. Long ago, ONE optimal move for each of several thousand end-games was loaded into a "very big computer" and it win a game of chess, which had been considered drawn in principal. The same approach we use for mask filtering. If the program discovers a zone in the image similar to one of preset samples (masks), it processes this area properly. For example, the "fill up" command will be applied for a black "hole" in a line enclosed in white pixels, "delete" - for an island of 2-3 white pixels on black background, and so on.

Unfortunately, a lot of variants are possible for every situation if we consider several tens points instead of 2 or 3. But there is a way out - you code the pattern once, and the computer constructs all possible versions basing on the following principles of filtering.

  • all masks got out of the initial one by a series of 90-degree turns as well as vertical and horizontal mirror images will be used;
  • pixels in the mask may be coded in 3 ways - black, white, and gray (i. å. any color);
Combination of black and white pixels forms the pattern that the program looks for in the image. When found, white pixels will be added or deleted in the specified positions of the mask.

Next step is organizing of masks to certain successions - Filters and grouping of the latter into Filtering strategies. It should be think through because of the successive way of mask use. The program applies one masks (all its versions) first, and the result is a new image (initial one remains unchanged of course). The second mask will be applied to this new-created image, etc.

Mask grouping into filters depends on similarity of operations. For example, there may be filters for "rubbish" deletion, line form improvement, separation of merged lines and so on. Order of filters forms a Strategy: to delete the "rubbish", to delete defects in lines, to join ends of torn lines, to search for line continuations, to join line ends once more...

Width of lines differs in images scanned with different resolution. We recognize 3 types of raster lines: thin (1-3 pix), medium (3-5 pix), and thick (more than 5 pix). Some masks, filters, and strategies should be developed for each type separately.

On the other hand, some filters are width-independent. These are raster cleaning, deletion of local defects in lines surface, filling of caverns ("holes") in lines, etc. It means that many masks may be used in different filters. We placed all masks, filters, and strategies to a special-purpose storage - Repository. It is easy to take them from the storage and to form new filters and strategies.

Development of mask filters is based on several reasonable ideas.

  • You may see alternations caused by filtering;
  • You may run strategies and filters in parts, right up to one individual mask at every step;
  • A mean is provided to know which mask alternated this particular pixel;
  • You may form a mask from a pattern taken just in the image.
It takes only several minutes to create a simple filter for deletion of specific "rubbish" and/or "cure" lines of frequent defects and thus improve the image significantly. Unfortunately, development of every next filter improvement is more and more difficult. But you will be the gainer all the same, even if you spent some hours...

Current strategy and list of filters

  • Current strategy

    The pulldown list enables selection of a strategy from the Repository. After selection, you may change the set of masks in the strategy and their execution order. Filters and masks of the current strategy may be used in other strategies as well. If this is the case, their icons are represented in red to remind that any alternation of the object affects ALL the strategies, which comprise it. It is convenient for filters that improve line form regardless of line width but inconvenient for filters depending on this parameter.

    Before alternation of a RED mask or filter, you may want to know, what strategies (filters) comprise it. Click the mouse right button on the object's name and select Information command in the submenu.

  • Add new strategy

    Creates a new (empty!) strategy. Filters and their masks may be either created with the Mask Development Tool or taken from the Repository.

  • Delete current strategy

    Deletes the selected strategy. All the filters forming the strategy and all their masks are saved in the Repository (which has its own means of deletion).

  • Open Repository

    Gives access to the Repository - a storage of masks and filters for their selection and inclusion into the current strategy.

  • Filters of the current strategy

    The list controls the set of current strategy's filters and their execution order. every filter may be on (all masks of the filter will be applied) or off (all its masks will be ignored). Filter order in the list corresponds to the execution order. It may be changed by drag-and-drop method.

    Besides, the list may contain names of files - filtering subproducts. Open the submenu with the mouse right button to add, rename, or delete filters and files forming the strategy.

    • create a new "empty" filter;
    • add a filter from the Repository to the current strategy;
    • add saving of filtering results as a new raster file;
    • delete the filter from the strategy (but remain in the Repository!);
    • rename the filter in the strategy and Repository;
    • edit text description of the current filter
    • show information about filter use in other strategies

    If the icon representing the filter is RED, it indicates that the filter is included not in the current strategy only, but also in other strategies of the Repository. It is reasonable to open Information from the submenu before you alternate it to know, which strategies will be affected.

Control over masks in the current filter

  • list of masks in the current filter

    Remember, that the only copy of the mask is saved to the Repository, and filters comprise only references to it. Any alternation of mask body affects all the filters that comprise such references.

    Similar to the list of filters in a strategy, the list of masks represents their execution order. Any mask may be also on or off, and you may drag-and-drop them in the list. Unlike filters in a strategy, any mask may be used in a filter several times. Usually it concerns masks that fill up holes in lines or make raster lines thinner. It is reasonable to find out, which filters and strategies comprise a "red" mask before you alternate it. To remove all doubts, save the mask as one with a new name before editing.

    • add a new mask to the Repository and corresponding reference to the current filter;
    • add a reference to a mask from the Repository to the current filter;
    • add saving of filtering results as a new raster file;
    • copy to clipboard a reference to the current mask;
    • insert the reference from clipboard to the filter;
    • duplicate the current mask's body for new mask creation
    • delete the reference to a mask from the filter;
    • rename the mask in the strategy and Repository;
    • edit text description of the current mask
    • show information about mask use in other filters of the Repository

    Filtering is not as quick as one would like it to be. Besides, it is difficult sometimes to guess what alternations should be done in the mask succession for better results. Optional mask switching on/off simplifies selection of masks to be included into the filter. And saving of filtering subproducts as raster files allows to save a lot of time at this selection - just switch off the filters applied the file was saved and regard the saved image as the initial one.

    You may give the command to save filtering intermediate results as new files both in the list of masks and filters. At that, Raster Filtering command (that runs ready strategies) ignores the command.

Mask development and editing

  • Mask Editor

    The "chess-board" in the upper right corner is intended for mask review, development, and editing. Maximal mask size in Easy Trace is 8 õ 8 pixels. White squares correspond to pixels of a line, and pixels of the background are black. The mask will trigger only at strict correspondence of white and black pixels' positions in the mask and in the image.

    Gray color indicates that pixels in these positions will be ignored at comparison of the mask and an area in the image. It helps to cover more raster combinations by every black and white pattern.

    Masks are always square. Current size of the mask is shown by the dashed line. The smaller is the mask, the quicker it processes the image. The program decreases mask size automatically if right columns and low lines of the mask contain only gray pixels.

    To change color of a pixel in the mask, click it with the mouse left button. Color change is cyclic: black - white - gray.

    To specify modifications of the image use the mouse right button. Red squares or cross-marks will appear in the fields you click. Red square means that pixels will be white after mask applying (adding of the pixel), and cross-marked pixels will become black (deletion of the pixel). Repeated clicks change the command cyclically: delete - add - don't change.

  • Rotate option

    Adds three turns of the current mask in 90 degrees to the mask itself. May be specified separately for every use of the mask in the filter.

  • Reflectivity option

    Adds the flip image of the current mask relative to the vertical and horizontal axes to the mask itself. May be specified separately for every use of the mask in the filter.

  • Add sample

    Allows to take masks from the image directly. To do it, click the button and stretch the frame over the place of interest. Then specify in the draft pixels to be added, deleted and pixels unimportant for further search in the image, and save the new-created mask.

    The reference to this mask will be added ABOVE the currently selected mask name. The mask itself will be saved to the Repository, and may be used in other filters if you save made alternations of the strategy at dialog box closing.

Filter checkout and control

  • Check points

    The field contains coordinates of points in the image selected for control over filtering.

    Unwanted side effects are frequent at filter checkout - stray merging of neighboring lines, breakthroughs, etc. Select the pixel being damaged by filtering as a control point. The process will be terminated when the pixel changes the color and you will see the name of the mask, which causes the problem.

  • Delete current check point

    If you needn't check filtering effect on this particular point of the image any more, delete the control point - select it in the pulldown list and click the Delete current point button.

  • Add control point

    The Mask Development Tool interacts with the image in two cases only - taking a sample for a new mask and adding a new control point. Left click of a pixel in the screen makes it a control point after the program receives your confirmation.

  • Minimize the Bar option

    Parameter bar of the tool may hinder one from review of filtering results. Perhaps, you will find it convenient to hide the bar automatically (or maybe not)...

  • Show the Difference option

    Is extremely important! Filter (mask) checkout is based on study of image alternations this mask causes at filtering. Switch on the option to simplify comparison of the image before and after filtering. By default, it makes added pixels red and deleted ones - blue. Besides, they will blink to draw your attention.

    On the other hand, blink may be an obstacle when you inspect the image considering what should be done more - switch off the option then. The undo command also stops the flicker (as it cancels all the alternations caused by filtering). On the contrary, REDO restores initial state of the image.

    The undo and redo commands are usually well in use when you are developing a filter: improvement of the filter, filtering and estimation of results, new improvement of the filter, undo of alternations made in the image by previous filtering, new filtering...

    Note, that some of masks in the filter may be switch off at filter debug, but estimation of every mask's effect is extremely difficult all the same. Thus, it is reasonable to save results of filtering by already debugged part of the filter (strategy) as an intermediate image and use it as initial one at further debug. Move this "point of readiness" until you arrive to the end of the process.

  • Parameters

    Control two functions - presentation of difference in two images at their comparison (color and blink period of alternated points in the image) and report minuteness. Three options are available:

    • without report;
    • hit number only - mask names and number of their coincidence with image areas;
    • hit number and all versions of the mask - it is difficult sometimes to understand unexpected behavior of the mask without analysis of all its versions.

  • Test

    Starts filtering applying the current strategy. Filtering is a separate flow, and other operations may be execute at the same time if they don't affect the "experimental" image. To stop filtering, click the button in the lower right corner of the screen.


As any mask may be a member of several filters, the problem of well-organized mask storage and easy extraction arises. It is impossible to get by with text format and only copy and paste operations when you have about one hundred masks...

To solve the problem, a special storage was formed - Repository. It allowed order establishing in the "Augean stables" and development of new affective strategies of mask filtering may be expected soon.

Repository function

Repository is a storage containing strategies (consisting of filters), filters (consisting of masks), and masks themselves. Mask grouping into filters is based on community of their functions - i.e., filling of caverns, line smoothing, tying of torn lines' ends together, etc. Strategy is something more - a ready tool for processing of images of a certain type. Different strategies are necessary as masks differ depending on width of raster lines.

Classification of masks in the Repository is grounded on two features - operation, which the mask fulfills, and width of raster lines the mask is applicable for.

Presentation of Repository content

The bar displaying Repository content is its main element. Optionally, content of the storage may be shown in different ways, i.e. grouped by:

  • ...strategies and filters

    Full list of strategies, filters, and masks shown in their thumbnail representation. Strategies may be unfolded up to filters and filters - up to masks they consist of. Every mask is saved only once in the Repository, but may be included in numerous filters (more precisely, a reference to it). Masks are included in filters in the order and number specified at filter debug.

  • ... categories

    Development of new filters is easier if you use previously prepared masks from the Repository. Mask grouping by categories gathers masks designed for similar operations

  • ...image types and categories

    Raster lines of different width have different pixel patterns and thus demand different masks for search and processing of generally similar situations. Use masks from the appropriate width range when you prepare a filter for an image having a certain line width.

Control of Repository content

Functions of the Repository and the Mask Development Tool are partly the same, but some operations may be done in the Repository only. First of all, it is gathering of strategies elaborated on different computers, i.e. import of strategies. Besides, classification and categorization of masks and filters is possible only here. Do it every time after new strategy development, and you will get a good stock for further creation of filtering facilities.

Direct object management is based on drag-and-drop operations or use of the submenu (right click to open). At that, the following commands are provided:

  • imports content of both new StdMasks.msb mask files and old text files with the *.mst extension
  • creates a new empty strategy;
  • creates a new empty filter;
  • adds a new category to the list of mask categories;
  • deletes the current object. When you delete strategies and filters, the masks they consist of are moved to the Unused;
  • renames the current object;
  • shows content sorted by strategies;
  • ... by categories;
  • ... by image types.
Drag-and-drop operations in the Repository help to perform two tasks - object sorting first, and new strategy (filter) forming / editing second. Classification is clear - one mask may not belong to two categories but the second task needs some explanation. References to masks may be simply dragged (it is equal to cut + paste operations) or duplicated (copy + paste) - if the CTRL key is pressed.

Drag-and-drop function is also used for mask insertion into the dialog box of the Mask Development Tool. You just "take" a mask (filter) in the Repository and "bring" it to the filter being developed. Remember, that only a reference to the mask will be inserted without alternations in the storage.

  • New strategy

    The command forms a new empty strategy. It may be stuffed by dragging of already existing filters (CTRL pressed!!!), but better use the Mask Development Tool for this operation.

  • New filter

    The command forms a new empty filter. It may be stuffed by dragging of already existing masks (CTRL pressed!!!), but better use the Mask Development Tool for this operation.

  • Create new category

    Creates a new category for sorting of mask and filters. Category is a user-specified name of an image operation this group of masks is provided for.

  • Import

    Filters may be easily transferred to another computer - it is enough to copy and transfer the StdMasks.msb file of the Repository from the Filters folder. But you may also want to join results of filter development from several computers, perhaps even ones in the previous format. Import function is provided for this purpose, both from other Repositories and outdated *.mst files;

Cataloging and comments

  • Description of Repository Objects fieldis intended for descriptions of mask/filter/strategy functions.
  • Mask Structure field shows the pixel pattern the mask is based on and the commands of pixel changes it contains.
  • Image Type field allows selection of image type (according to raster line width) the current mask is applicable for.
  • Object Categories field allows assignment of a category (type of operation) the current mask belongs to.
More in this category: « Prev Next »

Add comment

Security code