00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 #include <mln/core/image/image1d.hh>
00027 #include <mln/core/image/image2d.hh>
00028 #include <mln/core/image/image3d.hh>
00029 
00030 #include <mln/win/segment1d.hh>
00031 #include <mln/win/rectangle2d.hh>
00032 #include <mln/win/cuboid3d.hh>
00033 
00034 #include <mln/make/pixel.hh>
00035 
00036 
00037 template <typename I, typename W>
00038 void test_fill(I& ima, const W& win, unsigned nsites)
00039 {
00040   mln_piter(I) p(ima.domain());
00041   mln_fwd_qixter(I, W) fq(ima, win, p);
00042   for_all(p)
00043   {
00044     unsigned i = 0;
00045     for_all(fq)
00046       ++i, fq.val() = 51;
00047     mln_assertion(i == nsites);
00048   }
00049   mln_bkd_qixter(I, W) bq(ima, win, p);
00050   for_all(p)
00051   {
00052     unsigned i = 0;
00053     for_all(bq)
00054       ++i, bq.val() = 42;
00055     mln_assertion(i == nsites);
00056   }
00057 }
00058 
00059 
00060 
00061 template <typename P, typename W>
00062 void test_pixel(const P& pxl, const W& win)
00063 {
00064   mln_fwd_qixter(mln_image(P), W) fq(pxl, win);
00065   for_all(fq)
00066     fq.val() = 2 * fq.val();
00067   mln_bkd_qixter(mln_image(P), W) bq(pxl, win);
00068   for_all(bq)
00069     bq.val() = bq.val() + 1;
00070 }
00071 
00072 int main()
00073 {
00074   using namespace mln;
00075 
00076   border::thickness = 1;
00077 
00078   
00079   {
00080     typedef image1d<int> I;
00081     I ima(6);
00082 
00083     win::segment1d seg(3);
00084     point1d p = point1d(3);
00085 
00086     test_fill(ima, seg, 3);
00087     test_pixel(make::pixel(ima, p), seg);
00088   }
00089 
00090   
00091   {
00092     typedef image2d<int> I;
00093     I ima(5, 5);
00094 
00095     win::rectangle2d rect(3, 3);
00096     point2d p = point2d(1, 1);
00097 
00098     test_fill(ima, rect, 3 * 3);
00099     test_pixel(make::pixel(ima, p), rect);
00100   }
00101 
00102   
00103   {
00104     typedef image3d<int> I;
00105     I ima(3, 4, 5);
00106 
00107     win::cuboid3d cuboid(3, 3, 3);
00108     point3d p = point3d(2, 1, 3);
00109 
00110     test_fill(ima, cuboid, 3 * 3 * 3);
00111     test_pixel(make::pixel(ima, p), cuboid);
00112   }
00113 
00114 }