-
Christof Kaufmann authored
Parallelizer may not be used anymore with STARFM and ESTARFM. They are not parallelized using OpenMP directly, which is more efficient and easier to use. This led to some documentation changes, since the mainpage showed how to parallelize STARFM. Actually all included image fusion algorithms are now parallelized internally. So Parallelizer is left for custom fusors only and the documentation shows how to do that now.
Christof Kaufmann authoredParallelizer may not be used anymore with STARFM and ESTARFM. They are not parallelized using OpenMP directly, which is more efficient and easier to use. This led to some documentation changes, since the mainpage showed how to parallelize STARFM. Actually all included image fusion algorithms are now parallelized internally. So Parallelizer is left for custom fusors only and the documentation shows how to do that now.
starfm.cpp 20.68 KiB
#include "logging.h"
#include "starfm.h"
#include <math.h>
namespace imagefusion {
void StarfmFusor::processOptions(Options const& o) {
SPDLOG_SINGLE_TRACE("Processing new StarfmOptions");
options_type newOpts = dynamic_cast<options_type const&>(o);
if (!newOpts.isDate1Set)
IF_THROW_EXCEPTION(runtime_error("No input pair date has been set. At least one pair date is required for prediction"));
if (newOpts.highTag == newOpts.lowTag)
IF_THROW_EXCEPTION(invalid_argument_error("The resolution tags for the input pairs have to be different. You chose '" + newOpts.highTag + "' for both."));
opt = newOpts;
}
void StarfmFusor::checkInputImages(ConstImage const& validMask, ConstImage const& predMask, int date2) const {
SPDLOG_SINGLE_TRACE("Checking input images");
if (!imgs)
IF_THROW_EXCEPTION(logic_error("No MultiResImage object stored in StarfmFusor while predicting. This looks like a programming error."));
bool isDoublePairMode = opt.isDate3Set;
std::string strH1 = "High resolution image (tag: " + opt.getHighResTag() + ") at date 1 (date: " + std::to_string(opt.date1) + ")";
std::string strL1 = "Low resolution image (tag: " + opt.getLowResTag() + ") at date 1 (date: " + std::to_string(opt.date1) + ")";
std::string strL2 = "Low resolution image (tag: " + opt.getLowResTag() + ") at date 2 (date: " + std::to_string( date2) + ")";
std::string strH3 = isDoublePairMode ? "High resolution image (tag: " + opt.getHighResTag() + ") at date 3 (date: " + std::to_string(opt.date3) + ")" : "";
std::string strL3 = isDoublePairMode ? "Low resolution image (tag: " + opt.getLowResTag() + ") at date 3 (date: " + std::to_string(opt.date3) + ")" : "";
if (!imgs->has(opt.getHighResTag(), opt.date1) || !imgs->has(opt.getLowResTag(), opt.date1) || !imgs->has(opt.getLowResTag(), date2) ||
(isDoublePairMode && (!imgs->has(opt.getHighResTag(), opt.date3) || !imgs->has(opt.getLowResTag(), opt.date3))))
{
IF_THROW_EXCEPTION(not_found_error("Not all required images are available. For STARFM you need to provide:\n"
" * " + strH1 + " [" + (imgs->has(opt.getHighResTag(), opt.date1) ? "" : "NOT ") + "available]\n" +
" * " + strL1 + " [" + (imgs->has(opt.getLowResTag(), opt.date1) ? "" : "NOT ") + "available]\n" +
" * " + strL2 + " [" + (imgs->has(opt.getLowResTag(), date2) ? "" : "NOT ") + "available]\n" +
(isDoublePairMode ? " * " + strH3 + " [" + (imgs->has(opt.getHighResTag(), opt.date3) ? "" : "NOT ") + "available]\n" +
" * " + strL3 + " [" + (imgs->has(opt.getLowResTag(), opt.date3) ? "" : "NOT ") + "available]\n" : "")));
}
Type highType = imgs->get(opt.getHighResTag(), opt.date1).type();
if (isDoublePairMode && imgs->get(opt.getHighResTag(), opt.date3).type() != highType)
IF_THROW_EXCEPTION(image_type_error("The data types for the high resolution images are different:\n"
" * " + strH1 + ": " + to_string(imgs->get(opt.getHighResTag(), opt.date1).type()) + "\n"
" * " + strH3 + ": " + to_string(imgs->get(opt.getHighResTag(), opt.date3).type())));
Type lowType = imgs->get(opt.getLowResTag(), opt.date1).type();
if (imgs->get(opt.getLowResTag(), date2).type() != lowType || (isDoublePairMode && imgs->get(opt.getLowResTag(), opt.date3).type() != lowType))
IF_THROW_EXCEPTION(image_type_error("The data types for the low resolution images are different:\n"
" * " + strL1 + " " + to_string(imgs->get(opt.getLowResTag(), opt.date1).type()) + "\n" +
" * " + strL2 + " " + to_string(imgs->get(opt.getLowResTag(), date2).type()) + "\n" +
(isDoublePairMode ? " * " + strL3 + " " + to_string(imgs->get(opt.getLowResTag(), opt.date3).type()) + "\n" : "")));
if (getBaseType(lowType) != getBaseType(highType))
IF_THROW_EXCEPTION(image_type_error("The base data types for the high resolution images (" + to_string(getBaseType(highType)) +
") and the low resolution images (" + to_string(getBaseType(lowType)) + ") are different."));
if (getChannels(lowType) != getChannels(highType))
IF_THROW_EXCEPTION(image_type_error("The number of channels of the low resolution images (" + std::to_string(getChannels(lowType)) +
") are different than of the high resolution images (" + std::to_string(getChannels(highType)) + ")."));
Size s = imgs->get(opt.getLowResTag(), opt.date1).size();
if (imgs->get(opt.getHighResTag(), opt.date1).size() != s || imgs->get(opt.getLowResTag(), date2).size() != s ||
(isDoublePairMode && (imgs->get(opt.getHighResTag(), opt.date3).size() != s || imgs->get(opt.getLowResTag(), opt.date3).size() != s)))
{
IF_THROW_EXCEPTION(size_error("The required images have a different size:\n"