Main Content

imregmoment

Fast registration of grayscale images or intensity volumes using moment of mass method

Since R2022b

Description

The imregmoment function uses the moment of mass method for fast, similarity registration of grayscale images or intensity volumes. You can use this function to register multimodal medical images or volumes as a preprocessing step before multimodal medical image fusion.

[tform,reg] = imregmoment(moving,fixed) transforms the grayscale image or intensity volume moving, so that it is registered with the reference image or volume fixed, and returns the transformation tform and the registered image or volume reg.

[tform,reg] = imregmoment(moving,movingRef,fixed,fixedRef) specifies the spatial referencing information movingRef and fixedRef for moving and fixed, respectively.

[tform,reg] = imregmoment(___,MedianThresholdBitmap=mtb) specifies whether to threshold moving and fixed before registration, in addition to any combination of input arguments from previous syntaxes.

example

Examples

collapse all

The data used in this example is a modified version of the 3-D CT and MRI datasets provided by Dr. Michael Fitzpatrick as part of The Retrospective Image Registration Evaluation (RIRE) Dataset. The modified dataset contains the CT and MRI scans stored in the NRRD file format. The size of the entire data set is approximately 35 MB. Download the data set from the MathWorks® website, then unzip the folder.

zipFile = matlab.internal.examples.downloadSupportFile("medical", ...
    "MedicalRegistrationNRRDdata.zip");
filepath = fileparts(zipFile);
unzip(zipFile,filepath);

Read an MRI volume into the workspace as the reference volume. Get the spatial referencing information for the MRI volume.

fixedFile = fullfile(filepath,"supportfilesNRRD","Patient007MRT1.nrrd");
fixedVol  = nrrdinfo(fixedFile);
fixed = nrrdread(fixedFile);
fixedRef  = imref3d(size(fixed),fixedVol.PixelDimensions(2), ...
    fixedVol.PixelDimensions(1),fixedVol.PixelDimensions(3));

Read a CT volume into the workspace as the volume to be registered. Get the spatial referencing information for the CT volume.

movingFile = fullfile(filepath,"supportfilesNRRD","Patient007CT.nrrd");
movingVol = nrrdinfo(movingFile);
moving = nrrdread(movingFile);
movingRef = imref3d(size(moving),movingVol.PixelDimensions(2), ...
    movingVol.PixelDimensions(1),movingVol.PixelDimensions(3));

Compare a slice of the unregistered volume to a corresponding slice of the reference volume.

fixedRef2d = imref2d([size(fixed,1) size(fixed,2)], fixedRef.PixelExtentInWorldX, fixedRef.PixelExtentInWorldY);
movingRef2d = imref2d([size(moving,1) size(moving,2)], movingRef.PixelExtentInWorldX, movingRef.PixelExtentInWorldY);
centerFixed = size(fixed)/2;
centerMoving = size(moving)/2;
figure
imshowpair(moving(:,:,centerMoving(3)), movingRef2d, fixed(:,:,centerFixed(3)), fixedRef2d)
title("Unregistered Axial Slice")

Register the volumes, and return the registered volume and the transformation between the moving and fixed volumes.

[tform,reg] = imregmoment(moving,movingRef,fixed,fixedRef,MedianThresholdBitmap=true);

Compare the same slice of the registered volume to the corresponding slice of the reference volume.

figure
imshowpair(reg(:,:,centerFixed(3)),fixed(:,:,centerFixed(3)))
title("Registered Axial Slice")

Input Arguments

collapse all

Image or volume to be registered, specified as a 2-D numeric matrix or 3-D numeric array, respectively.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

Reference image or volume, specified as a 2-D numeric matrix or 3-D numeric array, respectively.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Spatial referencing information for the image or volume to be registered, specified as an imref2d object or an imref3d object, respectively. Use the spatial referencing inputs when the images or volumes differ in size by a scaling factor.

Spatial referencing information for the reference image or volume, specified as an imref2d object or an imref3d object, respectively. Use the spatial referencing inputs when the images or volumes differ in size by a scaling factor.

Median threshold bitmap processing, specified as a numeric or logical 0 (false) or 1 (true). Specify MedianThresholdBitmap as true to threshold moving and fixed. This can improve registration if the images have been captured using different sensors or have different intensity levels.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Output Arguments

collapse all

Similarity transformation, returned as an affinetform2d object or an affinetform3d object.

Registered image or volume, returned with the same size as fixed and same data type as moving.

Version History

Introduced in R2022b