[Insight-users] Error when using ConnectedThresholdImageFilter to segment image

Luis Ibanez luis.ibanez at kitware.com
Fri Jun 25 00:15:11 EDT 2004


Hi diaoxianfen,

The first suspect when you use the ThresholdConnected filter
is the settings of the lower and upper threshold. You are
probably selecting values in the original image, but given
that you do a smoothing before passing the image to the
ThresholdConnected filter, the distribution of intensity
values received by the segmentation filter is different
from the one in the image where you selected the threshold
values.

The secon typical suspect is that your seed point is not
necesarily inside the range of lower,upper, and therefore
the region do not even grow past one pixel.

An easy thing to do is for you to use the examples in

  Insight/Examples/Segmentation/
             ConnectedThresholdImageFilter.cxx

until you find values of the thresholds that result in
acceptable segmentations for your input image.

Once you find such values, try them again in your MFC
application.


Note that you can remove the Caster filter in your pipeline
if you instantiate the ConnnectedThreshold filter for using
InternalImageType as input type and OutputImageType as
output type.



    Regards,


       Luis


----------------------
diaoxianfen wrote:
> I am a new learner of ITK.I compiled ItkMFC.I want to add some 
> function for segmentation referring the examples.The function as follows:
>  
> void CItkMFCView::ConnectedThresholdImageFilter(int seedx, int seedy,int 
> lower,int upper, CString inPath, CString outPath)
> {
>  typedef   unsigned short        InternalPixelType;
>  const     unsigned int    Dimension = 2;
>  typedef itk::Image< InternalPixelType, Dimension >  InternalImageType;
>  // Software Guide : EndCodeSnippet
>  
>  
>  typedef unsigned char OutputPixelType;
>  typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
>  typedef itk::CastImageFilter< InternalImageType, OutputImageType >
>   CastingFilterType;
>  CastingFilterType::Pointer caster = CastingFilterType::New();
>  
>  // We instantiate reader and writer types
>  //
>  typedef  itk::ImageFileReader< InternalImageType > ReaderType;
>  typedef  itk::ImageFileWriter<  OutputImageType  > WriterType;
>  
>  ReaderType::Pointer reader = ReaderType::New();
>  WriterType::Pointer writer = WriterType::New();
>  
>  reader->SetFileName( inPath );
>  writer->SetFileName( outPath );
>  
>  
>  
>  typedef itk::CurvatureFlowImageFilter< InternalImageType, 
> InternalImageType >
>   CurvatureFlowImageFilterType;
>  
>  CurvatureFlowImageFilterType::Pointer smoothing =
>   CurvatureFlowImageFilterType::New();
>  
>  typedef itk::ConnectedThresholdImageFilter< InternalImageType,
>   InternalImageType > ConnectedFilterType;
>  
>  ConnectedFilterType::Pointer connectedThreshold = 
> ConnectedFilterType::New();
>  
>  smoothing->SetInput( reader->GetOutput() );
>  connectedThreshold->SetInput( smoothing->GetOutput() );
>  caster->SetInput( connectedThreshold->GetOutput() );
>  writer->SetInput( caster->GetOutput() );
>  
>  smoothing->SetNumberOfIterations( 5 );
>  smoothing->SetTimeStep( 0.125 );
>  
>  //const InternalPixelType lowerThreshold = atof(  );
>  //const InternalPixelType upperThreshold = atof(  );
>  
>  // Software Guide : BeginCodeSnippet
>  connectedThreshold->SetLower(  lower );
>  connectedThreshold->SetUpper(  upper  );
>  
>  connectedThreshold->SetReplaceValue(255);
>  
>  InternalImageType::IndexType  index;
>  
>  //index[0] = atoi( argv[3] );
>  //index[1] = atoi( argv[4] );
>  index[0]=seedx;
>  index[1]=seedy;
>  
>  // Software Guide : BeginCodeSnippet
>  connectedThreshold->SetSeed( index );
>  
>  try
>     {
>   writer->Update();
>     }
>  catch( itk::ExceptionObject & excep )
>     {
>   std::cerr << "Exception caught !" << std::endl;
>   std::cerr << excep << std::endl;
>     }
>  
> }
> 
> Every thing is OK.But the writed image is all black.I can't find the 
> bug.Can help me?
>  
> In addition,I have a series DICOM images of head .What I want to do is 
> to display the image in 3D.From the image I want to segment the 
> cochlea.Display the cochlea and measure the length of cochlea.
> Now I know combining VTK and ITK can get that.
> I have learned VTK for a time and I already visualized the image in 
> 3D,but don't know how to segment the cochlea.Is there somebody could 
> tell me what I should do.Which classes of ITK should I read 
> particularly,or a general progress to achieve segment and 3D visualization?
>  
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users





More information about the Insight-users mailing list