[Insight-users] ITK 3.2 png read/write problem

David Doria daviddoria at gmail.com
Wed Mar 16 08:47:01 EDT 2011


I recently switched to ITK 3.2 while waiting for some problems with master
to be resolved. With this very simple example, 3.2 seems to produce an all
black image, where I would expect the output to be the same as the input (at
least the first channel). There are no errors or warnings. Are there any
known problems with this?

#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"

int main(int argc, char *argv[])
{
  if(argc < 2)
    {
    std::cerr << "Required: filename" << std::endl;

    return EXIT_FAILURE;
    }
  std::string inputFilename = argv[1];

  typedef itk::Image< unsigned char, 2 >  ImageType;

  typedef itk::ImageFileReader<ImageType> ReaderType;
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName(inputFilename.c_str());
  reader->Update();

  typedef itk::ImageFileWriter<ImageType> WriterType;
  WriterType::Pointer writer = WriterType::New();
  writer->SetInput(reader->GetOutput());
  writer->SetFileName("output.png");
  writer->Update();

  return EXIT_SUCCESS;
}

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110316/570eb1f6/attachment.htm>


More information about the Insight-users mailing list