[Insight-users] ItkFileReader crashes for ITK 3.20 on Windows 7 with vs 2008

Emma Ryan eryanvtk at yahoo.com
Fri Sep 3 21:51:18 EDT 2010


Hello All,

  I would appreciate  a little help in understanding the odd behavior of ITK 
read and write functions.
The following program works fine in release mode, but crashes in debug mode with 
a 'read access violation'. 


If however, I use Input and OutputPixelTypes as 'char' instead of 'unsigned 
char', it crashes in both release and debug mode.

My input to the program is image.jpg. Any debugging suggestions for access 
violations are welcome too.

Thank you,
Emma

#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"

int main( int argc, char * argv[] )
{
  if( argc < 3 )
    {
    std::cerr << "Usage: " << argv[0];
    std::cerr << " inputImageFile outputImageFile ";  
    std::cerr << std::endl;  
    return EXIT_FAILURE;
    }
   
  typedef  unsigned char  InputPixelType;
  typedef  unsigned char  OutputPixelType;
  
  typedef itk::Image< InputPixelType,  2 >   InputImageType;
  typedef itk::Image< OutputPixelType, 2 >   OutputImageType;
 
  typedef itk::ImageFileReader< InputImageType >  ReaderType;
  
  typedef itk::ImageFileWriter< OutputImageType >  WriterType;
  
  ReaderType::Pointer reader = ReaderType::New();
 
  WriterType::Pointer writer = WriterType::New();

  reader->SetFileName( argv[1] );
  reader->Update();
 
  writer->SetFileName( argv[2] );
  writer->SetInput( reader->GetOutput());
  writer->Update();

  return EXIT_SUCCESS;
}







________________________________
From: "insight-users-request at itk.org" <insight-users-request at itk.org>
To: insight-users at itk.org
Sent: Thu, September 2, 2010 7:58:03 AM
Subject: Insight-users Digest, Vol 77, Issue 5

Send Insight-users mailing list submissions to
    insight-users at itk.org

To subscribe or unsubscribe via the World Wide Web, visit
    http://www.itk.org/mailman/listinfo/insight-users
or, via email, send a message with subject or body 'help' to
    insight-users-request at itk.org

You can reach the person managing the list at
    insight-users-owner at itk.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Insight-users digest..."


Today's Topics:

   1. Build error - itk 3.20, gdcm 2.0.[15+] under mingw (Markus Neuner)
   2. Image assignment does not work (D?enan Zuki?)
   3. Re: Image assignment does not work (wanlin)
   4. Re: Image assignment does not work (Matt McCormick)
   5. Re: Image assignment does not work (D?enan Zuki?)
   6. Re: Build error - itk 3.20,    gdcm 2.0.[15+] under mingw
      (Bill Lorensen)


----------------------------------------------------------------------

Message: 1
Date: Thu, 02 Sep 2010 14:10:42 +0200
From: "Markus Neuner" <neuner.markus at gmx.net>
Subject: [Insight-users] Build error - itk 3.20, gdcm 2.0.[15+] under
    mingw
To: insight-users at itk.org
Message-ID: <20100902121042.64950 at gmx.net>
Content-Type: text/plain; charset="utf-8"

Hi,

i get a linker error when building gdcm 2.0.15 or greater with itk 3.20 with 
mingw under windows xp:

---- SNIP ----
Scanning dependencies of target itkTestDriver
[ 96%] Building CXX object 
Code/IO/CMakeFiles/itkTestDriver.dir/itkTestDriver.obj
Linking CXX executable ..\..\bin\itkTestDriver.exe
c:/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot 
find -lgdcmMSFF
collect2: ld gab 1 als Ende-Status zur?ck
mingw32-make[2]: *** [bin/itkTestDriver.exe] Error 1
mingw32-make[1]: *** [Code/IO/CMakeFiles/itkTestDriver.dir/all] Error 2
mingw32-make: *** [all] Error 2
---- SNAP ----

Bilding with gdcm 2.0.14 works fine without any issues.

gdcm and itk are configured without any changes to teh standard cmake 
configurations insted of: ITK_USE_SYSTEM_GDCM=ON and the correct GDCM_DIR.

To put the gscm-build/bin on the path does not solve the problem.

Greetings,
Markus

Additional informations:
MinGW versions used:
binutils-2.20.51-1-mingw32-bin.tar.lzma
gcc-c++-4.4.0-mingw32-bin.tar.gz
gcc-c++-4.4.0-mingw32-dll.tar.gz
gcc-core-4.4.0-mingw32-bin.tar.gz
gcc-core-4.4.0-mingw32-dll.tar.gz
gdb-7.1-2-mingw32-bin.tar.gz
gmp-5.0.1-1-mingw32-dev.tar.lzma
libexpat-2.0.1-1-mingw32-dll-1.tar.gz
libgmp-5.0.1-1-mingw32-dll-10.tar.lzma
libgomp-4.5.0-1-mingw32-dll-1.tar.lzma
libmpc-0.8.1-1-mingw32-dll-2.tar.lzma
libmpfr-2.4.1-1-mingw32-dll-1.tar.lzma
libpthread-2.8.0-3-mingw32-dll-2.tar.lzma
libssp-4.5.0-1-mingw32-dll-0.tar.lzma
libstdc++-4.5.0-1-mingw32-dll-6.tar.lzma
mingw-utils-0.4-1-mingw32-bin.tar.lzma
mingw32-make-3.81-20090910.tar.gz
mingwrt-3.18-mingw32-dev.tar.gz
mingwrt-3.18-mingw32-dll.tar.gz
mpc-0.8.1-1-mingw32-dev.tar.lzma
mpfr-2.4.1-1-mingw32-dev.tar.lzma
pthreads-w32-2.8.0-3-mingw32-dev.tar.lzma
w32api-3.15-1-mingw32-dev.tar.lzma
-- 
GMX DSL SOMMER-SPECIAL: Surf & Phone Flat 16.000 f?r nur 19,99 &euro;/mtl.!*
http://portal.gmx.net/de/go/dsl


------------------------------

Message: 2
Date: Thu, 2 Sep 2010 14:48:21 +0200
From: D?enan Zuki? <dzenanz at gmail.com>
Subject: [Insight-users] Image assignment does not work
To: Insight-users <insight-users at itk.org>
Message-ID:
    <AANLkTikeCbU4DT3BCFf9tfEnoQM3f=mQMH+zp9mxN7g_ at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi everyone!

I have the following routine:

void applyFilter(InternalImageType::Pointer image,
itk::ImageToImageFilter<InternalImageType,InternalImageType>::Pointer
filter)
{
if (!checkImageLoaded())
return;
statusbar->showMessage("Applying filter:
"+QString(filter->GetNameOfClass()));
filter->SetInput( image );
filter->Update();
image=filter->GetOutput();
updateVisualizing();
resetVisualization();
statusbar->showMessage("Ready");
}

and it is invoked like this:

typedef itk::SmoothingRecursiveGaussianImageFilter < InternalImageType,
InternalImageType> FilterType;
FilterType::Pointer filter = FilterType::New();
filter->SetSigmaArray(myImage->GetSpacing());
applyFilter(myImage,
(itk::ImageToImageFilter<InternalImageType,InternalImageType>::Pointer)filter);

However, the above code produces no effect (the image does not change). When
content of "applyFilter" is copied to invocation points, it works.

What am I doing wrong?

Regards,
D?enan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.itk.org/pipermail/insight-users/attachments/20100902/b19c9fe4/attachment-0001.htm>


------------------------------

Message: 3
Date: Thu, 2 Sep 2010 23:41:06 +1000
From: wanlin <wanlinzhu at gmail.com>
Subject: Re: [Insight-users] Image assignment does not work
To: D?enan Zuki? <dzenanz at gmail.com>
Cc: Insight-users <insight-users at itk.org>
Message-ID:
    <AANLkTinfjqfbF37A2bWxU7xFCNLZfcKdKYn1AOPyM2m3 at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

What about
void applyFilter(InternalImageType:
:Pointer & image,
itk::ImageToImageFilter<InternalImageType,InternalImageType>::Pointer
filter)

image=filter->GetOutput();//here image pointer inside function has been
changed, however, the image outside the function does not.




2010/9/2 D?enan Zuki? <dzenanz at gmail.com>

> Hi everyone!
>
> I have the following routine:
>
> void applyFilter(InternalImageType::Pointer image,
> itk::ImageToImageFilter<InternalImageType,InternalImageType>::Pointer
> filter)
> {
> if (!checkImageLoaded())
> return;
> statusbar->showMessage("Applying filter:
> "+QString(filter->GetNameOfClass()));
>  filter->SetInput( image );
> filter->Update();
> image=filter->GetOutput();
>  updateVisualizing();
> resetVisualization();
> statusbar->showMessage("Ready");
> }
>
> and it is invoked like this:
>
> typedef itk::SmoothingRecursiveGaussianImageFilter < InternalImageType,
> InternalImageType> FilterType;
> FilterType::Pointer filter = FilterType::New();
> filter->SetSigmaArray(myImage->GetSpacing());
> applyFilter(myImage,
> 
(itk::ImageToImageFilter<InternalImageType,InternalImageType>::Pointer)filter);
>
> However, the above code produces no effect (the image does not change).
> When content of "applyFilter" is copied to invocation points, it works.
>
> What am I doing wrong?
>
> Regards,
> D?enan
>
> _____________________________________
> 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.html
>
> 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://www.itk.org/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.itk.org/pipermail/insight-users/attachments/20100902/212631ce/attachment-0001.htm>


------------------------------

Message: 4
Date: Thu, 2 Sep 2010 13:42:40 +0000 (UTC)
From: Matt McCormick <matt at mmmccormick.com>
Subject: Re: [Insight-users] Image assignment does not work
To: insight-users at itk.org
Message-ID: <loom.20100902T153756-236 at post.gmane.org>
Content-Type: text/plain; charset=us-ascii

Hi Dzenan,

> 
> void applyFilter(InternalImageType::Pointer image, 
itk::ImageToImageFilter<InternalImageType,InternalImageType>::Pointer filter)

How about changing the signature to use references, i.e.

void applyFilter(InternalImageType::Pointer& image, 
itk::ImageToImageFilter<InternalImageType,InternalImageType>::Pointer& filter)

> 
> {
> 
>     if (!checkImageLoaded())
> 
>         return;
> 
>     statusbar->showMessage("Applying filter: "+QString(filter-
>GetNameOfClass()));
> 
> 
>     filter->SetInput( image );
> 
>     filter->Update();
> 
>     image=filter->GetOutput();
> 
> 
>     updateVisualizing();
> 
>     resetVisualization();
> 
>     statusbar->showMessage("Ready");
> 
> }
> 
> 
> and it is invoked like this:
> 
> 
> typedef itk::SmoothingRecursiveGaussianImageFilter < InternalImageType, 
InternalImageType> FilterType;
> FilterType::Pointer filter = FilterType::New();
> 
> filter->SetSigmaArray(myImage->GetSpacing());

I would not expect much of a change with such a small sigma.

> applyFilter(myImage, 
(itk::ImageToImageFilter<InternalImageType,InternalImageType>::Pointer)filter);

I am surprised this cast works given the recent discussions of smart pointer 
casting on the ITK developers list.  If there is intention to cast to base 
classes, then using raw pointers may be better.

Regards,
Matt



------------------------------

Message: 5
Date: Thu, 2 Sep 2010 16:02:50 +0200
From: D?enan Zuki? <dzenanz at gmail.com>
Subject: Re: [Insight-users] Image assignment does not work
To: Matt McCormick <matt at mmmccormick.com>, wanlinzhu at gmail.com
Cc: insight-users at itk.org
Message-ID:
    <AANLkTikBrpYQCNe+M6sZCfHwzWVAhk8bMSvTFCCHg+Ar at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Thanks both, that was it.

D?enan

How about changing the signature to use references, i.e.
>
> void applyFilter(InternalImageType::Pointer& image,
> itk::ImageToImageFilter<InternalImageType,InternalImageType>::Pointer&
> filter)
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.itk.org/pipermail/insight-users/attachments/20100902/cb6184b3/attachment-0001.htm>


------------------------------

Message: 6
Date: Thu, 2 Sep 2010 10:57:56 -0400
From: Bill Lorensen <bill.lorensen at gmail.com>
Subject: Re: [Insight-users] Build error - itk 3.20,    gdcm 2.0.[15+]
    under mingw
To: Markus Neuner <neuner.markus at gmx.net>
Cc: insight-users at itk.org
Message-ID:
    <AANLkTimbn=85QhD3vuUzkE84-BAdv=gQqpk9Dh-F5j2Q at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

I was getting the same error a while back. Since then I have upgraded
to cmake 2.8.2 and I'm building against the current itk head.

What version of cmake are you using?

Mathieu, Has something changed since 3.20 that would fix this issue.
Other than the move of gdcm 2 into the itk tree.

Bill

On Thu, Sep 2, 2010 at 8:10 AM, Markus Neuner <neuner.markus at gmx.net> wrote:
> Hi,
>
> i get a linker error when building gdcm 2.0.15 or greater with itk 3.20 with 
>mingw under windows xp:
>
> ---- SNIP ----
> Scanning dependencies of target itkTestDriver
> [ 96%] Building CXX object 
>Code/IO/CMakeFiles/itkTestDriver.dir/itkTestDriver.obj
> Linking CXX executable ..\..\bin\itkTestDriver.exe
> c:/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot 
>find -lgdcmMSFF
> collect2: ld gab 1 als Ende-Status zur?ck
> mingw32-make[2]: *** [bin/itkTestDriver.exe] Error 1
> mingw32-make[1]: *** [Code/IO/CMakeFiles/itkTestDriver.dir/all] Error 2
> mingw32-make: *** [all] Error 2
> ---- SNAP ----
>
> Bilding with gdcm 2.0.14 works fine without any issues.
>
> gdcm and itk are configured without any changes to teh standard cmake 
>configurations insted of: ITK_USE_SYSTEM_GDCM=ON and the correct GDCM_DIR.
>
> To put the gscm-build/bin on the path does not solve the problem.
>
> Greetings,
> Markus
>
> Additional informations:
> MinGW versions used:
> binutils-2.20.51-1-mingw32-bin.tar.lzma
> gcc-c++-4.4.0-mingw32-bin.tar.gz
> gcc-c++-4.4.0-mingw32-dll.tar.gz
> gcc-core-4.4.0-mingw32-bin.tar.gz
> gcc-core-4.4.0-mingw32-dll.tar.gz
> gdb-7.1-2-mingw32-bin.tar.gz
> gmp-5.0.1-1-mingw32-dev.tar.lzma
> libexpat-2.0.1-1-mingw32-dll-1.tar.gz
> libgmp-5.0.1-1-mingw32-dll-10.tar.lzma
> libgomp-4.5.0-1-mingw32-dll-1.tar.lzma
> libmpc-0.8.1-1-mingw32-dll-2.tar.lzma
> libmpfr-2.4.1-1-mingw32-dll-1.tar.lzma
> libpthread-2.8.0-3-mingw32-dll-2.tar.lzma
> libssp-4.5.0-1-mingw32-dll-0.tar.lzma
> libstdc++-4.5.0-1-mingw32-dll-6.tar.lzma
> mingw-utils-0.4-1-mingw32-bin.tar.lzma
> mingw32-make-3.81-20090910.tar.gz
> mingwrt-3.18-mingw32-dev.tar.gz
> mingwrt-3.18-mingw32-dll.tar.gz
> mpc-0.8.1-1-mingw32-dev.tar.lzma
> mpfr-2.4.1-1-mingw32-dev.tar.lzma
> pthreads-w32-2.8.0-3-mingw32-dev.tar.lzma
> w32api-3.15-1-mingw32-dev.tar.lzma
> --
> GMX DSL SOMMER-SPECIAL: Surf & Phone Flat 16.000 f?r nur 19,99 &euro;/mtl.!*
> http://portal.gmx.net/de/go/dsl
> _____________________________________
> 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.html
>
> 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://www.itk.org/mailman/listinfo/insight-users
>


------------------------------

_______________________________________________
Insight-users mailing list
Insight-users at itk.org
http://www.itk.org/mailman/listinfo/insight-users


End of Insight-users Digest, Vol 77, Issue 5
********************************************



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100903/7e3f253d/attachment-0001.htm>


More information about the Insight-users mailing list