No BSD License  

Highlights from
GeoML

image thumbnail
from GeoML by Gabriele Lombardi
A general morphable template tool for image segmentation.

GeoMLParseModel(modelname)
function [model,free,freestruct] = GeoMLParseModel(modelname)
% GEOMLPARSEMODEL  Parsing of a GeoML XML model description.
%
% function [model,free] = GeoMLParseModel(modelname)
%
%  This function parse a GeoML XML model descriptin file starting from its
% name, the model file must be in the current directory and the GeoML jar
% file must be loaded, its dependencies must be loaded too.
%
%  Params
%  ------
% IN:
%  modelname    = The model name without extension.
% OUT:
%  model        = The GeoML model as a Java class.
%  free         = The free parameters.
%  freestruct   = A struct containing the free variables by name (multiple
%                 equal names gives errors).
%
%  Pre
%  ---
% -  The model file must be in the current directory, with the correct
%   filename and readable from the user.
% -  The DTD file must be in the current directory if accessed with SYSTEM
%   or accessible via Web if accessed with PUBLIC.
% -  The model file must be a valid GeoML file.
% 
%  Post
%  ----
% -  A Java com.dsi.libs.geoml.Group class containing the model is
%   returned.

% Checking the number of parameters:
if nargin<1 || ~isa(modelname,'char')
    error('A valid model file name must be provided!');
end

% Importing the Java classes:
import com.dsi.libs.geoml.matlab.GeoMLMatlabUtils;

% Obtaining the model:
o = GeoMLMatlabUtils.parseFile([pwd filesep modelname '.xml']);
model = o(1);
free = o(2);

% Converting the free variables in a struct:
if nargout>2
    % Preparing the struct:
    freestruct = struct;
    % Iterating on variables:
    for ind=1:numel(free)
        % Adding a variable:
        freestruct = setfield(freestruct,char(free(ind).getName),free(ind));
    end
end

Contact us at files@mathworks.com