<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Most likely this is a problem with how you are using CMake for ITK and is not related to the code you have included here.<div><br></div><div>There is an example of what a basic CMake project which uses ITK should like like int ITK/Examples/Installation/CMakeLists.txt</div><div><br></div><div><a href="http://itk.org/gitweb?p=ITK.git;a=blob;f=Examples/Installation/CMakeLists.txt;h=5e1b9e7ae0a95430f5162e8ff435b98570c5ad6e;hb=HEAD">http://itk.org/gitweb?p=ITK.git;a=blob;f=Examples/Installation/CMakeLists.txt;h=5e1b9e7ae0a95430f5162e8ff435b98570c5ad6e;hb=HEAD</a></div><div><br></div><div>Hopefully, this will get you started in the right direction to solve you problem.</div><div><br></div><div>Brad<br><div><br></div><div><br><div><div>On May 22, 2012, at 4:35 AM, Sebastian Losch wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi!<div><br></div><div>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:</div>
<div><br></div><div><div>#include "itkImage.h"</div><div>#include "itkImageFileReader.h"</div><div>#include "itkImageFileWriter.h"</div><div>#include "itkCannyEdgeDetectionImageFilter.h"</div>
<div>#include "itkObjectFactoryBase.h"</div><div>#include "itkPNGImageIOFactory.h"</div><div><br></div><div>int main(int argc, char *argv[])</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>itk::ObjectFactoryBase::RegisterFactory(itk::PNGImageIOFactory::New());</div>
<div><br></div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>double variance = 2.0;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>double upperThreshold = 0.0;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>double lowerThreshold = 0.0;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>typedef itk::Image<double, 2> DoubleImageType;</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>typedef itk::ImageFileReader<DoubleImageType> ReaderType;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>ReaderType::Pointer reader = ReaderType::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>reader->SetFileName("input.png");</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>typedef itk::CannyEdgeDetectionImageFilter <DoubleImageType, DoubleImageType></div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>CannyEdgeDetectionImageFilterType;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>CannyEdgeDetectionImageFilterType::Pointer cannyFilter = CannyEdgeDetectionImageFilterType::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>cannyFilter->SetInput(reader->GetOutput());</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>cannyFilter->SetVariance( variance );</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>cannyFilter->SetUpperThreshold( upperThreshold );</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>cannyFilter->SetLowerThreshold( lowerThreshold );</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>typedef itk::ImageFileWriter<DoubleImageType> WriterType;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>WriterType::Pointer writer = WriterType::New();</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>writer->SetFileName("test.png");</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>writer->SetInput(cannyFilter->GetOutput());</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>try {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>writer->Update();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>} catch (itk::ExceptionObject &e) {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>std::cerr << e << std::endl;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>std::cout << "ENDE" << std::endl;</div>
<div>}</div></div><div><br></div><div>and this is the error:</div><div><br></div><div><div>itk::ImageFileReaderException (0059E4A8)</div><div>Location: "void __thiscall itk::ImageFileReader<class itk::Image<double,2>,class itk::DefaultConvertPixelTraits<double> >::GenerateOutputInformation(void)"</div>
<div>File: c:\libs\itk\include\itk-4.1\itkimagefilereader.hxx</div><div>Line: 143</div><div>Description: Could not create IO object for file input.png</div><div> Tried to create one of the following:</div><div> PNGImageIO</div>
<div> You probably failed to set a file suffix, or</div><div> set the suffix to an unsupported type.</div></div><div><br></div><div><br></div><div>What am i doing wrong?</div><div><br></div><div>Thanks in advance, Sebastian</div>
_____________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Kitware offers ITK Training Courses, for more information visit:<br>http://www.kitware.com/products/protraining.php<br><br>Please keep messages on-topic and check the ITK FAQ at:<br>http://www.itk.org/Wiki/ITK_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://www.itk.org/mailman/listinfo/insight-users<br></blockquote></div><br><div>
<span class="Apple-style-span" style="font-size: 12px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">========================================================</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Bradley Lowekamp<span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Medical Science and Computing for</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Office of High Performance Computing and Communications</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">National Library of Medicine<span class="Apple-converted-space"> </span></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; "><a href="mailto:blowekamp@mail.nih.gov">blowekamp@mail.nih.gov</a></font></p><br class="Apple-interchange-newline"></span></div></span><br class="Apple-interchange-newline">
</div>
<br></div></div></body></html>