17 #include "itkImageRegionIterator.h"
31 int main(
int argc,
char *argv[])
34 parser.
setTitle(
"Contrast Adaption");
36 parser.
setDescription(
"Stretches or pushes image intensities above a given threshold");
48 map<string, us::Any> parsedArgs = parser.
parseArguments(argc, argv);
50 if (parsedArgs.size() == 0)
54 if (parsedArgs.count(
"help") || parsedArgs.count(
"h"))
60 std::string outFile =
us::any_cast<
string>(parsedArgs[
"output"]);
62 float cutOff =
us::any_cast<
float>(parsedArgs[
"cutOff"]);
70 itk::ImageRegionIterator<FeatureImage> inputIt(itkInputImage, itkInputImage->GetLargestPossibleRegion());
72 while (!inputIt.IsAtEnd())
74 if (inputIt.Get() >
max)
82 while (!inputIt.IsAtEnd())
84 if (inputIt.Get() > cutOff)
86 inputIt.Set(cutOff + slope * (inputIt.Get() - cutOff) / (max - cutOff));
97 if (inputFile->GetPixelType().GetComponentTypeAsString() !=
"double")
100 mitkResult = inputFile;
static void Save(const mitk::BaseData *data, const std::string &path)
Save a mitk::BaseData instance.
itk::Image< mitk::ScalarType, 3 > FeatureImage
itk::SmartPointer< Self > Pointer
itk::ImageRegionIterator< FeatureImage > FeatureIteratorType
itk::Image< unsigned char, 3 > SeedImage
void setContributor(std::string contributor)
ValueType * any_cast(Any *operand)
std::map< std::string, us::Any > parseArguments(const StringContainerType &arguments, bool *ok=nullptr)
Image::Pointer GrabItkImageMemory(itk::SmartPointer< ItkOutputImageType > &itkimage, mitk::Image *mitkImage=nullptr, const BaseGeometry *geometry=nullptr, bool update=true)
Grabs the memory of an itk::Image (with a specific type) and puts it into an mitk::Image.The memory is managed by the mitk::Image after calling this function. The itk::Image remains valid until the mitk::Image decides to free the memory.
void addArgument(const std::string &longarg, const std::string &shortarg, Type type, const std::string &argLabel, const std::string &argHelp=std::string(), const us::Any &defaultValue=us::Any(), bool optional=true, bool ignoreRest=false, bool deprecated=false)
itk::ImageRegionIterator< SeedImage > SeedIteratorType
int main(int argc, char *argv[])
void setCategory(std::string category)
void setArgumentPrefix(const std::string &longPrefix, const std::string &shortPrefix)
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
std::string helpText() const
void setTitle(std::string title)
void setDescription(std::string description)
static mitk::Image::Pointer LoadImage(const std::string &path)
LoadImage Convenience method to load an arbitrary mitkImage.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.