contrib/mul/mbl/tools/mbl_mask_on_mask.cxx
Go to the documentation of this file.
00001 /*
00002  * Tool to replace 'true' values in B with values taken from A.
00003  *  Size of A must match 'true' count in B
00004  */
00005 
00006 #include <vcl_string.h>
00007 #include <vcl_exception.h>
00008 #include <vcl_iostream.h>
00009 #include <vul/vul_arg.h>
00010 #include <mbl/mbl_mask.h>
00011 
00012 int main(int argc, char **argv)
00013 {
00014   vul_arg<vcl_string> maskA_filename(0,"Filename of mask A");
00015   vul_arg<vcl_string> maskB_filename(0,"Filename of mask B");
00016   vul_arg<vcl_string> maskout_filename(0,"Filename of the output mask");
00017   vul_arg_parse(argc, argv);
00018 
00019   mbl_mask maskA, maskB;
00020   mbl_load_mask(maskA, maskA_filename().c_str());
00021   mbl_load_mask(maskB, maskB_filename().c_str());
00022   
00023   try { mbl_mask_on_mask(maskA, maskB); }
00024   catch (vcl_exception & e)
00025   {
00026     vcl_cout << "An error occurred while applying the mask.\n" << e.what() << vcl_endl;
00027     return 1;
00028   }
00029   catch (...)
00030   {
00031     vcl_cout << "An unknown error occurred while applying the mask." << vcl_endl;
00032     return 1;
00033   }
00034 
00035   mbl_save_mask(maskB, maskout_filename().c_str());
00036 }