MergeRegions

MLModule
genre Subimage
status stable
author Jan-Martin Kuhnigk
package MeVisLab/Standard
dll MLGeometry1
definition MLGeometry1.def
see also ModifyRegion, SubImage
keywords bounding, box, merge, roi, mask, world, coordinates, match, jmk

Purpose

The module MergeRegions offers operations to combine a number of regions described by multiple input images that usually represent different regions of a single volume.

They are registered via their world coordinates.

The number of images to be combined is user-defined and can be set between 2 and 20.

Usage

Select the number of images you would like to combine and the region the output image(s) shall describe. If you want to combine the image data itself, you can also select a merge mode (for example a maximum operation).

Details

  • Use the Merge Img Mode feature with care, behavior is not always consistent, especially if 0 is passed for any of the C values or non-0 values for Fill Value. Note that, if one of the merging modes does not appear to work properly for your data, you can always select mode None and compose the output images with other modules such as Mask or Arithmetic (FME release package)
  • In particular, if the output data type minimum (maximum) value is the result of a maximum (minimum) operation at some positions, the results of an operation using min or max might be incorrect at these positions. This is due to the 'in-place' approach and having to initialize the output memory with something within the data type range.

MeVis only: There is a macro module called MergeRegionsExt extending this module's functionality by combining it with a ModifyRegion macro module (to allow additional ROI modifications) as well as resampling operators (to align the voxel coordinates of images with different voxel sizes).

Interaction

  • Each input image or parameter change is directly relayed to the output image(s).
  • For all merge modes with special treatment of input0 except Bitwise Write with LUT, the first input (input0) must be connected to a valid image in order to obtain an output image.

Windows

Default Panel

../../../Modules/ML/MLGeometry1/mhelp/Images/Screenshots/MergeRegions._default.png

Input Fields

The module has as many inputs as specified by Maximum Number of Active Image Connections.

Depending on the selected merge mode, different configurations of unconnected inputs are allowed.

input0

name: input0, type: Image

input1

name: input1, type: Image

input2

name: input2, type: Image

input3

name: input3, type: Image

input4

name: input4, type: Image

input5

name: input5, type: Image

input6

name: input6, type: Image

input7

name: input7, type: Image

input8

name: input8, type: Image

input9

name: input9, type: Image

input10

name: input10, type: Image

input11

name: input11, type: Image

input12

name: input12, type: Image

input13

name: input13, type: Image

input14

name: input14, type: Image

input15

name: input15, type: Image

input16

name: input16, type: Image

input17

name: input17, type: Image

input18

name: input18, type: Image

input19

name: input19, type: Image

Output Fields

The number of outputs depends on the Merge Img Mode:

  • Merge Img Mode == copy only: The number of outputs equals the number of inputs. Every output whose input is connected will display its input image in the selected region (if valid).
  • Merge Img Mode != copy only: The module has only one (active) output. Output0 will display the result of the selected merge operation with respect to the selected region (if valid). All other outputs will be invalidated (and hidden, if possible).

output0

name: output0, type: Image

output1

name: output1, type: Image

output2

name: output2, type: Image

output3

name: output3, type: Image

output4

name: output4, type: Image

output5

name: output5, type: Image

output6

name: output6, type: Image

output7

name: output7, type: Image

output8

name: output8, type: Image

output9

name: output9, type: Image

output10

name: output10, type: Image

output11

name: output11, type: Image

output12

name: output12, type: Image

output13

name: output13, type: Image

output14

name: output14, type: Image

output15

name: output15, type: Image

output16

name: output16, type: Image

output17

name: output17, type: Image

output18

name: output18, type: Image

output19

name: output19, type: Image

Parameter Fields

Field Index

#: Integer Update: Trigger
-> Outbox (in WC): String  
Clear: Trigger  
Enable Auto-Update: Bool  
Fill Value: Double  
Maximum Number of Active Image Connections: Integer  
Merge Img Mode: Enum  
Select ROI: Enum  

Visible Fields

-> Outbox (in WC)

name: outWorldBox, type: String, default: 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1

Shows the current output box using world coordinates.

In custom region mode, an external modification to this field results in an actual change on the output(s).

Fill Value

name: fillValue, type: Double, default: 0

Sets the fill value (fV) for undefined image regions.

Select ROI

name: selectROI, type: Enum, default: UseInputRegion

Defines the region of interest to work on.

Values:

Title Name Description
Region from input0 (deprecated, use UseInputRegion instead) UseRegion0_deprecated  
Region from input1 (deprecated, use UseInputRegion instead) UseRegion1_deprecated  
Region from input2 (deprecated, use UseInputRegion instead) UseRegion2_deprecated  
Region from input3 (deprecated, use UseInputRegion instead) UseRegion3_deprecated  
Input Region UseInputRegion

The exact region of one of the inputs is used for the output image(s).

The index of the input is described in the number field (#) appearing on the right hand side of the region selection field.

Possible values for the number range from 0 to (Maximum Number of Active Image Connections - 1).

Union of all regions UseUnion The union of the regions of all input images is used.
Intersection of all regions UseSection The intersection of the regions of all input images is used.
Custom region UseCustomRegion

The region specified by the field Output image box will be used.

It is a SubImgBoxf-field that can be modified manually, by using setStringValue() in scripting or by a field connection from another SubImgBoxf-field in the network (for example, you can use a VecBoxConvert macro to generate a SubImgBox).

#

name: roiSourceIndex, type: Integer, default: 1, minimum: 0, maximum: :field:`numActiveImages`

Shows the number of used input regions.

Maximum Number of Active Image Connections

name: numActiveImages, type: Integer, default: 2, minimum: 2, maximum: 20

Sets the number of image connections that are displayed in the network and used for output computation.

Note that it is not possible to decrease this value further if this would cause one of the current connections to become inactive. The maximum value of active is fixed (currently at 20) and can only be changed in the source code.

Merge Img Mode

name: mergeImgMode, type: Enum, default: None

Defines the merge mode.

Values:

Title Name Description
Copy only: outX = inX; X = 0,1,... None

Every output whose corresponding input is connected to an image will put out exactly the input image, but with respect to the selected region.

In every other mode, only the first output image (output0) will be used.

Maximum: out0 = MAX(in0,in1,...) Maximum

output0 holds the maximum of the available input images.

Where no input image is defined, the Fill Value is written.

Minimum: out0 = MIN(in0,in1,...) Minimum

output0 holds the minimum of the available input images.

Where no input image is defined, the Fill Value is written.

Minimum where defined: out0 = MIN(inX; X = 0,1,... and inX defined) MinWhereDefined

output0 holds the minimum of the available input images where all images are defined, otherwise the Fill Value.

Note that problems might arise if the maximum value for the output data type is used within one of the input images, where all other input images are not defined (because the that output data type maximum is used for initialization of the minimum-operation).

Bitwise OR: out0 = OR (in0,in1,...) BitWiseOr

output0 holds the bit-wise OR of the available input images.

Note that the Fill Value is ignored (i.e. assumed to be 0) in this mode.

In floating point images, Maximum mode will be used instead.

Bitwise AND: out0 = AND(in0,in1,...) BitWiseAnd

output0 holds the bit-wise AND of the available input images where all images are defined (otherwise the Fill Value).

In floating point images, Minimum mode will be used instead.

Bitwise XOR: out0 = XOR(in0,in1,...) BitWiseXor

output0 holds the bit-wise XOR of the available input images.

In floating point images, Absolute Difference mode will be used.

Note that the Fill Value is ignored (i.e. assumed to be 0) in this mode.

Mask Original (2): out0 = in1 ? in0 : fV MaskOrig2 output0 holds the input image0 masked with image1.
Mask in Original (2): out0 = in1 ? in1 : in0 MaskInOrig2

output0 holds the input image1 masked into image0.

Where no input image is defined, the Fill Value is written.

Mask C in Original (2): out0 = in1 ? C0 : in0 MaskCInOrig2

output0 holds C0 where the input image1 is non-zero, otherwise image0.

Where no input image is defined, the Fill Value is written.

Absolute Difference: out0 = ABS(in0 - in1) AbsDiff2

output0 holds the absolute value of the difference of the input image0 and image1.

Note that the Fill Value is ignored (i.e. assumed to be 0) in this mode.

ArgMax (2): out0 = OR (in0!=0,in1!=0) ? CX; X = ARGMAX(in0, in1) : fV ArgMax2

output0 holds basically the C-value that corresponds to the greater image value (but only for non-zero image values)

Where no input image is defined, the Fill Value is written.
Mask Original Any: out0 = OR (in1!=0,in2!=0,...) ? in0 : 0 MaskOrigAny

output0 holds input image 0 only where at least one of the other images is defined and non-zero.

Note that the Fill Value is ignored (i.e. assumed to be 0) in this mode.

Mask Original None: out0 = OR (in1!=0,in2!=0,...) ? 0 : in0 MaskOrigNone

output0 holds input image0 only where none of the other images is defined or non-zero.

Note that the Fill Value is ignored (i.e. assumed to be 0) in this mode.

Mask Original All: out0 = AND(in1!=0,in2!=0,...) ? in0 : 0 MaskOrigAll

output0 holds input image0 only where all of the other images are defined and non-zero.

Note that the Fill Value is ignored (i.e. assumed to be 0) in this mode.

Mask Original Not All: out0 = AND(in1!=0,in2!=0,...) ? 0 : in0 MaskOrigNotAll

output0 holds input image0 only where at least one of the other images is not defined or zero.

Note that Fill Value is ignored (i.e. assumed to be 0) in this mode.

Mask Max in Original: out0 = MAX(in1,in2,...) ? MAX(in1,in2,...) : in0 MaskMaxInOrig

The maximum of the images with index >= 1 is masked into image0.

Note that the Fill Value is ignored (i.e. assumed to be 0) in this mode.

Mask C in Original : out0 = OR (in1!=0,in2!=0,...) ? C0 : in0 MaskCInOrig

If any of the images with index >= 1 is non-zero, C0 will be written, otherwise image0.

Note that the Fill Value is ignored (i.e. assumed to be 0) in this mode.

Maximum with LUT: out0 = MAX(inX ? (useCX ? CX : inX) : 0; X = 0,1,...) MaxWithLUT Similar to Mask Max in Original, but allows to select a constant instead of the image value for the maximum computation, and allows the use of Fill Value.
Bitwise OR with LUT: out0 = OR (inX ? (useCX ? CX : inX) : 0; X = 0,1,...) BitWiseOrWithLUT

This can be used to merge several masks into one image without losing information.

Opposed to the ordinary OR-option, you can replace positive mask values by a constant. Note that the Fill Value is ignored (i.e. assumed to be 0) in this mode.

Bitwise AND with LUT: out0 = AND (inX ? (useCX ? CX : inX) : 0; X = 0,1,...) BitWiseAndWithLUT Works like Bitwise OR with LUT, but uses AND for value combination.
Write Label(s) in Orig.: out0 = OR (AND(NEG(C0),in0), AND(C0, OR(inX ? (useCX ? CX : 0) : inX; X = 1,2,...)) BitWiseWriteWithLUT

This can be used to merge multiple masks (at input1,2,...) into a label image at input0 and thus requires integer images at all connected inputs.

The (optional) input image 0 can only be modified at those bits that are set in c0.

Note that the Fill Value is ignored (i.e. assumed to be 0) in this mode.

Enable Auto-Update

name: autoUpdate, type: Bool, default: TRUE

Enable or disable automatic updates on all input/parameter field changes. Temporarily disabling helps preventing unwanted computation/notifications when multiple input images or parameters change at the same time.

Update

name: update, type: Trigger

Updates box computation and active outputs (not available if Enable Auto-Update is TRUE)

Clear

name: clear, type: Trigger

Invalidates all image outputs (not available if Enable Auto-Update is TRUE)