You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: Function_correct_DPSD_identification.m
    path of file: ./repos/MATBOX_Microstructure_analysis_toolbox/src/Microstructure_characterization
    
    the code of the file until where you have to start completion: function [Label_lake] = Function_correct_DPSD_identification(binary_phase, Label_lake, cpsd_refining, details_convergence, chess_pattern_removal, P1, P2, P3, visualize_2D)

% ITERATIVE PROCESS - NON SPECIFIC TO THE WATERSHED-IMMERSION METHOD

% If chess_pattern_removal true
% STEP 1a: remove chess pattern usually induced by the method
% STEP 1b: remove the remaining chess pattern not replaced in step 1

% Commom for both chess_pattern_removal true or false
% STEP 1c: search for non-continguous discrete particle and correct them
% STEP 2: treat 1 voxel size particle
% STEP 3: calculate D-PSD size
% STEP 4: calculate C-PSD size from another algorithm (will be done only for the first iteration)
% STEP 5: treat voxel whom D-PSD size < C-PSD size

% Initialize iteration
iteration_=0;
number_change=1e9;

% Domain size of the microstructure
Domain_size=size(binary_phase);
[~,number_of_
    
function for detetecting and labeling non continguous particle/cluster
    % L = bwlabeln(BW,6)
    % L is containing labels for the connected components in BW
    % L is the same size as BW
    % The elements of L are integer values greater than or equal to 0.
    % The pixels labeled 0 are the background. The pixels labeled 1 make up one connected cluster. The pixels labeled 2 make up a second connected cluster, and so on
    
    % Get all unique id particle
    unique_particle = unique(Label_lake);
    unique_particle(1)=[]; % Remove id 0 (complementary phase)
    % Get number of different id
    number_id = length(unique_particle);
    % Loop over id
    for current_=1:1:number_id
        % Get id
        current_id = unique_particle(current_);
        % Create binary matrix for this particle id
        binary_particle = zeros(Domain_size(1),Domain_size(2),Domain_size(3));
        binary_particle(Label_lake==current_id)=1;
        % Label particle
        L_particle = bwlabeln(binary_particle,6);
        % Unique label
        unique_cluster = unique(L_particle);
        unique_cluster(1)=[]; % remobe background cluster id
        % Number of distinct cluster
        cluster_number=length(unique_cluster);
        % Treat the case where there are more than 1 cluster
        if cluster_number>1
            % The largest cluster will be unchanged
            % All the other cluster will be treated as follow:
            % Case a) If they are surrounded by ONLY voxels of the complementary phase, then this cluster is considered as a new particle
            % Case b) otherwise, voxels of this cluster will be attributed to the particle id of the nearest voxel that belong to the phase and
            % that does not belong to this particular cluster
            cluster_size=zeros(cluster_number,2);
            % Column: cluster id, size
            for current_cluster=1:1:cluster_number
                cluster_id = unique_cluster(current_cluster);
                cluster_size(current_cluster,1)=cluster_id;
                cluster_size(current_cluster,2)=sum(sum(sum(L_particle==cluster_id)));
            end