[Insight-users] Fwd: Need help in 3D volume segmentation

qt.itk.vtk.help qt.itk.vtk.help at gmail.com
Fri May 31 03:44:28 EDT 2013


---------- Forwarded message ----------
From: qt.itk.vtk.help <qt.itk.vtk.help at gmail.com>
Date: Fri, May 31, 2013 at 11:56 AM
Subject: Need help in 3D volume segmentation
To: Luis Ibanez <luis.ibanez at kitware.com>, Insight-user at itk.org


Hi,

I am working on connected threshold Segmentation for 3D volume  .
#  2D segmentation works fine for me as I have  understood the example
given by ITK for 2D Image.

#  Then i tried to convert image reader to Sequence reader that also work
fine as I have tested it by saving CurvatureFlowImageFilter result in
analyse file.

# But when i pass output of CurvatureFlowImageFilter
to ConnectedThresholdImageFilter with same *seed point and threshold
value*it give me black output means nothing is segmented.

# *This is my Code *

#include "itkConnectedThresholdImageFilter.h"
#include "itkImage.h"
#include "itkCastImageFilter.h"
#include "itkNumericSeriesFileNames.h"
#include "itkJPEGImageIO.h"
#include "itkCurvatureFlowImageFilter.h"
#include "itkImageSeriesReader.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"


int main( int argc, char *argv[])
{

  typedef   float           InternalPixelType;
  const     unsigned int    Dimension = 3;
  typedef itk::Image< InternalPixelType, Dimension >  InternalImageType;



  typedef unsigned char                            OutputPixelType;
  typedef itk::Image< OutputPixelType, Dimension > OutputImageType;

  typedef itk::CastImageFilter< InternalImageType, OutputImageType
>CastingFilterType;
  CastingFilterType::Pointer caster = CastingFilterType::New();


  typedef  itk::ImageSeriesReader< InternalImageType > ReaderType;
  typedef  itk::ImageFileWriter<  OutputImageType  > WriterType;

  ReaderType::Pointer reader = ReaderType::New();
  WriterType::Pointer writer = WriterType::New();

  typedef itk::NumericSeriesFileNames NameGeneratorType;
  NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();

  nameGenerator->SetSeriesFormat(
"D:/testing_Dataset/WIP/jpg/New_folder/pelvis%04d.jpg" );
  nameGenerator->SetStartIndex( 0000 );
  nameGenerator->SetEndIndex( 0023 );
  nameGenerator->SetIncrementIndex( 1 );

  reader->SetImageIO( itk::JPEGImageIO::New() );
  reader->SetFileNames( nameGenerator->GetFileNames() );
  itk::Indent indent;
  nameGenerator->Print(std::cout,indent);

 writer->SetFileName( "D:\\out.img" );

  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 = 200;
  const InternalPixelType upperThreshold = 270;


  connectedThreshold->SetLower(  lowerThreshold  );
  connectedThreshold->SetUpper(  upperThreshold  );

  connectedThreshold->SetReplaceValue( 255 );

  InternalImageType::IndexType  index;

  index[0] = 258  ;
  index[1] = 226;



  connectedThreshold->SetSeed( index );

  try
    {
    writer->Update();
    }
  catch( itk::ExceptionObject & excep )
    {
    std::cerr << "Exception caught !" << std::endl;
    std::cerr << excep << std::endl;
    }



  return 0;
}

Do i need to give more seed points.
Any help is appreciated.


Thank you,
Shilpa Dogra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130531/069dd111/attachment.htm>


More information about the Insight-users mailing list