Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include "mmn_order_cost.h"
00007 #include <vcl_vector.h>
00008
00009
00010
00011
00012
00013 void mmn_get_order(unsigned v0, unsigned v1, unsigned v2,
00014 unsigned& i0, unsigned& i1, unsigned& i2)
00015 {
00016 if (v0<v1)
00017 {
00018 if (v1<v2) { i0=0; i1=1; i2=2; return; }
00019 if (v2<v0) { i0=1; i1=2; i2=0; return; }
00020 i0=0; i1=2; i2=1; return;
00021 }
00022 if (v0<v2) { i0=1; i1=0; i2=2; return; }
00023 if (v2<v1) { i0=2; i1=1; i2=0; return; }
00024 i0=2; i1=0; i2=1; return;
00025 }
00026
00027
00028
00029 void mmn_get_rank(unsigned v0, unsigned v1, unsigned v2,
00030 unsigned& i0, unsigned& i1, unsigned& i2)
00031 {
00032 if (v0<v1)
00033 {
00034 if (v1<v2) { i0=0; i1=1; i2=2; return; }
00035 if (v2<v0) { i0=2; i1=0; i2=1; return; }
00036 i0=0; i1=2; i2=1; return;
00037 }
00038 if (v0<v2) { i0=1; i1=0; i2=2; return; }
00039 if (v2<v1) { i0=2; i1=1; i2=0; return; }
00040 i0=1; i1=2; i2=0; return;
00041 }
00042
00043
00044
00045
00046
00047
00048
00049
00050 vil_image_view<double> mmn_order_cost(const vil_image_view<double>& c,
00051 unsigned v1, unsigned v2, unsigned v3)
00052 {
00053 unsigned i1,i2,i3;
00054 mmn_get_rank(v1,v2,v3, i1,i2,i3);
00055 vcl_vector<unsigned> n(3);
00056 n[0]=c.ni(); n[1]=c.nj(); n[2]=c.nplanes();
00057 vcl_vector<vcl_ptrdiff_t> step(3);
00058 step[0]=c.istep(); step[1]=c.jstep(); step[2]=c.planestep();
00059
00060 return vil_image_view<double>(c.top_left_ptr(),
00061 n[i1],n[i2],n[i3],
00062 step[i1],step[i2],step[i3]);
00063 }
00064
00065
00066
00067
00068
00069
00070 vil_image_view<double> mmn_unorder_cost(const vil_image_view<double>& c,
00071 unsigned v1, unsigned v2, unsigned v3)
00072 {
00073 unsigned i1,i2,i3;
00074 mmn_get_order(v1,v2,v3, i1,i2,i3);
00075 vcl_vector<unsigned> n(3);
00076 n[0]=c.ni(); n[1]=c.nj(); n[2]=c.nplanes();
00077 vcl_vector<vcl_ptrdiff_t> step(3);
00078 step[0]=c.istep(); step[1]=c.jstep(); step[2]=c.planestep();
00079
00080 return vil_image_view<double>(c.top_left_ptr(),
00081 n[i1],n[i2],n[i3],
00082 step[i1],step[i2],step[i3]);
00083 }