28 int main(
int argc,
char* argv[])
34 parser.
setDescription(
"Copies transformation matrix of one image to another");
43 map<string, us::Any> parsedArgs = parser.
parseArguments(argc, argv);
44 if (parsedArgs.size()==0)
48 string imageName =
us::any_cast<
string>(parsedArgs[
"in"]);
49 string refImage =
us::any_cast<
string>(parsedArgs[
"ref"]);
50 string outImage =
us::any_cast<
string>(parsedArgs[
"out"]);
52 bool originOnly =
false;
55 if ( parsedArgs.count(
"alignCentroid") || parsedArgs.count(
"a"))
68 c[0] = source->GetGeometry()->GetOrigin()[0]
69 + source->GetGeometry()->GetExtent(0)/2.0
70 - target->GetGeometry()->GetOrigin()[0]
71 - target->GetGeometry()->GetExtent(0)/2.0;
73 c[1] = source->GetGeometry()->GetOrigin()[1]
74 + source->GetGeometry()->GetExtent(1)/2.0
75 - target->GetGeometry()->GetOrigin()[1]
76 - target->GetGeometry()->GetExtent(1)/2.0;
79 c[2] = source->GetGeometry()->GetOrigin()[2]
80 + source->GetGeometry()->GetExtent(2)/2.0
81 - target->GetGeometry()->GetOrigin()[2]
82 - target->GetGeometry()->GetExtent(2)/2.0;
85 newOrigin[0] = target->GetGeometry()->GetOrigin()[0] +c[0];
86 newOrigin[1] = target->GetGeometry()->GetOrigin()[1] +c[1];
87 newOrigin[2] = target->GetGeometry()->GetOrigin()[2] +c[2];
89 target->GetGeometry()->SetOrigin(newOrigin);
97 target->SetGeometry(t_geom);
101 catch (itk::ExceptionObject e)
106 catch (std::exception e)
108 std::cout << e.what();
113 std::cout <<
"ERROR!?!";
void SetIndexToWorldTransform(mitk::AffineTransform3D *transform)
void setContributor(std::string contributor)
DataCollection - Class to facilitate loading/accessing structured data.
ValueType * any_cast(Any *operand)
std::map< std::string, us::Any > parseArguments(const StringContainerType &arguments, bool *ok=nullptr)
static bool SaveImage(mitk::Image::Pointer image, const std::string &path)
SaveImage Convenience method to save an arbitrary mitkImage.
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)
int main(int argc, char *argv[])
Copies transformation matrix of one image to another.
void setCategory(std::string category)
void setArgumentPrefix(const std::string &longPrefix, const std::string &shortPrefix)
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.
BaseGeometry Describes the geometry of a data object.
mitk::AffineTransform3D * GetIndexToWorldTransform()
Get the transformation used to convert from index to world coordinates.