X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkLabelImageOverlapMeasureFilter.txx;h=037570916b0346be55ed56ff47cf1988485db821;hb=6986b996d66273ab7818c12f51cbf5ae049ac04e;hp=11c1e42bca39d9a9aa6662c7e99ac0c08f1051fe;hpb=727a01d91215b6c4c808fd92d42ea168d638bf82;p=clitk.git diff --git a/itk/clitkLabelImageOverlapMeasureFilter.txx b/itk/clitkLabelImageOverlapMeasureFilter.txx index 11c1e42..0375709 100644 --- a/itk/clitkLabelImageOverlapMeasureFilter.txx +++ b/itk/clitkLabelImageOverlapMeasureFilter.txx @@ -51,7 +51,6 @@ void clitk::LabelImageOverlapMeasureFilter:: GenerateInputRequestedRegion() { - // DD("GenerateInputRequestedRegion"); // Call default itk::ImageToImageFilter::GenerateInputRequestedRegion(); // Get input pointers and set requested region to common region @@ -87,15 +86,25 @@ GenerateData() // Resize like the union ImagePointer input1 = clitk::ResizeImageLike(m_Input1, bbo, GetBackgroundValue()); ImagePointer input2 = clitk::ResizeImageLike(m_Input2, bbo, GetBackgroundValue()); + //DD(input1->GetLargestPossibleRegion()); + //DD(input2->GetLargestPossibleRegion()); // Compute overlap image ImagePointer image_union = clitk::Clone(input1); ImagePointer image_intersection = clitk::Clone(input1); clitk::Or(image_union, input2, GetBackgroundValue()); clitk::And(image_intersection, input2, GetBackgroundValue()); + + ImagePointer image_1NotIn2 = clitk::Clone(input1); + clitk::AndNot(image_1NotIn2, input2, GetBackgroundValue()); - writeImage(image_union, "union.mha"); - writeImage(image_intersection, "intersection.mha"); + ImagePointer image_2NotIn1 = clitk::Clone(input2); + clitk::AndNot(image_2NotIn1, input1, GetBackgroundValue()); + + //writeImage(image_union, "union.mha"); + //writeImage(image_intersection, "intersection.mha"); + //writeImage(image_1NotIn2, "image_1NotIn2.mha"); + //writeImage(image_2NotIn1, "image_2NotIn1.mha"); // Compute size typedef itk::LabelStatisticsImageFilter StatFilterType; @@ -120,7 +129,25 @@ GenerateData() statFilter->Update(); int in2 = statFilter->GetCount(GetLabel1()); - std::cout << in1 << " " << in2 << " " << inter << " " << u << " " << (double)inter/(double)u << std::endl; + statFilter->SetInput(image_1NotIn2); + statFilter->SetLabelInput(image_1NotIn2); + statFilter->Update(); + int l1notIn2 = statFilter->GetCount(GetLabel1()); + + statFilter->SetInput(image_2NotIn1); + statFilter->SetLabelInput(image_2NotIn1); + statFilter->Update(); + int l2notIn1 = statFilter->GetCount(GetLabel1()); + + double dice = 2.0*(double)inter/(double)(in1+in2); + int width = 6; + std::cout << std::setw(width) << in1 << " " + << std::setw(width) << in2 << " " + << std::setw(width) << inter << " " + << std::setw(width) << u << " " + << std::setw(width) << l1notIn2 << " " + << std::setw(width) << l2notIn1 << " " + << std::setw(width) << dice << " "; //std::endl; } //--------------------------------------------------------------------