[Insight-users] ERROR: PNG Writer can only write 2-dimensionalimages

Miller, James V (Research) millerjv at crd.ge.com
Wed Aug 31 07:43:38 EDT 2005


The print out of filter->GetOutput()->Print(std::cout)  indicates the image has not data.  All the sizes of the regions are [0,0].  For whatever reason, "filter" is producing no output.  Is it getting any input?  I would print out the input to filter and the outputs of anything before filter.
 
I believe the ImageFileWriter collapses unused dimensions, so it is probably giving the PNGImageIO a zero dimensonal image.

-----Original Message-----
From: insight-users-bounces+millerjv=crd.ge.com at itk.org [mailto:insight-users-bounces+millerjv=crd.ge.com at itk.org]On Behalf Of Seniha Esen Yuksel
Sent: Tuesday, August 30, 2005 7:27 PM
To: insight-users at itk.org
Subject: [Insight-users] ERROR: PNG Writer can only write 2-dimensionalimages


Hi all,
I had asked this question before unfortunately, and now I am extending it with minor changes, but the problem is still the same. Please give me some clues, ideas, just anything that comes to your mind... 
 
What does it mean
 
Description: itk::ERROR: PNGImageIO(026955F0): PNG Writer can only write 2-dimen
sional images
 
And yes I am asking for a 2D image as well ....??
 
Here is the question: I am trying to use Qt+ITK to test some functions, so I want to define a public filter in Qt's main function which I will use as a buffer to hold my images, but I am getting an exception error (as above). I don't understand if my declerations are wrong, or if only the image writing stage is wrong or else...
 
The output of my code is:
 
This program resizes the input file with the following parameters
x starting value: 300
y starting value: 200
x extension     : 400
y extension     : 400
===========================
images are cropped
Image (02685C30)
  RTTI typeinfo:   class itk::Image<unsigned char,2>
  Reference Count: 1
  Modified Time: 231
  Debug: Off
  Observers:
    none
  Source: (02685D20)
  Source output index: 0
  Release Data: Off
  Data Released: False
  Global Release Data: Off
  PipelineMTime: 218
  UpdateMTime: 232
  LargestPossibleRegion:
    Dimension: 2
    Index: [0, 0]
    Size: [0, 0]
  BufferedRegion:
    Dimension: 2
    Index: [0, 0]
    Size: [0, 0]
  RequestedRegion:
    Dimension: 2
    Index: [0, 0]
    Size: [0, 0]
  Spacing: [1, 1]
  Origin: [300, 200]
  PixelContainer:
    ImportImageContainer (02684BE0)
      RTTI typeinfo:   class itk::ImportImageContainer<unsigned long,unsigned ch
ar>
      Reference Count: 1
      Modified Time: 230
      Debug: Off
      Observers:
        none
      Pointer: 02684C10
      Container manages memory: true
      Size: 0
      Capacity: 0
Exception caught:
itk::ExceptionObject (0109E460)
Location: "Unknown"
File: D:\Esen\C++ STUFF\C++ LIBRARIES\ITK\InsightToolkit-2.0.0\Code\IO\itkPNGIma
geIO.cxx
Line: 395
Description: itk::ERROR: PNGImageIO(026857F0): PNG Writer can only write 2-dimen
sional images

 
 
I am copying parts of the code below from the header file and the c++ file. 
 
//------------------------------------------------------------------------------
//part of the code from my .h file:
//------------------------------------------------------------------------------
 
public:
 
// ........
 
//===================
//My ITK Object Pointers
//===================
    
  typedef int integer;
  typedef unsigned short      PixelType;
  typedef  unsigned char  InputPixelType;
  typedef  unsigned char  OutputPixelType;
  typedef itk::Image< InputPixelType,  2 >   InputImageType;
  typedef itk::Image< OutputPixelType, 2 >   OutputImageType;
  typedef itk::RegionOfInterestImageFilter<InputImageType, OutputImageType >  FilterType;
  typedef itk::ImageFileWriter< OutputImageType> WriterTypeGL;
  
  FilterType::Pointer filter ;
  WriterTypeGL::Pointer writergl;

  typedef InputImageType::RegionType RegionType;
 

  // ........
 
 
//------------------------------------------------------------------------------
//-------------------- part of my c++ code --------------------------
 
int FrontDialog::CropImage(){
 
//...........................
 
writerMoving->SetInput( cropMoving->GetOutput() );
 
     try {
         writerMoving->Update();
         }     catch (itk::ExceptionObject &err)         {
         std::cout<< "Exception caught in writing the moving image:" << std::endl;
         std::cout<< err <<std::endl;
        
         return -1;
         }
  
 cout << "images are cropped \n" << endl;
 
//here I definitely know that cropMoving->GetOutput()  gives correct results
//because I am able to save it as an image. However, I also want to save it in a
//public variable to use over and over.
 
//here comes the part which fails:
 
 RegionType regionGL;
 regionGL.SetSize(Width, Height);
 regionGL.SetIndex(0,0);

 filter = FilterType::New();
 filter->SetRegionOfInterest(regionGL);
 filter->SetInput( cropMoving->GetOutput());
 
 try {
          filter->Update();
         }     catch (itk::ExceptionObject &err)         {
         std::cout<< "Exception caught:" << std::endl;
         std::cout<< err <<std::endl;
         return -1;
         }

  filter->GetOutput()->Print( std::cout );
 
 writergl = WriterTypeGL::New();
 writergl->SetFileName( "test.png" );
 writergl->SetInput(filter->GetOutput());
  try {
         writergl->Update();
         }     catch (itk::ExceptionObject &err)         {
         std::cout<< "Exception caught:" << std::endl;
         std::cout<< err <<std::endl;
        
         return -1;
         }
 
return 0;
}
 
 
//-------------------------------------------------------------------
 
If I couldn't express my problem clearly, I am very sorry. I would be glad to send the whole project though... I will really appreciate it a lot if anyone could help me...
Thanks a lot !
Seniha
 
PS: I have an idea that even if I got the previous code working, it will not do the thing I want, or will it? What should I do?
 
 



  _____  

Yahoo! Mail for Mobile
Take  <http://us.rd.yahoo.com/evt=31132/*http://mobile.yahoo.com/learn/mail> Yahoo! Mail with you! Check email on your mobile phone.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20050831/cd7deac9/attachment.htm


More information about the Insight-users mailing list