<br>Dear Insight Users,<br>(sorry if this email appears twice)<br><br>i am quite new to insight and have gotten a code which i would like to modify. <br>I have basically an image on which i want to run a label statistics filter.<br>
The image is thresholded such that the statistcs will be obtained from the <br>
thresholded image. <br>The problem is i cannot set the voxels outside the threshold range to NaN such that they are<br>not included in the statistics later on.<br>Any help can is appreciated. (Code snippet is below)<br>Jaime<br>
<br>.<br>.<br>.<br>.<br> <span style="font-family: courier new,monospace;">typedef itk::ThresholdImageFilter< ImageType > ThresholdFilterType;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">ThresholdFilterType::Pointer threshold = ThresholdFilterType::New();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">threshold->SetInput( reader->GetOutput() );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">typedef itk::LabelStatisticsImageFilter< ImageType, Float2BinAdaptorType > ...LabelStatisticsFilterType;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"><br>LabelStatisticsFilterType::Pointer labelstatistic = LabelStatisticsFilterType::New();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">labelstatistic->SetInput( threshold->GetOutput() );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;"> labelstatistic->SetLabelInput( float2bin );</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">for ( int  lowerTInt = -100; lowerTInt <=-20; lowerTInt += 20 ) {</span><span style="font-family: courier new,monospace;"></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">   const ImageType::PixelType lowerThresh= static_cast<float>( lowerTInt );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">   threshold->ThresholdBelow(lowerThresh);</span><span style="font-family: courier new,monospace;"></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">   threshold->SetOutsideValue(-20);</span>  // <span style="font-family: courier new,monospace;">SetOutsideValue(NaN) Doesn't work;</span> <br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">   threshold->Update();    </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">   labelstatistic->Update();</span><br>
   .<br>   . <br>   . <br>   .<br>   // Get Statistics from the image<br>   const RealType min      =  labelstatistic->GetMinimum( );<br>   const RealType max      =  labelstatistic->GetMaximum( );<br>   std::cout <<labelstatistic->GetCount( 0 )<br>
                 <<" label non XCT " <<labelstatistic->GetCount( 254 )<br>.<br>.<br>.<br>}