Go to the documentation of this file.00001 #ifndef ouml_image_convert_txx_
00002 #define ouml_image_convert_txx_
00003
00004 #include "image_convert.h"
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 template <class T1, class T2>
00022 vil1_memory_image_of<T2> *convert_image
00023 (
00024 const vil1_memory_image_of<T1> &from,
00025 T2 &var
00026 )
00027 {
00028 vil1_memory_image_of<T2> *to;
00029 to = new vil1_memory_image_of<T2>(from.width(), from.height());
00030
00031 for (int x=0; x<from.width(); x++)
00032 for (int y=0; y<from.height(); y++)
00033 (*to)(x,y) = (T2)from(x,y);
00034
00035 return to;
00036 }
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 template <> vil1_memory_image_of<unsigned char> *
00052 convert_image<vil1_rgb<unsigned char>, unsigned char>
00053 (
00054 const vil1_memory_image_of<vil1_rgb<unsigned char> > &from,
00055 unsigned char &var
00056 )
00057 {
00058 vil1_memory_image_of<unsigned char> *to
00059 = new vil1_memory_image_of<unsigned char>(from.width(), from.height());
00060
00061 for (int x=0; x<from.width(); x++)
00062 for (int y=0; y<from.height(); y++)
00063 (*to)(x,y) = from(x,y).grey();
00064
00065 return to;
00066 }
00067
00068 template <> vil1_memory_image_of<double> *
00069 convert_image<vil1_rgb<unsigned char>, double>
00070 (
00071 const vil1_memory_image_of<vil1_rgb<unsigned char> > &from,
00072 double &var
00073 )
00074 {
00075 vil1_memory_image_of<double> *to
00076 = new vil1_memory_image_of<double>(from.width(), from.height());
00077
00078 for (int x=0; x<from.width(); x++)
00079 for (int y=0; y<from.height(); y++)
00080 (*to)(x,y) = (double)from(x,y).grey();
00081
00082 return to;
00083 }
00084
00085 #endif // ouml_image_convert_txx_