1
\$\begingroup\$

This is a follow-up question for GetNeighborhood function for 3D cells structure in MATLAB. Based on the existing 2D non-local algorithm, I am attempting to implement 3D non-local mean algorithm in MATLAB and GetNeighborhood function is used here for extracting sub-region of 3D cells.

The experimental implementation

The experimental implementation of NonLocalMean3D(main function), NonLocalMeanWeight, NonLocalMeanSimilarity and GetNeighborhood functions are as below.

  • NonLocalMean3D function:
function [outputCells] = NonLocalMean3D(Sigma, inputCells)
%   NonLocalMean implementation
    IntermediateFilename = "NonLocalMean.mat";
    if isfile(IntermediateFilename)
        
        load(IntermediateFilename);
        X = X + 1;
        
        while X < size(inputCells, 1)
            for Y = 1:size(inputCells, 2)
                for Z = 1:size(inputCells, 3)
                    %TargetCube = inputCells{X, Y, Z};
                    SingleOutput = {zeros([size(inputCells{X, Y, Z}, 1) size(inputCells{X, Y, Z}, 2) size(inputCells{X, Y, Z}, 3)])};
                    SumOfWeight = 0.0;
                    for x = 1:size(inputCells, 1)
                        for y = 1:size(inputCells, 2)
                            for z = 1:size(inputCells, 3)
                                weight = NonLocalMeanWeight(Sigma, inputCells, ...
                                    [X Y Z], ...
                                    [x y z]);
                                
                                SingleOutput = {cell2mat(SingleOutput) + cell2mat(inputCells{x, y, z}) .* weight};
                                SumOfWeight = SumOfWeight + weight;
                            end
                        end
                    end
                    SingleOutput = {cell2mat(SingleOutput) ./ SumOfWeight};
                    outputCells{X, Y, Z} = SingleOutput;
                    
                    fprintf('3D non-local mean: The %d_%d_%d / %d_%d_%d block calculation has done. \n' , X, Y, Z, size(inputCells, 1), size(inputCells, 2), size(inputCells, 3));
                end
            end
            save("NonLocalMean.mat", '-v7.3');
            
            X = X + 1;
        end
        
        return;
    else
        outputCells = inputCells;
    
        for X = 1:size(inputCells, 1)
            for Y = 1:size(inputCells, 2)
                for Z = 1:size(inputCells, 3)
                    %TargetCube = inputCells{X, Y, Z};
                    SingleOutput = {zeros([size(inputCells{X, Y, Z}, 1) size(inputCells{X, Y, Z}, 2) size(inputCells{X, Y, Z}, 3)])};
                    SumOfWeight = 0.0;
                    for x = 1:size(inputCells, 1)
                        for y = 1:size(inputCells, 2)
                            for z = 1:size(inputCells, 3)
                                weight = NonLocalMeanWeight(Sigma, inputCells, ...
                                    [X Y Z], ...
                                    [x y z]);
                                
                                SingleOutput = {cell2mat(SingleOutput) + cell2mat(inputCells{x, y, z}) .* weight};
                                SumOfWeight = SumOfWeight + weight;
                            end
                        end
                    end
                    SingleOutput = {cell2mat(SingleOutput) ./ SumOfWeight};
                    outputCells{X, Y, Z} = SingleOutput;
                    
                    fprintf('3D non-local mean: The %d_%d_%d / %d_%d_%d block calculation has done. \n' , X, Y, Z, size(inputCells, 1), size(inputCells, 2), size(inputCells, 3));
                end
            end
            save("NonLocalMean.mat", '-v7.3');
        end
        return;
    end
end
  • NonLocalMeanWeight function:
function [outputDistance] = NonLocalMeanWeight(Sigma, inputCells, location1, location2)
%NonLocalMeanDistance function
%   Calculate 3D data weight for non-local mean algorithm
    SigmaForGaussian = Sigma;
    MeanForGaussian = 0;
    NeighborhoodDist = 1;
    
    NormalDistance = NonLocalMeanSimilarity(inputCells, location1, location2, NeighborhoodDist);
    outputDistance = gaussmf(NormalDistance, [SigmaForGaussian MeanForGaussian]);
end
  • NonLocalMeanSimilarity function:
function [output] = NonLocalMeanSimilarity(inputCells, location1, location2, sizeInput)
%   NonLocalMeanSimilarity Calculate the similarity between two
%   locations for non-local mean algorithm
    output = 0.0;
    block1 = GetNeighborhood(inputCells, sizeInput, location1);
    block2 = GetNeighborhood(inputCells, sizeInput, location2);
    
    for x = 1:size(block1, 1)
        for y = 1:size(block1, 2)
            for z = 1:size(block1, 3)
                if (x == sizeInput + 1) && (y == sizeInput + 1) && (z == sizeInput + 1) % Central location
                    continue;
                end
                
                object1 = block1(x, y, z);
                object2 = block2(x, y, z);
                
                if iscell(object1{1})
                    matBlock1 = cell2mat(object1{1});
                else
                    matBlock1 = object1{1};
                end
                
                if iscell(block2{1})
                    matBlock2 = cell2mat(object2{1});
                else
                    matBlock2 = object2{1};
                end
                
                output = output + sum(abs(matBlock1 - matBlock2), 'all');
            end
        end
    end
end
  • GetNeighborhood function:
function [output] = GetNeighborhood(inputCells, sizeInput, centralLocation)
    %   Get neighborhood of fixed size and centered at centralLocation
    output = cell( sizeInput ,sizeInput ,sizeInput );
    X = centralLocation(1);
    Y = centralLocation(2);
    Z = centralLocation(3);
    for x = -sizeInput:sizeInput
        for y = -sizeInput:sizeInput
            for z = -sizeInput:sizeInput
                
                xLocation = min(max(X + x, 1), size(inputCells, 1));
                yLocation = min(max(Y + y, 1), size(inputCells, 2));
                zLocation = min(max(Z + z, 1), size(inputCells, 3));
                output{sizeInput + x + 1, sizeInput + y + 1, sizeInput + z + 1} = ...
                    inputCells{xLocation, yLocation, zLocation};
            end
        end
    end
end

Test cases

For testing purpose, a simple test for three-dimensional non-local mean algorithm script is created as below.

%% Create test cells
testCellsSize = 10;

test = cell(testCellsSize, testCellsSize, testCellsSize);
for x = 1:size(test, 1)
    for y = 1:size(test, 2)
        for z = 1:size(test, 3)
            test{x, y, z} = {[x * 100 + y * 10 + z]};
        end
    end
end


%% Specify test parameters
Sigma = 20;

%% Perform test
result = NonLocalMean3D(Sigma, test);

%% Print output
for z = 1:size(result, 3)
    fprintf('3D non-local mean result: %d plane\n' , z);
    for x = 1:size(result, 1)
        for y = 1:size(result, 2)
            fprintf('%f\t' , result{x, y, z}{1});
        end
        fprintf('\n');
    end
    fprintf('\n');
end

Note: Each element in the three-dimensional data structure test in the test script above is a single number, it can be a vector / multidimensional data in different scenarios.

The output of the above testing code:

3D non-local mean: The 1_1_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_1_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_1_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_1_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_1_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_1_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_1_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_1_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_1_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_1_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_2_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_2_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_2_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_2_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_2_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_2_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_2_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_2_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_2_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_2_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_3_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_3_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_3_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_3_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_3_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_3_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_3_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_3_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_3_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_3_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_4_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_4_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_4_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_4_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_4_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_4_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_4_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_4_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_4_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_4_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_5_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_5_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_5_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_5_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_5_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_5_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_5_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_5_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_5_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_5_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_6_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_6_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_6_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_6_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_6_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_6_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_6_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_6_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_6_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_6_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_7_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_7_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_7_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_7_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_7_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_7_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_7_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_7_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_7_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_7_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_8_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_8_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_8_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_8_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_8_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_8_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_8_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_8_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_8_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_8_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_9_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_9_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_9_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_9_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_9_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_9_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_9_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_9_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_9_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_9_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_10_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_10_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_10_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_10_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_10_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_10_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_10_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_10_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_10_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 1_10_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_1_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_1_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_1_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_1_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_1_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_1_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_1_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_1_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_1_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_1_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_2_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_2_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_2_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_2_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_2_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_2_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_2_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_2_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_2_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_2_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_3_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_3_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_3_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_3_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_3_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_3_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_3_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_3_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_3_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_3_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_4_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_4_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_4_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_4_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_4_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_4_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_4_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_4_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_4_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_4_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_5_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_5_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_5_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_5_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_5_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_5_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_5_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_5_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_5_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_5_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_6_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_6_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_6_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_6_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_6_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_6_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_6_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_6_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_6_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_6_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_7_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_7_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_7_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_7_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_7_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_7_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_7_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_7_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_7_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_7_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_8_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_8_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_8_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_8_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_8_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_8_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_8_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_8_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_8_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_8_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_9_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_9_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_9_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_9_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_9_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_9_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_9_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_9_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_9_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_9_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_10_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_10_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_10_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_10_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_10_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_10_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_10_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_10_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_10_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 2_10_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_1_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_1_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_1_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_1_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_1_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_1_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_1_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_1_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_1_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_1_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_2_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_2_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_2_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_2_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_2_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_2_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_2_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_2_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_2_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_2_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_3_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_3_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_3_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_3_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_3_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_3_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_3_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_3_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_3_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_3_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_4_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_4_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_4_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_4_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_4_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_4_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_4_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_4_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_4_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_4_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_5_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_5_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_5_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_5_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_5_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_5_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_5_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_5_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_5_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_5_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_6_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_6_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_6_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_6_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_6_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_6_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_6_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_6_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_6_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_6_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_7_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_7_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_7_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_7_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_7_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_7_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_7_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_7_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_7_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_7_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_8_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_8_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_8_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_8_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_8_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_8_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_8_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_8_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_8_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_8_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_9_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_9_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_9_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_9_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_9_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_9_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_9_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_9_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_9_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_9_10 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_10_1 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_10_2 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_10_3 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_10_4 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_10_5 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_10_6 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_10_7 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_10_8 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_10_9 / 10_10_10 block calculation has done. 
3D non-local mean: The 3_10_10 / 10_10_10 block calculation has done. 
...

3D non-local mean result: 1 plane
111.502034  121.502033  131.418892  141.418892  151.418892  161.418892  171.418892  181.418892  191.418892  201.502033  
211.502034  221.502033  231.418892  241.418892  251.418892  261.418892  271.418892  281.418892  291.418892  301.502033  
311.502034  321.502033  331.418892  341.418892  351.418892  361.418892  371.418892  381.418892  391.418892  401.502033  
411.502034  421.502033  431.418892  441.418892  451.418892  461.418892  471.418892  481.418892  491.418892  501.502033  
511.502034  521.502033  531.418892  541.418892  551.418892  561.418892  571.418892  581.418892  591.418892  601.502033  
611.502034  621.502033  631.418892  641.418892  651.418892  661.418892  671.418892  681.418892  691.418892  701.502033  
711.502034  721.502033  731.418892  741.418892  751.418892  761.418892  771.418892  781.418892  791.418892  801.502033  
811.502034  821.502033  831.418892  841.418892  851.418892  861.418892  871.418892  881.418892  891.418892  901.502033  
911.502034  921.502033  931.418892  941.418892  951.418892  961.418892  971.418892  981.418892  991.418892  1001.502033 
1011.502034 1021.502033 1031.418892 1041.418892 1051.418892 1061.418892 1071.418892 1081.418892 1091.418892 1101.502033 

3D non-local mean result: 2 plane
111.908532  121.908532  131.899467  141.899467  151.899467  161.899467  171.899467  181.899467  191.899467  201.908532  
211.908532  221.908532  231.899467  241.899467  251.899467  261.899467  271.899467  281.899467  291.899467  301.908532  
311.908532  321.908532  331.899467  341.899467  351.899467  361.899467  371.899467  381.899467  391.899467  401.908532  
411.908532  421.908532  431.899467  441.899467  451.899467  461.899467  471.899467  481.899467  491.899467  501.908532  
511.908532  521.908532  531.899467  541.899467  551.899467  561.899467  571.899467  581.899467  591.899467  601.908532  
611.908532  621.908532  631.899467  641.899467  651.899467  661.899467  671.899467  681.899467  691.899467  701.908532  
711.908532  721.908532  731.899467  741.899467  751.899467  761.899467  771.899467  781.899467  791.899467  801.908532  
811.908532  821.908532  831.899467  841.899467  851.899467  861.899467  871.899467  881.899467  891.899467  901.908532  
911.908532  921.908532  931.899467  941.899467  951.899467  961.899467  971.899467  981.899467  991.899467  1001.908532 
1011.908532 1021.908532 1031.899467 1041.899467 1051.899467 1061.899467 1071.899467 1081.899467 1091.899467 1101.908532 

3D non-local mean result: 3 plane
112.935427  122.935427  132.935310  142.935310  152.935310  162.935310  172.935310  182.935310  192.935310  202.935427  
212.935427  222.935427  232.935310  242.935310  252.935310  262.935310  272.935310  282.935310  292.935310  302.935427  
312.935427  322.935427  332.935310  342.935310  352.935310  362.935310  372.935310  382.935310  392.935310  402.935427  
412.935427  422.935427  432.935310  442.935310  452.935310  462.935310  472.935310  482.935310  492.935310  502.935427  
512.935427  522.935427  532.935310  542.935310  552.935310  562.935310  572.935310  582.935310  592.935310  602.935427  
612.935427  622.935427  632.935310  642.935310  652.935310  662.935310  672.935310  682.935310  692.935310  702.935427  
712.935427  722.935427  732.935310  742.935310  752.935310  762.935310  772.935310  782.935310  792.935310  802.935427  
812.935427  822.935427  832.935310  842.935310  852.935310  862.935310  872.935310  882.935310  892.935310  902.935427  
912.935427  922.935427  932.935310  942.935310  952.935310  962.935310  972.935310  982.935310  992.935310  1002.935427 
1012.935427 1022.935427 1032.935310 1042.935310 1052.935310 1062.935310 1072.935310 1082.935310 1092.935310 1102.935427 

3D non-local mean result: 4 plane
113.996732  123.996732  133.996732  143.996732  153.996732  163.996732  173.996732  183.996732  193.996732  203.996732  
213.996732  223.996732  233.996732  243.996732  253.996732  263.996732  273.996732  283.996732  293.996732  303.996732  
313.996732  323.996732  333.996732  343.996732  353.996732  363.996732  373.996732  383.996732  393.996732  403.996732  
413.996732  423.996732  433.996732  443.996732  453.996732  463.996732  473.996732  483.996732  493.996732  503.996732  
513.996732  523.996732  533.996732  543.996732  553.996732  563.996732  573.996732  583.996732  593.996732  603.996732  
613.996732  623.996732  633.996732  643.996732  653.996732  663.996732  673.996732  683.996732  693.996732  703.996732  
713.996732  723.996732  733.996732  743.996732  753.996732  763.996732  773.996732  783.996732  793.996732  803.996732  
813.996732  823.996732  833.996732  843.996732  853.996732  863.996732  873.996732  883.996732  893.996732  903.996732  
913.996732  923.996732  933.996732  943.996732  953.996732  963.996732  973.996732  983.996732  993.996732  1003.996732 
1013.996732 1023.996732 1033.996732 1043.996732 1053.996732 1063.996732 1073.996732 1083.996732 1093.996732 1103.996732 

3D non-local mean result: 5 plane
114.999977  124.999977  134.999977  144.999977  154.999977  164.999977  174.999977  184.999977  194.999977  204.999977  
214.999977  224.999977  234.999977  244.999977  254.999977  264.999977  274.999977  284.999977  294.999977  304.999977  
314.999977  324.999977  334.999977  344.999977  354.999977  364.999977  374.999977  384.999977  394.999977  404.999977  
414.999977  424.999977  434.999977  444.999977  454.999977  464.999977  474.999977  484.999977  494.999977  504.999977  
514.999977  524.999977  534.999977  544.999977  554.999977  564.999977  574.999977  584.999977  594.999977  604.999977  
614.999977  624.999977  634.999977  644.999977  654.999977  664.999977  674.999977  684.999977  694.999977  704.999977  
714.999977  724.999977  734.999977  744.999977  754.999977  764.999977  774.999977  784.999977  794.999977  804.999977  
814.999977  824.999977  834.999977  844.999977  854.999977  864.999977  874.999977  884.999977  894.999977  904.999977  
914.999977  924.999977  934.999977  944.999977  954.999977  964.999977  974.999977  984.999977  994.999977  1004.999977 
1014.999977 1024.999977 1034.999977 1044.999977 1054.999977 1064.999977 1074.999977 1084.999977 1094.999977 1104.999977 

3D non-local mean result: 6 plane
116.000023  126.000023  136.000023  146.000023  156.000023  166.000023  176.000023  186.000023  196.000023  206.000023  
216.000023  226.000023  236.000023  246.000023  256.000023  266.000023  276.000023  286.000023  296.000023  306.000023  
316.000023  326.000023  336.000023  346.000023  356.000023  366.000023  376.000023  386.000023  396.000023  406.000023  
416.000023  426.000023  436.000023  446.000023  456.000023  466.000023  476.000023  486.000023  496.000023  506.000023  
516.000023  526.000023  536.000023  546.000023  556.000023  566.000023  576.000023  586.000023  596.000023  606.000023  
616.000023  626.000023  636.000023  646.000023  656.000023  666.000023  676.000023  686.000023  696.000023  706.000023  
716.000023  726.000023  736.000023  746.000023  756.000023  766.000023  776.000023  786.000023  796.000023  806.000023  
816.000023  826.000023  836.000023  846.000023  856.000023  866.000023  876.000023  886.000023  896.000023  906.000023  
916.000023  926.000023  936.000023  946.000023  956.000023  966.000023  976.000023  986.000023  996.000023  1006.000023 
1016.000023 1026.000023 1036.000023 1046.000023 1056.000023 1066.000023 1076.000023 1086.000023 1096.000023 1106.000023 

3D non-local mean result: 7 plane
117.003268  127.003268  137.003268  147.003268  157.003268  167.003268  177.003268  187.003268  197.003268  207.003268  
217.003268  227.003268  237.003268  247.003268  257.003268  267.003268  277.003268  287.003268  297.003268  307.003268  
317.003268  327.003268  337.003268  347.003268  357.003268  367.003268  377.003268  387.003268  397.003268  407.003268  
417.003268  427.003268  437.003268  447.003268  457.003268  467.003268  477.003268  487.003268  497.003268  507.003268  
517.003268  527.003268  537.003268  547.003268  557.003268  567.003268  577.003268  587.003268  597.003268  607.003268  
617.003268  627.003268  637.003268  647.003268  657.003268  667.003268  677.003268  687.003268  697.003268  707.003268  
717.003268  727.003268  737.003268  747.003268  757.003268  767.003268  777.003268  787.003268  797.003268  807.003268  
817.003268  827.003268  837.003268  847.003268  857.003268  867.003268  877.003268  887.003268  897.003268  907.003268  
917.003268  927.003268  937.003268  947.003268  957.003268  967.003268  977.003268  987.003268  997.003268  1007.003268 
1017.003268 1027.003268 1037.003268 1047.003268 1057.003268 1067.003268 1077.003268 1087.003268 1097.003268 1107.003268 

3D non-local mean result: 8 plane
118.064573  128.064690  138.064690  148.064690  158.064690  168.064690  178.064690  188.064690  198.064573  208.064573  
218.064573  228.064690  238.064690  248.064690  258.064690  268.064690  278.064690  288.064690  298.064573  308.064573  
318.064573  328.064690  338.064690  348.064690  358.064690  368.064690  378.064690  388.064690  398.064573  408.064573  
418.064573  428.064690  438.064690  448.064690  458.064690  468.064690  478.064690  488.064690  498.064573  508.064573  
518.064573  528.064690  538.064690  548.064690  558.064690  568.064690  578.064690  588.064690  598.064573  608.064573  
618.064573  628.064690  638.064690  648.064690  658.064690  668.064690  678.064690  688.064690  698.064573  708.064573  
718.064573  728.064690  738.064690  748.064690  758.064690  768.064690  778.064690  788.064690  798.064573  808.064573  
818.064573  828.064690  838.064690  848.064690  858.064690  868.064690  878.064690  888.064690  898.064573  908.064573  
918.064573  928.064690  938.064690  948.064690  958.064690  968.064690  978.064690  988.064690  998.064573  1008.064573 
1018.064573 1028.064690 1038.064690 1048.064690 1058.064690 1068.064690 1078.064690 1088.064690 1098.064573 1108.064573 

3D non-local mean result: 9 plane
119.091468  129.100533  139.100533  149.100533  159.100533  169.100533  179.100533  189.100533  199.091468  209.091468  
219.091468  229.100533  239.100533  249.100533  259.100533  269.100533  279.100533  289.100533  299.091468  309.091468  
319.091468  329.100533  339.100533  349.100533  359.100533  369.100533  379.100533  389.100533  399.091468  409.091468  
419.091468  429.100533  439.100533  449.100533  459.100533  469.100533  479.100533  489.100533  499.091468  509.091468  
519.091468  529.100533  539.100533  549.100533  559.100533  569.100533  579.100533  589.100533  599.091468  609.091468  
619.091468  629.100533  639.100533  649.100533  659.100533  669.100533  679.100533  689.100533  699.091468  709.091468  
719.091468  729.100533  739.100533  749.100533  759.100533  769.100533  779.100533  789.100533  799.091468  809.091468  
819.091468  829.100533  839.100533  849.100533  859.100533  869.100533  879.100533  889.100533  899.091468  909.091468  
919.091468  929.100533  939.100533  949.100533  959.100533  969.100533  979.100533  989.100533  999.091468  1009.091468 
1019.091468 1029.100533 1039.100533 1049.100533 1059.100533 1069.100533 1079.100533 1089.100533 1099.091468 1109.091468 

3D non-local mean result: 10 plane
119.497967  129.581108  139.581108  149.581108  159.581108  169.581108  179.581108  189.581108  199.497967  209.497966  
219.497967  229.581108  239.581108  249.581108  259.581108  269.581108  279.581108  289.581108  299.497967  309.497966  
319.497967  329.581108  339.581108  349.581108  359.581108  369.581108  379.581108  389.581108  399.497967  409.497966  
419.497967  429.581108  439.581108  449.581108  459.581108  469.581108  479.581108  489.581108  499.497967  509.497966  
519.497967  529.581108  539.581108  549.581108  559.581108  569.581108  579.581108  589.581108  599.497967  609.497966  
619.497967  629.581108  639.581108  649.581108  659.581108  669.581108  679.581108  689.581108  699.497967  709.497966  
719.497967  729.581108  739.581108  749.581108  759.581108  769.581108  779.581108  789.581108  799.497967  809.497966  
819.497967  829.581108  839.581108  849.581108  859.581108  869.581108  879.581108  889.581108  899.497967  909.497966  
919.497967  929.581108  939.581108  949.581108  959.581108  969.581108  979.581108  989.581108  999.497967  1009.497966 
1019.497967 1029.581108 1039.581108 1049.581108 1059.581108 1069.581108 1079.581108 1089.581108 1099.497967 1109.497966 

Another test case with three-dimensional elements:

%% Create test cells
testCellsSize = 10;
testElementSize = 5;

test = cell(testCellsSize, testCellsSize, testCellsSize);
for x = 1:size(test, 1)
    for y = 1:size(test, 2)
        for z = 1:size(test, 3)
            test{x, y, z} = {ones(testElementSize, testElementSize) .* (x * 100 + y * 10 + z)};
        end
    end
end


%% Specify test parameters
Sigma = 20;

%% Perform test
result = NonLocalMean3D(Sigma, test);

%% Print output

for z = 1:size(result, 3)
    fprintf('3D non-local mean result: %d plane\n' , z);
    for x = 1:size(result, 1)
        for y = 1:size(result, 2)
            fprintf('%f\t' , result{x, y, z}{1});
        end
        fprintf('\n');
    end
    fprintf('\n');
end

Test Platform Information

Matlab version: '9.10.0.1629609 (R2021a)'

Reference

  • A. Buades, B. Coll and J. -. Morel, "A non-local algorithm for image denoising," 2005 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR'05), 2005, pp. 60-65 vol. 2, doi: 10.1109/CVPR.2005.38.

All suggestions are welcome.

The summary information:

  • Which question it is a follow-up to?

    GetNeighborhood function for 3D cells structure in MATLAB

  • What changes has been made in the code since last question?

    NonLocalMean3D, NonLocalMeanWeight, NonLocalMeanSimilarity functions are implemented here.

  • Why a new review is being asked for?

    The run-time performance of the testing code above is Total time: 619.584 s on a desktop with an AMD 3950x CPU (16C / 32T) and 64GB of 3600MHz RAM. Is it a good way to use parfor like the following version NonLocalMeanSimilarity?

    function [output] = NonLocalMeanSimilarity(inputCells, location1, location2, sizeInput)
    %   NonLocalMeanSimilarity Calculate the similarity between two
    %   locations for non-local mean algorithm
        output = 0.0;
        block1 = GetNeighborhood(inputCells, sizeInput, location1);
        block2 = GetNeighborhood(inputCells, sizeInput, location2);
    
        parfor x = 1:size(block1, 1)
            for y = 1:size(block1, 2)
                for z = 1:size(block1, 3)
                    if (x == sizeInput + 1) && (y == sizeInput + 1) && (z == sizeInput + 1) % Central location
                        continue;
                    end
    
                    object1 = block1(x, y, z);
                    object2 = block2(x, y, z);
    
                    if iscell(object1{1})
                        matBlock1 = cell2mat(object1{1});
                    else
                        matBlock1 = object1{1};
                    end
    
                    if iscell(block2{1})
                        matBlock2 = cell2mat(object2{1});
                    else
                        matBlock2 = object2{1};
                    end
    
                    output = output + sum(abs(matBlock1 - matBlock2), 'all');
                end
            end
        end
    end
    

    On the other hand, is it good idea to save intermediate calculation result like the performed method above?

    If there is any possible improvement, please let me know.

May 13, 2021 Update

Another version NonLocalMean3D function with short period intermediate file updating.

function [outputCells] = NonLocalMean3D(Sigma, inputCells)
%   NonLocalMean implementation
    IntermediateFilename = "NonLocalMean.mat";
    if isfile(IntermediateFilename)
        
        load(IntermediateFilename);
        X = X + 1;
        Y = Y + 1;
        
        while X < size(inputCells, 1)
            while Y < size(inputCells, 2)
                for Z = 1:size(inputCells, 3)
                    %TargetCube = inputCells{X, Y, Z};
                    SingleOutput = {zeros([size(inputCells{X, Y, Z}, 1) size(inputCells{X, Y, Z}, 2) size(inputCells{X, Y, Z}, 3)])};
                    SumOfWeight = 0.0;
                    for x = 1:size(inputCells, 1)
                        for y = 1:size(inputCells, 2)
                            for z = 1:size(inputCells, 3)
                                weight = NonLocalMeanWeight(Sigma, inputCells, ...
                                    [X Y Z], ...
                                    [x y z]);
                                
                                SingleOutput = {cell2mat(SingleOutput) + cell2mat(inputCells{x, y, z}) .* weight};
                                SumOfWeight = SumOfWeight + weight;
                            end
                        end
                    end
                    SingleOutput = {cell2mat(SingleOutput) ./ SumOfWeight};
                    outputCells{X, Y, Z} = SingleOutput;
                    
                    fprintf('3D non-local mean: The %d_%d_%d / %d_%d_%d block calculation has done. \n' , X, Y, Z, size(inputCells, 1), size(inputCells, 2), size(inputCells, 3));
                end
                save("NonLocalMean.mat", '-v7.3');
                Y = Y + 1;
            end
            Y = 1;
            X = X + 1;
        end
        
        return;
    else
        outputCells = inputCells;
    
        for X = 1:size(inputCells, 1)
            for Y = 1:size(inputCells, 2)
                for Z = 1:size(inputCells, 3)
                    %TargetCube = inputCells{X, Y, Z};
                    SingleOutput = {zeros([size(inputCells{X, Y, Z}, 1) size(inputCells{X, Y, Z}, 2) size(inputCells{X, Y, Z}, 3)])};
                    SumOfWeight = 0.0;
                    for x = 1:size(inputCells, 1)
                        for y = 1:size(inputCells, 2)
                            for z = 1:size(inputCells, 3)
                                weight = NonLocalMeanWeight(Sigma, inputCells, ...
                                    [X Y Z], ...
                                    [x y z]);
                                
                                SingleOutput = {cell2mat(SingleOutput) + cell2mat(inputCells{x, y, z}) .* weight};
                                SumOfWeight = SumOfWeight + weight;
                            end
                        end
                    end
                    SingleOutput = {cell2mat(SingleOutput) ./ SumOfWeight};
                    outputCells{X, Y, Z} = SingleOutput;
                    
                    fprintf('3D non-local mean: The %d_%d_%d / %d_%d_%d block calculation has done. \n' , X, Y, Z, size(inputCells, 1), size(inputCells, 2), size(inputCells, 3));
                end
                save("NonLocalMean.mat", '-v7.3');
            end
        end
        return;
    end
end
```
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.