<div dir="ltr">Dear Amir,<div><br></div><div>What image file format are you trying to read? I've been unable to replicate the error. </div><div><br></div><div><span style="color:rgb(0,0,0);font-family:'Lucida Grande',Verdana,Geneva,Arial,sans-serif;font-size:12px;line-height:22px">"Normally just setting the FileName with the appropriate suffix is enough to get the reader to instantiate the correct ImageIO and read the file properly. However, some files (like raw binary format) have no accepted suffix, so you will have to manually create the ImageIO instance of the write type. "</span><br></div><div><font color="#000000" face="Lucida Grande, Verdana, Geneva, Arial, sans-serif"><span style="font-size:12.222222328186px;line-height:22px"><a href="http://www.itk.org/Doxygen/html/classitk_1_1ImageFileReader.html">http://www.itk.org/Doxygen/html/classitk_1_1ImageFileReader.html</a></span></font><br></div><div><font color="#000000" face="Lucida Grande, Verdana, Geneva, Arial, sans-serif"><span style="font-size:12.222222328186px;line-height:22px"><br></span></font></div><div><font color="#000000" face="Lucida Grande, Verdana, Geneva, Arial, sans-serif"><span style="font-size:12.222222328186px;line-height:22px">Regards,</span></font></div><div><font color="#000000" face="Lucida Grande, Verdana, Geneva, Arial, sans-serif"><span style="font-size:12.222222328186px;line-height:22px">Jose</span></font></div><div><span style="color:rgb(0,0,0);font-family:'Lucida Grande',Verdana,Geneva,Arial,sans-serif;font-size:12px;line-height:22px"><br></span></div><div><span style="color:rgb(0,0,0);font-family:'Lucida Grande',Verdana,Geneva,Arial,sans-serif;font-size:12px;line-height:22px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 1, 2015 at 6:33 PM, Khojaste, Amir <span dir="ltr"><<a href="mailto:amir.khojaste@sunnybrook.ca" target="_blank">amir.khojaste@sunnybrook.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-CA" link="#0563C1" vlink="#954F72">
<div>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">Hey guys,
<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">I am new to developping with ITK,VTK and will appreciate if someone can pull me off from this problem! Sorry I have included VTK mailing list here too,
 I have not gotten my answer in ITK mailing list yet so was thinking maybe VTK users faced the same problem too.<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">The following is the simplest piece of code that is simply reading an Image using “itkImageFileReader”. I have built my ITK in debug mode using Cmake and
 VS2008. The Hello World program is running just fine but when I try to add couple of lines of code to read an image I get the following error:<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:#a31515">Unhandled exception at 0x000000013fcedb03 in HelloWorld.exe: 0xC0000005: Access violation reading location 0xffffffffffffffff.<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">I am confused and don’t know if this is the problem with Linking/my Cmakelists.txt or whatever else! I can read the image if I build the ITK examples and
 then use the codes there. This has made me even more confused! <u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">In the Call Stack the code goes to the lines 118 to 120 of “itkImageFileReader.txx” if which I think should’t.<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">if ( m_UserSpecifiedImageIO == false ) //try creating via factory<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">    {<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">    m_ImageIO = ImageIOFactory::CreateImageIO( m_FileName.c_str(), ImageIOFactory::ReadMode );<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">}<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:blue"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:blue"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">Any help?!<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:blue"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:blue"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:blue">/***** Code<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:blue"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:blue">#include</span><span style="font-size:10.0pt;font-family:"Courier New"">
<span style="color:#a31515">"itkImage.h"<u></u><u></u></span></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:blue">#include</span><span style="font-size:10.0pt;font-family:"Courier New"">
<span style="color:#a31515">"itkImageFileWriter.h"<u></u><u></u></span></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:blue">#include</span><span style="font-size:10.0pt;font-family:"Courier New"">
<span style="color:#a31515">"itkImageFileReader.h"<u></u><u></u></span></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:blue">#include</span><span style="font-size:10.0pt;font-family:"Courier New"">
<span style="color:#a31515">"itkCropImageFilter.h"<u></u><u></u></span></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:blue">#include</span><span style="font-size:10.0pt;font-family:"Courier New"">
<span style="color:#a31515">"itksys/SystemTools.hxx"<u></u><u></u></span></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:#a31515"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:blue">typedef</span><span style="font-size:10.0pt;font-family:"Courier New"">
<span style="color:blue">unsigned</span> <span style="color:blue">char</span>          PixelType;<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:blue">const</span><span style="font-size:10.0pt;font-family:"Courier New"">
<span style="color:blue">unsigned</span> <span style="color:blue">int</span>             Dimension = 3;<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:blue">typedef</span><span style="font-size:10.0pt;font-family:"Courier New""> itk::Image< PixelType, Dimension >   ImageType;<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:blue">typedef</span><span style="font-size:10.0pt;font-family:"Courier New""> itk::ImageFileReader<ImageType> ReaderType;<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:blue">int</span><span style="font-size:10.0pt;font-family:"Courier New""> main(<span style="color:blue">int</span> argc,
<span style="color:blue">char</span> *argv[])<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">{<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:green"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">  ReaderType::Pointer reader = ReaderType::New();<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">  reader->SetFileName( argv[1] );<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""> 
<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">  reader->Update();
<span style="color:green">// This line will crash<u></u><u></u></span></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">  system(<span style="color:#a31515">"pause"</span>);<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:blue">  return</span><span style="font-size:10.0pt;font-family:"Courier New""> EXIT_SUCCESS;<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">}<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">/*==== CMakeLists.txt<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""># This is the root ITK CMakeLists file.<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">CMAKE_MINIMUM_REQUIRED(VERSION 2.4)<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">IF(COMMAND CMAKE_POLICY)<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">  CMAKE_POLICY(SET CMP0003 NEW)<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">ENDIF(COMMAND CMAKE_POLICY)<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""># This project is designed to be built outside the Insight source tree.<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">PROJECT(HelloWorld)<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""># Find ITK.<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">FIND_PACKAGE(ITK REQUIRED)<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">INCLUDE(${ITK_USE_FILE})<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">ADD_EXECUTABLE(HelloWorld HelloWorld.cxx )<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New"">TARGET_LINK_LIBRARIES(HelloWorld ${ITK_LIBRARIES})<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal"><b><i><span style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:black">This e-mail is intended only for the named recipient(s) and may contain confidential, personal and/or health
 information (information which may be subject to legal restrictions on use, retention and/or disclosure).  No waiver of confidence is intended by virtue of communication via the internet.  Any review or distribution by anyone other than the person(s) for whom
 it was originally intended is strictly prohibited.  If you have received this e-mail in error, please contact the sender and destroy all copies.</span></i></b><span style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:black"><u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
</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://public.kitware.com/mailman/listinfo/insight-users" target="_blank">http://public.kitware.com/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br></div>