contrib/tbl/vipl/vipl_with_vbl_array_2d/accessors/vipl_accessors_vbl_array_2d.txx
Go to the documentation of this file.
00001 #ifndef vipl_accessors_vbl_array_2d_txx_
00002 #define vipl_accessors_vbl_array_2d_txx_
00003 
00004 #include "vipl_accessors_vbl_array_2d.h"
00005 #include "../vipl_filterable_section_container_generator_vbl_array_2d.txx"
00006 
00007 template <class DataType>
00008 DataType fgetpixel(vbl_array_2d<DataType> const& i, int x, int y, DataType /* dummy */) {
00009   return i(x,y);
00010 }
00011 template <class DataType>
00012 void fsetpixel(vbl_array_2d<DataType>& i, int x, int y, DataType e) {
00013   i(x,y) = e;
00014 }
00015 template <class DataType>
00016 DataType getpixel(vbl_array_2d<DataType> const& i, int x, int y, DataType /* dummy */) {
00017   if (x<0 || y<0 || x>=int(i.columns()) || y>=int(i.rows())) return DataType();
00018   return i(x,y);
00019 }
00020 template <class DataType>
00021 void setpixel(vbl_array_2d<DataType>& i, int x, int y, DataType e) {
00022   if (x<0 || y<0 || x>=int(i.columns()) || y>=int(i.rows())) return;
00023   i(x,y) = e;
00024 }
00025 
00026 #undef VIPL_INSTANTIATE_ACCESSORS
00027 #define VIPL_INSTANTIATE_ACCESSORS(T) \
00028 template T fgetpixel(vbl_array_2d<T > const&, int, int, T);\
00029 template void fsetpixel(vbl_array_2d<T >&, int, int, T);\
00030 template T getpixel(vbl_array_2d<T > const&, int, int, T);\
00031 template void setpixel(vbl_array_2d<T >&, int, int, T)
00032 
00033 #endif // vipl_accessors_vbl_array_2d_txx_