core/vil/vil_print.h
Go to the documentation of this file.
00001 // This is core/vil/vil_print.h
00002 #ifndef vil_print_h_
00003 #define vil_print_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \author Ian Scott, Tim Cootes.
00010 
00011 #include <vil/vil_image_view.h>
00012 #include <vcl_iomanip.h>
00013 #include <vcl_iostream.h>
00014 
00015 //: How to print value in vil_print_all(image_view)
00016 // \relatesalso vil_image_view
00017 template<class T>
00018 void vil_print_value(vcl_ostream& s, const T& value, unsigned=0);
00019 
00020 // Specializations must be declared before use, so they need to be
00021 // declared here.
00022 
00023 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00024 
00025 #define vil_print_declare_specialization( T ) \
00026   VCL_DEFINE_SPECIALIZATION \
00027   void vil_print_value(vcl_ostream& os, const T & value, unsigned)
00028 
00029 vil_print_declare_specialization( bool );
00030 vil_print_declare_specialization( vxl_byte );
00031 vil_print_declare_specialization( vxl_sbyte );
00032 vil_print_declare_specialization( vxl_int_16 );
00033 vil_print_declare_specialization( vxl_uint_16 );
00034 vil_print_declare_specialization( vxl_int_32 );
00035 vil_print_declare_specialization( vxl_uint_32 );
00036 #if VXL_HAS_INT_64
00037 vil_print_declare_specialization( vxl_int_64 );
00038 vil_print_declare_specialization( vxl_uint_64 );
00039 #endif
00040 vil_print_declare_specialization( float );
00041 vil_print_declare_specialization( double );
00042 vil_print_declare_specialization( vcl_complex<float> );
00043 vil_print_declare_specialization( vcl_complex<double> );
00044 vil_print_declare_specialization( vil_rgb<vxl_byte> );
00045 vil_print_declare_specialization( vil_rgb<vxl_sbyte> );
00046 vil_print_declare_specialization( vil_rgb<vxl_int_16> );
00047 vil_print_declare_specialization( vil_rgb<vxl_uint_16> );
00048 vil_print_declare_specialization( vil_rgb<vxl_int_32> );
00049 vil_print_declare_specialization( vil_rgb<vxl_uint_32> );
00050 #if VXL_HAS_INT_64
00051 vil_print_declare_specialization( vil_rgb<vxl_int_64> );
00052 vil_print_declare_specialization( vil_rgb<vxl_uint_64> );
00053 #endif
00054 vil_print_declare_specialization( vil_rgb<float> );
00055 vil_print_declare_specialization( vil_rgb<double> );
00056 vil_print_declare_specialization( vil_rgba<vxl_byte> );
00057 vil_print_declare_specialization( vil_rgba<vxl_sbyte> );
00058 vil_print_declare_specialization( vil_rgba<vxl_int_16> );
00059 vil_print_declare_specialization( vil_rgba<vxl_uint_16> );
00060 vil_print_declare_specialization( vil_rgba<vxl_int_32> );
00061 vil_print_declare_specialization( vil_rgba<vxl_uint_32> );
00062 #if VXL_HAS_INT_64
00063 vil_print_declare_specialization( vil_rgba<vxl_int_64> );
00064 vil_print_declare_specialization( vil_rgba<vxl_uint_64> );
00065 #endif
00066 vil_print_declare_specialization( vil_rgba<float> );
00067 vil_print_declare_specialization( vil_rgba<double> );
00068 
00069 #undef vil_print_declare_specialization
00070 
00071 #endif // DOXYGEN_SHOULD_SKIP_THIS
00072 
00073 
00074 //: Print all image data to os in a grid (rounds output to int)
00075 // \relatesalso vil_image_view
00076 template<class T>
00077 inline void vil_print_all(vcl_ostream& os,const vil_image_view<T>& view, unsigned width=0)
00078 {
00079   if (!width) width = static_cast<unsigned>(os.width());
00080   os<<view.is_a()<<' '<<view.nplanes()<<" planes, each "<<view.ni()<<" x "<<view.nj()
00081     <<" istep: "<<(int)view.istep()<<' '
00082     <<" jstep: "<<(int)view.jstep()<<' '
00083     <<" planestep: "<<(int)view.planestep()<<'\n' << vcl_flush;
00084   for (unsigned int p=0;p<view.nplanes();++p)
00085   {
00086     if (view.nplanes()>1) os<<"Plane "<<p<<":\n" << vcl_flush;
00087     for (unsigned int j=0;j<view.nj();++j)
00088     {
00089       for (unsigned int i=0;i<view.ni();++i)
00090       {
00091         os<<' '<<vcl_setw(width);
00092         vil_print_value(os,view(i,j,p), width);
00093       }
00094       os<<'\n'<<vcl_flush;
00095     }
00096   }
00097 }
00098 
00099 //: Print all image data to os in a grid
00100 // \relatesalso vil_image_view
00101 void vil_print_all(vcl_ostream& os, vil_image_view_base_sptr const& view);
00102 
00103 #endif // vil_print_h_