1 //This is brl/bseg/bvxm/pro/processes/bvxm_create_mog_image_process.h
2 #ifndef bvxm_create_mog_image_process_h_
3 #define bvxm_create_mog_image_process_h_
4 //:
5 // \file
6 // \brief A process to create a Mixture of Gaussian (MOG) image of a voxel world from a given view point
7 // MOG is the 2D appearance model (background model) of the 3D scene
8 // the view point is given by the input camera
9 // the size of the output MOG is given by the input ni and nj
10 //
11 // \author Gamze Tunali
12 // \date Feb. 10, 2009
13 // \verbatim
14 // Modifications
15 // Ozge C Ozcanli - Feb 10, 2009 - change input/output signature
16 // Peter Vanroose - Jul 10, 2009 - split into .h and .cxx
17 // \endverbatim
18
19 #include <iostream>
20 #include <bprb/bprb_func_process.h>
21
22 #include <bvxm/bvxm_image_metadata.h>
23 #include <bvxm/bvxm_voxel_traits.h>
24 #include <bvxm/bvxm_voxel_world.h>
25 #include <bvxm/grid/bvxm_voxel_slab_base.h>
26
27 #ifdef _MSC_VER
28 # include <vcl_msvc_warnings.h>
29 #endif
30
31 bool bvxm_create_mog_image_process_cons(bprb_func_process& pro);
32
33 bool bvxm_create_mog_image_process(bprb_func_process& pro);
34
35 template <bvxm_voxel_type APM_T>
mix_gaussian(bvxm_voxel_world_sptr world,unsigned mog_creation_method_,unsigned bin_index,unsigned scale_index,unsigned n_samples,bvxm_image_metadata observation,bvxm_voxel_slab_base_sptr & mog_image)36 bool mix_gaussian(bvxm_voxel_world_sptr world,
37 unsigned mog_creation_method_,
38 unsigned bin_index, unsigned scale_index,unsigned n_samples,
39 bvxm_image_metadata observation,
40 bvxm_voxel_slab_base_sptr& mog_image)
41 {
42 typedef typename bvxm_voxel_traits<APM_T>::obs_datatype obs_datatype;
43
44 bool done = false;
45 switch (mog_creation_method_)
46 {
47 case bvxm_mog_image_creation_methods::MOST_PROBABLE_MODE:
48 done = world->mog_most_probable_image<APM_T>(observation, mog_image, bin_index,scale_index); break;
49 case bvxm_mog_image_creation_methods::EXPECTED_VALUE:
50 done = world->mixture_of_gaussians_image<APM_T>(observation, mog_image, bin_index,scale_index); break;
51 case bvxm_mog_image_creation_methods::SAMPLING:
52 done = world->mog_image_with_random_order_sampling<APM_T>(observation, n_samples, mog_image, bin_index, scale_index);
53 break;
54 default:
55 std::cout << "In bvxm_create_mog_image_process::mix_gaussian() - unrecognized option: " << mog_creation_method_ << " to create mog image\n";
56 return false;
57 }
58 if (!done)
59 std::cout << "In bvxm_create_mog_image_process::mix_gaussian() - problems in creating mixture of gaussian image!\n";
60
61 return done;
62 }
63
64 #endif // bvxm_create_mog_image_process_h_
65