Making a Mask Using the Script
Back to User's Manual Table of Contents
This page describes mask creatation from overlays. It is also
possible
to create a blank mask and then manually paint the ON regions into
it.
That is explained in the SRView
Quick
Start chapter.
The mask image will have the same file name as the image from which it was made except "Msk" will be appended to the name just prior to any extensions introduced by a period. Similarly, the mask image will appear in the SRView Images menu with "Msk" appended to the end of the name.
The overlay file for the image must reside in the same directory as the image and have the same name but with a .paf extension. If there is no such file makeMask.tcl will create one before making the mask. If there are unsaved changes to the overlay when makeMask.tcl is called, makeMask.tcl will save those changes before making the mask; your original overlay file will be overwritten with an updated version of the overlay.
Masks are made utilizing only ROIs drawn in the three principal planes of the image: XY, XZ and YZ. ROIs drawn on oblique planes are ignored.
To control selection and application of mask images, follow the instructions provided in the Quick Start guide.
The makeMask script opens a dialog box for the user to control which ROIs are used to make the mask.
Enter 0 to make mask regions only from ROIs having the active label shown in the SRView window. To make a ROI label active, choose the ROI Edit tool and click on the desired ROI. Or go to the ROIs/Masks menu, select ROI Labels, then select a ROI label. The resulting mask will have the Mask On Value, set in the Edit - Settings dialog.
Enter 1 to make a mask from all ROIs. The resulting mask will have the Mask On Value, set in the Edit - Settings dialog.
Enter 2 to make a multi-level mask from all ROIs. The makeMask program will read the ROI labels from the overlay (.paf) file. The ROI labels will be assigned the values 1, 2, 3, ... as different labels are read. Then these values are put into the mask regions generated from the ROIs with the corresponding label. The list of ROI labels is saved in the mask's .hdr file.
makeMask <image file name> <ROI Label> <timePos> <maskValue> <mask file name>
<image file name> - name of image file for which to make the mask.A scan analysis (.paf) file of the same name as the image file must be in the same directory as the image file. The ROIs contained in that scan analysis file are used to make the mask. The header of the image file is used to determine the header information for the new mask image. Only the image header is used; the image pixel data are not needed to make the mask, and therefore are not read.
<ROI Label> - label of the ROIs from which to make the mask. If <ROI Label> is "ALL" then all ROIs will be used regardless of label. If <ROI Label> is "MULTILEVEL", a multilevel mask is made -- see Mask making options above (Enter 2 ...).
<timePos> - time position of ROIs to use. If a negative number is given, then ROIs at all time points are used. If a positive number is given, then only ROIs at that time point will be used and the mask image will be created with only one time point. If timePos exceeds the maximum time position for this image, an error is returned.
<maskValue> - integer value, 1 to 255, to be used to represent ON pixels in the mask. OFF is always zero. Not used for multilevel mask.
<mask file name> - name of mask file to be created.
An image file containing the mask is written to the same directory as the input image file, and with the same name, except the mask file name has "Msk" appended to the base name of the image file. For example, the mask image made from the image file of name foobar.img, would be foobarMsk.img.makeMask overwrites any existing file of the name used for the mask image.
Error messages are written to stderr.
At a terminal window command line simply follow the usage statement above.At the command line of the Tcl command window in SRView, use the exec command to execute this standalone program:
exec makeMask <image file name> <ROI Label> <timePos> <maskValue> <mask file name>Be sure you give the full path name to the image file, or change to that directory before invoking makeMask.