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: cumulative_histogram_mapping.m
    path of file: ./repos/Image-Harmonization-Dataset-iHarmony4/color_transfer_methods/cumulative_histogram_mapping
    
    the code of the file until where you have to start completion: function [new_im_dst, chist_dst, chist_ref, map, M] = cumulative_histogram_mapping(im_dst, im_ref, edges)

% image color correction using cumulatie histogram mapping
% 
%  Inputs:

    
function [new_im_dst, chist_dst, chist_ref, map, M] = cumulative_histogram_mapping(im_dst, im_ref, edges)

% image color correction using cumulatie histogram mapping
% 
%  Inputs:
%      im_dst, im_ref, new_im_dst - Nx3 matrix (for color image) or Nx1 vector (for
%      gray-scale image)
%
% Wei Xu
% August 2009
% Modified in Oct. 2009

[N,d] = size(im_ref);
   
for i=1:d
    cens{i} = (edges{i}(1:end