00001
00002 #ifndef vimt3d_slice_h_
00003 #define vimt3d_slice_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011 #include <vil/vil_image_view.h>
00012 #include <vil3d/vil3d_slice.h>
00013 #include <vimt/vimt_image_2d_of.h>
00014 #include <vimt3d/vimt3d_image_3d_of.h>
00015 #include <vimt3d/vimt3d_transform_3d.h>
00016 #include <vimt/vimt_transform_2d.h>
00017 #include <vcl_cassert.h>
00018
00019
00020
00021
00022
00023 template<class T>
00024 inline vimt_image_2d_of<T> vimt3d_slice_ji(const vimt3d_image_3d_of<T> &im, unsigned k)
00025 {
00026
00027 assert(k<im.image().nk());
00028
00029
00030 vil_image_view<T> imview = vil3d_slice_ji(im.image(),k);
00031
00032
00033 vimt3d_transform_3d trans3 = im.world2im();
00034 assert(trans3.is_identity() ||
00035 trans3.form()==vimt3d_transform_3d::Translation ||
00036 trans3.form()==vimt3d_transform_3d::ZoomOnly);
00037
00038
00039 vimt_transform_2d trans2;
00040 trans2.set_zoom_only(trans3.matrix()(1,1),trans3.matrix()(0,0),trans3.matrix()(1,3),trans3.matrix()(0,3));
00041
00042 return vimt_image_2d_of<T>(imview,trans2);
00043 }
00044
00045
00046
00047
00048
00049 template<class T>
00050 inline vimt_image_2d_of<T> vimt3d_slice_ij(const vimt3d_image_3d_of<T> &im, unsigned k)
00051 {
00052
00053 assert(k<im.image().nk());
00054
00055
00056 vil_image_view<T> imview = vil3d_slice_ij(im.image(),k);
00057
00058
00059 vimt3d_transform_3d trans3 = im.world2im();
00060 assert(trans3.is_identity() ||
00061 trans3.form()==vimt3d_transform_3d::Translation ||
00062 trans3.form()==vimt3d_transform_3d::ZoomOnly);
00063
00064
00065 vimt_transform_2d trans2;
00066 trans2.set_zoom_only(trans3.matrix()(0,0),trans3.matrix()(1,1),trans3.matrix()(0,3),trans3.matrix()(1,3));
00067
00068 return vimt_image_2d_of<T>(imview,trans2);
00069 }
00070
00071
00072
00073
00074
00075 template<class T>
00076 inline vimt_image_2d_of<T> vimt3d_slice_jk(const vimt3d_image_3d_of<T> &im, unsigned i)
00077 {
00078
00079 assert(i<im.image().ni());
00080
00081
00082 vil_image_view<T> imview = vil3d_slice_jk(im.image(),i);
00083
00084
00085 vimt3d_transform_3d trans3 = im.world2im();
00086 assert(trans3.is_identity() ||
00087 trans3.form()==vimt3d_transform_3d::Translation ||
00088 trans3.form()==vimt3d_transform_3d::ZoomOnly);
00089
00090
00091 vimt_transform_2d trans2;
00092 trans2.set_zoom_only(trans3.matrix()(1,1),trans3.matrix()(2,2),trans3.matrix()(1,3),trans3.matrix()(2,3));
00093
00094 return vimt_image_2d_of<T>(imview,trans2);
00095 }
00096
00097
00098
00099
00100
00101 template<class T>
00102 inline vimt_image_2d_of<T> vimt3d_slice_kj(const vimt3d_image_3d_of<T> &im, unsigned i)
00103 {
00104
00105 assert(i<im.image().ni());
00106
00107
00108 vil_image_view<T> imview = vil3d_slice_kj(im.image(),i);
00109
00110
00111 vimt3d_transform_3d trans3 = im.world2im();
00112 assert(trans3.is_identity() ||
00113 trans3.form()==vimt3d_transform_3d::Translation ||
00114 trans3.form()==vimt3d_transform_3d::ZoomOnly);
00115
00116
00117 vimt_transform_2d trans2;
00118 trans2.set_zoom_only(trans3.matrix()(2,2),trans3.matrix()(1,1),trans3.matrix()(2,3),trans3.matrix()(1,3));
00119
00120 return vimt_image_2d_of<T>(imview,trans2);
00121 }
00122
00123
00124
00125
00126
00127 template<class T>
00128 inline vimt_image_2d_of<T> vimt3d_slice_ki(const vimt3d_image_3d_of<T> &im, unsigned j)
00129 {
00130
00131 assert(j<im.image().nj());
00132
00133
00134 vil_image_view<T> imview = vil3d_slice_ki(im.image(),j);
00135
00136
00137 vimt3d_transform_3d trans3 = im.world2im();
00138 assert(trans3.is_identity() ||
00139 trans3.form()==vimt3d_transform_3d::Translation ||
00140 trans3.form()==vimt3d_transform_3d::ZoomOnly);
00141
00142
00143 vimt_transform_2d trans2;
00144 trans2.set_zoom_only(trans3.matrix()(2,2),trans3.matrix()(0,0),trans3.matrix()(2,3),trans3.matrix()(0,3));
00145
00146 return vimt_image_2d_of<T>(imview,trans2);
00147 }
00148
00149
00150
00151
00152
00153 template<class T>
00154 inline vimt_image_2d_of<T> vimt3d_slice_ik(const vimt3d_image_3d_of<T> &im, unsigned j)
00155 {
00156
00157 assert(j<im.image().nj());
00158
00159
00160 vil_image_view<T> imview = vil3d_slice_ik(im.image(),j);
00161
00162
00163 vimt3d_transform_3d trans3 = im.world2im();
00164 assert(trans3.is_identity() ||
00165 trans3.form()==vimt3d_transform_3d::Translation ||
00166 trans3.form()==vimt3d_transform_3d::ZoomOnly);
00167
00168
00169 vimt_transform_2d trans2;
00170 trans2.set_zoom_only(trans3.matrix()(0,0),trans3.matrix()(2,2),trans3.matrix()(0,3),trans3.matrix()(2,3));
00171
00172 return vimt_image_2d_of<T>(imview,trans2);
00173 }
00174
00175 #endif // vimt3d_slice_h_