X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=segmentation%2FclitkRelativePositionList.txx;h=39cc272cd1156253b4578efa45b30f1a0789d0b0;hb=5e63914651ec58eebb2a08537c94a00e9e861d35;hp=ec49a548fdad4859038c70df544481ab3605e9c0;hpb=42e050104aebe7830f2111d096f0dd6673987d1e;p=clitk.git diff --git a/segmentation/clitkRelativePositionList.txx b/segmentation/clitkRelativePositionList.txx index ec49a54..39cc272 100644 --- a/segmentation/clitkRelativePositionList.txx +++ b/segmentation/clitkRelativePositionList.txx @@ -16,11 +16,24 @@ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html ======================================================================-====*/ +#include "clitkLabelImageOverlapMeasureFilter.h" //-------------------------------------------------------------------- template clitk::RelativePositionList:: RelativePositionList() { + ComputeOverlapFlagOff(); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +template +void +clitk::RelativePositionList:: +SetReferenceImageForOverlapMeasure(ImagePointer ref) { + m_reference = ref; + ComputeOverlapFlagOn(); } //-------------------------------------------------------------------- @@ -87,6 +100,8 @@ Read(std::string filename) { std::ofstream os; openFileForWriting(os, tmpfilename); os << text; + os << "input = nothing" << std::endl; + os << "output = nothing" << std::endl; os.close(); // Create a struct to store options. I use two step to allow to @@ -97,14 +112,11 @@ Read(std::string filename) { std::copy(tmpfilename.begin(), tmpfilename.end(), writable.begin()); char ** argv = new char*[1]; argv[0] = new char[1]; - cmdline_parser_clitkRelativePosition2(1, argv, &args_info, 1, 1, 0); - args_info.input_given = 1; - args_info.input_arg = new char[1]; - args_info.output_given = 1; - args_info.output_arg = new char[1]; - cmdline_parser_clitkRelativePosition_configfile(&writable[0], &args_info, 0, 0, 1); - - // Store the args + struct cmdline_parser_clitkRelativePosition_params params; + params.override = 0; + params.initialize = 1; + params.check_required = 0; + cmdline_parser_clitkRelativePosition_configfile(&writable[0], &args_info, 1, 1, 1); mArgsInfoList.push_back(args_info); // Delete the temporary file @@ -146,14 +158,18 @@ GenerateOutputInformation() { // Loop on RelativePositionList of operations std::string s = GetInputName(); for(uint i=0; iUpdate(); m_working_input = relPosFilter->GetOutput(); StopCurrentStep(m_working_input); + + // Compute overlap with reference if needed + if (GetComputeOverlapFlag()) { + typedef clitk::LabelImageOverlapMeasureFilter FilterType; + typename FilterType::Pointer filter = FilterType::New(); + filter->SetInput(0, m_working_input); + filter->SetInput(1, m_reference); + filter->Update(); + } + } } //-------------------------------------------------------------------- @@ -211,9 +237,10 @@ void clitk::RelativePositionList:: SetFilterOptions(typename RelPosFilterType::Pointer filter, ArgsInfoType & options) { - if (options.orientation_given != 1) { - DD("ERRROR DEBUG TODO no more than 1 orientation yet"); - exit(0); + if (options.orientation_given > 1) { + clitkExceptionMacro("Error in the RelPos options. I need a single --orientation (for the moment)." + << " Current options are for obj = '" << options.object_arg + << "', threshold = " << options.threshold_arg << std::endl); } ImagePointer object = GetAFDB()->template GetImage(options.object_arg); @@ -222,8 +249,21 @@ SetFilterOptions(typename RelPosFilterType::Pointer filter, ArgsInfoType & optio filter->SetVerboseImageSizeFlag(GetVerboseImageSizeFlag()); filter->SetFuzzyThreshold(options.threshold_arg); filter->SetInverseOrientationFlag(options.inverse_flag); // MUST BE BEFORE AddOrientationTypeString - for(uint i=0; iAddOrientationTypeString(options.orientation_arg[i]); + + if (options.orientation_given == 1) { + for(uint i=0; iAddOrientationTypeString(options.orientation_arg[i]); + } + else { + if (options.angle1_given && options.angle2_given) { + filter->AddAnglesInDeg(options.angle1_arg, options.angle2_arg); + } + else { + clitkExceptionMacro("Error in the RelPos options. I need --orientation or (--angle1 and --angle2)." + << " Current options are for obj = '" << options.object_arg + << "', threshold = " << options.threshold_arg << std::endl); + } + } filter->SetIntermediateSpacing(options.spacing_arg); if (options.spacing_arg == -1) filter->IntermediateSpacingFlagOff(); else filter->IntermediateSpacingFlagOn();