Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

imfuse

Composite of two images

Syntax

Description

example

C = imfuse(A,B) creates a composite image from two images, A and B. If A and B are different sizes, imfuse pads the smaller dimensions with zeros so that both images are the same size before creating the composite. The output, C, is a numeric matrix containing a fused version of images A and B.

example

[C RC] = imfuse(A,RA,B,RB) creates a composite image from two images, A and B, using the spatial referencing information provided in RA and RB. The output RC defines the spatial referencing information for the output fused image C.

example

C = imfuse(___,method) uses the algorithm specified by method.

example

C = imfuse(___,Name,Value) specifies additional options with one or more Name,Value pair arguments, using any of the previous syntaxes.

Examples

collapse all

Load an image into the workspace. Create a copy and apply a rotation offset.

A = imread('cameraman.tif');
B = imrotate(A,5,'bicubic','crop');

Create blended overlay image, scaling the intensities of A and B jointly as a single data set.

C = imfuse(A,B,'blend','Scaling','joint');

Save the resulting image as a .png file and view the fused image.

imwrite(C,'my_blend_overlay.png');
imshow(C);

Load an image into the workspace. Create a copy and apply a rotation offset.

A = imread('cameraman.tif');
B = imrotate(A,5,'bicubic','crop');

Create blended overlay image, using red for one image, green for image B, and yellow for areas of similar intensity between the two images.

C = imfuse(A,B,'falsecolor','Scaling','joint','ColorChannels',[1 2 0]);

Save the resulting image as a .png file and view the fused image.

imwrite(C,'my_blend_red-green.png');
imshow(C)

Load an image into the workspace and create a spatial referencing object associated with it.

A = dicomread('knee1.dcm');
RA = imref2d(size(A));

Create a second image by resizing image A and create a spatial referencing object associated with that image.

B = imresize(A,2);
RB = imref2d(size(B));

Set referencing object parameters to specify the limits of the coordinates in world coordinates.

RB.XWorldLimits = RA.XWorldLimits;
RB.YWorldLimits = RA.YWorldLimits;

Create a blended overlay image and view it, using color to indicate areas of similar intensity. This example uses red for image A, green for image B, and yellow for areas of similar intensity between the two images. Note how the images do not appear to share any areas of similar intensity.

C = imfuse(A,B,'falsecolor','Scaling','joint','ColorChannels',[1 2 0]);
imshow(C)

Create a new fused image, this time using the spatial referencing information in RA and RB, and view it. In this version, the image appears yellow, because the images A and B have the same extent in the world coordinate system. The images actually are aligned, even though B is twice the size of A.

[C,RC] = imfuse(A,RA,B,RB,'ColorChannels',[1 2 0]);

Input Arguments

collapse all

Image to be combined into a composite image, specified as a grayscale, truecolor, or binary image.

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

Image to be combined into a composite image, specified as a grayscale, truecolor, or binary image.

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

Spatial referencing information associated with the input image A, specified as a spatial referencing object of class imref2d.

Spatial referencing information associated with the input image B, specified as a spatial referencing object of class imref2d.

Algorithm used to combine images, specified as one of the following values.

MethodDescription
'falsecolor'Creates a composite RGB image showing A and B overlaid in different color bands. Gray regions in the composite image show where the two images have the same intensities. Magenta and green regions show where the intensities are different. This is the default method.
'blend'Overlays A and B using alpha blending.
'diff'Creates a difference image from A and B.
'montage'Puts A and B next to each other in the same image.

Example: C = imfuse(A,B,'montage') places A and B next to each other in the output image.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Scaling','joint' scales the intensity values of A and B together as a single data set.

collapse all

Intensity scaling option, specified as one of the following values:

'independent'Scales the intensity values of A and B independently when C is created.
'joint'Scales the intensity values in the images jointly as if they were together in the same image. This option is useful when you want to visualize registrations of monomodal images, where one image contains fill values that are outside the dynamic range of the other image.
'none'No additional scaling.

Output color channel for each input image, specified as one of the following values:

[R G B]A three element vector that specifies which image to assign to the red, green, and blue channels. The R, G, and B values must be 1 (for the first input image), 2 (for the second input image), and 0 (for neither image).
'red-cyan'A shortcut for the vector [1 2 2], which is suitable for red/cyan stereo anaglyphs
'green-magenta'A shortcut for the vector [2 1 2], which is a high contrast option, ideal for people with many kinds of color blindness

Output Arguments

collapse all

Fused image that is a composite of the input images, returned as a grayscale, truecolor, or binary image.

Data Types: uint8

Spatial referencing information, returned as a spatial referencing object.

More About

collapse all

Tips

  • Use imfuse to create composite visualizations that you can save to a file. Use imshowpair to display composite visualizations to the screen.

Introduced in R2012a

Was this topic helpful?