[Insight-users] Thresholding and label statistics

jaime peña japenbe2 at googlemail.com
Wed Nov 17 10:23:45 EST 2010


Dear Insight Users,
(sorry if this email appears twice)

i am quite new to insight and have gotten a code which i would like to
modify.
I have basically an image on which i want to run a label statistics filter.
The image is thresholded such that the statistcs will be obtained from the
thresholded image.
The problem is i cannot set the voxels outside the threshold range to NaN
such that they are
not included in the statistics later on.
Any help can is appreciated. (Code snippet is below)
Jaime

.
.
.
.
 typedef itk::ThresholdImageFilter< ImageType > ThresholdFilterType;
ThresholdFilterType::Pointer threshold = ThresholdFilterType::New();
threshold->SetInput( reader->GetOutput() );
typedef itk::LabelStatisticsImageFilter< ImageType, Float2BinAdaptorType >
...LabelStatisticsFilterType;

LabelStatisticsFilterType::Pointer labelstatistic =
LabelStatisticsFilterType::New();
labelstatistic->SetInput( threshold->GetOutput() );
 labelstatistic->SetLabelInput( float2bin );


for ( int  lowerTInt = -100; lowerTInt <=-20; lowerTInt += 20 ) {
   const ImageType::PixelType lowerThresh= static_cast<float>( lowerTInt );
   threshold->ThresholdBelow(lowerThresh);
   threshold->SetOutsideValue(-20);  // SetOutsideValue(NaN) Doesn't work;
   threshold->Update();
   labelstatistic->Update();
   .
   .
   .
   .
   // Get Statistics from the image
   const RealType min      =  labelstatistic->GetMinimum( );
   const RealType max      =  labelstatistic->GetMaximum( );
   std::cout <<labelstatistic->GetCount( 0 )
                 <<" label non XCT " <<labelstatistic->GetCount( 254 )
.
.
.
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20101117/4cb446f0/attachment.htm>


More information about the Insight-users mailing list