[Insight-users] ITK 4.1 ImageIOFactory Could not create IO Object

Luis Ibanez luis.ibanez at kitware.com
Wed May 23 20:38:33 EDT 2012


Hi Sebastian,

Thanks for sharing the input.png image.

              Mystery solved !   :-)

The .png image is actually a JPEG image,
with the wrong extension.

Just change the extension to .jpg and this
will work fine.

Please find attached the a cleaner main.cpp
and the output of the canny filter in the
input image.

Note that the output of the Canny filter was
connected to a rescale intensity filter to
scale the values from 0,1 to 0,255 and
make them easily visible in standard image
viewers.


     Thanks


          Luis


------------------------------
On Wed, May 23, 2012 at 8:17 PM, Sebastian Losch
<seb.losch at googlemail.com>wrote:

> Hi Luis,
>
>  i attached the .png file to this email. It's a beauitiful picture of
> myself, shot with a cheap webcam ;)
>
> Thanks, Sebastian
>
>
> 2012/5/24 Luis Ibanez <luis.ibanez at kitware.com>
>
>> Hi Sebastian,
>>
>> Could you please send me that .png file ?
>>
>>    Thanks
>>
>>
>>         Luis
>>
>>
>> -----------------
>>
>> On Wed, May 23, 2012 at 7:47 PM, Sebastian Losch <
>> seb.losch at googlemail.com> wrote:
>>
>>>  Hi Luis!
>>>
>>> Thanks for your response. As i wrote in my first post the .png file is
>>> in the same folder as the executable, so that cannot be the reason. When i
>>> change the filename to something different (e.g. to a file which does not
>>> exists) then itk throws a different exception (file not found).
>>>
>>> Sebastian
>>>
>>> Am 24.05.2012 01:40, schrieb Luis Ibanez:
>>>
>>> Hi Sebastian,
>>>
>>>  You are using a plain filename (instead of a full path)
>>> to point to your image:
>>>
>>>   reader->SetFileName("input.png");
>>>
>>>
>>> The factories are telling you that the file
>>>
>>>                    "input.png"
>>>
>>>  is not in the same directory that the executable
>>> that you build with Visual Studio.
>>>
>>>
>>>  You may want to try one of these tree options:
>>>
>>>
>>>  1) Use a full path to point to your image,
>>>      something like:
>>>
>>>                 C:\MyImages\input.png
>>>
>>> or
>>>
>>> 2) Copy the image to where the executable is
>>>
>>>  or
>>>
>>>  3) Copy the executable to where the image is
>>>     and run the executable from that directory
>>>
>>>
>>>
>>> Option (1) is probably the best way to go.
>>>
>>>
>>>
>>>  Ideally your code should have been:
>>>
>>>
>>>  A) If using a command line approach
>>>
>>>  reader->SetFileName( argv[1] );
>>>
>>> or,
>>>
>>>  B) If using a GUI to get the filename from the user:
>>>
>>>        const char * filename = GetMeAFileNameFromGUI();
>>>
>>>  reader->SetFileName( filename );
>>>
>>>
>>>
>>>     Hope this helps,
>>>
>>>
>>>          Luis
>>>
>>>
>>>  -----------------------------------------
>>> On Tue, May 22, 2012 at 4:35 AM, Sebastian Losch <
>>> seb.losch at googlemail.com> wrote:
>>>
>>>> Hi!
>>>>
>>>>  I am having problems getting the ImageFileReader and ImageFileWriter
>>>> to work. I just want to read a PNG File, apply a filter and write it back
>>>> to the harddrive. I found out that there is a problem in 4.1 with the
>>>> ImageIOFactory registration, so i register the PNGFactory manually. The
>>>> .png file is in the same folder as the executable. Here is my Code:
>>>>
>>>>  #include "itkImage.h"
>>>> #include "itkImageFileReader.h"
>>>> #include "itkImageFileWriter.h"
>>>> #include "itkCannyEdgeDetectionImageFilter.h"
>>>> #include "itkObjectFactoryBase.h"
>>>> #include "itkPNGImageIOFactory.h"
>>>>
>>>>  int main(int argc, char *argv[])
>>>> {
>>>>
>>>> itk::ObjectFactoryBase::RegisterFactory(itk::PNGImageIOFactory::New());
>>>>
>>>>
>>>>  double variance = 2.0;
>>>>  double upperThreshold = 0.0;
>>>>  double lowerThreshold = 0.0;
>>>>
>>>>  typedef itk::Image<double, 2>  DoubleImageType;
>>>>
>>>>  typedef itk::ImageFileReader<DoubleImageType> ReaderType;
>>>>  ReaderType::Pointer reader = ReaderType::New();
>>>>  reader->SetFileName("input.png");
>>>>
>>>>  typedef itk::CannyEdgeDetectionImageFilter <DoubleImageType,
>>>> DoubleImageType>
>>>>  CannyEdgeDetectionImageFilterType;
>>>>
>>>>  CannyEdgeDetectionImageFilterType::Pointer cannyFilter =
>>>> CannyEdgeDetectionImageFilterType::New();
>>>>  cannyFilter->SetInput(reader->GetOutput());
>>>>  cannyFilter->SetVariance( variance );
>>>>  cannyFilter->SetUpperThreshold( upperThreshold );
>>>>  cannyFilter->SetLowerThreshold( lowerThreshold );
>>>>
>>>>  typedef itk::ImageFileWriter<DoubleImageType> WriterType;
>>>>  WriterType::Pointer writer = WriterType::New();
>>>>
>>>>  writer->SetFileName("test.png");
>>>>  writer->SetInput(cannyFilter->GetOutput());
>>>>
>>>>  try {
>>>>  writer->Update();
>>>>  } catch (itk::ExceptionObject &e) {
>>>>  std::cerr << e << std::endl;
>>>>  }
>>>>
>>>>  std::cout << "ENDE" << std::endl;
>>>> }
>>>>
>>>>  and this is the error:
>>>>
>>>>  itk::ImageFileReaderException (0059E4A8)
>>>> Location: "void __thiscall itk::ImageFileReader<class
>>>> itk::Image<double,2>,class itk::DefaultConvertPixelTraits<double>
>>>> >::GenerateOutputInformation(void)"
>>>> File: c:\libs\itk\include\itk-4.1\itkimagefilereader.hxx
>>>> Line: 143
>>>> Description:  Could not create IO object for file input.png
>>>>   Tried to create one of the following:
>>>>     PNGImageIO
>>>>   You probably failed to set a file suffix, or
>>>>     set the suffix to an unsupported type.
>>>>
>>>>
>>>>  What am i doing wrong?
>>>>
>>>>  Thanks in advance, Sebastian
>>>>
>>>> _____________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Kitware offers ITK Training Courses, for more information visit:
>>>> http://www.kitware.com/products/protraining.php
>>>>
>>>> Please keep messages on-topic and check the ITK FAQ at:
>>>> http://www.itk.org/Wiki/ITK_FAQ
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.itk.org/mailman/listinfo/insight-users
>>>>
>>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120523/8927a984/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cpp
Type: text/x-c++src
Size: 1525 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120523/8927a984/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.png
Type: image/png
Size: 13875 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120523/8927a984/attachment.png>


More information about the Insight-users mailing list