It is your input file that you are having problems <div>with. PNG supports unsigned char or unsigned </div><div>short but you are trying to read your input as </div><div>double. You need to change this <br><span class="Apple-style-span" style>typedef itk::ImageFileReader<DoubleImageType> ReaderType;</span></div>
<div><font class="Apple-style-span" color="#500050" face="arial, sans-serif">to </font></div><div><font class="Apple-style-span" color="#500050" face="arial, sans-serif"><span class="Apple-style-span" style>typedef itk::ImageFileReader<IntImageType> ReaderType;</span></font></div>
<div><font class="Apple-style-span" color="#500050" face="arial, sans-serif"><span class="Apple-style-span" style="color:rgb(0,0,0);font-family:arial">and modify the rest of your code keeping the imagetypes </span></font></div>
<div><font class="Apple-style-span" color="#500050" face="arial, sans-serif"><span class="Apple-style-span" style="color:rgb(0,0,0);font-family:arial">consistent. </span></font></div><div><font class="Apple-style-span" color="#500050" face="arial, sans-serif"><span class="Apple-style-span" style="color:rgb(0,0,0);font-family:arial"><br>
</span></font></div><div><font class="Apple-style-span" color="#500050" face="arial, sans-serif"><span class="Apple-style-span" style="color:rgb(0,0,0);font-family:arial">Cheers, </span></font></div><div><font class="Apple-style-span" color="#500050" face="arial, sans-serif"><span class="Apple-style-span" style="color:rgb(0,0,0);font-family:arial">Cagatay</span></font></div>
<div><font class="Apple-style-span" color="#500050" face="arial, sans-serif"><span class="Apple-style-span" style="color:rgb(0,0,0);font-family:arial"><br></span></font></div><div><font class="Apple-style-span" color="#500050" face="arial, sans-serif"><span class="Apple-style-span" style="color:rgb(0,0,0);font-family:arial"><br>
</span></font></div><div><div class="gmail_quote">On Tue, May 22, 2012 at 7:42 AM, Sebastian Losch <span dir="ltr"><<a href="mailto:seb.losch@googlemail.com" target="_blank">seb.losch@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">hi Bill!<div><br></div><div>it is the same as in my first posting. Sorry, i thought i made that clear.</div><div><br></div>
<div><div class="im">Description: Could not create IO object for file input.png <br><br></div><div><div class="h5"><div class="gmail_quote">2012/5/22 Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Pleases post the complete line for<br>
<div>Description: Could not create IO object for fi<br>
<br>
<br>
</div><div><div>On Tue, May 22, 2012 at 9:30 AM, Sebastian Losch<br>
<<a href="mailto:seb.losch@googlemail.com" target="_blank">seb.losch@googlemail.com</a>> wrote:<br>
> Hm okay, i just created a solution for visual studio using this helloworld<br>
> cmake project as basis. The only difference is that there are more Image<br>
> types he tried, but it is not working. I did try it with JPEG instead of<br>
> PNG, i had to use a castimagefilter in order to use it with the canny filter<br>
> which only support real values. No errors, but the output image is just<br>
> black.<br>
><br>
> Some other ideas?<br>
><br>
> This is the error:<br>
><br>
> Description: Could not create IO object for fi<br>
> Tried to create one of the following:<br>
> JPEGImageIO<br>
> GDCMImageIO<br>
> BMPImageIO<br>
> LSMImageIO<br>
> PNGImageIO<br>
> TIFFImageIO<br>
> VTKImageIO<br>
> StimulateImageIO<br>
> BioRadImageIO<br>
> MetaImageIO<br>
> NiftiImageIO<br>
> NrrdImageIO<br>
> GiplImageIO<br>
> HDF5ImageIO<br>
> PNGImageIO<br>
> JPEGImageIO<br>
> You probably failed to set a file suffix, or<br>
> set the suffix to an unsupported type.<br>
><br>
> 2012/5/22 Sebastian Losch <<a href="mailto:seb.losch@googlemail.com" target="_blank">seb.losch@googlemail.com</a>><br>
>><br>
>> Hi Brad,<br>
>><br>
>> thanks for your response. I should have mentioned in my first post that i<br>
>> am using Visual Studio 2010 on a Win7 32bit machine. I've read that this<br>
>> problem can be solved by adding include(${ITK_USE_FILE}) to the makefile.<br>
>> But what is the corresponding way to do it in visual studio?<br>
>><br>
>> Thanks, Sebastian<br>
>><br>
>><br>
>> 2012/5/22 Bradley Lowekamp <<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>><br>
>>><br>
>>> Most likely this is a problem with how you are using CMake for ITK and is<br>
>>> not related to the code you have included here.<br>
>>><br>
>>> There is an example of what a basic CMake project which uses ITK should<br>
>>> like like int ITK/Examples/Installation/CMakeLists.txt<br>
>>><br>
>>><br>
>>> <a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Examples/Installation/CMakeLists.txt;h=5e1b9e7ae0a95430f5162e8ff435b98570c5ad6e;hb=HEAD" target="_blank">http://itk.org/gitweb?p=ITK.git;a=blob;f=Examples/Installation/CMakeLists.txt;h=5e1b9e7ae0a95430f5162e8ff435b98570c5ad6e;hb=HEAD</a><br>
>>><br>
>>> Hopefully, this will get you started in the right direction to solve you<br>
>>> problem.<br>
>>><br>
>>> Brad<br>
>>><br>
>>><br>
>>> On May 22, 2012, at 4:35 AM, Sebastian Losch wrote:<br>
>>><br>
>>> Hi!<br>
>>><br>
>>> I am having problems getting the ImageFileReader and ImageFileWriter to<br>
>>> work. I just want to read a PNG File, apply a filter and write it back to<br>
>>> the harddrive. I found out that there is a problem in 4.1 with the<br>
>>> ImageIOFactory registration, so i register the PNGFactory manually. The .png<br>
>>> file is in the same folder as the executable. Here is my Code:<br>
>>><br>
>>> #include "itkImage.h"<br>
>>> #include "itkImageFileReader.h"<br>
>>> #include "itkImageFileWriter.h"<br>
>>> #include "itkCannyEdgeDetectionImageFilter.h"<br>
>>> #include "itkObjectFactoryBase.h"<br>
>>> #include "itkPNGImageIOFactory.h"<br>
>>><br>
>>> int main(int argc, char *argv[])<br>
>>> {<br>
>>> itk::ObjectFactoryBase::RegisterFactory(itk::PNGImageIOFactory::New());<br>
>>><br>
>>><br>
>>> double variance = 2.0;<br>
>>> double upperThreshold = 0.0;<br>
>>> double lowerThreshold = 0.0;<br>
>>><br>
>>> typedef itk::Image<double, 2> DoubleImageType;<br>
>>><br>
>>> typedef itk::ImageFileReader<DoubleImageType> ReaderType;<br>
>>> ReaderType::Pointer reader = ReaderType::New();<br>
>>> reader->SetFileName("input.png");<br>
>>><br>
>>> typedef itk::CannyEdgeDetectionImageFilter <DoubleImageType,<br>
>>> DoubleImageType><br>
>>> CannyEdgeDetectionImageFilterType;<br>
>>><br>
>>> CannyEdgeDetectionImageFilterType::Pointer cannyFilter =<br>
>>> CannyEdgeDetectionImageFilterType::New();<br>
>>> cannyFilter->SetInput(reader->GetOutput());<br>
>>> cannyFilter->SetVariance( variance );<br>
>>> cannyFilter->SetUpperThreshold( upperThreshold );<br>
>>> cannyFilter->SetLowerThreshold( lowerThreshold );<br>
>>><br>
>>> typedef itk::ImageFileWriter<DoubleImageType> WriterType;<br>
>>> WriterType::Pointer writer = WriterType::New();<br>
>>><br>
>>> writer->SetFileName("test.png");<br>
>>> writer->SetInput(cannyFilter->GetOutput());<br>
>>><br>
>>> try {<br>
>>> writer->Update();<br>
>>> } catch (itk::ExceptionObject &e) {<br>
>>> std::cerr << e << std::endl;<br>
>>> }<br>
>>><br>
>>> std::cout << "ENDE" << std::endl;<br>
>>> }<br>
>>><br>
>>> and this is the error:<br>
>>><br>
>>> itk::ImageFileReaderException (0059E4A8)<br>
>>> Location: "void __thiscall itk::ImageFileReader<class<br>
>>> itk::Image<double,2>,class itk::DefaultConvertPixelTraits<double><br>
>>> >::GenerateOutputInformation(void)"<br>
>>> File: c:\libs\itk\include\itk-4.1\itkimagefilereader.hxx<br>
>>> Line: 143<br>
>>> Description: Could not create IO object for file input.png<br>
>>> Tried to create one of the following:<br>
>>> PNGImageIO<br>
>>> You probably failed to set a file suffix, or<br>
>>> set the suffix to an unsupported type.<br>
>>><br>
>>><br>
>>> What am i doing wrong?<br>
>>><br>
>>> Thanks in advance, Sebastian<br>
>>> _____________________________________<br>
>>> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>>><br>
>>> Visit other Kitware open-source projects at<br>
>>> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>>><br>
>>> Kitware offers ITK Training Courses, for more information visit:<br>
>>> <a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
>>><br>
>>> Please keep messages on-topic and check the ITK FAQ at:<br>
>>> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
>>><br>
>>> Follow this link to subscribe/unsubscribe:<br>
>>> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
>>><br>
>>><br>
>>> ========================================================<br>
>>><br>
>>> Bradley Lowekamp<br>
>>><br>
>>> Medical Science and Computing for<br>
>>><br>
>>> Office of High Performance Computing and Communications<br>
>>><br>
>>> National Library of Medicine<br>
>>><br>
>>> <a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a><br>
>>><br>
>>><br>
>>><br>
>>><br>
>><br>
><br>
><br>
> _____________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Kitware offers ITK Training Courses, for more information visit:<br>
> <a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
><br>
<br>
<br>
<br>
</div></div><span><font color="#888888">--<br>
Unpaid intern in BillsBasement at noware dot com<br>
</font></span></blockquote></div><br></div></div></div>
<br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br></div>