Here is a link to a plug-in for David Tschumperlé’s CImg library that adds methods to read and write Matlab arrays from CImg. The interface consists of

 

It constructs a CImg<T> object from a Matlab mxArray. The

Matlab array “u” must be at most 4-dimensional. The Boolean

argumentvdata” is used in the case where the input array has

dimension 3, say M x N x K. If vdata is true, the constructed

CImg object will have dimensions N x M x 1 x K, otherwise

it will have dimensions N x M x K x 1.

  Assigns a Matlab mxArray to a CImg<T> object. Works as

  The constructor above, but without the vdata.

  It exports a CImg<T> object to a Matlab array. The exported

  type is controlled by “id” that must be a valid Matlab numerical

  class identifier, by default floating point double precision, while

  the boolean variable “squeeze” is used in case the CImg<T>

  object has dimensions M x N x 1 x K. If squeeze is true,

  the created Matlab array has dimension N x M x K. 

 

I provide also a sample Visual Studio 2005 solution that uses the plug-in to add a blur function, using the CImg get_blur method. You will need to modify the paths for additional include and additional libraries to match you local Matlab installation in order to compile it.

 

About Licensing: the plug-in is copyright of myself and the IT University of Copenhagen and is under the GNU General Public License or any license compatible with the CeCILL license used by CImg. To say: this is a very small piece of code, that can nevertheless be very useful, I believe, and you are free to use it the way you want as long this is an ethical way.

 

Note that this is a new and slightly modified version of the previous plug-in “cimgmatlabplugin.h”, now called “cimgmatlab.h”, which works with relatively recent versions of CImg (due to the presence of the const member “shared” in the CImg class, thanks to Nicholas Dowson for pointing the problem to me).