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: imPrincipalAxes.m
    path of file: ./repos/matImage/matImage/imQuantify
    
    the code of the file until where you have to start completion: function [center, rotMat] = imPrincipalAxes(img, varargin)
% Computes principal axes of a 2D/3D binary image.
%
%   [CENTER, ROTMAT] = imPrincipalAxes(IMG)
%
%   (Note: currently only implemented for binary images)
%
%   Example
%     % Compute principal axes of a discretized 3D ellipsoid
%     % (requires the MatGeom toolbox)
%     elli = [50.12 50.23 50.34  30 20 10   30 20 10];
%     img = discreteEllipsoid(1:100, 1:100, 1:100, elli);
%     [center, rotMat] = imPrincipalAxes(img);
%     center
%     center =
%        51.1209   51.2245   51.3454
%     rotation3dToEulerAngles(rotMat)
%     ans =
%        30.0107   19.9733   10.0252
%
%
%   See also
%     imEquivalentEllipse, imEquivalentEllipsoid, imMoment, principalAxes

    
function [center, rotMat] = imPrincipalAxes(img, varargin)
% Computes principal axes of a 2D/3D binary image.
%
%   [CENTER, ROTMAT] = imPrincipalAxes(IMG)
%
%   (Note: currently only implemented for binary images)
%
%   Example
%     % Compute principal axes of a discretized 3D ellipsoid
%     % (requires the MatGeom toolbox)
%     elli = [50.12 50.23 50.34  30 20 10   30 20 10];
%     img = discreteEllipsoid(1:100, 1:100, 1:100, elli);
%     [center, rotMat] = imPrincipalAxes(img);
%     center
%     center =
%        51.1209   51.2245   51.3454
%     rotation3dToEulerAngles(rotMat)
%     ans =
%        30.0107   19.9733   10.0252
%
%
%   See also
%     imEquivalentEllipse, imEquivalentEllipsoid, imMoment, principalAxes
%

% ------
% Author: David Legland
% e-mail: david.legland@inrae.fr
% Created: 2019-08-09,    using Matlab 9.6.0.1072779 (R2019a)
% Copyright 2019 INRAE - Cepia Software Platform.

%% Default parameters

spacing = [1 1 1];
origin = [1 1 1];


%% Parse inputs

dim = size(img);

% check image data type
binary = islogical(img);
if ~binary
    error('Requires a binary image as input');
end