[Insight-users] read an image from a file

John Drescher drescherjm at gmail.com
Tue Jul 19 10:51:51 EDT 2011


On Tue, Jul 19, 2011 at 10:21 AM, JOJOW <jieqiong.wang17 at gmail.com> wrote:
>    I compiled itk in  vs2008. There is a problem in the example of itk. The
> code is
> #include "itkImage.h"
> #include "itkImageFileReader.h"
> int main( int , char * argv[])
> {
> typedef unsigned char          PixelType;
> const unsigned int             Dimension = 3;
>
> typedef itk::Image< PixelType, Dimension >   ImageType;
> typedef itk::ImageFileReader< ImageType >  ReaderType;
> ReaderType::Pointer reader = ReaderType::New();
> const char * filename ="mprage_noface.nii";
> reader->SetFileName( filename );
> reader->Update();
> ImageType::Pointer image = reader->GetOutput();
>
> return 0;
> }
>
> If I choose release mode, the result is correct. But If I choose debug mode,
> when the code run to reader->update(), there is an error:
> Unhandled exception at 0x00ae7ca0 in *.exe: 0xC0000005: access conflict
> occours when read  location 0xcccccccc
>
> I don't know what's wrong!
>

When you built ITK did you install it using the INSTALL target? If so
that is your problem. The reason is you can not mix debug and release
libraries in the same application. In visual studio Debug and Release
have different incompatible memory heaps. So you must build all for
Release or Debug and not mix the two.

John


More information about the Insight-users mailing list