Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include "vimt_load.h"
00008 #include <vil/vil_property.h>
00009
00010
00011
00012 vimt_transform_2d vimt_load_transform(const vil_image_resource_sptr& im,
00013 float unit_scaling)
00014 {
00015 float pixSize[2] = { 1.0f, 1.0f };
00016 bool valid_pixSize = im->get_property(vil_property_pixel_size, pixSize);
00017
00018 float offset[2] = { 0.0f, 0.0f};
00019 bool valid_offset = im->get_property(vil_property_offset, offset);
00020 if (!valid_offset)
00021 {
00022 offset[0]=offset[1]=0.0f;
00023 }
00024
00025 for(unsigned i=0; i<2;i++)
00026 {
00027 pixSize[i]*= unit_scaling;
00028 }
00029
00030 vimt_transform_2d tx;
00031 if (valid_pixSize)
00032 {
00033 tx.set_zoom_only(1.0/pixSize[0], 1.0/pixSize[1],
00034 offset[0], offset[1]);
00035 }
00036 else if( valid_offset)
00037 {
00038 tx.set_translation(offset[0], offset[1]);
00039 }
00040 else
00041 {
00042
00043 tx.set_identity();
00044 }
00045
00046 return tx;
00047 }
00048
00049
00050
00051
00052
00053
00054 vimt_transform_2d vimt_load_transform_right_hand(const vil_image_resource_sptr& im,
00055 float unit_scaling)
00056 {
00057 float pixSize[2] = { 1.0f, 1.0f };
00058 bool valid_pixSize = im->get_property(vil_property_pixel_size, pixSize);
00059 if (!valid_pixSize)
00060 {
00061 pixSize[0] = 1.0f;
00062 pixSize[1] = 1.0f;
00063 }
00064
00065 float offset[2] = { 0.0f, 0.0f};
00066 bool valid_offset = im->get_property(vil_property_offset, offset);
00067 if (!valid_offset)
00068 {
00069 offset[0] = offset[1] = 0.0f;
00070 }
00071
00072 for(unsigned i=0; i<2; i++)
00073 {
00074 pixSize[i] *= unit_scaling;
00075 }
00076
00077
00078 vimt_transform_2d tx;
00079 tx.set_zoom_only(1.0/pixSize[0], -1.0/pixSize[1],
00080 offset[0], -offset[1]);
00081
00082 return tx;
00083 }
00084