[Insight-users] How to use multithreaded filters

Mª Dolores Villalobos Ortiz lolalobos17 at yahoo.es
Sun Mar 20 06:39:03 EDT 2011


Hi
 
I'd like to know how to run several threads when I use a multithreaded-filter (e.g., FlipImageFilter). I have compiled the next code, but only one thread is spawned. The code is:

int main( int argc, char * argv[] )
{
  typedef   unsigned char  PixelType;

  itk::MultiThreader::SetGlobalDefaultNumberOfThreads(2); 

  typedef itk::Image< PixelType,  2 >   ImageType;

  typedef
 itk::ImageFileReader< ImageType >  ReaderType;
  typedef itk::ImageFileWriter< ImageType >  WriterType;

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

  reader->SetFileName("example.jpg");
  writer->SetFileName("example2.jpg");

  typedef itk::FlipImageFilter< ImageType >  FilterType;

  FilterType::Pointer filter = FilterType::New();

  typedef FilterType::FlipAxesArrayType     FlipAxesArrayType;
  
  FlipAxesArrayType flipArray;

  flipArray[0] = 1;
  flipArray[1] = 0;

  filter->SetFlipAxes( flipArray );
  
  filter->SetInput( reader->GetOutput() );
  writer->SetInput( filter->GetOutput() );
  writer->Update();
 
  return
 EXIT_SUCCESS;
}


 ITK toolkit and my example are compiled in Debug mode.

 

Thank you



       María Dolores



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110320/aa0ed16b/attachment.htm>


More information about the Insight-users mailing list