[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libcvd-members] libcvd/cvd image_convert.h
From: |
Edward Rosten |
Subject: |
[libcvd-members] libcvd/cvd image_convert.h |
Date: |
Wed, 28 Mar 2007 21:40:15 +0000 |
CVSROOT: /cvsroot/libcvd
Module name: libcvd
Changes by: Edward Rosten <edrosten> 07/03/28 21:40:15
Modified files:
cvd : image_convert.h
Log message:
Lazy image_convert function. Can now do:
Image<byte> a;
Image<byte> b;
...
b = convert_image(a);
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/image_convert.h?cvsroot=libcvd&r1=1.10&r2=1.11
Patches:
Index: image_convert.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/image_convert.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- image_convert.h 15 May 2006 15:58:59 -0000 1.10
+++ image_convert.h 28 Mar 2007 21:40:15 -0000 1.11
@@ -80,7 +80,6 @@
/// @param Conv The conversion to use
/// @param from The image to convert from
/// @ingroup gImageIO
-
template<class D, class Conv, class C> Image<D> convert_image(const
BasicImage<C>& from)
{
Image<D> to(from.size());
@@ -100,7 +99,6 @@
/// @param C The source image pixel type
/// @param from The image to convert from
/// @ingroup gImageIO
-
template<class D, class C> Image<D> convert_image(const BasicImage<C>& from)
{
Image<D> to(from.size());
@@ -117,7 +115,6 @@
/// @param C The source image pixel type
/// @param from The image to convert from
/// @ingroup gImageIO
-
template<class D1, class D2, class C> std::pair<Image<D1>, Image<D2> >
convert_image_pair(const BasicImage<C>& from)
{
std::pair<Image<D1>, Image<D2> > to(Image<D1>(from.size()),
Image<D2>(from.size()));
@@ -126,6 +123,48 @@
return to;
}
+
+ #ifndef DOXYGEN_IGNORE_INTERNAL
+ namespace Internal
+ {
+ template<class C> class ImageConverter{};
+ template<class C> struct ImagePromise<ImageConverter<C> >
+ {
+ ImagePromise(const BasicImage<C>& im)
+ :i(im)
+ {}
+
+ const BasicImage<C>& i;
+ template<class D> void execute(Image<D>& j)
+ {
+ j.resize(i.size());
+ convert_image(i, j);
+ }
+ };
+ };
+ template<class C> Internal::ImagePromise<Internal::ImageConverter<C> >
convert_image(const BasicImage<C>& c)
+ {
+ return Internal::ImagePromise<Internal::ImageConverter<C> >(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<byte> a;
+ /// Image<byte> 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<class D> Image<D> convert_image(const BasicImage<C>& from);
+
+ #endif
}
#endif
- [libcvd-members] libcvd/cvd image_convert.h,
Edward Rosten <=