contrib/mul/ipts/ipts_draw.h
Go to the documentation of this file.
00001 #ifndef ipts_draw_h_
00002 #define ipts_draw_h_
00003 
00004 //:
00005 //  \file
00006 //  \brief Functions to draw shapes into an image (may get moved to vil in time)
00007 //  \author Tim Cootes
00008 
00009 #include <vil/vil_image_view.h>
00010 
00011 //: Draws line between (i0,j0) and (i0+L,j0) (which may be outside image)
00012 //  Assumes single plane
00013 template<class T>
00014 inline void ipts_draw_i_line(vil_image_view<T>& image, 
00015                              int i0, int j0, unsigned L, T value)
00016 {
00017   int ilo = i0; if (ilo<0) ilo=0;
00018   int ihi = i0+L; if (ihi>=int(image.ni()))  ihi=image.ni()-1;
00019   for (int i=ilo;i<=ihi;++i) image(i,j0)=value;
00020 }
00021 
00022 //: Draws line between (i0,j0) and (i0,j0+L) (which may be outside image)
00023 //  Assumes single plane
00024 template<class T>
00025 inline void ipts_draw_j_line(vil_image_view<T>& image, 
00026                              int i0, int j0, unsigned L, T value)
00027 {
00028   int jlo = j0; if (jlo<0) jlo=0;
00029   int jhi = j0+L; if (jhi>=int(image.nj()))  jhi=image.nj()-1;
00030   for (int j=jlo;j<=jhi;++j) image(i0,j)=value;
00031 }
00032 
00033 //: Draw cross centred at (i0,j0) with half-width L
00034 template<class T>
00035 void ipts_draw_cross(vil_image_view<T>& image, int i0, int j0, unsigned L, T value)
00036 {
00037   ipts_draw_i_line(image,i0-L,j0,2*L+1,value);
00038   ipts_draw_j_line(image,i0,j0-L,2*L+1,value);
00039 }
00040 
00041 
00042 #endif // ipts_draw_h_