17 #include "itkImageRegionIterator.h"
31 int main(
int argc,
char *argv[])
34 parser.
setTitle(
"Mri Normalization");
37 "Normalizes an MRI volume between medians of two given masks (e.g. ventricles and brain matter)");
52 map<string, us::Any> parsedArgs = parser.
parseArguments(argc, argv);
55 if (parsedArgs.size() == 0 || parsedArgs.count(
"help") || parsedArgs.count(
"h"))
61 std::string outFile =
us::any_cast<
string>(parsedArgs[
"output"]);
78 std::vector<mitk::ScalarType> medianMin;
79 std::vector<mitk::ScalarType> medianMax;
81 itk::ImageRegionIterator<FeatureImage> inputIt(itkInputImage, itkInputImage->GetLargestPossibleRegion());
82 itk::ImageRegionIterator<SeedImage> excludeIt(itkExcludeImage, itkExcludeImage->GetLargestPossibleRegion());
83 itk::ImageRegionIterator<SeedImage> minIt(itkMinImage, itkMinImage->GetLargestPossibleRegion());
84 itk::ImageRegionIterator<SeedImage> maxIt(itkMaxImage, itkMaxImage->GetLargestPossibleRegion());
86 while (!inputIt.IsAtEnd())
88 if (excludeIt.Get() == 0)
91 medianMin.push_back(inputIt.Get());
94 medianMax.push_back(inputIt.Get());
102 std::sort(medianMax.begin(), medianMax.end());
103 std::sort(medianMin.begin(), medianMin.end());
110 while (!inputIt.IsAtEnd())
112 inputIt.Set(1.0 * (inputIt.Get() - minVal) / (maxVal - minVal));
static void Save(const mitk::BaseData *data, const std::string &path)
Save a mitk::BaseData instance.
itk::SmartPointer< Self > Pointer
itk::Image< mitk::ScalarType, 3 > FeatureImage
void setContributor(std::string contributor)
ValueType * any_cast(Any *operand)
std::map< std::string, us::Any > parseArguments(const StringContainerType &arguments, bool *ok=nullptr)
int main(int argc, char *argv[])
itk::Image< unsigned char, 3 > SeedImage
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)
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)
itk::ImageRegionIterator< SeedImage > SeedIteratorType
itk::ImageRegionIterator< FeatureImage > FeatureIteratorType
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.