| 35 | typedef itk::Image< unsigned char, 3 > MaskImageType; |
| 36 | |
| 37 | int main(int argc, char* argv[]) |
| 38 | { |
| 39 | MITK_INFO << "Start"; |
| 40 | mitkCommandLineParser parser; |
| 41 | parser.setArgumentPrefix("--", "-"); |
| 42 | // required params |
| 43 | parser.addArgument("image", "i", mitkCommandLineParser::Image, "Input Image", "Path to the input VTK polydata", us::Any(), false, false, false, mitkCommandLineParser::Input); |
| 44 | parser.addArgument("mode", "mode", mitkCommandLineParser::Image, "Normalisation mode", "1,2,3: Single Area normalization to Mean, Median, Mode, 4,5,6: Mean, Median, Mode of two regions. ", us::Any(), false, false, false, mitkCommandLineParser::Input); |
| 45 | parser.addArgument("mask0", "m0", mitkCommandLineParser::Image, "Input Mask", "The median of the area covered by this mask will be set to 0", us::Any(), false, false, false, mitkCommandLineParser::Input); |
| 46 | parser.addArgument("mask1", "m1", mitkCommandLineParser::Image, "Input Mask", "The median of the area covered by this mask will be set to 1", us::Any(), true, false, false, mitkCommandLineParser::Input); |
| 47 | parser.addArgument("output", "o", mitkCommandLineParser::File, "Output Image", "Target file. The output statistic is appended to this file.", us::Any(), false, false, false, mitkCommandLineParser::Output); |
| 48 | parser.addArgument("ignore-outlier", "outlier", mitkCommandLineParser::Bool, "Ignore Outlier", "Ignores the highest and lowest 2% during calculation. Only on single mask normalization.", us::Any(), true); |
| 49 | parser.addArgument("value", "v", mitkCommandLineParser::Float, "Target Value", "Target value, the target value (for example median) is set to this value.", us::Any(), true); |
| 50 | parser.addArgument("width", "w", mitkCommandLineParser::Float, "Target Width", "Ignores the highest and lowest 2% during calculation. Only on single mask normalization.", us::Any(), true); |
| 51 | parser.addArgument("float", "float", mitkCommandLineParser::Bool, "Target Width", "Ignores the highest and lowest 2% during calculation. Only on single mask normalization.", us::Any(), true); |
| 52 | |
| 53 | // Miniapp Infos |
| 54 | parser.setCategory("Classification Tools"); |
| 55 | parser.setTitle("MR Normalization Tool"); |
| 56 | parser.setDescription("Normalizes a MR image. Sets the Median of the tissue covered by mask 0 to 0 and the median of the area covered by mask 1 to 1."); |
| 57 | parser.setContributor("German Cancer Research Center (DKFZ)"); |
| 58 | |
| 59 | std::map<std::string, us::Any> parsedArgs = parser.parseArguments(argc, argv); |
| 60 | |
| 61 | if (parsedArgs.size()==0) |
| 62 | { |
| 63 | return EXIT_FAILURE; |
| 64 | } |
| 65 | if ( parsedArgs.count("help") || parsedArgs.count("h")) |
| 66 | { |
| 67 | return EXIT_SUCCESS; |
| 68 | } |
| 69 | |
| 70 | bool ignore_outlier = false; |
| 71 | if (parsedArgs.count("ignore-outlier")) |
| 72 | { |
| 73 | ignore_outlier = us::any_cast<bool>(parsedArgs["ignore-outlier"]); |
| 74 | } |
| 75 | |
| 76 | MITK_INFO << "Mode access"; |
| 77 | int mode =std::stoi(us::any_cast<std::string>(parsedArgs["mode"])); |
| 78 | MITK_INFO << "Mode: " << mode; |
| 79 | |
| 80 | MITK_INFO << "Read images"; |
| 81 | mitk::Image::Pointer mask1; |
| 82 | mitk::Image::Pointer image = mitk::IOUtil::Load<mitk::Image>(parsedArgs["image"].ToString()); |
| 83 | |
| 84 | if (parsedArgs.count("float")) |
| 85 | { |
| 86 | typedef itk::Image<float, 3> ImageType; |
| 87 | ImageType::Pointer img = ImageType::New(); |
| 88 | mitk::CastToItkImage(image, img); |
| 89 | mitk::CastToMitkImage(img, image); |
| 90 | } |
| 91 | |
| 92 | mitk::Image::Pointer mask0 = mitk::IOUtil::Load<mitk::Image>(parsedArgs["mask0"].ToString()); |
| 93 | if (mode > 3) |
| 94 | { |
nothing calls this directly
no test coverage detected