[ITK-users] Reading an Image in ITK, help plz!!

jose alejandro matute flores jmatuteflores at gmail.com
Fri May 1 19:23:50 EDT 2015


Dear Amir,

What image file format are you trying to read? I've been unable to
replicate the error.

"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. "
http://www.itk.org/Doxygen/html/classitk_1_1ImageFileReader.html

Regards,
Jose



On Fri, May 1, 2015 at 6:33 PM, Khojaste, Amir <amir.khojaste at sunnybrook.ca>
wrote:

>  Hey guys,
>
>
>
> 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.
>
>
>
> 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:
>
>
>
> Unhandled exception at 0x000000013fcedb03 in HelloWorld.exe: 0xC0000005:
> Access violation reading location 0xffffffffffffffff.
>
>
>
> 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!
>
>
>
> In the Call Stack the code goes to the lines 118 to 120 of
> “itkImageFileReader.txx” if which I think should’t.
>
>
>
> if ( m_UserSpecifiedImageIO == false ) //try creating via factory
>
>     {
>
>     m_ImageIO = ImageIOFactory::CreateImageIO( m_FileName.c_str(),
> ImageIOFactory::ReadMode );
>
> }
>
>
>
>
>
> Any help?!
>
>
>
>
>
> /***** Code
>
>
>
> #include "itkImage.h"
>
> #include "itkImageFileWriter.h"
>
> #include "itkImageFileReader.h"
>
> #include "itkCropImageFilter.h"
>
> #include "itksys/SystemTools.hxx"
>
>
>
> typedef unsigned char          PixelType;
>
> const unsigned int             Dimension = 3;
>
>
>
> typedef itk::Image< PixelType, Dimension >   ImageType;
>
> typedef itk::ImageFileReader<ImageType> ReaderType;
>
>
>
> int main(int argc, char *argv[])
>
> {
>
>
>
>   ReaderType::Pointer reader = ReaderType::New();
>
>    reader->SetFileName( argv[1] );
>
>
>
>   reader->Update(); // This line will crash
>
>    system("pause");
>
>
>
>   return EXIT_SUCCESS;
>
>
>
> }
>
>
>
>
>
> /*==== CMakeLists.txt
>
>
>
> # This is the root ITK CMakeLists file.
>
> CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
>
> IF(COMMAND CMAKE_POLICY)
>
>   CMAKE_POLICY(SET CMP0003 NEW)
>
> ENDIF(COMMAND CMAKE_POLICY)
>
>
>
>
>
> # This project is designed to be built outside the Insight source tree.
>
> PROJECT(HelloWorld)
>
>
>
> # Find ITK.
>
> FIND_PACKAGE(ITK REQUIRED)
>
> INCLUDE(${ITK_USE_FILE})
>
>
>
> ADD_EXECUTABLE(HelloWorld HelloWorld.cxx )
>
>
>
> TARGET_LINK_LIBRARIES(HelloWorld ${ITK_LIBRARIES})
>
>
>
> *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.*
>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20150502/d64c10c2/attachment.html>


More information about the Insight-users mailing list