From: Romulo Pinho Date: Thu, 24 May 2012 14:36:25 +0000 (+0200) Subject: updates in calculation of motion mask X-Git-Tag: v1.3.0~33 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=84e378fed8d19c14b4d3641b4ffd179f732cabc3;p=clitk.git updates in calculation of motion mask - new way of guessing initial ellipse --- diff --git a/segmentation/clitkMotionMaskGenericFilter.txx b/segmentation/clitkMotionMaskGenericFilter.txx index 81efecc..c6476c2 100644 --- a/segmentation/clitkMotionMaskGenericFilter.txx +++ b/segmentation/clitkMotionMaskGenericFilter.txx @@ -520,6 +520,12 @@ MotionMaskGenericFilter::InitializeEllips( typename itk::VectorGetLargestPossibleRegion(); + typename InternalImageType::SizeType size = region_before.GetSize(); + size[2] /= 2; + region.SetSize(size); + lungs_low->SetRegions(region); + // compute statistics of the (mirroed) lung region in order to guess the params of the ellipse typedef itk::LabelImageToShapeLabelMapFilter LabelImageToShapeLabelMapFilter; typename LabelImageToShapeLabelMapFilter::Pointer label_filter = LabelImageToShapeLabelMapFilter::New(); @@ -529,9 +535,12 @@ MotionMaskGenericFilter::InitializeEllips( typename itk::VectorGetSpacing(); typedef typename LabelImageToShapeLabelMapFilter::OutputImageType::LabelObjectType LabelType; const LabelType* label = dynamic_cast(label_filter->GetOutput()->GetNthLabelObject(0)); - - // try to guess ideal ellipse axes from the lungs' bounding box + // lungs' barycenter + typename LabelType::CentroidType lung_centroid = label->GetCentroid(); + + // try to guess ideal ellipse axes from the lungs' bounding box and centroid + // with some hard-coded "magic" constants... #if ITK_VERSION_MAJOR >= 4 typename LabelType::RegionType lung_bbox = label->GetBoundingBox(); #else @@ -539,15 +548,18 @@ MotionMaskGenericFilter::InitializeEllips( typename itk::VectorGetOrigin(); centerEllips[0] = origin[0] + (lung_bbox.GetIndex()[0] + lung_bbox.GetSize()[0]/2)*spacing[0]; centerEllips[1] = origin[1] + (lung_bbox.GetIndex()[1] + lung_bbox.GetSize()[1]/2)*spacing[1]; - centerEllips[2] = origin[2] + (lung_bbox.GetIndex()[2] + lung_bbox.GetSize()[2]/2)*spacing[2]; + centerEllips[2] = center[2]; + + lungs_low->SetRegions(region_before); if(m_Verbose) { + std::cout << "Lungs'centroid at " << lung_centroid << std::endl; std::cout << "Ellipse center at " << centerEllips << std::endl; std::cout << "Ellipse axes as " << axes << std::endl; std::cout << "Lung's bounding box (index,size) " << lung_bbox.GetIndex() << lung_bbox.GetSize() << std::endl;