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 #ifndef MLN_WORLD_INTER_PIXEL_DISPLAY_EDGE_HH
00027 # define MLN_WORLD_INTER_PIXEL_DISPLAY_EDGE_HH
00028 
00033 
00034 # include <mln/core/image/image2d.hh>
00035 # include <mln/core/image/dmorph/image_if.hh>
00036 # include <mln/data/fill.hh>
00037 # include <mln/world/inter_pixel/is_separator.hh>
00038 # include <mln/opt/at.hh>
00039 
00040 namespace mln
00041 {
00042 
00043   namespace world
00044   {
00045 
00046     namespace inter_pixel
00047     {
00048 
00060       template <typename I>
00061       inline
00062       I display_edge(const I& ima, mln_value(I) bg, unsigned zoom);
00063 
00064 # ifndef MLN_INCLUDE_ONLY
00065 
00066 
00067       template <typename I>
00068       inline
00069       I display_edge(const I& ima, mln_value(I) bg, unsigned zoom)
00070       {
00071         box2d b = ima.bbox();
00072         I output(make::box2d(((b.pmin()[0] + 1) / 2) * (zoom + 1),
00073                              ((b.pmin()[1] + 1) / 2) * (zoom + 1),
00074                              ((b.pmax()[0] + 1) / 2 + 1) * (zoom + 1) - 2,
00075                              ((b.pmax()[1] + 1) / 2 + 1) * (zoom + 1) - 2));
00076         data::fill(output, bg);
00077         typedef image_if<const I, is_separator> edge_t;
00078         edge_t edge = ima | is_separator();
00079         mln_piter(edge_t) p(edge.domain());
00080         for_all(p)
00081           if (p.row() % 2) 
00082           {
00083             unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1;
00084             unsigned col = (p.col() / 2) * (zoom + 1);
00085             for (unsigned i = 0; i < zoom; ++i)
00086               opt::at(output, row, col + i) = ima(p);
00087           }
00088           else 
00089           {
00090             unsigned row = (p.row() / 2) * (zoom + 1);
00091             unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1;
00092             for (unsigned i = 0; i < zoom; ++i)
00093               opt::at(output, row + i, col) = ima(p);
00094           }
00095         return output;
00096       }
00097 
00098 
00099 # endif // ! MLN_INCLUDE_ONLY
00100 
00101     } 
00102 
00103   } 
00104 
00105 } 
00106 
00107 #endif // ! MLN_WORLD_INTER_PIXEL_DISPLAY_EDGE_HH