I am facing some trouble when I try to convert from a dip::Image object to a vigra::MultiArrayView. The way vice versa works fine, but when I try to call dip_Vigra::DipToVigra I am getting:
error: no matching function for call to ‘DipToVigra(dip::Image&)
How should I do this conversion?
As said, the way vice versa works fine with dip_vigra::VigraToDip()
vigra::FImage Img;
Img.resize(width, height);
vigra::MultiArrayView<2, float> VigraView = Img;
dip::Image DIPimage;
DIPimage = dip_vigra::VigraToDip(VigraView); // works fine
VigraView = dip_vigra::DipToVigra(DIPimage); // fails
I am working on opensuse using code::blocks as IDE.
CodePudding user response:
Because dip::Image has properties (dimensionality and pixel type) defined at runtime, and vigra::MultiArrayView has properties defined at compile time through template parameters, the templated function dip_vigra::DipToVigra() needs explicit template parameters for the compiler to know what the output type is.
That is, the compiler can automatically determine template parameters for dip_vigra::VigraToDip(), but not for dip_vigra::DipToVigra().
So you need to explicitly mention these parameters:
VigraView = dip_vigra::DipToVigra<2, float>(DIPimage);
Note that, at runtime, the function will check that the properties of DIPimage match the given template parameters, and error out if they don't.
The repository has an example C program that shows how to convert images between DIPlib and Vigra: https://github.com/DIPlib/diplib/blob/master/examples/external_interfaces/vigra_with_dip.cpp
