8 #include <boost/range/iterator_range.hpp> 9 #include <boost/foreach.hpp> 10 #include <boost/filesystem.hpp> 36 HDF5IO hdf5(input_filename,
false);
37 std::vector<size_t> dim;
40 std::string groupname =
"raw/spectral/position_" + position_code;
41 std::string datasetname =
"spectral";
42 boost::shared_array<uint16_t> spectrals = hdf5.
getArray<uint16_t>(groupname, datasetname, dim);
46 size_t num_rows = dim[1];
47 size_t num_cols = dim[2];
50 if(num_channels < max_channel)
52 std::cout <<
"The dataset has only " << num_channels <<
" channels. Using this as upper boundary." << std::endl;
57 GeoTIFFIO gtifio(output_filename, num_cols, num_rows, num_channels);
61 for(
size_t channel = 0; channel <
num_channels; channel++)
63 cv::Mat *mat =
new cv::Mat(num_rows, num_cols, CV_16UC1);
64 for(
size_t row = 0; row < num_rows; row++)
66 for(
size_t col = 0; col < num_cols; col++)
68 mat->at<uint16_t>(row, col) = spectrals.get()[(channel +
min_channel) * num_cols * num_rows + row * num_cols + col];
72 int ret = gtifio.
writeBand(mat, channel + 1);
88 boost::filesystem::path input_filename(options.
getH5File());
89 std::string input_extension = boost::filesystem::extension(input_filename);
91 boost::filesystem::path output_filename(options.
getGTIFFFile());
92 std::string output_extension = boost::filesystem::extension(output_filename);
101 boost::filesystem::path output_dir = output_filename.parent_path();
102 if (output_dir !=
"" && !boost::filesystem::exists(output_dir))
104 boost::filesystem::create_directory(output_dir);
107 std::cout <<
"Starting conversion..." << std::endl;
110 std::cout <<
"An Error occurred during conversion." << std::endl;
const kaboom::Options * options
int processConversion(std::string input_filename, std::string position_code, std::string output_filename, size_t min_channel, size_t max_channel)
Extraction of radiometric data from a given HDF5 file into a new GeoTIFF file in (optionally) given o...
string getPositionCode() const
size_t getMaxChannel() const
int main(int argc, char **argv)
class providing and encapsulating GDAL GeoTIFF I/O functions
boost::shared_array< T > getArray(std::string groupName, std::string datasetName, unsigned int &size)
size_t getMinChannel() const
string getGTIFFFile() const
int writeBand(cv::Mat *mat, int band)
Writing given band into open GeoTIFF file.
A class to parse the program options for the extraction of radiometric data from a HDF5 dataset...