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];
52 std::cout <<
"The dataset has only " <<
num_channels <<
" channels. Using this as upper boundary." << std::endl;
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);
97 std::string position_code =
options.getPositionCode();
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;