Hi,<br><br>Did you copy the png images to the same directory as your executable program?<br>(otherwise you may need to specify the path)<br><br>I revised your code as attached and it worked for me on linux.<br>(I used the attached CMakeLists.txt file that specifies the include_directories where the libraries are on my system,<br>
it includes more directories because I use this CMakeLists.txt file&#39;s include_directories on all my compiliations)<br>Unfortunately, I have not figured out how to get CMake to automatically find the include_directories and ITK_DIR. I enter the ITK_DIR each time I first compile the program.<br>
<br>John<br><br><div class="gmail_quote">On Fri, Nov 26, 2010 at 1:57 PM, Brecht Heyde <span dir="ltr">&lt;<a href="mailto:Brecht.Heyde@med.kuleuven.be">Brecht.Heyde@med.kuleuven.be</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">









<div link="blue" vlink="purple" lang="NL">

<div>

<p class="MsoNormal"><span lang="EN-GB">Hi all,</span></p>

<p class="MsoNormal"><span lang="EN-GB"> </span></p>

<p class="MsoNormal"><span lang="EN-GB">I am fairly new to ITK and have a couple of
questions:</span></p>

<p class="MsoNormal"><span lang="EN-GB"> </span></p>

<p class="MsoNormal"><span lang="EN-GB">1. When creating a new ITK program, do I
always have to go through CMake to create (in my case) a .sln Visual Studio
Solution? Or do I otherwise have to specify all the additional directories +
libraries for the linker manually?</span></p>

<p><span lang="EN-GB"> </span></p>

<p class="MsoNormal" style="margin-bottom: 12pt;"><span lang="EN-GB">2. I tried
adapting the ImageReadWrite.cxx slightly in order to read the BrainMidSagittalSlice.png
found in the ITK/Examples/Data directory. <br>
My source code is:</span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;" lang="EN-US">#include</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"> <span style="color: maroon;">&quot;itkImageFileReader.h&quot;</span></span></p>


<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;" lang="EN-US">#include</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"> <span style="color: maroon;">&quot;itkImageFileWriter.h&quot;</span></span></p>


<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;" lang="EN-US"> </span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;" lang="EN-US">#include</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"> <span style="color: maroon;">&quot;itkImage.h&quot;</span></span></p>


<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;" lang="EN-US"> </span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: maroon;" lang="EN-US"> </span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;" lang="EN-US">int</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"> main()</span></p>


<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">{</span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">  <span style="color: blue;">typedef</span> <span style="color: blue;">short</span>     
PixelType;</span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">  <span style="color: blue;">const</span>   <span style="color: blue;">unsigned</span>
<span style="color: blue;">int</span>       
Dimension = 2;</span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">  <span style="color: blue;">typedef</span> itk::Image&lt; PixelType, Dimension
&gt;    ImageType;</span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">  </span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">  <span style="color: blue;">typedef</span> itk::ImageFileReader&lt; ImageType &gt; 
ReaderType;</span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">  <span style="color: blue;">typedef</span> itk::ImageFileWriter&lt; ImageType &gt; 
WriterType;</span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"> </span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"> 
ReaderType::Pointer reader = ReaderType::New();</span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">  WriterType::Pointer
writer = WriterType::New();</span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">  </span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">  <span style="color: blue;">const</span> <span style="color: blue;">char</span> *
inputFilename  = <span style="color: maroon;">&quot;BrainMidSagittalSlice.png&quot;</span>;</span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">  <span style="color: blue;">const</span> <span style="color: blue;">char</span> *
outputFilename = <span style="color: maroon;">&quot;BrainMidSagittalSlice_output.png&quot;</span>;</span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"> </span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"> 
reader-&gt;SetFileName( inputFilename  );</span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"> 
writer-&gt;SetFileName( outputFilename );</span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">  </span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"> 
writer-&gt;SetInput( reader-&gt;GetOutput() );</span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">  </span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">  <span style="color: blue;">try</span> </span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">   
{ </span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">   
writer-&gt;Update(); </span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">   
} </span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">  <span style="color: blue;">catch</span>( itk::ExceptionObject &amp; err ) </span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">   
{ </span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">   
std::cerr &lt;&lt; <span style="color: maroon;">&quot;ExceptionObject caught
!&quot;</span> &lt;&lt; std::endl; </span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">   
std::cerr &lt;&lt; err &lt;&lt; std::endl;</span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">   
<span style="color: blue;">return</span> EXIT_FAILURE;</span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">   
} </span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"> </span></p>

<p class="MsoNormal" style="margin-left: 36pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">  <span style="color: blue;">return</span> EXIT_SUCCESS;</span></p>

<p style="margin-left: 72pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">}</span><span lang="EN-GB"></span></p>

<p class="MsoNormal"><span lang="EN-GB"> </span></p>

<p class="MsoNormal"><span lang="EN-GB">With CmakeList.txt:</span></p>

<p class="MsoNormal"><span lang="EN-GB"> </span></p>

<p class="MsoNormal" style=""><span lang="EN-GB">               
</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">CMAKE_MINIMUM_REQUIRED(VERSION
2.4)</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">IF(COMMAND
CMAKE_POLICY)</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"> 
CMAKE_POLICY(SET CMP0003 NEW)</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">ENDIF(COMMAND
CMAKE_POLICY)</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"> </span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"> </span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"># This project is
designed to be built outside the Insight source tree.</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">PROJECT(ImageReadWrite)</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"> </span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"># Find ITK.</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">FIND_PACKAGE(ITK
REQUIRED)</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">INCLUDE(${ITK_USE_FILE})</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"> </span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">ADD_EXECUTABLE(ImageReadWrite
ImageReadWrite.cxx)</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"> </span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">TARGET_LINK_LIBRARIES(ImageReadWrite
ITKIO)</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">When running the resulting executable from
a cmd prompt as ‘ImageReadWrite’, I get the following error:</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">C:\ITK-dev\ImageReadWrite\debug&gt;ImageReadWrite</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">ExceptionObject
caught !</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US"> </span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">itk::ImageFileReaderException
(0133F0CC)</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">Location:
&quot;void __thiscall itk::ImageFileReader&lt;class
itk::Image&lt;short,2&gt;,class</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">itk::DefaultConvertPixelTraits&lt;short&gt;
&gt;::GenerateOutputInformation(void)&quot;</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">File:
c:\itk-src\insighttoolkit-3.20.0\insighttoolkit-3.20.0\code\io\itkImageFileReader.txx</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">Line: 146</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">Description: 
Could not create IO object for file BrainMidSagittalSlice.png</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">  Tried to
create one of the following:</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">   
BioRadImageIO</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">   
GDCMImageIO</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">   
MetaImageIO</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">   
PNGImageIO</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">   
VTKImageIO</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">   
GiplImageIO</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">   
LSMImageIO</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">   
AnalyzeImageIO</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">   
NiftiImageIO</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">   
StimulateImageIO</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">   
JPEGImageIO</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">   
TIFFImageIO</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">   
NrrdImageIO</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">   
BMPImageIO</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">   
DICOMImageIO2</span></p>

<p class="MsoNormal" style="margin-left: 35.4pt;"><span lang="EN-US">  You
probably failed to set a file suffix, or  set the suffix to an unsupported
type.</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">As I understood from previous mails on this
list, the IO object decides automatically to what format it should write. What am
I doing wrong?</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-GB">3. I’d like to read a 3D+time dataset in
ITK. The original dataset is in dicom format but I have previously extracted
the relevant data and converted to a .mat format for further processing in
Matlab (in practice this is just one big 4D matrix). Furthermore, we have
developed a visualisation tool to manually segment such a dataset and export a
mesh (cloud of points with connectivity matrix) containing this manual
contouring.</span></p>

<p class="MsoNormal"><span lang="EN-GB"> </span></p>

<p class="MsoNormal"><span lang="EN-GB">I was wondering what format I could use to
import such a series of 3D matrices and import this cloud of points. I doubt
that a dicomreader would work as the image data is stored in a private
datastructure in the dicomformat.</span></p>

<p class="MsoNormal"><span lang="EN-GB"> </span></p>

<p class="MsoNormal"><span lang="EN-GB">4. I’d like to register this set of 3D
images and know how my cloud of points are deformed by the registration
algorithm. Is this possible in ITK? Likewise, would it be possible to calculate
how an overlying grid deforms due to this registration? Finally, I would like
to export the positions of this deformed set of points (and preferably the deformed
floating images). Can I do this in a Matlab compatible format or do I have to
write a mex wrapper for this? </span></p>

<p class="MsoNormal"><span lang="EN-GB"> </span></p>

<p class="MsoNormal"><span lang="EN-GB">Many thanks,</span></p>

<p class="MsoNormal"><span lang="EN-GB"> </span></p>

<p class="MsoNormal"><span lang="EN-GB">Best regards,</span></p>

<p class="MsoNormal"><span lang="EN-GB">Brecht </span></p>

<p class="MsoNormal"><span lang="EN-GB"> </span></p>

</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.html" target="_blank">http://www.kitware.com/products/protraining.html</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><br clear="all"><br>-- <br><div>John Jan Drozd, Ph.D.</div>
<div>Post-Doctoral Fellow</div>
<div>Imaging Research Laboratories</div>
<div>Robarts Research Institute</div>
<div>The University of Western Ontario</div>
<div>London, ON, Canada</div>
<div><a href="http://imaging.robarts.ca/%7Ejdrozd" target="_blank">http://imaging.robarts.ca/~jdrozd</a></div><br>