Selection using Masks

See the introductory Selections topic for an introduction to selection in general and for a tutorial on basic selection methods that apply to all components.

 

This topic discusses a selection feature that is unique to images and surfaces. Because images are made up of a continuous sea of pixels certain selection functions make sense in images but have no equivalent in drawings or tables. In particular, when selecting pixels in images we often can refer to the selection as a region of particular shape. It is often highly desirable to be able to modify the shape of the region of selected pixels. We can do this with the Modify Selections commands or through the use of Masks. Masks are used for purposes other than selection. See the Masks topic for other uses.

 

Masks

 

Masks are a way of using one image to make selections in another image. They are also a handy way of saving as many selections as we like for a particular image by saving the desired selection pattern to a file. A mask can be any grayscale image. There is nothing special about grayscale images used as masks. What makes a grayscale image a "mask" is simply how we use it.

 

We can create masks using any method used to create or edit grayscale images. Since masks are often used as a means of saving selections or other patterns from existing images Manifold provides an Edit - Save Mask/Channel command that makes it easy to create a mask using an existing image.

 

To Create a Selection Mask

 

1. Make a selection in the image.

2. Choose Edit - Save Mask/Channel.

3. In the Save Mask dialog, save the Selection to an image name.

 

This creates a new image that has white pixels in the region to be selected and black pixels elsewhere.

 

images\img_mask_eg01.gif images\img_mask_eg02.gif

 

If we were to save the selection on the left as a mask the resultant mask image is shown on the right. Once saved, we can subsequently load the mask as a selection at any time we desire.

 

images\img_mask_eg02a.gif

 

When we use Edit - Load Mask/Channel to make a selection in the image using a mask it is as if the mask were a cut-out in a sheet of cardboard through which we "spray" selection color onto the image, just like using a stencil.

 

Masks are Images

 

Masks are simply grayscale images like any other grayscale image. They may be opened, edited and otherwise changed as we desire. No selection will occur wherever there is a pure black (value 0) pixel. Pixels in any other color result in a selection being made at that spot. Masks used for selection are most often saved using just black and white colors so that the region to be selected is obvious.

 

We can create a new mask image at any time by simply inserting a new grayscale image into the project and then coloring it in black and white to show where the selection should occur. We can then use the "mask" image to make a selection. This allows us to specify regions that are to be selected using the full set of image editing tools within Manifold.

 

images\img_mask_manifold_invert.gif images\img_mask_bronze_manifold.gif

 

If we create the image at left above we can use it as a mask. Regions of white pixels will be selected. If we open the bronze sample image and use Edit - Load Mask/Channel to load the image as the Selection, we can select a region of pixels in the bronze image in the shape of the word "manifold."

 

We can create a selection mask by creating a grayscale image that has white pixels wherever we want a selection and black pixels where we do not want a selection. We can also create a selection mask by making a selection in an image and then using Edit - Save Mask/Channel to save it as a mask. We can combine the two methods, by first using Edit - Save Mask/Channel and then opening and editing the resultant mask.

 

Matching Masks to Target Images

 

Masks are usually the same size as the image on which they are to operate. If the mask is larger or smaller than the target image it will be used centered on the image and all pixels outside the mask will not be changed (that is, will not be selected).

 

Masks are often created to work with a particular image. For example, one might wish to create a selection mask that selected pixels only to one side of a riverbank in an aerial photograph. There are two frequently used methods to assure that the mask is the same size and otherwise matches positions in the target image:

 

·      We can make a copy of the aerial photograph image and then edit that copy so that all the pixels not to be selected are black. We then convert the image copy to a grayscale image. If desired we can also use Threshold to force all non-black pixels into pure white.

·      We can copy the aerial photo image and to position it as a partially transparent layer above the aerial photo image in a map. We can then "trace" the area desired using various editing tools to fill in the region not to be selected with black (or other convenient color) pixels. Using a map in this way makes it possible to create the selection mask by tracing over the target image as a guide where the guiding image will always be visible through the partially-transparent layer.

 

Invisible Pixels in Masks

 

Any invisible pixels in masks will not participate in whatever the mask is asked to do. If the mask is loaded as a selection, regions of invisible pixels will not be selected. If the mask is loaded as a channel, any parts of the mask containing invisible pixels will not alter the target image.

 

Additional Choices for Save Mask

 

When using Edit - Save Mask/Channel to save a mask, we have many choices in the dialog's Save box in addition to saving the current selection as a mask. We can also save the mask using:

 

·      The current selection.

·      The region of invisible pixels.

·      Any saved selection we have made for this image in the Selections pane.

·      The R, G, or B channels in the image if it is an RGB image.

·      The alpha channel in the image if it is an RGBa image.

 

See the Masks topic for a discussion on how the above options can be used to separate an image into different images for each channel.

 

Use with Surfaces

 

Masks can also be used with surfaces. Saving a mask from a surface results in an image that is georegistered to the surface and that retains any selection that was made in the surface. This is a handy way of saving complex selections as an alternative to using the Selections pane.