* lazzara/igr/igr-biggest-comp.cc: new. Variant of igr.cc which
extract the biggest component before registrating.
* lazzara/irm/wst_rag.cc,
* lazzara/irm_seg_with_mm_and_rag.mine.cc,
* lazzara/igr-cloud.cc,
* lazzara/igr.cc,
* lazzara/irm/hsl_grad_and_wst.cc,
* lazzara/irm/irm_seg_with_mm_and_rag.cc,
* lazzara/irm/wst_rag_hsl.cc: Move to...
* lazzara/igr/irm/wst_rag.cc,
* lazzara/igr/irm_seg_with_mm_and_rag.mine.cc,
* lazzara/igr/igr-cloud.cc,
* lazzara/igr/igr.cc,
* lazzara/igr/irm/hsl_grad_and_wst.cc,
* lazzara/igr/irm/irm_seg_with,
* lazzara/igr/irm/wst_rag_hsl.cc: ... here.
* lazzara/igr/registration_3d.cc: 3D registration.
* lazzara/igr/tr_image.cc: quick test on transformed image.
---
milena/sandbox/ChangeLog | 27 ++
milena/sandbox/lazzara/igr/igr-biggest-comp.cc | 294 ++++++++++++++++++++
milena/sandbox/lazzara/{ => igr}/igr-cloud.cc | 0
milena/sandbox/lazzara/{ => igr}/igr.cc | 17 +-
.../lazzara/{ => igr}/irm/hsl_grad_and_wst.cc | 0
.../{ => igr}/irm/irm_seg_with_mm_and_rag.cc | 0
milena/sandbox/lazzara/{ => igr}/irm/wst_rag.cc | 0
.../sandbox/lazzara/{ => igr}/irm/wst_rag_hsl.cc | 0
.../{ => igr}/irm_seg_with_mm_and_rag.mine.cc | 0
milena/sandbox/lazzara/igr/registration_3d.cc | 48 ++++
milena/sandbox/lazzara/igr/tr_image.cc | 185 ++++++++++++
11 files changed, 557 insertions(+), 14 deletions(-)
create mode 100644 milena/sandbox/lazzara/igr/igr-biggest-comp.cc
rename milena/sandbox/lazzara/{ => igr}/igr-cloud.cc (100%)
rename milena/sandbox/lazzara/{ => igr}/igr.cc (93%)
rename milena/sandbox/lazzara/{ => igr}/irm/hsl_grad_and_wst.cc (100%)
rename milena/sandbox/lazzara/{ => igr}/irm/irm_seg_with_mm_and_rag.cc (100%)
rename milena/sandbox/lazzara/{ => igr}/irm/wst_rag.cc (100%)
rename milena/sandbox/lazzara/{ => igr}/irm/wst_rag_hsl.cc (100%)
rename milena/sandbox/lazzara/{ => igr}/irm_seg_with_mm_and_rag.mine.cc (100%)
create mode 100644 milena/sandbox/lazzara/igr/registration_3d.cc
create mode 100644 milena/sandbox/lazzara/igr/tr_image.cc
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index e4e1643..4065f8d 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,30 @@
+2009-02-20 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Cleanup sandbox.
+
+ * lazzara/igr/igr-biggest-comp.cc: new. Variant of igr.cc which
+ extract the biggest component before registrating.
+
+ * lazzara/irm/wst_rag.cc,
+ * lazzara/irm_seg_with_mm_and_rag.mine.cc,
+ * lazzara/igr-cloud.cc,
+ * lazzara/igr.cc,
+ * lazzara/irm/hsl_grad_and_wst.cc,
+ * lazzara/irm/irm_seg_with_mm_and_rag.cc,
+ * lazzara/irm/wst_rag_hsl.cc: Move to...
+
+ * lazzara/igr/irm/wst_rag.cc,
+ * lazzara/igr/irm_seg_with_mm_and_rag.mine.cc,
+ * lazzara/igr/igr-cloud.cc,
+ * lazzara/igr/igr.cc,
+ * lazzara/igr/irm/hsl_grad_and_wst.cc,
+ * lazzara/igr/irm/irm_seg_with,
+ * lazzara/igr/irm/wst_rag_hsl.cc: ... here.
+
+ * lazzara/igr/registration_3d.cc: 3D registration.
+
+ * lazzara/igr/tr_image.cc: quick test on transformed image.
+
2009-02-20 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Update DICOM support to n dimensions.
diff --git a/milena/sandbox/lazzara/igr/igr-biggest-comp.cc
b/milena/sandbox/lazzara/igr/igr-biggest-comp.cc
new file mode 100644
index 0000000..ecfc7a1
--- /dev/null
+++ b/milena/sandbox/lazzara/igr/igr-biggest-comp.cc
@@ -0,0 +1,294 @@
+#include <mln/registration/registration.hh>
+#include <mln/essential/2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/binarization/binarization.hh>
+#include <mln/labeling/flat_zones.hh>
+#include <mln/labeling/background.hh>
+
+#include <mln/debug/colorize.hh>
+
+
+#include <mln/essential/3d.hh>
+#include <mln/core/image/slice_image.hh>
+#include <mln/core/image/tr_image.hh>
+#include <mln/core/image/interpolated.hh>
+
+#include <mln/io/cloud/load.hh>
+#include <mln/util/timer.hh>
+#include <mln/core/concept/function.hh>
+#include <mln/trait/ch_value.hh>
+
+#include <mln/fun/p2b/big_chess.hh>
+
+#include <mln/fun/x2v/trilinear.hh>
+
+namespace mln
+{
+
+ struct threshold : mln::Function_p2b<threshold>
+ {
+ bool operator()(const mln::value::rgb8& val) const
+ {
+ unsigned inty = (val.red() + val.blue() + val.green());
+ return inty > 100 && inty < 600;
+ }
+ };
+
+
+ namespace registration
+ {
+ extern std::string method;
+ }
+
+ template <typename I>
+ mln_concrete(I)
+ fill_holes(const mln::Image<I>& ima)
+ {
+ using namespace mln;
+
+ mln_concrete(I) output;
+ initialize(output, ima);
+ data::fill(output, true);
+
+ value::label_16 nlabels;
+ mln_ch_value(I, value::label_16) lbl = labeling::background(ima, c4(), nlabels);
+
+ mln_VAR(lbl_count, labeling::compute(accu::meta::count(), ima, lbl, nlabels));
+
+ unsigned max_id = 1;
+ for (unsigned i = 2; i <= nlabels; ++i)
+ if (lbl_count[max_id] < lbl_count[i])
+ max_id = i;
+
+ data::fill((output | pw::value(lbl) == max_id).rw(), false);
+
+ return output;
+ }
+
+ template <typename I>
+ mln_concrete(I)
+ keep_largest_component(const mln::Image<I>& ima)
+ {
+ using namespace mln;
+
+ image2d<bool> in_bw_cleaned = fill_holes(ima);
+ io::pbm::save(in_bw_cleaned, "in_bw_cleaned.pbm");
+
+ logical::not_inplace(in_bw_cleaned);
+ image2d<bool> in_bw_cleaned_full = fill_holes(in_bw_cleaned);
+ io::pbm::save(in_bw_cleaned_full, "in_bw_cleaned_full.pbm");
+
+ logical::not_inplace(in_bw_cleaned_full);
+ return in_bw_cleaned_full;
+ }
+
+ template <typename I>
+ mln_ch_value(I,bool)
+ get_main_object_shape(const mln::Image<I>& in)
+ {
+ using namespace mln;
+
+ typedef image2d<bool> J;
+
+ value::label_16 nlabels;
+ mln_ch_value(I, value::label_16) labels = labeling::flat_zones(in, c8(), nlabels);
+ util::array<unsigned> arr = labeling::compute(accu::meta::count(),
+ in, labels, nlabels);
+
+ unsigned big_second_count = 0;
+ unsigned big_second_lbl = 0;
+ unsigned big_first_count = 0;
+ unsigned big_first_lbl = 0;
+ for (unsigned i = 0; i < arr.nelements(); ++i)
+ {
+ if (arr[i] > big_second_count)
+ {
+ big_second_count = arr[i];
+ big_second_lbl = i;
+ }
+ if (big_second_count > big_first_count)
+ {
+ int swap = big_first_count;
+ int swap_lbl = big_first_lbl;
+ big_first_count = big_second_count;
+ big_first_lbl = big_second_lbl;
+ big_second_count = swap;
+ big_second_lbl = swap_lbl;
+ }
+ }
+
+ J result;
+ initialize(result, in);
+ data::fill(result, false);
+ data::fill((result | (pw::value(labels) == big_second_lbl)).rw(), true);
+
+ return morpho::elementary::gradient_internal(keep_largest_component(result), c8());
+ }
+
+
+ namespace debug
+ {
+
+ template <typename I, typename T>
+ image3d<value::rgb8>
+ make_registered_image(Image<I>& P_, Image<I>& X_, const T&
transf)
+ {
+ I& P = exact(P_);
+ I& X = exact(X_);
+
+ mln_pset(I) box = geom::bbox(X);
+ box.enlarge(1, 60);
+ box.enlarge(2, 60);
+
+ typedef mln_ch_value(I,value::rgb8) result_t;
+ result_t result(box);
+
+ typedef extension_fun<result_t,pw::cst_<mln_value(result_t)> >
result_ext_t;
+ result_ext_t ext_result(result, pw::cst(value::rgb8(0,0,0)));
+
+ extension_fun<I,pw::cst_<mln_value(I)> > ext_X(X, pw::cst(false));
+ data::fill(ext_result, literal::black);
+
+ mln_VAR(ig, (P | pw::value(P) == true));
+ mln_piter(ig_t) p(ig.domain());
+ for_all(p)
+ ext_result(transf(p)) = literal::green;
+
+ return ext_result;
+ }
+
+ template <typename I, typename J>
+ void
+ compare_registration(Image<I>& registered_, Image<J>& X_)
+ {
+ I& registered = exact(registered_);
+ J& X = exact(X_);
+
+ typedef mln_ch_value(I,value::rgb8) result_t;
+ result_t result;
+ initialize(result, registered);
+ extension_fun<J,pw::cst_<mln_value(J)> > ext_X(X, pw::cst(false));
+
+ data::fill(result, literal::black);
+ data::fill((result | (pw::value(ext_X) == true)).rw(), literal::white);
+ data::fill((result | (pw::value(registered) != pw::cst(literal::black))).rw(),
+ literal::cyan);
+
+ io::ppm::save(slice(result,0), "final_registered.ppm");
+ }
+
+
+
+ template <typename I, typename T>
+ void
+ compare_registration2(Image<I>& P_, Image<I>& X_,
+ const T& transf)
+ {
+ I& P = exact(P_);
+ const I& X = exact(X_);
+
+ typedef extension_fun<I,pw::cst_<mln_value(I)> > ext_P_t;
+ ext_P_t ext_P(P, pw::cst(value::rgb8(literal::black)));
+ typedef interpolated<ext_P_t, fun::x2v::trilinear> inter_t;
+ inter_t inter(ext_P);
+ tr_image<box3d, inter_t, T> trima(X.domain(), inter, transf);
+ io::ppm::save(slice(trima, 0), "trima.ppm");
+
+ I tmp = duplicate(X);
+ fun::p2b::big_chess<box3d> fun(tmp.domain(), 20);
+ data::paste((trima | fun), tmp);
+
+ io::ppm::save(slice(tmp,0), "registration_filter.ppm");
+ }
+
+ }
+}
+
+
+int main(int, char* argv[])
+{
+ using namespace mln;
+ using namespace fun::x2x;
+ using value::rgb8;
+ using value::int_u8;
+ using value::label_16;
+
+ //Load image
+ typedef image2d<rgb8> I;
+ typedef image2d<bool> J;
+ typedef image3d<bool> K;
+ typedef image3d<value::rgb8> L;
+
+// Load ppm images and apply a threshold.
+// I in;
+// io::ppm::load(in, argv[1]);
+// image2d<bool> in_bw = level::transform(in, threshold());
+// J in_obj = get_main_object_shape(in_bw);
+//
+// I ref;
+// io::ppm::load(ref, argv[2]);
+// image2d<bool> ref_bw = level::transform(ref, threshold());
+// J ref_obj = get_main_object_shape(ref_bw);
+
+
+
+ I in;
+ io::ppm::load(in, argv[1]);
+ J in_obj = get_main_object_shape(in);
+ io::pbm::save(in_obj, "in_obj.pbm");
+
+ I ref;
+ io::ppm::load(ref, argv[2]);
+ J ref_obj = get_main_object_shape(ref);
+ io::pbm::save(ref_obj, "ref_obj.pbm");
+
+ I in_orig;
+ io::ppm::load(in_orig, argv[3]);
+
+ I ref_orig;
+ io::ppm::load(ref_orig, argv[4]);
+
+ K in_3d = make::image3d(in_obj);
+ K ref_3d = make::image3d(ref_obj);
+ std::cout << " igr.cc - in_3d.nsites = " << in_3d.nsites()
<< std::endl;
+ std::cout << " igr.cc - ref_3d.nsites = " << ref_3d.nsites()
<< std::endl;
+
+ typedef p_array<point3d> p_arr_t;
+ p_arr_t in_3d_ = convert::to<p_arr_t>(in_3d);
+ p_arr_t ref_3d_ = convert::to<p_arr_t>(ref_3d);
+
+
+ /// Add objects shapes in original images.
+ L in_wborders = make::image3d(in_orig);
+ data::fill((in_wborders | in_3d_).rw(), literal::green);
+ io::ppm::save(slice(in_wborders,0), "in_with_borders.ppm");
+
+ L ref_wborders = make::image3d(ref_orig);
+ data::fill((ref_wborders | ref_3d_).rw(), literal::green);
+ io::ppm::save(slice(ref_wborders,0), "ref_with_borders.ppm");
+
+ // Starting registration.
+ util::timer t;
+ t.start();
+ typedef rotation<3u,float> rot_t;
+ typedef translation<3u,float> trans_t;
+ box3d bbox = geom::bbox(in_3d);
+ bbox.enlarge(0, in_3d.nslices() / 2);
+ bbox.enlarge(1, in_3d.nrows() / 2);
+ bbox.enlarge(2, in_3d.ncols() / 2);
+
+ composed<trans_t,rot_t> qk = registration::registration3(bbox, in_3d_, ref_3d_);
+ std::cout << "igr.cc - Registration - " << t <<
"s" << std::endl;
+
+ std::cout << qk.first().mat() << std::endl << std::endl;;
+ std::cout << qk.first().inv().mat() << std::endl << std::endl;;
+ std::cout << qk.second().mat() << std::endl;
+ std::cout << qk.second().inv().mat() << std::endl;
+
+ std::cout << "* Build result image" << std::endl;
+ image3d<value::rgb8> registered = debug::make_registered_image(in_3d, ref_3d,
qk);
+ debug::compare_registration(registered, ref_3d);
+
+ debug::compare_registration2(in_wborders, ref_wborders, qk);
+
+}
diff --git a/milena/sandbox/lazzara/igr-cloud.cc
b/milena/sandbox/lazzara/igr/igr-cloud.cc
similarity index 100%
rename from milena/sandbox/lazzara/igr-cloud.cc
rename to milena/sandbox/lazzara/igr/igr-cloud.cc
diff --git a/milena/sandbox/lazzara/igr.cc b/milena/sandbox/lazzara/igr/igr.cc
similarity index 93%
rename from milena/sandbox/lazzara/igr.cc
rename to milena/sandbox/lazzara/igr/igr.cc
index 0df1d92..98e1ce4 100644
--- a/milena/sandbox/lazzara/igr.cc
+++ b/milena/sandbox/lazzara/igr/igr.cc
@@ -202,22 +202,11 @@ namespace mln
typedef extension_fun<I,pw::cst_<mln_value(I)> > ext_P_t;
ext_P_t ext_P(P, pw::cst(value::rgb8(literal::black)));
- tr_image<box3d, ext_P_t, T> trima(P.domain(), ext_P, transf);
+ typedef interpolated<ext_P_t, fun::x2v::bilinear> inter_t;
+ inter_t inter(ext_P);
+ tr_image<box3d, inter_t, T> trima(X.domain(), inter, transf);
io::ppm::save(slice(trima, 0), "trima.ppm");
- I reg(X.domain());
- data::fill(reg, literal::black);
- mln_piter(I) p(P.domain());
- for_all(p)
- if (reg.domain().has(transf(p.to_vec())))
- reg(transf(p.to_vec())) = P(p);
- io::ppm::save(slice(reg,0), "registered-2.ppm");
-
- I tmp2 = duplicate(X);
- fun::p2b::big_chess<box3d> fun2(tmp2.domain(), 20);
- data::paste((reg | fun2), tmp2);
- io::ppm::save(slice(tmp2,0), "registration_filter-a.ppm");
-
I tmp = duplicate(X);
fun::p2b::big_chess<box3d> fun(tmp.domain(), 20);
data::paste((trima | fun), tmp);
diff --git a/milena/sandbox/lazzara/irm/hsl_grad_and_wst.cc
b/milena/sandbox/lazzara/igr/irm/hsl_grad_and_wst.cc
similarity index 100%
rename from milena/sandbox/lazzara/irm/hsl_grad_and_wst.cc
rename to milena/sandbox/lazzara/igr/irm/hsl_grad_and_wst.cc
diff --git a/milena/sandbox/lazzara/irm/irm_seg_with_mm_and_rag.cc
b/milena/sandbox/lazzara/igr/irm/irm_seg_with_mm_and_rag.cc
similarity index 100%
rename from milena/sandbox/lazzara/irm/irm_seg_with_mm_and_rag.cc
rename to milena/sandbox/lazzara/igr/irm/irm_seg_with_mm_and_rag.cc
diff --git a/milena/sandbox/lazzara/irm/wst_rag.cc
b/milena/sandbox/lazzara/igr/irm/wst_rag.cc
similarity index 100%
rename from milena/sandbox/lazzara/irm/wst_rag.cc
rename to milena/sandbox/lazzara/igr/irm/wst_rag.cc
diff --git a/milena/sandbox/lazzara/irm/wst_rag_hsl.cc
b/milena/sandbox/lazzara/igr/irm/wst_rag_hsl.cc
similarity index 100%
rename from milena/sandbox/lazzara/irm/wst_rag_hsl.cc
rename to milena/sandbox/lazzara/igr/irm/wst_rag_hsl.cc
diff --git a/milena/sandbox/lazzara/irm_seg_with_mm_and_rag.mine.cc
b/milena/sandbox/lazzara/igr/irm_seg_with_mm_and_rag.mine.cc
similarity index 100%
rename from milena/sandbox/lazzara/irm_seg_with_mm_and_rag.mine.cc
rename to milena/sandbox/lazzara/igr/irm_seg_with_mm_and_rag.mine.cc
diff --git a/milena/sandbox/lazzara/igr/registration_3d.cc
b/milena/sandbox/lazzara/igr/registration_3d.cc
new file mode 100644
index 0000000..f049d88
--- /dev/null
+++ b/milena/sandbox/lazzara/igr/registration_3d.cc
@@ -0,0 +1,48 @@
+#include <mln/essential/2d.hh>
+#include <mln/essential/3d.hh>
+#include <mln/registration/registration.hh>
+#include <mln/io/cloud/all.hh>
+#include <mln/debug/slices_2d.hh>
+
+int main(int, char *argv[])
+{
+ using namespace mln;
+
+ typedef p_array<point3d> arr_t;
+
+ arr_t in;
+ io::cloud::load(in, argv[1]);
+
+ arr_t ref;
+ io::cloud::load(ref, argv[2]);
+
+ // Starting registration.
+ util::timer t;
+ t.start();
+
+ typedef fun::x2x::rotation<3u,float> rot_t;
+ typedef fun::x2x::translation<3u,float> trans_t;
+ fun::x2x::composed<trans_t,rot_t> qk = registration::registration3(in, ref);
+
+ std::cout << "igr.cc - Registration - " << t <<
"s" << std::endl;
+
+ box3d bbox = geom::bbox(ref);
+ bbox.enlarge(1, 50);
+ bbox.enlarge(2, 50);
+ image3d<value::rgb8> ima_in(bbox);
+ data::fill(ima_in, literal::black);
+ data::fill((ima_in | in).rw(), literal::green);
+
+ mln_VAR(ext_ima, extended_with(ima_in, pw::cst(value::rgb8(literal::black))));
+ mln_VAR(trima, transposed_image(bbox, ext_ima, qk));
+
+ image3d<value::rgb8> ima_ref(geom::bbox(ref));
+ mln_VAR(ext_ima_ref, extended_with(ima_ref, pw::cst(value::rgb8(literal::black))));
+ data::fill(ext_ima_ref, literal::black);
+ data::fill((ext_ima_ref | ref).rw(), literal::white);
+ data::fill((ext_ima_ref | pw::value(trima) == pw::cst(literal::green)).rw(),
literal::green);
+
+// io::cloud::save(res, "registered.txt");
+
+ io::ppm::save(debug::slices_2d(ima_ref, 5, 3, literal::black),
"registration_3d.ppm");
+}
diff --git a/milena/sandbox/lazzara/igr/tr_image.cc
b/milena/sandbox/lazzara/igr/tr_image.cc
new file mode 100644
index 0000000..d1a8056
--- /dev/null
+++ b/milena/sandbox/lazzara/igr/tr_image.cc
@@ -0,0 +1,185 @@
+#include <mln/essential/2d.hh>
+#include <mln/essential/3d.hh>
+#include <mln/fun/x2x/composed.hh>
+#include <mln/fun/x2x/rotation.hh>
+#include <mln/fun/x2x/translation.hh>
+#include <mln/core/image/interpolated.hh>
+#include <mln/fun/x2v/trilinear.hh>
+#include <mln/fun/x2v/bilinear.hh>
+#include <mln/core/image/tr_image.hh>
+
+#include <mln/io/cloud/save.hh>
+#include <mln/debug/slices_2d.hh>
+
+int main(int, char *argv[])
+{
+ using namespace mln;
+ using namespace fun::x2x;
+ using value::rgb8;
+ using value::int_u8;
+ using value::label_16;
+
+ //Load image
+ typedef image2d<bool> J;
+ typedef image3d<rgb8> K;
+ typedef image2d<rgb8> I;
+
+ I P;
+ io::ppm::load(P, argv[1]);
+ K P_3d = make::image3d(P);
+
+
+ {
+ typedef rotation<3u,float> rot_t;
+ rot_t rot(1.57f, make::vec(0,0, 1));
+ typedef translation<3u,float> trans_t;
+ trans_t trans(make::vec(150, 50, 0));
+ typedef composed<trans_t, rot_t> transf_t;
+ transf_t qk(trans, rot);
+
+// std::cout << rot.mat() << std::endl;
+//
+ point3d p10_3d(0,1,0);
+ std::cout << "point " << p10_3d << " == vec "
<< p10_3d.to_vec() << std::endl;
+// point3d p11_3d(0,1,1);
+// algebra::vec<4u,float> p10 = make::vec(0,1,0,1);
+// algebra::vec<4u,float> p11 = make::vec(0.f,1.f,1.f,1.f);
+// algebra::vec<4u,float> p01 = make::vec(0.f,0.f,1.f,1.f);
+// algebra::vec<4u,float> p_01 = make::vec(0,0,-1,1);
+//
+// std::cout << "qk(p10_3d.to_vec) = " << qk(p10_3d.to_vec())
<< std::endl;
+// std::cout << "rot(p10) = " << (rot.mat() * p10) <<
std::endl;
+// std::cout << "rot(p10) + trans = " << (qk.mat() * p10)
<< std::endl << std::endl << std::endl;
+//
+//
+// std::cout << "rot.inv()(p10) = " << (rot.inv().mat() * p10)
<< std::endl;
+// std::cout << "rot.inv()(p_01) = " << (rot.inv().mat() * p_01)
<< std::endl;
+// std::cout << "rot.inv()(p01) = " << (rot.inv().mat() * p01)
<< std::endl;
+// std::cout << "qk.inv()(p11_3d) = " <<
qk.inv()(p11_3d.to_vec()) << std::endl;
+// std::cout << "qk.inv().mat() * p11 = " << (qk.inv().mat() *
p11) << std::endl;
+// std::cout << "rot(p).inv() (p11 + trans.inv) = " <<
rot.inv().mat() * (trans.inv().mat() * p11) << std::endl;
+// std::cout << "trans.inv()(p01) = " << trans.inv().mat() * p01
<< std::endl;
+//
+// std::cout << std::endl << "trans.mat" << std::endl;
+// std::cout << trans.mat() << std::endl;
+// std::cout << "trans.mat.inv" << std::endl;
+// std::cout << trans.inv().mat() << std::endl;
+//
+//
+// std::cout << std::endl << "rot.mat" << std::endl;
+// std::cout << rot.mat() << std::endl;
+// std::cout << "rot.mat.inv" << std::endl;
+// std::cout << rot.inv().mat() << std::endl;
+//
+// std::cout << "qk.mat" << std::endl;
+// std::cout << qk.mat() << std::endl;
+// std::cout << "qk.inv().mat()" << std::endl;
+// std::cout << qk.inv().mat() << std::endl;
+
+ typedef extension_fun<K,pw::cst_<mln_value_(I)> > ext_P_t;
+ ext_P_t ext_P(P_3d, pw::cst(value::rgb8(literal::black)));
+
+ typedef interpolated<ext_P_t, fun::x2v::trilinear> inter_t;
+ inter_t inter(ext_P);
+
+ std::cout << std::endl << "DEBUG TR_IMAGE" << std::endl;
+ tr_image<box3d, inter_t, transf_t> trima(P_3d.domain(), inter, qk);
+
+ io::ppm::save(slice(trima, 0), "trima_3d2.ppm");
+
+ }
+
+// {
+// typedef rotation<3u,float> rot_t;
+//
+// algebra::quat q;
+// q[0] = 0
+// q[3] = cos(1.57f / 2);
+// rot_t rot(1.57f, make::vec(0, 0, 1));
+// typedef translation<3u,float> trans_t;
+// trans_t trans(make::vec(150, 50, 0));
+// typedef composed<trans_t, rot_t> transf_t;
+// transf_t qk(trans, rot);
+//
+// typedef extension_fun<K,pw::cst_<mln_value_(I)> > ext_P_t;
+// ext_P_t ext_P(P_3d, pw::cst(value::rgb8(literal::black)));
+//
+// typedef interpolated<ext_P_t, fun::x2v::trilinear> inter_t;
+// inter_t inter(ext_P);
+//
+// std::cout << std::endl << "DEBUG TR_IMAGE" <<
std::endl;
+// tr_image<box3d, inter_t, transf_t> trima(P_3d.domain(), inter, qk);
+//
+// io::ppm::save(slice(trima, 0), "trima_3d3.ppm");
+//
+// }
+
+
+ {
+
+ typedef rotation<2u,float> rot_t;
+ rot_t rot(1.57f, make::vec(1, 0));
+
+ typedef translation<2u,float> trans_t;
+ trans_t trans(make::vec(150, 50));
+ typedef composed<trans_t, rot_t> transf_t;
+ transf_t qk(trans, rot);
+
+ std::cout << rot.mat() << std::endl;
+
+ typedef extension_fun<I,pw::cst_<mln_value_(I)> > ext_P_t;
+ ext_P_t ext_P(P, pw::cst(value::rgb8(literal::black)));
+ typedef interpolated<ext_P_t, fun::x2v::bilinear> inter_t;
+ inter_t inter(ext_P);
+ tr_image<box2d, inter_t, transf_t> trima(P.domain(), inter, qk);
+ io::ppm::save(trima, "trima_2d.ppm");
+
+ }
+/*
+ {
+ typedef rotation<3u,float> rot_t;
+ rot_t rot(1.57f, make::vec(0, 0, 1));
+ typedef translation<3u,float> trans_t;
+ trans_t trans(make::vec(160, 60, 0));
+ typedef composed<trans_t, rot_t> transf_t;
+ transf_t qk(trans, rot);
+
+ std::cout << rot.mat() << std::endl;
+
+ typedef extension_fun<K,pw::cst_<mln_value_(I)> > ext_P_t;
+ ext_P_t ext_P(P_3d, pw::cst(value::rgb8(literal::black)));
+ typedef interpolated<ext_P_t, fun::x2v::bilinear> inter_t;
+ inter_t inter(ext_P);
+ tr_image<box3d, inter_t, transf_t> trima(P_3d.domain(), inter, qk);
+ io::ppm::save(slice(trima, 0), "trima_3d.ppm");
+
+ std::cout << std::endl << " points: " << std::endl;
+ unsigned i = 0;
+ mln_piter_(box3d) p (P_3d.domain());
+ for_all(p)
+ {
+ algebra::vec<4,float> tmp;
+ for (unsigned j = 0; j < 3; ++j)
+ tmp[j] = p.to_vec()[j];
+ tmp[3] = 1;
+ tmp = (qk.mat() * tmp);
+ algebra::vec<3,float> res;
+ for (unsigned j = 0; j < 3; ++j)
+ res[j] = tmp[j];
+ point3d ptmp = res;
+ std::cout << p << " - " << res << " - "
<< point3d(res) << " - " << ptmp << std::endl;
+ if (i >10)
+ break;
+ ++i;
+ }
+ }
+*/
+// K reg(b);
+// data::fill(reg, literal::black);
+// mln_piter_(K) p(P_3d.domain());
+// for_all(p)
+// if (reg.domain().has(qk(p.to_site().to_vec())))
+// reg(qk(p.to_site().to_vec())) = P_3d(p);
+// io::ppm::save(slice(reg,0), "trima_mine.ppm");
+
+}
--
1.5.6.5