Index: ChangeLog
from Simon Odou <simon(a)lrde.epita.fr>
* tests/core/tests/image3d: New.
* oln/fancy/print.hh: Add print for image3d.
* oln/fancy/iota.hh: Add iota for image3d.
* oln/core/2d/image2d.hh: Fix a 80 columns line.
* oln/core/3d/array3d.hh: Fix a missing variable.
* oln/core/3d/image3d.hh: New.
* oln/core/3d/point3d.hh: Fix a missing "rhs".
* oln/basics3d.hh: Add image3d include.
oln/basics3d.hh | 1
oln/core/2d/image2d.hh | 3 -
oln/core/3d/array3d.hh | 4 -
oln/core/3d/image3d.hh | 102 +++++++++++++++++++++++++++++++++++++++++++++++
oln/core/3d/point3d.hh | 2
oln/fancy/iota.hh | 16 ++++++-
oln/fancy/print.hh | 28 +++++++++++-
tests/core/tests/image3d | 40 ++++++++++++++++++
8 files changed, 187 insertions(+), 9 deletions(-)
Index: tests/core/tests/image3d
--- tests/core/tests/image3d (revision 0)
+++ tests/core/tests/image3d (revision 0)
@@ -0,0 +1,40 @@
+
+#include <iostream>
+
+#include <ntg/real/int_u8.hh>
+#include <oln/basics3d.hh>
+
+#include <oln/fancy/iota.hh>
+#include <oln/fancy/print.hh>
+
+#include "check.hh"
+#include "data.hh"
+
+
+
+template <typename I>
+void foo(oln::abstract::image<I>& input, const oln_point_type(I)& p)
+{
+ // FIXME: dummy code below
+// struct dummy {};
+// oln_typeof(I,value) tmp = (dummy*)0;
+ input[p] = 7;
+}
+
+
+bool check()
+{
+ oln::point3d p(0,0,0);
+
+ typedef oln::image3d<ntg::int_u8> image_type;
+ image_type ima(3, 3, 3);
+ oln::fancy::iota(ima);
+ oln::fancy::println(ima);
+
+ image_type ima2;
+ ima2 = ima;
+
+ foo(ima, p);
+ oln::fancy::println(ima2);
+ return false;
+}
Index: oln/fancy/print.hh
--- oln/fancy/print.hh (revision 13)
+++ oln/fancy/print.hh (working copy)
@@ -10,6 +10,7 @@
# include <oln/core/1d/image1d.hh>
# include <oln/core/2d/image2d.hh>
+# include <oln/core/3d/image3d.hh>
namespace oln {
@@ -25,6 +26,8 @@
void print(const image1d<T>& input, std::ostream& ostr);
template <typename T>
void print(const image2d<T>& input, std::ostream& ostr);
+ template <typename T>
+ void print(const image3d<T>& input, std::ostream& ostr);
// FIXME: it should be abstract::image2d<I>...
} // end of namespace impl
@@ -71,6 +74,17 @@
}
template <typename T>
+ void print(const image1d<T>& input, std::ostream& ostr)
+ {
+ // FIXME: lacks cleaning
+ for (coord_t index = 0; index < input.size().nindices(); ++index)
+ {
+ ostr << internal::pp<T>(input[point1d(index)]) << ' ';
+ }
+ ostr << std::endl;
+ }
+
+ template <typename T>
void print(const image2d<T>& input, std::ostream& ostr)
{
// FIXME: lacks cleaning
@@ -83,15 +97,21 @@
}
template <typename T>
- void print(const image1d<T>& input, std::ostream& ostr)
+ void print(const image3d<T>& input, std::ostream& ostr)
{
// FIXME: lacks cleaning
- for (coord_t index = 0; index < input.size().nindices(); ++index)
+ for (coord_t slice = 0; slice < input.size().nslices(); ++slice)
+ {
+ for (coord_t row = 0; row < input.size().nrows(); ++row)
{
- ostr << internal::pp<T>(input[point1d(index)]) << ' ';
+ for (coord_t col = 0; col < input.size().ncols(); ++col)
+ ostr << internal::pp<T>(input[point3d(slice,row,col)]) << '
';
+ ostr << ", ";
}
- ostr << std::endl;
+ ostr << std::endl;
+ }
}
+
} // end of namespace impl
Index: oln/fancy/iota.hh
--- oln/fancy/iota.hh (revision 13)
+++ oln/fancy/iota.hh (working copy)
@@ -1,8 +1,9 @@
#ifndef OLENA_FANCY_IOTA_HH
# define OLENA_FANCY_IOTA_HH
+# include <oln/core/1d/image1d.hh>
# include <oln/core/2d/image2d.hh>
-# include <oln/core/1d/image1d.hh>
+# include <oln/core/3d/image3d.hh>
namespace oln {
@@ -14,6 +15,8 @@
void iota(image1d<T>& inout); // FIXME: abstract::image1d<I>...
template <typename T>
void iota(image2d<T>& inout); // FIXME: abstract::image2d<I>...
+ template <typename T>
+ void iota(image3d<T>& inout); // FIXME: abstract::image2d<I>...
} // end of namespace impl
@@ -54,6 +57,17 @@
inout[point1d(index)] = ++counter;
}
+ template <typename T>
+ void iota(image3d<T>& inout)
+ {
+ unsigned counter = 0;
+ // FIXME: lacks cleaning
+ for (coord_t slice = 0; slice < inout.size().nslices(); ++slice)
+ for (coord_t row = 0; row < inout.size().nrows(); ++row)
+ for (coord_t col = 0; col < inout.size().ncols(); ++col)
+ inout[point3d(slice,row,col)] = ++counter;
+ }
+
} // end of namespace impl
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 13)
+++ oln/core/2d/image2d.hh (working copy)
@@ -16,7 +16,8 @@
template <typename T> class image2d;
// category decl
- template <typename T> struct category_type< image2d<T> > { typedef
cat::image ret; };
+ template <typename T>
+ struct category_type< image2d<T> > { typedef cat::image ret; };
/*! \class props< abstract::image, image2d<T> >
Index: oln/core/3d/array3d.hh
--- oln/core/3d/array3d.hh (revision 13)
+++ oln/core/3d/array3d.hh (working copy)
@@ -114,7 +114,7 @@
for (size_t slice = 0; slice < nslices_eff; ++slice)
{
T** a2 = array2_ + slice * nrows_eff;
- array[slice] = a2 + size_.border();
+ array_[slice] = a2 + size_.border();
for (size_t row = 0; row < nrows_eff; ++row)
{
a2[row] = buf;
@@ -179,8 +179,8 @@
private:
T* buffer_;
+ T*** array_;
T** array2_;
- T*** array_;
size3d size_;
void invariant_() const
Index: oln/core/3d/image3d.hh
--- oln/core/3d/image3d.hh (revision 0)
+++ oln/core/3d/image3d.hh (revision 0)
@@ -0,0 +1,102 @@
+#ifndef OLENA_CORE_IMAGE3D_HH
+# define OLENA_CORE_IMAGE3D_HH
+
+# include <mlc/traits.hh>
+
+# include <oln/core/abstract/image_with_data.hh>
+# include <oln/core/3d/array3d.hh>
+
+/*! \namespace oln
+** \brief oln namespace.
+*/
+namespace oln {
+
+
+ // fwd decl
+ template <typename T> class image3d;
+
+ // category decl
+ template <typename T>
+ struct category_type< image3d<T> > { typedef cat::image ret; };
+
+
+ /*! \class props< abstract::image, image3d<T> >
+ **
+ ** Properties of common 3D images. Specialization of props<abstraction,type>.
+ ** Parameter T is the type of pixel values.
+ **
+ ** \see image3d<T>, props<category,type>
+ */
+
+ template <typename T>
+ struct props < cat::image, image3d<T> > : public default_props <
cat::image >
+ {
+ typedef mlc::no_type delegated_type;
+
+ typedef size3d size_type;
+ typedef point3d point_type;
+ typedef T value_type;
+
+ // please note that value_storage_type means data_type
+ // since image3d is an image_with_data
+ typedef mlc_encoding_type(T) value_storage_type;
+
+ // please note that value_container_type means
+ // data_container_type (or value_storage_container_type)
+ // FIXME: find a better name...
+ typedef array3d<value_storage_type> value_container_type;
+
+ // tags
+ typedef tag::readwrite constness_tag;
+
+ // functions
+
+ template <typename U>
+ struct ch_value_type
+ {
+ typedef image3d<U> ret;
+ };
+
+ };
+
+
+
+ /*! \class image3d<T>
+ **
+ ** Common class for 3D images. Pixels values are stored in memory.
+ ** FIXME: give details about other properties (border, etc.)
+ **
+ ** Parameter T is the type of pixel values.
+ */
+
+ template <typename T>
+ class image3d : public abstract::image_with_data< image3d<T> >
+ {
+ public:
+
+ typedef abstract::image_with_data< image3d<T> > super_type;
+
+ image3d()
+ {
+ this->exact_ptr = this;
+ }
+
+ image3d(coord_t nslices, coord_t nrows, coord_t ncols) :
+ super_type(size3d(nslices, nrows, ncols))
+ {
+ this->exact_ptr = this;
+ }
+
+ image3d(image3d& rhs) :
+ super_type(rhs)
+ {
+ this->exact_ptr = this;
+ }
+
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_IMAGE3D_HH
Index: oln/core/3d/point3d.hh
--- oln/core/3d/point3d.hh (revision 13)
+++ oln/core/3d/point3d.hh (working copy)
@@ -25,7 +25,7 @@
}
point3d(const point3d& rhs) :
- slice_(slice_),
+ slice_(rhs.slice_),
row_(rhs.row_),
col_(rhs.col_)
{
Index: oln/basics3d.hh
--- oln/basics3d.hh (revision 13)
+++ oln/basics3d.hh (working copy)
@@ -6,5 +6,6 @@
# include <oln/core/3d/size3d.hh>
# include <oln/core/3d/point3d.hh>
+# include <oln/core/3d/image3d.hh>
#endif // ! OLENA_BASICS3D_HH