Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 93 lines (71 sloc) 2.426 kb
6678052 @zmoratto Still working the repo organization
zmoratto authored
1 // __BEGIN_LICENSE__
e958375 @zmoratto Run relicense
zmoratto authored
2 // Copyright (C) 2006-2011 United States Government as represented by
19bd812 @zmoratto Update licensing
zmoratto authored
3 // the Administrator of the National Aeronautics and Space Administration.
4 // All Rights Reserved.
6678052 @zmoratto Still working the repo organization
zmoratto authored
5 // __END_LICENSE__
6
19bd812 @zmoratto Update licensing
zmoratto authored
7
6678052 @zmoratto Still working the repo organization
zmoratto authored
8 /// \file nurbs.cc
9 ///
10
11 #ifdef _MSC_VER
12 #pragma warning(disable:4244)
13 #pragma warning(disable:4267)
14 #pragma warning(disable:4996)
15 #endif
16
17 #include <boost/program_options.hpp>
18 namespace po = boost::program_options;
19
20 #include <vw/vw.h>
21 using namespace vw;
22
23 #include "SurfaceNURBS.h"
24
25 using namespace vw;
26
27 int main( int argc, char *argv[] ) {
28
29 std::string input_file_name, output_file_name;
30 unsigned int num_iterations;
31
32 po::options_description desc("Options");
33 desc.add_options()
34 ("help", "Display this help message")
35 ("input-file", po::value<std::string>(&input_file_name), "Explicitly specify the input file")
36 ("output-file,o", po::value<std::string>(&output_file_name)->default_value("output.png"), "Specify the output file")
37 ("iterations,i", po::value<unsigned int>(&num_iterations), "The number of iterations to perform")
38 ("holes-only,h", "Only fill areas with no pixels (zero alpha) with interpolated data.")
39 ("normalize", "Normalize the output image")
40 ("verbose", "Verbose output");
41 po::positional_options_description p;
42 p.add("input-file", 1);
43
44 po::variables_map vm;
45 po::store( po::command_line_parser( argc, argv ).options(desc).positional(p).run(), vm );
46 po::notify( vm );
47
48 if( vm.count("help") ) {
49 std::cout << desc << std::endl;
50 return 1;
51 }
52
53 if( vm.count("input-file") != 1 ) {
54 std::cout << "Error: Must specify exactly one input file!" << std::endl;
55 std::cout << desc << std::endl;
56 return 1;
57 }
58
59 if( vm.count("verbose") ) {
60 set_debug_level(VerboseDebugMessage);
61 }
62
63 try {
64 ImageView<PixelGrayA<float> > image;
65 read_image( image, input_file_name );
66
67 ImageView<PixelGrayA<float> > output;
68 output = MBASurfaceNURBS(image, num_iterations);
69
70 if (vm.count("holes-only") ) {
71 for (int j = 0; j < image.rows(); ++j) {
72 for (int i = 0; i < image.cols(); ++i) {
73 if (image(i,j).a() != 0) {
74 output(i,j) = image(i,j);
75 }
76 }
77 }
78 }
79
80 if( vm.count("normalize") ) {
81 output = normalize(output);
82 }
83
84 write_image( output_file_name, output );
85 }
86 catch( Exception& e ) {
87 std::cerr << "Error: " << e.what() << std::endl;
88 }
89
90 return 0;
91 }
92
Something went wrong with that request. Please try again.