<div dir="ltr"><div><div><div><div><div><div>Hello,<br><br></div>If you use the ITK IO factory, your first piece of code should work. The automatic detection of the image format does not rely on the inclusion of "itkImage.h", but relies on itkImageFileReader.h.<br></div>Do you use CMake to configure your project? If so, if you have the following lines in your CMakeLists files, everything should be done automatically:<br></div>find_package(ITK REQUIRED)<br></div>include(${ITK_USE_FILE})<br><br></div>After configuring your project, your build directory should contain a folder named ITKIOFactoryRegistration.<br></div><div>If you do not use CMake to configure your project, I strongly suggest you to do so. It will simplify a lot of things.<br></div><div>You can also manually register the ITK IOs that you want to support before use reading your file. You can find some information in the last part of the documentation provided on this page:<br><a href="https://itk.org/Wiki/ITK/FAQ">https://itk.org/Wiki/ITK/FAQ</a><br><br></div><div>Hope this helps,<br><br></div><div>Francois<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 3, 2016 at 10:01 AM, adariush <span dir="ltr"><<a href="mailto:adariush@ast.cam.ac.uk" target="_blank">adariush@ast.cam.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I am using ITK 10.0 on a MacBook Pro running on OS X El Capitan.<br>
<br>
I have problem with reading/writing images. For example to read/write PNG image formats, I expect to do something like this:<br>
<br>
==============================<wbr>===========================<br>
#include "itkImage.h"<br>
#include "itkImageFileReader.h"<br>
<br>
typedef unsigned char InputPixelType;<br>
typedef itk::Image< InputPixelType , 2 > InputImageType;<br>
typedef itk::ImageFileReader<InputImag<wbr>eType> ReaderType;<br>
ReaderType::Pointer reader = ReaderType::New();<br>
reader->SetFileName('image name');<br>
reader->Update();<br>
==============================<wbr>===========================<br>
However, the above code returns an error since it seems that "itkImage.h" does nothing at all!<br>
<br>
Instead every time I want to read/write a PNG image, I should modify the above code as follow:<br>
<br>
<br>
==============================<wbr>===========================<br>
#include "itkImageFileReader.h"<br>
#include "itkPNGImageIOFactory.h" // new line<br>
<br>
typedef unsigned char InputPixelType;<br>
typedef itk::Image< InputPixelType , 2 > InputImageType;<br>
typedef itk::ImageFileReader<InputImag<wbr>eType> ReaderType;<br>
ReaderType::Pointer reader = ReaderType::New();<br>
itk::PNGImageIOFactory::Regist<wbr>erOneFactory(); // new line<br>
reader->SetFileName('image name');<br>
reader->Update();<br>
==============================<wbr>===========================<br>
<br>
<br>
In short, I expect by including "itkImage.h", ITK automatically identify input/output image format. However, I have to do it manually. The problem is when I want to read for example a '.mha' file format.<br>
<br>
Does anyone know what might be the problem and how could I 'SOLVE' it?<br>
<br>
Thanks, Ali<br>
______________________________<wbr>_______<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" 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" rel="noreferrer" target="_blank">http://www.kitware.com/opensou<wbr>rce/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" target="_blank">http://www.kitware.com/product<wbr>s/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" rel="noreferrer" target="_blank">http://www.itk.org/Wiki/ITK_FA<wbr>Q</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/insight-users</a><br>
</blockquote></div><br></div>