Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

CallImLib3DImageProcessorByName.cpp

00001 
00002 #include<ImLib3D/ImLib3D.hpp>
00003 #include<ImLib3D/Display.hpp>
00004 #include<ImLib3D/BitImage3D.hpp>
00005 #include<ImLib3D/Transformation.hpp>
00006 #include<ImLib3D/MorphologicalOperators.hpp>
00007 #include<ImLib3D/FFT.hpp>
00008 #include<ImLib3D/Convolution.hpp>
00009 #include<ImLib3D/TestPatterns.hpp>
00010 #include<ImLib3D/Threshold.hpp>
00011 #include<ImLib3D/ImageStats.hpp>
00012 #include<ImLib3D/ImageAs1DVector.hpp>
00013 #include<ImLib3D/Draw.hpp>
00014 #include<ImLib3D/ConvenienceProcessors.hpp>
00015 #include<ImLib3D/Normalization.hpp>
00016 #include<ImLib3D/VoxelCoding.hpp>
00017 #include<ImLib3D/Arithmetic.hpp>
00018 #include<ImLib3D/VisualizationAids.hpp>
00019 #include<ImLib3D/FileConversion.hpp>
00020 #include<ImLib3D/ShapeAnalysis.hpp>
00021 #include<ImLib3D/NoiseEstimation.hpp>
00022 #include<ImLib3D/TypeSafeGenericPointer.hpp>
00023 #include<ImLib3D/PluginManagement.hpp>
00024 #include<ImLib3D/XMLTools.hpp>
00025 #include<ImLib3D/TemplateGroups.hpp>
00026 
00027 #include"CallImLib3DImageProcessorByName.hpp"
00028 #include"StringArgumentConversion.hpp"
00029 #include"ImageProcessorsByNameDefinitions.cpp"
00030 #include"ImageProcessorsByNameCalls.cpp"
00031 
00032 template<class ImageType >
00033 void
00034 ImProc_ReadFromFileAVW_StrArgs(const string &procName,const vector<string> &args,vector<TypeSafeGenericPointer> &alternateArgs)
00035 {
00036     typedef typename ImageType::value_type Im3DValue;
00037     string& arg0 =*StringOrAlternateInputArg<string >( args[0] ,alternateArgs,0 );
00038     ImageType& arg1 =*CreateOutputArg<ImageType >(alternateArgs,1 );
00039     IP3D::ReadFromFileAVW(arg0, arg1);
00040     CleanupArg< string >(arg0,alternateArgs,0);
00041     ImProcOutputArg< ImageType >(arg1,args[1],alternateArgs,1);
00042     CleanupArg< ImageType >(arg1,alternateArgs,1);
00043 }
00044 
00045 template<class ImageType >
00046 void
00047 ImProc_ImageFromRawData_StrArgs(const vector<string> &args,vector<TypeSafeGenericPointer> alternateArgs)
00048 {
00049     typedef typename ImageType::value_type Im3DValue;
00050     string& arg0 =*StringOrAlternateInputArg<string >( args[0] ,alternateArgs,0 );
00051     typename ImageType::value_type *arg1=(typename ImageType::value_type *)Read(args[1]);
00052     Size3D& arg2 =*StringOrAlternateInputArg<Size3D >( args[2] ,alternateArgs,2 );
00053     string& arg3 =*StringOrAlternateInputArg<string >( args[3] ,alternateArgs,3 );
00054     ImageType& arg4 =*CreateOutputArg<ImageType >(alternateArgs,4 );
00055     bool& arg5 =*OptionalDefaultValueArg<bool >( args[5] ,alternateArgs,5 ,false);
00056     IP3D::ImageFromRawData( arg1, arg2, arg3, arg4, arg5);
00057     CleanupArg< string >(arg0,alternateArgs,0);
00058 //  CleanupArg< raw data >(arg1,alternateArgs,1);
00059     CleanupArg< Size3D >(arg2,alternateArgs,2);
00060     CleanupArg< string >(arg3,alternateArgs,3);
00061     ImProcOutputArg< ImageType >(arg4,args[4],alternateArgs,4);
00062     CleanupArg< ImageType >(arg4,alternateArgs,4);
00063 }
00064 
00065 
00066 
00067 bool 
00068 CustomImProcCalls(const string &procName,const vector<string> &args,vector<TypeSafeGenericPointer> alternateArgs)
00069 {
00070     if(procName=="ReadFromFileAVW")
00071     {
00072         string typeName=FileConversion::AVWImLib3DImageType(args[0]);
00073         CallWithImage3DAVWCompatible_3(ImProc_ReadFromFileAVW_StrArgs,typeName,procName,args,alternateArgs);
00074         return true;
00075     }
00076 
00077     if(procName=="ImageFromRawData")
00078     {
00079         string resultTypename=args[0];
00080         CallWithImage3DBasicCTypes_2(ImProc_ImageFromRawData_StrArgs,resultTypename,args,alternateArgs);
00081         return true;
00082     }
00083     if(procName=="RawDataFromImage")
00084     {
00085         string resultTypename=args[0];
00086         ThrowError("interface to imageprocessor RawDataFromImage is not currently available, please use RawDataFromImage directly from C++ code");
00087         //      CallWithImage3DBasicCTypes_2(ImProc_ImageFromRawData_StrArgs,resultTypename,args,alternateArgs);
00088         return true;
00089     }
00090     if(procName=="ImageTypeConversion")
00091     {
00092         if(args.size()!=3){ThrowError("ImageTypeConversion: wrong number of args, did you forget second image type?");}
00093         string type;
00094         if(alternateArgs.size()>0 && alternateArgs[0].IsSet())
00095         {
00096             type=alternateArgs[0].Get<Image3D *>()->GetTypeName();
00097         }
00098         else{type=Container3D_ReadImageType(args[0]);}
00099         string type2=args[2];
00100         mprintf("conversion:\"%s\" to \"%s\"\n",type,type2);
00101 
00102 
00103 #define _conv0(ImageType,TypeName,ImageType2,TypeName2) if(type==TypeName && type2==TypeName2 ) \
00104 { \
00105     ImageType & arg0 =*StringOrAlternateInputArg<ImageType >( args[0] ,alternateArgs,0 ); \
00106     ImageType2& arg1 =*CreateOutputArg<ImageType2 >(alternateArgs,1 ); \
00107     IP3D::ImageTypeConversion<ImageType,ImageType2 >(arg0,arg1); \
00108     ImProcOutputArg<ImageType2 >(arg1,args[1],alternateArgs,1); \
00109     CleanupArg< ImageType  >(arg0,alternateArgs,0); \
00110     CleanupArg< ImageType2 >(arg1,alternateArgs,1); \
00111     return true; \
00112 }
00113 #define _conv(ImageType,ImageType2) _conv0(ImageType,#ImageType,ImageType2,#ImageType2)
00114 
00115         _conv(Image3Df  ,Image3Df        )
00116         _conv(Image3Df  ,Image3Dd        )
00117         _conv(Image3Df  ,Mask3D          )
00118         _conv(Image3Df  ,Image3Dcomplex  )
00119         _conv(Image3Df  ,Image3Dlinear<int>)
00120         _conv(Image3Df  ,Image3Dlinear<short int>)
00121                                                            
00122         _conv(Image3Dd  ,Image3Df        )
00123         _conv(Image3Dd  ,Image3Dd        )
00124         _conv(Image3Dd  ,Mask3D          )
00125         _conv(Image3Dd  ,Image3Dcomplex  )
00126         _conv(Image3Dd  ,Image3Dlinear<int>)
00127         _conv(Image3Dd  ,Image3Dlinear<short int>)
00128               
00129         _conv(Mask3D  ,Image3Df        ) 
00130         _conv(Mask3D  ,Image3Dd        ) 
00131         _conv(Mask3D  ,Mask3D          ) 
00132         _conv(Mask3D  ,Image3Dcomplex  ) 
00133         _conv(Mask3D  ,Image3Dlinear<int>) 
00134         _conv(Mask3D  ,Image3Dlinear<short int>  )
00135         _conv(Mask3D  ,BitMask3D )
00136         typedef BitImage3D<byte,2,byte> BitImage3Dbyte2byte;
00137         _conv0(Mask3D  , "Mask3D",BitImage3Dbyte2byte,"BitImage3D<byte,2,byte>" )
00138 
00139         _conv(BitMask3D  ,Mask3D)
00140         _conv0(BitMask3D  ,"BitImage3D<byte,1,byte>",Mask3D,"Mask3D")
00141         _conv0(BitMask3D  ,"BitMask3D"              ,BitImage3Dbyte2byte,"BitImage3D<byte,2,byte>")
00142         _conv0(BitMask3D  ,"BitImage3D<byte,1,byte>",BitImage3Dbyte2byte,"BitImage3D<byte,2,byte>")
00143 
00144         _conv0(BitImage3Dbyte2byte ,"BitImage3D<byte,2,byte>" ,Mask3D,"Mask3D")
00145         _conv0(BitImage3Dbyte2byte ,"BitImage3D<byte,2,byte>" ,BitMask3D,"BitMask3D")
00146 
00147 //          _conv(Image3Dcomplex  ,Image3Df        )    
00148 //          _conv(Image3Dcomplex  ,Image3Dd        )     
00149 //          _conv(Image3Dcomplex  ,Mask3D          )     
00150         _conv(Image3Dcomplex  ,Image3Dcomplex  )     
00151 //          _conv(Image3Dcomplex  ,Image3Dlinear<int>)     
00152                                                                                             
00153         _conv(Image3Dlinear<int>  ,Image3Df        )    
00154         _conv(Image3Dlinear<int>  ,Image3Dd        )     
00155         _conv(Image3Dlinear<int>  ,Mask3D          )     
00156         _conv(Image3Dlinear<int>  ,Image3Dcomplex  )     
00157         _conv(Image3Dlinear<int>  ,Image3Dlinear<int>) 
00158         _conv(Image3Dlinear<int>  ,Image3Dlinear<short int>)
00159 
00160         _conv(Image3Dlinear<short int>  ,Image3Df        )    
00161         _conv(Image3Dlinear<short int>  ,Image3Dd        )     
00162         _conv(Image3Dlinear<short int>  ,Mask3D          )     
00163         _conv(Image3Dlinear<short int>  ,Image3Dcomplex  )     
00164         _conv(Image3Dlinear<short int>  ,Image3Dlinear<int>) 
00165 
00166         _conv(Image3Dcomplexd  ,Image3Dcomplexf  )     
00167         _conv(Image3Dcomplexf  ,Image3Dcomplexd  )     
00168 
00169         ThrowError("ImageTypeConversion did not find instance for converting types:\"%s\" to \"%s\"",
00170                    type.c_str(),type2.c_str());
00171         return false;
00172     }
00173     if(procName=="FFT")
00174     {
00175         if(args.size()!=3){ThrowError("FFT: wrong number of args");}
00176         // source image type is determined from source image
00177         string type;
00178         if(alternateArgs.size()>0 && alternateArgs[0].IsSet())
00179         {
00180             type=alternateArgs[0].Get<Image3D *>()->GetTypeName();
00181         }
00182         else{type=Container3D_ReadImageType(args[0]);}
00183 
00184         // result image type is determined either from source image
00185         // or from alternate arg result image
00186         string type2=TypeName<Image3Dcomplexf>();
00187         if(type==TypeName<Image3Dcomplexd>() || type==TypeName<Image3Dd>())
00188         {
00189             type2=TypeName<Image3Dcomplexd>();
00190         }
00191         if(alternateArgs.size()>1 && alternateArgs[1].IsSet())
00192         {
00193             type=alternateArgs[1].Get<Image3D *>()->GetTypeName();
00194         }
00195         mprintf("FFT:\"%s\" to \"%s\"\n",type,type2);
00196 
00197 #define _fft0(ImageType,TypeName,ImageType2,TypeName2) if(type==TypeName && type2==TypeName2 ) \
00198 { \
00199     ImageType & arg0 =*StringOrAlternateInputArg<ImageType >( args[0] ,alternateArgs,0 ); \
00200     ImageType2& arg1 =*CreateOutputArg<ImageType2 >(alternateArgs,1 ); \
00201     IP3D::FFT(arg0,arg1); \
00202     ImProcOutputArg<ImageType2 >(arg1,args[1],alternateArgs,1); \
00203     CleanupArg< ImageType  >(arg0,alternateArgs,0); \
00204     CleanupArg< ImageType2 >(arg1,alternateArgs,1); \
00205     return true; \
00206 }
00207 #define _fft(ImageType,ImageType2) _fft0(ImageType,TypeName<ImageType>(),ImageType2,TypeName<ImageType2>())
00208 
00209         _fft(Image3Df         ,Image3Dcomplexf   )
00210         _fft(Image3Dcomplexf  ,Image3Dcomplexf   )
00211         _fft(Image3Dd         ,Image3Dcomplexd   )
00212         _fft(Image3Dcomplexd  ,Image3Dcomplexd   )
00213 
00214         ThrowError("FFT did not find instance for fft \"%s\" to \"%s\"",
00215                    type.c_str(),type2.c_str());
00216         return false;
00217 #undef _fft0
00218 #undef _fft
00219     }
00220     if(procName=="FFTInverse")
00221     {
00222         if(args.size()!=4){ThrowError("FFTInverse: wrong number of args");}
00223         // source image type is determined from source image
00224         string type;
00225         if(alternateArgs.size()>0 && alternateArgs[0].IsSet())
00226         {
00227             type=alternateArgs[0].Get<Image3D *>()->GetTypeName();
00228         }
00229         else{type=Container3D_ReadImageType(args[0]);}
00230 
00231         // result image type is determined either from source image
00232         // or from alternate arg result image
00233         string type2=TypeName<Image3Df>();
00234         if(type==TypeName<Image3Dcomplexd>())
00235         {
00236             type2=TypeName<Image3Dd>();
00237         }
00238         if(alternateArgs.size()>1 && alternateArgs[1].IsSet())
00239         {
00240             type=alternateArgs[1].Get<Image3D *>()->GetTypeName();
00241         }
00242         mprintf("FFTInverse:\"%s\" to \"%s\"\n",type,type2);
00243 
00244 #define _fftinv0(ImageType,TypeName,ImageType2,TypeName2) if(type==TypeName && type2==TypeName2 ) \
00245 { \
00246     ImageType & arg0 =*StringOrAlternateInputArg<ImageType >( args[0] ,alternateArgs,0 ); \
00247     ImageType2& arg1 =*CreateOutputArg<ImageType2 >(alternateArgs,1 ); \
00248     IP3D::FFTInverse(arg0,arg1); \
00249     ImProcOutputArg<ImageType2 >(arg1,args[1],alternateArgs,1); \
00250     CleanupArg< ImageType  >(arg0,alternateArgs,0); \
00251     CleanupArg< ImageType2 >(arg1,alternateArgs,1); \
00252     return true; \
00253 }
00254 #define _fftinv1(ImageType,ImageType2) _fftinv0(ImageType,TypeName<ImageType>(),ImageType2,TypeName<ImageType2>())
00255 
00256         _fftinv1(Image3Dcomplexf ,Image3Df           )
00257         _fftinv1(Image3Dcomplexf ,Image3Dcomplexf    )
00258         _fftinv1(Image3Dcomplexd ,Image3Dd           )
00259         _fftinv1(Image3Dcomplexd ,Image3Dcomplexd    )
00260 
00261         ThrowError("FFTInverse did not find instance for inverse fft \"%s\" to \"%s\"",
00262                    type.c_str(),type2.c_str());
00263         return false;
00264     }
00265 
00266     return false;
00267 }
00268 
00269 
00270 void 
00271 CallImLib3DImageProcessorByName(const string &name,const vector<string> &args,string typeName,vector<TypeSafeGenericPointer> alternateArgs)
00272 {
00273     if(!CustomImProcCalls(name,args,alternateArgs))
00274     {
00275         StandardImProcCalls(name,args,typeName,alternateArgs);
00276     }
00277 }

Generated on Fri Jun 17 13:35:56 2005 for ImLib3D by  doxygen 1.4.2