diff --git a/cvd/image_convert.h b/cvd/image_convert.h index 6c580c64..2bcf772f 100644 --- a/cvd/image_convert.h +++ b/cvd/image_convert.h @@ -80,7 +80,6 @@ namespace CVD /// @param Conv The conversion to use /// @param from The image to convert from /// @ingroup gImageIO - template Image convert_image(const BasicImage& from) { Image to(from.size()); @@ -100,7 +99,6 @@ namespace CVD /// @param C The source image pixel type /// @param from The image to convert from /// @ingroup gImageIO - template Image convert_image(const BasicImage& from) { Image to(from.size()); @@ -117,7 +115,6 @@ namespace CVD /// @param C The source image pixel type /// @param from The image to convert from /// @ingroup gImageIO - template std::pair, Image > convert_image_pair(const BasicImage& from) { std::pair, Image > to(Image(from.size()), Image(from.size())); @@ -125,7 +122,49 @@ namespace CVD convert_image(from, to.second); return to; } - + + + #ifndef DOXYGEN_IGNORE_INTERNAL + namespace Internal + { + template class ImageConverter{}; + template struct ImagePromise > + { + ImagePromise(const BasicImage& im) + :i(im) + {} + + const BasicImage& i; + template void execute(Image& j) + { + j.resize(i.size()); + convert_image(i, j); + } + }; + }; + template Internal::ImagePromise > convert_image(const BasicImage& c) + { + return Internal::ImagePromise >(c); + } + #else + ///Convert an image from one type to another using the default. + ///Type deduction is automatic, and D does not need to be specified. The following usage will work: + /// + /// \code + /// Image a; + /// Image b; + /// ... + /// b = convert_image(a); + /// \endcode + /// Note that this is performed using lazy evaluation, so convertion happens on evaluation of assignment. + /// @param D The destination image pixel type + /// @param C The source image pixel type + /// @param from The image to convert from + /// @return The converted image + /// @ingroup gImageIO + template Image convert_image(const BasicImage& from); + + #endif } #endif