FUNCTION REFERENCE

imfuse

Composite of two images.

Composite of two images.

Syntax

C = imfuse(A, B)

Syntax

C = imfuse(A, B, method)

Syntax

C = imfuse(..., 'Scaling', scaling, 'ColorChannels', channels)

Syntax

[C, RC] = imfuse(A, RA, B, RB, ...)

A and B are grayscale or truecolor images of class double, single, logical, uint8, uint16 or int16; C is uint8. method: 'falsecolor' (default) puts A and B in different colour channels of an RGB image, so equal intensities look gray and differences look green or magenta; 'blend' is the mean (A + B) / 2; 'diff' is the absolute difference |A - B|; 'montage' places A and B side by side, [A B]; 'checkerboard' takes alternating tiles from A and B. 'falsecolor' and 'diff' convert RGB images to grayscale with the rgb2gray weights; the other methods keep colour (a grayscale image beside an RGB one is repeated in the three channels). Images of different sizes are padded with zeros at the bottom and right to the larger height and width. Each image is first put on its class's 0..1 scale (as im2double); Scaling 'independent' (default) then stretches each image's smallest..largest value to 0..1, 'joint' stretches the smallest..largest value of both images together, and 'none' leaves the values; the composite is converted as im2uint8. ColorChannels (falsecolor only) is [R G B] with 1 for A, 2 for B and 0 for neither; 'green-magenta' (default) is [2 1 2] and 'red-cyan' is [1 2 2].

Example

imfuse(uint8([0 100; 200 255]), uint8([50 50; 150 250]))   % 2x2x3 uint8; green channel [0 100; 200 255]

Example

imfuse(uint8([20 40]), uint8([60 120]), 'blend', 'Scaling', 'joint')   % uint8 [51 153]

Example

imfuse(uint8([10 20 30]), uint8([40; 50]), 'montage', 'Scaling', 'none')   % uint8 [10 20 30 40 0 0; 0 0 0 50 0 0]

Differences from MATLAB: the reference page does not give the formulas; MatRust chooses these: padding comes before scaling, so padded zeros take part in the scaling range; an image (or, with 'joint', both images) whose values are all equal is not stretched; 'blend' uses equal weights; 'diff' is not stretched after the difference; 'checkerboard' uses tiles of ceil(rows/8) by ceil(cols/8) pixels with the top-left tile from A. imfuse(A, RA, B, RB) with imref2d RA and RB: the output covers the union of both world extents at RA's pixel extents (starting at the lower world limits, whole pixels); A and B are resampled onto that grid with linear interpolation (identity transformation; pixels outside an image get its class's zero on the unit scale: 0 for uint8, uint16, logical and floating images, 32768/65535 (about 0.5) for int16, which shows as 128 with 'Scaling', 'none'; otherwise the fill takes part in the scaling range like the padded zeros), then fused as above; RC is the imref2d of the output ('montage': twice as wide). The second output RC is given only for this form; referencing structs and other objects are not supported yet.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.