[Insight-users] Black image.

Celina Redma britneyvosloo2000 at yahoo.ca
Wed Jul 28 19:28:18 EDT 2004


Can anyone tell me what's wrong with the code? It gave me a black output image file. I try reading a dicom file and output a "png" file. 
 
 
  typedef unsigned char InternalPixelType;
  typedef float   floatPixelType;
  const     unsigned int    Dimension = 2;
 
  typedef itk::Image< InternalPixelType, Dimension >  InternalImageType;
  typedef unsigned char OutputPixelType;
  typedef itk::Image< OutputPixelType, Dimension >    OutputImageType;
  typedef itk::Image<floatPixelType, Dimension >      floatImageType;   
  typedef itk::CastImageFilter< InternalImageType, floatImageType > CastingToFloatType;
  CastingToFloatType::Pointer caster = CastingToFloatType::New();
  typedef itk::CastImageFilter<floatImageType, OutputImageType> CastingToCharType;
  CastingToCharType::Pointer caster2 = CastingToCharType::New();

  typedef  itk::ImageFileReader< InternalImageType > ReaderType;
  typedef  itk::ImageFileWriter<  OutputImageType  > WriterType;
  ReaderType::Pointer reader = ReaderType::New();
  WriterType::Pointer writer = WriterType::New();
  reader->SetFileName( argv[1] );
  writer->SetFileName( argv[2] );

  typedef itk::CurvatureFlowImageFilter< floatImageType, floatImageType > CurvatureFlowImageFilterType;
  CurvatureFlowImageFilterType::Pointer smoothing = 
                         CurvatureFlowImageFilterType::New();
  typedef itk::ConnectedThresholdImageFilter< floatImageType, floatImageType > ConnectedFilterType;
  ConnectedFilterType::Pointer connectedThreshold = ConnectedFilterType::New();
  caster->SetInput( reader->GetOutput() );
  smoothing->SetInput( caster->GetOutput() );
  connectedThreshold->SetInput( smoothing->GetOutput() );
  caster2->SetInput( connectedThreshold->GetOutput() );
  writer->SetInput( caster2->GetOutput() );
  smoothing->SetNumberOfIterations( 5 );
  smoothing->SetTimeStep( 0.125 );
  const InternalPixelType lowerThreshold = atof( argv[5] );
  const InternalPixelType upperThreshold = atof( argv[6] );
  
  connectedThreshold->SetLower(  lowerThreshold  );
  connectedThreshold->SetUpper(  upperThreshold  );

  connectedThreshold->SetReplaceValue( 255 );
  InternalImageType::IndexType  index;
  
  index[0] = atoi( argv[3] );
  index[1] = atoi( argv[4] );

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




---------------------------------
Post your free ad now! Yahoo! Canada Personals
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20040728/2f0af46d/attachment.htm


More information about the Insight-users mailing list