Main Content

imregmtb

Register 2-D images using median threshold bitmaps

Description

example

[R1,R2,...,Rn,shift] = imregmtb(M1,M2,...,Mn,F) registers an arbitrary number of moving images M1,M2,...,Mn with respect to the fixed (reference) image, F, using the median threshold bitmap technique. The registered images are returned in R1,R2,...,Rn, and the estimated displacement of the registered images is returned in shift.

The median threshold bitmap technique is effective for registering images captured with variable exposures. imregmtb considers only translations, not rotations or other types of geometric transformations.

Examples

collapse all

Read a series of images with different exposures.

I1 = imread('office_1.jpg');
I2 = imread('office_2.jpg');
I3 = imread('office_3.jpg');
I4 = imread('office_4.jpg');
I5 = imread('office_5.jpg');
I6 = imread('office_6.jpg');

The images were captured from a fixed camera, and there are no moving objects in the scene. For this example, simulate camera motion, or jitter, by translating each image horizontally and vertically by a random amount in the range [–30, 30] pixels. Store the translation values for all five moving images in the 5-by-2 matrix t. Designate the sixth image, I6, as the fixed (or reference) image. Do not apply jitter to this image.

t = randi([-30 30],5,2);
I1 = imtranslate(I1,t(1,:));
I2 = imtranslate(I2,t(2,:));
I3 = imtranslate(I3,t(3,:));
I4 = imtranslate(I4,t(4,:));
I5 = imtranslate(I5,t(5,:));

To compare the image positions, display a region of interest (ROI) from the center of each image. The vector roi specifies the x- and y-coordinate of the top left corner, and the width and height of the ROI.

roi = [140 260 200 200];
montage({imcrop(I1,roi),imcrop(I2,roi),imcrop(I3,roi), ...
    imcrop(I4,roi),imcrop(I5,roi),imcrop(I6,roi)})
title('Misaligned Images')

Register the spatially shifted images using median threshold bitmaps. Display an ROI from the center of each image.

[R1,R2,R3,R4,R5,shift] = imregmtb(I1,I2,I3,I4,I5,I6);
montage({imcrop(R1,roi),imcrop(R2,roi),imcrop(R3,roi), ...
    imcrop(R4,roi),imcrop(R5,roi),imcrop(I6,roi)})
title('Registered Images')

The images look well-aligned.

Examine the estimated displacement, shift, of each moving image with respect to the fixed image. shift represents the estimated transformation that must be applied to the moving image to align it with the fixed image.

shift
shift = 5×2

   -26    25
   -25    14
    23    -3
   -25   -28
    -8   -28

Compare the estimated displacement to the actual displacement. Recall that the transformation t was applied to the fixed image to simulate the jitter of each moving image. Therefore, the transformation -t is analogous to the transformation returned by shift.

-t
ans = 5×2

   -19    25
   -25    14
    23    -3
   -25   -28
    -8   -28

The imregmtb function does a good job estimating the displacement of each frame.

Input Arguments

collapse all

Moving images, specified as a series of grayscale images or RGB images with identical or variable exposures. The images must have the same size and data type.

Data Types: single | double | uint8 | uint16

Fixed image, specified as a grayscale image or RGB image. F must have the same size and data type as the moving images, M1,M2,...,Mn.

Data Types: single | double | uint8 | uint16

Output Arguments

collapse all

Registered images, returned as a series of grayscale images or RGB images. The registered images have the same size and data type as the moving images, M1,M2,...,Mn.

Estimated displacement in the horizontal and vertical direction of the n registered images, returned as an n-by-2 numeric matrix.

References

[1] Reinhard, E., W. Heidrich, P. Debevec, S. Pattanaik, G. Ward, K. Myszkowski. High Dynamic Range Imaging, Second Edition. San Francisco, CA: Morgan Kaufmann Publishers Inc., 2010, pp. 155–170.

Extended Capabilities

Version History

Introduced in R2018a

expand all

See Also

| | | | (Medical Imaging Toolbox)