function output = stitch_all( image_list )

set = zeros(size(image_list,1),1);
posy = zeros(size(image_list,1),1);
posx = zeros(size(image_list,1),1);

set(1) = 1;
posy(1) = 0;
posx(1) = 0;

done = false;

% Try every possibility of mapping.
while ~done
    done = true;
    for i=1:size(image_list)
        if ( set(i) == 1 )
            % Already in the working set.
            continue;
        end
        % Load in unmatched image.
        image2 = double(imread(image_list(i,:))) / 255;
        bestPos = [0 0];
        bestScore = 0;
        id = 0;
        
        % Check to all matched images.
        for j=1:size(image_list)
            if ( set(j) == 0 )
                continue;
            end
            image1 = double(imread(image_list(j,:))) / 255;
            
            % Stitch and store score.
            [npos score] = stitch(image1, image2);
            if ( score > bestScore )
                bestScore = score;
                bestPos = npos;
                id = j;
            end
        end
        
        % Set as best position for this image.
        set(i) = 1;
        posy(i) = bestPos(1) + posy(id);
        posx(i) = bestPos(2) + posx(id);
    end
    
    if ( sum(set) == 0 )
        done = true;
    end
end

% Stitch them all together on a joint canvas.
output = multi_canvas(image_list, posy, posx);

end

