## Bsoft program

# bmask

### Usage: bmask [options] input.img output.img

Generates and uses binary masks of the size given or of the input image.
The selected regions have value 1 and the omitted regions 0. The default is a blank mask created of the same size as the input image.

### Actions for mask creation:

-create 20,60,30 | Create a new mask of this size in place of input image
-threshold -0.55,1.2 | One or more thresholds to generate a mask.
-variance 5,1 | Generate mask based on local variance in a kernel of a given size,
| and flag to generate a background with value -1.

### Actions for mask modification:

-invert | Invert mask.
-dilate 2 | Dilate mask a number of times.
-erode 3 | Erode mask a number of times.
-open 4 | Open (erode-dilate) mask a number of times.
-close 2 | Close (dilate-erode) mask a number of times.
-hole 3,56,23 | Fill a hole indicated by the voxel.
-plane | 0.3,0.5,-0.1,0,3,25 Mask on one side of a plane with the given normal and origin.
-rectangle 40,20,45 | Rectangular mask with given length, width and rotation angle.
-radius 10,45 | Generate a mask inside these radii.
-asu D3 | Generate an asymmetric unit mask.
-color size | Generate a RGBA image (random/size).
-size | Convert level mask to region size map.

### Actions for multi-level masks:

-collapse | Convert a multi-level mask to a binary mask.
-select 1,5-7 | Select levels in a multi-level mask.
-voxel 23,241,193 | Select the level including this voxel.
-level 134 | Convert a mask to multiple levels, with the given voxels per level.
-bands 250,-1,150,1,30,0 | Banded mask for reciprocal space (pairs of numbers: angstrom,value).
| Band with 0: Not used.
| Band with 1: Use for orientation determination.
| Band with -1: Use for cross-validation.

### Actions for mask application:

-apply | Apply the mask to the input image (default output mask).
-rescaleapply 0.5,2.3 | Rescale region inside mask and apply the mask to the input image.

### Parameters:

-verbose 1 | Verbosity of output.
-datatype u | Force writing of a new data type.
-sampling 1.5,1.5,1.5 | Sampling (A/pixel; a single value can be given).
-origin 110,50,44 | Origin for the mask (default from input image).
-fill 28.3 | Fill value (default average).
-wrap | Flag to wrap around image boundaries (default not).

### Input:

-Mask file.img | Input mask to apply or get difference with main input image.

### Examples:

| 1. Creating a new mask:
| bmask -v 7 -create 100,100,50 -radius 10,20 -origin 50,50,25 mask.mrc
| 2. Generating a mask from an image:
| bmask -v 7 -threshold 1.5 test.map mask.mrc
| 3. Applying a mask to an image:
| bmask -v 7 -Mask mask.mrc test.map new.map
| 4. Generating and applying a mask to an image:
| bmask -v 7 -apply -radius 50,80 -origin 100,100,100 test.map new.map

Bsoft version 2.0.3-20180917 (64 bit)