Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
CLSurWeighting.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 #ifndef mitkForest_cpp
13 #define mitkForest_cpp
14 
15 #include "time.h"
16 #include <sstream>
17 
18 #include <mitkDataCollection.h>
19 #include <mitkCollectionReader.h>
20 #include <mitkCollectionWriter.h>
22 #include <vtkSmartPointer.h>
23 #include <mitkIOUtil.h>
24 #include <sstream>
25 
27 
28 int main(int argc, char* argv[])
29 {
30  MITK_INFO << "Argc " << argc;
31 
33  // Read Images
36 
37  MITK_INFO << "Arg 2 " << argv[2];
38  mitk::Image::Pointer sur=mitk::IOUtil::Load<mitk::Image>(argv[2]);
39  col->AddData(sur.GetPointer(),"sur");
40  MITK_INFO << "Arg 3 " << argv[3];
41  mitk::Image::Pointer mask=mitk::IOUtil::Load<mitk::Image>(argv[3]);
42  col->AddData(mask.GetPointer(),"mask");
43 
44  std::vector<std::string> modalities;
45  for (int i = 4; i < argc; ++i)
46  {
47  MITK_INFO << "Img " << argv[i];
48  std::stringstream ss;
49  ss << i;
50  modalities.push_back(ss.str());
51  mitk::Image::Pointer img = mitk::IOUtil::Load<mitk::Image>(argv[i]);
52  col->AddData(img.GetPointer(),ss.str());
53  }
54 
56  est.SetCollection(col);
57  est.SetTrainMask("sur");
58  est.SetTestMask("mask");
59  est.SetModalities(modalities);
60  est.SetWeightName("weight");
61  est.Update();
62 
63  mitk::Image::Pointer w= col->GetMitkImage("weight");
64  mitk::IOUtil::Save(w,argv[1]);
65 
66  return 0;
67 }
68 
69 #endif
void SetWeightName(std::string name)
#define MITK_INFO
Definition: mitkLogMacros.h:18
void SetTrainMask(std::string name)
void SetTestMask(std::string name)
void SetModalities(std::vector< std::string > modalities)
static Pointer New()
int main(int argc, char *argv[])
void SetCollection(DataCollection::Pointer data)
static void Save(const mitk::BaseData *data, const std::string &path, bool setPathProperty=false)
Save a mitk::BaseData instance.
Definition: mitkIOUtil.cpp:774
mitk::Image::Pointer mask