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

diaoxianfen diaoxianfen at asisz.com
Thu Jun 24 23:28:51 EDT 2004


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?

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20040625/e46bb5ba/attachment.html


More information about the Insight-users mailing list