Main Content

wfusmat

Fusion of two matrices or arrays

    Description

    C = wfusmat(A,B,method) returns the fused array C obtained from the arrays A and B using the fusion method specified by method.

    example

    [C,D] = wfusmat(A,B,method) returns the Boolean matrix D when defined, or an empty matrix otherwise.

    Examples

    collapse all

    Create two matrices.

    m1 = reshape(1:2:32,4,4)
    m1 = 4×4
    
         1     9    17    25
         3    11    19    27
         5    13    21    29
         7    15    23    31
    
    
    m2 = reshape(2:2:33,4,4)
    m2 = 4×4
    
         2    10    18    26
         4    12    20    28
         6    14    22    30
         8    16    24    32
    
    

    Fuse m1 and m2 using the mean fusion method.

    c1 = wfusmat(m1,m2,'mean')
    c1 = 4×4
    
        1.5000    9.5000   17.5000   25.5000
        3.5000   11.5000   19.5000   27.5000
        5.5000   13.5000   21.5000   29.5000
        7.5000   15.5000   23.5000   31.5000
    
    

    Fuse m1 and m2 using the rand fusion method. Obtain the Boolean matrix. The nonzero entries of the Boolean matrix correspond to the values of m1 in the fused output. For reproducibility, set the random seed to the default value.

    rng default
    [c2,d2] = wfusmat(m1,m2,'rand')
    c2 = 4×4
    
         2    10    18    26
         4    11    20    27
         5    13    21    30
         8    16    24    31
    
    
    d2 = 4x4 logical array
    
       0   0   0   0
       0   1   0   1
       1   1   1   0
       0   0   0   1
    
    

    Fuse m1 and m2 using the UD_fusion method. Confirm the first row of c3 equals the first row in m1, and the last row in c3 equals the last row in m2.

    mtd = struct('name','UD_fusion','param',0.4);
    c3 = wfusmat(m1,m2,mtd)
    c3 = 4×4
    
        1.0000    9.0000   17.0000   25.0000
        3.6444   11.6444   19.6444   27.6444
        5.8503   13.8503   21.8503   29.8503
        8.0000   16.0000   24.0000   32.0000
    
    

    Input Arguments

    collapse all

    Input data to merge, specified as two arrays. The inputs A and B must be the same size.

    If A and B represent indexed images, then they are M-by-N matrices. If A and B represent truecolor images, then they are M-by-N-by-3 arrays.

    Fusion method, specified either as a structure array or as one of the values listed here. For some fusion methods, the wfusmat function creates a Boolean matrix D.

    methDescription
    'max'

    D = (abs(A) ≥ abs(B)); C = A(D) + B(~D)

    'min'

    D = (abs(A) ≤ abs(B)); C = A(D) + B(~D)

    'mean'

    C = (A+B)/2; D = ones(size(A))

    'img1'C = A
    'img2'C = B
    'rand'C = A(D) + B(~D); D is a Boolean random matrix

    When specified as a structure array, the structure has the form struct('name',nameMETH,'param',paramMETH), where nameMETH can be one of the values listed here.

    nameMETHDescription
    'linear'

    C = A*paramMETH + B*(1-paramMETH), where 0 ≤ paramMETH ≤ 1

    'UD_fusion'

    Up-down fusion, with paramMETH ≥ 0

    x = linspace(0,1,size(A,1));
    P = x.^paramMETH;
    
    Then each row of C is computed with
    C(i,:) = A(i,:)*(1-P(i)) + B(i,:)*P(i); 
    
    so C(1,:) = A(1,:), and C(end,:) = B(end,:)

    'DU_fusion'Down-up fusion
    'LR_fusion'Left-right fusion (column-wise fusion)
    'RL_fusion'Right-left fusion (column-wise fusion)
    'UserDEF'User-defined fusion, paramMETH is a character vector or string scalar 'userFUNCTION' containing a function name such that C = userFUNCTION(A,B).

    Output Arguments

    collapse all

    Fused output of A and B, returned as an array.

    Boolean matrix. For some fusion methods, the wfusmat function creates the Boolean matrix. Otherwise, D is an empty matrix. For more information, see method.

    Version History

    Introduced before R2006a

    See Also