[Insight-developers] Re: [Insight-users] ITK iterators debugging
problem in Visual Studio 8(VS 2005)
zjzhang at ee.cuhk.edu.hk
zjzhang at ee.cuhk.edu.hk
Mon Nov 5 09:15:54 EST 2007
Quoting Luis Ibanez <luis.ibanez at kitware.com>:
hi Luis:
I run my program with both vs.net and vs2005. when I use
fixedReader->GetOutput()->Print(std::cout);
Both have the same text in the console:
Image (019AC790)
RTTI typeinfo: class itk::Image<short,3>
Reference Count: 1
Modified Time: 157
Debug: Off
Observers:
none
Source: (019AC630)
Source output index: 0
Release Data: Off
Data Released: False
Global Release Data: Off
PipelineMTime: 0
UpdateMTime: 0
LargestPossibleRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [0, 0, 0]
BufferedRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [0, 0, 0]
RequestedRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [0, 0, 0]
Spacing: [1, 1, 1]
Origin: [0, 0, 0]
Direction:
1 0 0
0 1 0
0 0 1
PixelContainer:
ImportImageContainer (019B0F40)
RTTI typeinfo: class itk::ImportImageContainer<unsigned long,short>
Reference Count: 1
Modified Time: 154
Debug: Off
Observers:
none
Pointer: 019B0F70
Container manages memory: true
Size: 0
Capacity: 0
However, with the vc.net version I can pass fileReader->Update() function, and
everything is ok, but with the vs2005 there is the error I said before. I use
the GetLargestPossibleRegion() for my filter region.
even if I do nothing but just read a file and then write it out with this code:
typedef ImageFileReader< ImageType > ImageReaderType;
typedef ImageFileWriter< ImageType > ImageWriterType;
ImageReaderType::Pointer reader= ImageReaderType::New();
ImageWriterType::Pointer writer= ImageWriterType::New();
reader->SetFileName(inputname);
writer->SetInput(reader->GetOutput());
writer->SetFileName(outputname);
writer->Update();
for the vc.net version, it's ok, but with the vs2005 version it again stops
at the same line. or if I want to cast a image from short to unsigned char,
I dont think this filter need to be given a region. after the image is update
the filter should have the image region automatically. This is ok in vc.net
but not ok in vs2005.
>
> Hi Alex
>
> You missed to show the section of code where you are using
> the image iterators.
>
> Chances are that you are now getting an image region
> from the input image produced by the reader. If you
> run the reader again and read a different image, then
> that region will not match your current image.
>
> You must make sure that you call UpdateLargestPossibleRegion()
> in the last filter of your pipeline, or at least on the filter
> from which you are taking the region that defines your iterator.
>
> Also, make sure that you grab the region again, after you call
> UpdateLargestPossible region.
>
> Printing out the image data with
>
> filter->GetOutput()->Print( std::cout );
>
> and printing the region of the iterator, will help you to
> understand when these two are not matching.
>
>
> If you still find any problems, please post to the list the
> section of code where you are using the ImageIterators.
>
>
>
> Thanks
>
>
>
> Luis
>
>
>
> ----------------------------
> zjzhang at ee.cuhk.edu.hk wrote:
> > Dear All:
> >
> > I have a problem with my own program. I use vs 2005 , itk 3.4
> > version under windows xp. it happens with the debug mode of the
> > program with the following code:
> > ImageFileReader::Pointer fixedReader =
> ImageFileReader::New();
> > fixedReader->SetFileName( filename );
> > fixedReader->Update();
> >
> > every time when I call update() of the imagefilereader, there will be
> > an error:
> > Unhandled exception at 0x005ace01 in MyProgram.exe: 0xC0000005: Access
> > violation reading location 0xcccccccc.
> >
> > and the debug breaks at file "list" with lines:
> > #if _HAS_ITERATOR_DEBUGGING || _SECURE_SCL
> > iterator begin()
> > { // return iterator for beginning of mutable
> sequence
> > return (iterator(_Nextnode(_Myhead), this));
> > }
> >
> > I have seen there is a similar problem in:
> > http://www.itk.org/pipermail/insight-users/2006-December/020472.html
> > but It seem the discussion didn't reach a clear answer.
> > if I add # cmakedefine _HAS_ITERATOR_DEBUGGING=0
> > # cmakedefine _SECURE_SCL=0
> > into the itkConfigure.h.in, line 49, it seems after cmake, it is still
> > not defined in the itkconfigure.h file.
> > But if I add some words in cmakelist.txt, I wonder if I need add
> > _HAS_ITERATOR_DEBUGGING=0 every time in my program build on itk.
> >
> > I want to know how to solve this bug. Thank you for your help.
> >
> > regards,
> > Alex
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users
> >
>
More information about the Insight-developers
mailing list