dip_matlab_interface.h file

This file should be included in each MEX-file. It defines the dml namespace.

Contents

Namespaces

namespace dml
The dml namespace contains the interface between MATLAB and DIPlib.

Classes

class dml::MatlabInterface
This class is the dip::ExternalInterface for the MATLAB interface.
class dml::streambuf
An output stream buffer for MEX-files.

Enums

enum class dml::GetImageMode: dip::uint8{ REFERENCE, SHARED_COPY }
dml::GetImage can optionally create a shared copy of the input mxArray, which extends its lifetime. This is useful if the MEX-file needs to keep a reference to the object.
enum class dml::ArrayConversionMode: dip::uint8{ STANDARD, TENSOR_OPERATOR }
dml::GetImage can optionally turn an input numeric array to a tensor image. If the numeric array is a short vector (up to 5 elements) or a small matrix (up to 5x5 elements) it will be seen as a 0D tensor image.

Functions

auto dml::IsScalar(mxArray const* mx) -> bool
True if array is scalar (has single value)
auto dml::IsVector(mxArray const* mx) -> bool
True if empty or a one-dimensional array
auto dml::IsString(mxArray const* mx) -> bool
True if mx is a string (char vector or string class)
auto dml::GetUnsigned(mxArray const* mx) -> dip::uint
Convert an unsigned integer from mxArray to dip::uint by copy.
auto dml::GetInteger(mxArray const* mx) -> dip::sint
Convert a signed integer from mxArray to dip::sint by copy.
auto dml::GetFloat(mxArray const* mx) -> dip::dfloat
Convert a floating-point number from mxArray to dip::dfloat by copy.
auto dml::GetComplex(mxArray const* mx) -> dip::dcomplex
Convert a complex floating-point number from mxArray to dip::dcomplex by copy.
auto dml::GetBooleanArray(mxArray const* mx) -> dip::BooleanArray
Convert a boolean (logical) array from mxArray to dip::BooleanArray by copy.
auto dml::GetUnsignedArray(mxArray const* mx) -> dip::UnsignedArray
Convert an unsigned integer array from mxArray to dip::UnsignedArray by copy.
auto dml::GetIntegerArray(mxArray const* mx) -> dip::IntegerArray
Convert a signed integer array from mxArray to dip::IntegerArray by copy.
auto dml::GetFloatArray(mxArray const* mx) -> dip::FloatArray
Convert a floating-point array from mxArray to dip::FloatArray by copy.
auto dml::GetStdVectorOfFloats(mxArray const* mx) -> std::vector<dip::dfloat>
Convert a floating-point array for mxArray to std::vector<dip::dfloat> by copy.
auto dml::GetProcessArray(mxArray const* mx, dip::uint nDims) -> dip::BooleanArray
Convert an unsigned integer mxArray to a dip::BooleanArray, where elements of the input are indices where the output array is set. The output array has nDims elements. In MATLAB, dimensions start with 1. If mx is empty, all dimensions are to be processed.
auto dml::GetCoordinateArray(mxArray const* mx) -> dip::CoordinateArray
Convert a coordinates array from mxArray to dip::CoordinateArray by copy.
auto dml::GetFloatCoordinateArray(mxArray const* mx) -> dip::FloatCoordinateArray
Convert a coordinates array from mxArray to dip::FloatCoordinateArray by copy.
auto dml::HandleNewStyleString(mxArray const* mx) -> mxArray const*
If mx is a “string” class object, return a char vector or a cell array of char vectors.
auto dml::GetString(mxArray const* mx) -> dip::String
Convert a string from mxArray to dip::String by copy.
auto dml::GetStringUnicode(mxArray const* mx) -> dip::String
Convert a string from mxArray to a UTF-8 encoded dip::String by copy.
auto dml::GetStringArray(mxArray const* mx) -> dip::StringArray
Convert a cell array of strings from mxArray to dip::StringArray by copy.
auto dml::GetStringSet(mxArray const* mx) -> dip::StringSet
Convert a cell array of string from mxArray to dip::StringSet by copy.
auto dml::GetBoolean(mxArray const* mx) -> bool
Convert a boolean (logical) from mxArray to bool by copy. Accepts "yes" and "no" as well.
auto dml::GetRange(mxArray const* mx) -> dip::Range
Convert an integer array from mxArray to dip::Range by copy.
auto dml::GetRangeArray(mxArray const* mx) -> dip::RangeArray
Convert a cell array of integer array from mxArray to dip::RangeArray by copy.
auto dml::GetPixel(mxArray const* mx) -> dip::Image::Pixel
Convert a numeric array from mxArray to dip::Image::Pixel by copy.
auto dml::GetHistogramConfiguration(mxArray const* mx) -> dip::Histogram::Configuration
Reads a histogram Configuration struct from a cell mxArray with key-value pairs.
auto dml::CreateDouble2Vector(dip::dfloat v0, dip::dfloat v1) -> mxArray*
Create a two-element mxArray and write the two values in it.
auto dml::GetArray(bool in) -> mxArray*
Convert an boolean from bool to mxArray by copy.
auto dml::GetArray(dip::uint in) -> mxArray*
Convert an unsigned integer from dip::uint to mxArray by copy.
auto dml::GetArray(dip::sint in) -> mxArray*
Convert a signed integer from dip::sint to mxArray by copy.
auto dml::GetArray(dip::dfloat in) -> mxArray*
Convert a floating-point number from dip::dfloat to mxArray by copy.
auto dml::GetArray(dip::dcomplex in) -> mxArray*
Convert a complex floating-point number from dip::dcomplex to mxArray by copy.
template<typename T, typename <SFINAE>>
auto dml::GetArray(dip::DimensionArray const& in) -> mxArray*
Convert a numeric array from dip::DimensionArray to mxArray by copy. Works for dip::UnsignedArray, dip::IntegerArray and dip::FloatArray.
auto dml::GetArray(dip::CoordinateArray const& in) -> mxArray*
Convert a coordinates array from mxArray to dip::CoordinateArray by copy.
auto dml::GetArray(dip::String const& in) -> mxArray*
Convert a string from dip::String to mxArray by copy.
auto dml::GetArray(dip::StringArray const& in) -> mxArray*
Convert a string array from dip::StringArray to mxArray by copy.
auto dml::GetArrayUnicode(dip::String const& in) -> mxArray*
Convert a UTF-8 encoded string from dip::String to mxArray by copy.
auto dml::GetArray(dip::Image::Sample const& in) -> mxArray*
Convert a sample from dip::Image::Sample to mxArray by copy.
auto dml::GetArray(dip::Image::Pixel const& in) -> mxArray*
Convert a set of samples from dip::Image::Pixel to mxArray by copy.
auto dml::GetArray(dip::PixelSize const& pixelSize) -> mxArray*
Convert a pixel size object dip::PixelSize to mxArray by copy.
auto dml::GetArray(dip::FileInformation const& fileInformation) -> mxArray*
Convert a dip::FileInformation structure to mxArray by copy.
auto dml::GetArray(dip::Distribution const& in) -> mxArray*
Convert a dip::Distribution object to mxArray by copy.
auto dml::GetImage(mxArray const* mx, dml::GetImageMode mode = GetImageMode::REFERENCE, dml::ArrayConversionMode conversion = ArrayConversionMode::STANDARD) -> dip::Image
Passing an mxArray to DIPlib, keeping ownership of the data.
auto dml::GetImageArray(mxArray const* mx) -> dip::ImageArray
Convert a cell array of images from mxArray to dip::ImageArray, using dml::GetImage for each element of the cell array.
auto dml::GetArrayAsArray(dip::Image const& img, bool doNotSetToTrue = false) -> mxArray*
Find the mxArray that holds the data for the dip::Image img.
auto dml::GetArray(dip::Image const& img, bool doNotSetToTrue = false) -> mxArray*
Find the mxArray that holds the data for the dip::Image img, and create a MATLAB dip_image object around it.
template<typename K>
auto dml::GetKernel(int nrhs, mxArray const*[] prhs, int& index, dip::uint nDims) -> K
Gets a structuring element or kernel from the input argument(s) at index, and index+1. index is updated to point to the next unused input argument.
template<typename T>
auto dml::GetPreference(dip::String const& preference) -> T
Get the value of a property, equivalent to calling dipgetpref in MATLAB.

Macros

#define DML_MIN_ARGS
Tests to ensure the MEX-file has been called with sufficient inputs.
#define DML_MAX_ARGS
Tests to ensure the MEX-file has not been called with too many inputs.
#define DML_CATCH
Catch exceptions thrown in a MEX-file.