22 #include <itkDiffusionTensor3D.h>
29 #include "itkBinaryErodeImageFilter.h"
30 #include "itkFlatStructuringElement.h"
38 int main(
int argc,
char *argv[])
42 parser.
setTitle(
"Connectedness Maps");
66 map<string, us::Any> parsedArgs = parser.
parseArguments(argc, argv);
69 if (parsedArgs.size() == 0 || parsedArgs.count(
"help") || parsedArgs.count(
"h"))
76 bool applyErosion =
false;
77 bool useValueImage =
false;
78 if (parsedArgs.count(
"rankFilter") || parsedArgs.count(
"r"))
81 if (parsedArgs.count(
"valueImage") || parsedArgs.count(
"x"))
84 if (parsedArgs.count(
"erodeSeed") || parsedArgs.count(
"a"))
87 std::string inputFile =
us::any_cast<
string>(parsedArgs[
"input"]);
88 std::string propMap =
us::any_cast<
string>(parsedArgs[
"propMap"]);
89 std::string conMap =
us::any_cast<
string>(parsedArgs[
"distanceMap"]);
90 std::string tensImageFile =
us::any_cast<
string>(parsedArgs[
"vector"]);
91 std::string maskFile =
us::any_cast<
string>(parsedArgs[
"mask"]);
92 std::string mode =
us::any_cast<
string>(parsedArgs[
"mode"]);
93 std::string seedFile =
us::any_cast<
string>(parsedArgs[
"seed"]);
94 std::string confFile =
us::any_cast<
string>(parsedArgs[
"confidence"]);
95 std::string euclidFile =
us::any_cast<
string>(parsedArgs[
"euclidDistanceMap"]);
97 std::string valueImageFile =
"";
99 valueImageFile =
us::any_cast<
string>(parsedArgs[
"valueImage"]);
112 if (mode ==
"Vector" || mode ==
"FeatureVector")
137 typedef itk::FlatStructuringElement<3> StructuringElementType;
138 StructuringElementType::RadiusType elementRadius;
139 elementRadius.Fill(2);
140 elementRadius[2] = 0;
141 StructuringElementType structuringElement = StructuringElementType::Box(elementRadius);
143 typedef itk::BinaryErodeImageFilter<BinaryType, BinaryType, StructuringElementType> BinaryErodeImageFilterType;
146 erodeFilter->SetInput(itkSeed);
147 erodeFilter->SetKernel(structuringElement);
148 erodeFilter->SetForegroundValue(1);
149 erodeFilter->Update();
150 itkSeed = erodeFilter->GetOutput();
153 if (mode ==
"Vector" || mode ==
"FeatureVector")
163 filter->SetInputImage(itkImage);
164 filter->SetInputSeed(itkSeed);
165 filter->SetInputMask(itkMask);
166 if (mode ==
"Vector")
168 filter->SetInputVectorField(itkTensor);
169 filter->SetInputVectorFieldConfidenceMap(itkWeight);
172 else if (mode ==
"FeatureVector")
174 filter->SetInputVectorField(itkTensor);
175 filter->SetInputVectorFieldConfidenceMap(itkWeight);
182 filter->SetPropagationImage(itkValueImage);
184 filter->SetApplyRankFilter(useRank);
itk::Image< mitk::ScalarType, 3 > ResultType
static void Save(const mitk::BaseData *data, const std::string &path)
Save a mitk::BaseData instance.
itk::SmartPointer< Self > Pointer
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)
void setCategory(std::string category)
void setArgumentPrefix(const std::string &longPrefix, const std::string &shortPrefix)
itk::Image< unsigned char, 3 > BinaryType
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
this class encapsulates tensor images
itk::Image< itk::DiffusionTensor3D< float >, 3 > ItkTensorImage
int main(int argc, char *argv[])
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.