Skip to content
Browse files

added geodiff tool

  • Loading branch information...
1 parent 88aae7a commit a11702a662eb8808412a683955b5a4d60e2d544e @khusmann khusmann committed Dec 2, 2009
Showing with 110 additions and 1 deletion.
  1. +5 −1 configure.ac
  2. +6 −0 src/asp/Tools/Makefile.am
  3. +99 −0 src/asp/Tools/geodiff.cc
View
6 configure.ac
@@ -282,9 +282,9 @@ AX_APP(ISISADJUST, [src/asp/Tools], yes, [CORE ISISIO])
AX_APP(RESULTS, [src/asp/Tools], yes, [ISISIO])
AX_APP(RECONSTRUCT, [src/asp/Tools], no, [BOOST_ALL VW VW_CARTOGRAPHY])
AX_APP(ALIGNDEM, [src/asp/Tools], yes, [BOOST_COMMON VW VW_CARTOGRAPHY VW_INTEREST_POINT])
+AX_APP(GEODIFF, [src/asp/Tools], yes, [BOOST_COMMON VW VW_CARTOGRAPHY ISISIO])
AX_APP(DEMPROFILE, [src/asp/Tools], yes, [VW VW_CARTOGRAPHY BOOST_COMMON])
-
# These are here (instead of inside the APP macro where they belong)
# for backwards compatability with older versions of automake.
AM_CONDITIONAL(MAKE_MODULE_CORE, [test "$MAKE_MODULE_CORE" = "yes"])
@@ -307,7 +307,11 @@ AM_CONDITIONAL(MAKE_APP_ISISADJUST, [test "$MAKE_APP_ISISADJUST" = "yes"])
AM_CONDITIONAL(MAKE_APP_RESULTS, [test "$MAKE_APP_RESULTS" = "yes"])
AM_CONDITIONAL(MAKE_APP_RECONSTRUCT, [test "$MAKE_APP_RECONSTRUCT" = "yes"])
AM_CONDITIONAL(MAKE_APP_ALIGNDEM, [test "$MAKE_APP_ALIGNDEM" = "yes"])
+<<<<<<< .mine
+AM_CONDITIONAL(MAKE_APP_GEODIFF, [test "$MAKE_APP_GEODIFF" = "yes"])
+=======
AM_CONDITIONAL(MAKE_APP_DEMPROFILE, [test "$MAKE_APP_DEMPROFILE" = "yes"])
+>>>>>>> .r1053
##################################################
# final processing
View
6 src/asp/Tools/Makefile.am
@@ -95,6 +95,12 @@ if MAKE_APP_ALIGNDEM
aligndem_LDADD = $(APP_ALIGNDEM_LIBS)
endif
+if MAKE_APP_GEODIFF
+ bin_PROGRAMS += geodiff
+ geodiff_SOURCES = geodiff.cc
+ geodiff_LDADD = $(APP_GEODIFF_LIBS)
+endif
+
if MAKE_APP_DEMPROFILE
bin_PROGRAMS += dem_profile
dem_profile_SOURCES = dem_profile.cc
View
99 src/asp/Tools/geodiff.cc
@@ -0,0 +1,99 @@
+// __BEGIN_LICENSE__
+// Copyright (C) 2006-2009 United States Government as represented by
+// the Administrator of the National Aeronautics and Space Administration.
+// All Rights Reserved.
+// __END_LICENSE__
+
+#include <boost/program_options.hpp>
+namespace po = boost::program_options;
+
+#include <boost/filesystem.hpp>
+namespace fs = boost::filesystem;
+
+#include <vw/FileIO.h>
+#include <vw/Image.h>
+#include <vw/Cartography.h>
+#include <vw/InterestPoint.h>
+#include <vw/Math.h>
+#include <vw/Mosaic/ImageComposite.h>
+
+#include <asp/IsisIO/DiskImageResourceIsis.h>
+
+using std::cout;
+using std::endl;
+using std::string;
+
+using namespace vw;
+using namespace vw::cartography;
+using namespace vw::ip;
+
+// Allows FileIO to correctly read/write these pixel types
+namespace vw {
+ template<> struct PixelFormatID<Vector3> { static const PixelFormatEnum value = VW_PIXEL_GENERIC_3_CHANNEL; };
+}
+
+int main( int argc, char *argv[] ) {
+ string dem1_name, dem2_name, output_prefix;
+ float default_value;
+
+ po::options_description desc("Options");
+ desc.add_options()
+ ("help,h", "Display this help message")
+ ("default-value", po::value<float>(&default_value), "The value of missing pixels in the first dem")
+ ("dem1", po::value<string>(&dem1_name), "Explicitly specify the first dem")
+ ("dem2", po::value<string>(&dem2_name), "Explicitly specify the second dem")
+ ("output-prefix,o", po::value<string>(&output_prefix), "Specify the output prefix")
+ ;
+
+ po::positional_options_description p;
+ p.add("dem1", 1);
+ p.add("dem2", 1);
+
+ po::variables_map vm;
+ po::store( po::command_line_parser( argc, argv ).options(desc).positional(p).run(), vm );
+ po::notify( vm );
+
+ if( vm.count("help") ) {
+ cout << desc << endl;
+ return 1;
+ }
+
+ if( vm.count("dem1") != 1 || vm.count("dem2") != 1 ||
+ vm.count("default-value") != 1) {
+ cout << "Usage: " << argv[0] << "dem1.tif dem2.cub --default-value #" << endl;
+ cout << desc << endl;
+ return 1;
+ }
+
+ if (vm.count("output-prefix") != 1) {
+ fs::path dem1_path(dem1_name), dem2_path(dem2_name);
+ output_prefix = (dem1_path.branch_path() / (fs::basename(dem1_path) + "__" + fs::basename(dem2_path))).string();
+ }
+
+ DiskImageResourceGDAL dem1_rsrc(dem1_name), dem2_rsrc(dem2_name);
+
+ DiskImageView<double> dem1_dmg(dem1_name), dem2_dmg(dem2_name);
+
+ DiskImageResourceIsis dem2_isis_rsrc(dem2_name);
+
+ GeoReference dem1_georef, dem2_georef;
+ read_georeference(dem1_georef, dem1_rsrc);
+ read_georeference(dem2_georef, dem2_rsrc);
+
+ // dem2_reproj is calculated in the event that two dem's datums are
+ // different (for example, USGS uses 3396190m for the radius of Mars,
+ // while we use 3396000m)
+ ImageViewRef<double> dem2_reproj = select_channel(reproject_point_image(dem_to_point_image(dem2_dmg, dem2_georef), dem2_georef, dem1_georef), 2);
+ ImageViewRef<double> dem2_trans = crop(geo_transform(dem2_reproj, dem2_georef, dem1_georef), 0, 0, dem1_dmg.cols(), dem1_dmg.rows());
+
+ ImageViewRef<PixelMask<double> > diff_masked = copy_mask(dem1_dmg - dem2_trans, create_mask(dem1_dmg, default_value));
+ ImageViewRef<double> diff = apply_mask(diff_masked, default_value);
+
+ DiskImageResourceGDAL output_rsrc(output_prefix + "-diff.tif", diff.format(),
+ Vector2i(vw_settings().default_tile_size(),
+ vw_settings().default_tile_size()));
+ write_georeference(output_rsrc, dem1_georef);
+ block_write_image(output_rsrc, diff, TerminalProgressCallback(InfoMessage, "\t--> Differencing: "));
+
+ return 0;
+}

0 comments on commit a11702a

Please sign in to comment.
Something went wrong with that request. Please try again.