<br>Hi Michael,<br><br><br> This looks like a bug in your code :-(<br><br><br><br>Typical suspects are:<br><br><br>A) The fixed image is not available yet at<br> the time you call GetLargestPossibleRegion(),<br>
GetOrigin(), GetSpacing().<br><br> You should call <br><br> fixedIm->Update()<br><br> before you call any of the above methods.<br><br><br>We will learn a lot about other possible causes if<br>
you add to your code the following:<br><br> fixedIm->Print( std::cout );<br> movingIm->Print( std::cout );<br> resampler->Print( std::cout );<br><br>before the line<br><br> resampler->Update();<br>
<br>and if you post the resulting output text to the<br>mailing list.<br><br><br> Please let us know what you find.<br><br><br> Thanks<br><br><br> Luis<br><br><br>----------------------------------------------------------------<br>
<div class="gmail_quote">On Fri, Jun 26, 2009 at 6:42 AM, Michael Schildt <span dir="ltr"><<a href="mailto:michael.schildt@ifn-magdeburg.de">michael.schildt@ifn-magdeburg.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello!<br>
<br>
I have some trouble with ResampleImageFilter. I'm not sure if it is a<br>
bug in my program or in ITK. It works as expected in Debug configuration<br>
but crashes in Release mode. I traced to the source line in ITK were it<br>
appear in RelWithDebMode configuration. I attach some information and<br>
source.<br>
<br>
Best reguards,<br>
Michael Schildt<br>
<br>
The method based on the example in the itkSoftwareGuide:<br>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////<br>
template <typename dataT, typename TrfType><br>
typename itk::Image<dataT,3>::Pointer transformImage(typename<br>
itk::Image<dataT,3>::Pointer fixedIm,<br>
typename<br>
itk::Image<dataT,3>::Pointer movingIm,<br>
typename<br>
TrfType::ConstPointer transform)<br>
{<br>
typedef itk::Image<dataT, 3> ImageType;<br>
typedef TrfType TransformType;<br>
typedef itk::LinearInterpolateImageFunction<ImageType,double><br>
InterpolatorType;<br>
//typedef itk::WindowedSincInterpolateImageFunction<ImageType,3><br>
InterpolatorType;<br>
<br>
typedef itk::ResampleImageFilter<ImageType,ImageType> ResamplerType;<br>
<br>
typename InterpolatorType::Pointer interpolator = InterpolatorType::New();<br>
<br>
typename ResamplerType::Pointer resampler = ResamplerType::New();<br>
resampler->SetInput( movingIm );<br>
<br>
resampler->SetTransform( transform.GetPointer() );<br>
resampler->SetInterpolator( interpolator.GetPointer() );<br>
resampler->SetSize( fixedIm->GetLargestPossibleRegion().GetSize() );<br>
resampler->SetOutputOrigin( fixedIm->GetOrigin() );<br>
resampler->SetOutputSpacing( fixedIm->GetSpacing() );<br>
resampler->SetDefaultPixelValue( 0 );<br>
<br>
// resample the moving image<br>
resampler->Update();<br>
<br>
return resampler->GetOutput();<br>
}<br>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////<br>
<br>
It appears in the Update() method of the resampler. While debugging it<br>
seems like a problem in itkDataObject.cxx at line marked with **<br>
<br>
//----------------------------------------------------------------------------<br>
void<br>
DataObject<br>
::UpdateOutputData()<br>
{<br>
// If we need to update due to PipelineMTime, or the fact that our<br>
// data was released, then propagate the UpdateOutputData to the source<br>
// if there is one.<br>
if ( m_UpdateMTime < m_PipelineMTime || m_DataReleased ||<br>
this->RequestedRegionIsOutsideOfTheBufferedRegion() )<br>
{<br>
if ( m_Source ) // <---m_Source is valid, but when i step over<br>
here, it gets an invalid pointer<br>
{<br>
** m_Source->UpdateOutputData(this); // maybe call on invalid<br>
pointer?<br>
}<br>
}<br>
}<br>
//----------------------------------------------------------------------------<br>
<br>
Stack backtrace:<br>
<br>
BrainGUI.exe!std::_Vector_iterator<unsigned<br>
int,std::allocator<unsigned int> >::operator+() + 0x17 Bytes C++<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
BrainGUI.exe!std::vector<unsigned int,std::allocator<unsigned int> ::resize(unsigned int _Newsize=1, unsigned int _Val=0) Zeile 721 + <br>
</blockquote>
0x36 Bytes C++<br>
BrainGUI.exe!std::vector<bool,std::allocator<bool><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
::_Insert_x(std::_Vb_const_iterator<unsigned <br>
</blockquote>
int,int,std::vector<bool,std::allocator<bool> > > _Where=..., unsigned<br>
int _Count=1) Zeile 2312 C++<br>
BrainGUI.exe!std::vector<bool,std::allocator<bool><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
::_Insert_n(std::_Vb_const_iterator<unsigned <br>
</blockquote>
int,int,std::vector<bool,std::allocator<bool> > > _Where=..., unsigned<br>
int _Count=1, bool _Val=false) Zeile 2292 C++<br>
BrainGUI.exe!std::vector<bool,std::allocator<bool><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
::resize(unsigned int _Newsize=1, bool _Val=false) Zeile 2044 C++<br>
</blockquote>
BrainGUI.exe!itk::ProcessObject::CacheInputReleaseDataFlags()<br>
Zeile 1055 C++<br>
BrainGUI.exe!itk::ProcessObject::UpdateOutputData(itk::DataObject *<br>
__formal=0x02079270) Zeile 964 C++<br>
BrainGUI.exe!itk::DataObject::UpdateOutputData() Zeile 420 + 0x8<br>
Bytes C++<br>
<br>
BrainGUI.exe!transformImage<float,itk::VersorRigid3DTransform<double><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
(itk::SmartPointer<itk::Image<float,3> > fixedIm={...}, <br>
</blockquote>
itk::SmartPointer<itk::Image<float,3> > movingIm={...},<br>
itk::SmartPointer<itk::VersorRigid3DTransform<double> const ><br>
transform={...}) Zeile 123 C++<br>
BrainGUI.exe!VersorRigid3DRegistration::doRegistration(bool<br>
newVolume=true, void (const double &, const<br>
std::basic_string<char,std::char_traits<char>,std::allocator<char> > &)*<br>
progress=0x004029e1) Zeile 254 + 0x81 Bytes C++<br>
BrainGUI.exe!RegThread::Entry() Zeile 273 + 0xf Bytes C++<br>
BrainGUI.exe!wxThreadInternal::DoThreadStart() + 0xa5 Bytes C++<br>
BrainGUI.exe!wxThreadInternal::WinThreadStart() + 0x6a Bytes C++<br>
BrainGUI.exe!_callthreadstartex() Zeile 348 + 0x6 Bytes C<br>
BrainGUI.exe!_threadstartex(void * ptd=0x04ef1118) Zeile 326 + 0x5<br>
Bytes C<br>
<br>
System:<br>
- Windows XP Prof SP3<br>
- Visual Studio 2008 Express Edition<br>
- ITK 3.14<br>
- CMake 2.6.4<br>
- wxWidgets 2.8.9 (wxPack Installer)<br>
- Pentium 4<br>
- 2GB Ram<br>
<br>
<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>
Please keep messages on-topic and check the ITK FAQ at: <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://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</blockquote></div><br>