#include <IPSDKCore/Config/LibraryInitializer.h>
#include <IPSDKBaseProcessing/Logger/IPSDKBaseProcessingException.h>
#include <IPSDKImageFile/Logger/IPSDKImageFileException.h>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/program_options/cmdline.hpp>
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
#include <log4cplus/consoleappender.h>
#include <iostream>
bool
boost::filesystem::path& inputGreyImgPath,
boost::filesystem::path& inputBinLabImgPath,
std::string& inputFilterFormula,
boost::filesystem::path& outputImgPath);
int
main(
int argc,
char* argv[])
{
log4cplus::SharedAppenderPtr pConsole(new log4cplus::ConsoleAppender);
log4cplus::Logger::getRoot().addAppender(pConsole);
log4cplus::Logger::getRoot().setLogLevel(log4cplus::INFO_LOG_LEVEL);
case ipsdk::core::eLibInitStatus::eLIS_Warn:
break;
case ipsdk::core::eLibInitStatus::eLIS_Failed:
return -1;
break;
default:
break;
}
boost::filesystem::path inputGreyImgPath, inputBinLabImgPath, outputImgPath;
std::string inputFilterFormula;
if(!
readCmdArguments(argc, argv, inputGreyImgPath, inputBinLabImgPath, inputFilterFormula, outputImgPath))
return -1;
% inputGreyImgPath.string());
% inputBinLabImgPath.string());
try {
return -1;
}
try {
% outputImgPath % e.
getMsg());
return -1;
}
return 0;
}
bool
boost::filesystem::path& inputGreyImgPath,
boost::filesystem::path& inputBinLabImgPath,
std::string& inputFilterFormula,
boost::filesystem::path& outputImgPath)
{
boost::program_options::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("inputGreyImgPath", value<path>(),
"input grey image file path (optional; only TIFF format is accepted)")
("inputBinLabImgPath", value<path>(),
"input binary/label image file path (optional; only TIFF format is accepted)")
("inputFilterFormula", value<std::string>(),
"input formula string for filtering operation (optional)")
("outputImgPath", value<path>(),
"output result image path (optional)")
;
boost::program_options::variables_map vm;
try {
boost::program_options::store(parse_command_line(argc, argv, desc), vm);
} catch(const std::exception& e) {
% e.what());
return false;
}
boost::program_options::notify(vm);
if (vm.count("help")) {
std::cout << desc << "\n";
return false;
}
inputGreyImgPath =
getIPSDKDirectory(eInternalDirectory::eID_Images) /
"blobs_483x348_UInt8.tif";
if(vm.count("inputGreyImgPath"))
inputGreyImgPath = vm["inputGreyImgPath"].as<path>();
const boost::filesystem::path binLabRelToRootDir =
path("data") / "Sample" / "images" / "blobs_483x348_Binary.tif";
if(!boost::filesystem::exists(inputBinLabImgPath))
if(vm.count("inputBinLabImgPath"))
inputBinLabImgPath = vm["inputBinLabImgPath"].as<path>();
inputFilterFormula = "Area2dMsr > 800";
if(vm.count("inputFilterFormula"))
inputFilterFormula = vm["inputFilterFormula"].as<std::string>();
if(vm.count("outputImgFilePath"))
outputImgPath = vm["outputImgFilePath"].as<path>();
else {
const path outputDir =
"Sample";
if(!boost::filesystem::exists(outputDir)) {
try {
boost::filesystem::create_directories(outputDir);
} catch(const std::exception& e) {
% outputDir % e.what());
}
}
outputImgPath = outputDir / "shapeFiltering2dImg.tif";
}
return true;
}