<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Dear ITK members,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’d like to use the IO streaming capabilities of ITK <a href="http://www.kitware.com/media/html/IOStreamingInITK.html">http://www.kitware.com/media/html/IOStreamingInITK.html</a> for a simple pipeline: read mhd file, resample, write mhd
file. <o:p></o:p></p>
<p class="MsoNormal">I tried different combination of input image size, output image size and number of streams, and it works with input data of 4GB. But the program crashes trying to resample a 16G image into a 2G one(see log at the bottom). Is the problem
in the updatelargestregion /updateoutput information part? <o:p></o:p></p>
<p class="MsoNormal">Below the core of my program:<o:p></o:p></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">typedef</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">signed</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">short</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white;mso-highlight:white">PixelType</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">const</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">unsigned</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">int</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> Dimension = 3;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">typedef</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
itk::Ima</span><span lang="DE-CH" style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">ge<PixelType, Dimension> ImageType;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="DE-CH" style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">itk::OutputWindow::SetInstance(itk::TextOutput::New());<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">typedef</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
itk::ImageFileReader<ImageType> ReaderType;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">typedef</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
itk::ImageFileWriter<ImageType> WriterType; <o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">ReaderType::Pointer reader = ReaderType::New();<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">reader->SetFileName(inFileName);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">reader->UpdateOutputInformation();<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">ImageType::Pointer input = reader->GetOutput();<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">std::cout <<
</span><span style="font-size:9.5pt;font-family:Consolas;color:#A31515;background:white;mso-highlight:white">"Input size: "</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> << input->GetLargestPossibleRegion().GetSize()
<< std::endl;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">typedef</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
itk::ResampleImageFilter< ImageType, ImageType > ResampleFilterType;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">ResampleFilterType::Pointer resampleFilter = ResampleFilterType::New();<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">resampleFilter->SetInput( input );<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">resampleFilter->SetDefaultPixelValue(0);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">resampleFilter->SetSize(outputSize);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">resampleFilter->UpdateOutputInformation();<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:green;background:white;mso-highlight:white">//resampleFilter->SetOutputSpacing( spacing ); //just for demo</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">std::cout <<
</span><span style="font-size:9.5pt;font-family:Consolas;color:#A31515;background:white;mso-highlight:white">"Resampled image size: "</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> << resampleFilter->GetOutput()->GetLargestPossibleRegion().GetSize()
<< std::endl;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">typedef</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
itk::PipelineMonitorImageFilter< ImageType > MonitorFilterType;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">MonitorFilterType::Pointer monitorFilter = MonitorFilterType::New();<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">monitorFilter->SetInput(resampleFilter->GetOutput());<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">monitorFilter->DebugOn();<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">WriterType::Pointer outputWriter = WriterType::New();<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">outputWriter->SetFileName(outFileName);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">outputWriter->SetInput(monitorFilter->GetOutput());<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">outputWriter->UseCompressionOff();<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">outputWriter->SetNumberOfStreamDivisions(nStreamDivisions);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">outputWriter->Update();
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">And the error is:
</span><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Unhandled exception at 0x000007FEED1EA511 (msvcr110d.dll) in Resample.exe: 0xC0000005: Access violation writing location 0x00000002FA09B000.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> msvcr110d.dll!memcpy() Line 362 Unknown<o:p></o:p></p>
<p class="MsoNormal">> msvcp110d.dll!std::char_traits<char>::copy(char * _First1, const char * _First2, unsigned __int64 _Count) Line 530 C++<o:p></o:p></p>
<p class="MsoNormal"> msvcp110d.dll!std::basic_streambuf<char,std::char_traits<char> >::xsgetn(char * _Ptr, __int64 _Count) Line 372 C++<o:p></o:p></p>
<p class="MsoNormal"> msvcp110d.dll!std::basic_streambuf<char,std::char_traits<char> >::sgetn(char * _Ptr, __int64 _Count) Line 160 C++<o:p></o:p></p>
<p class="MsoNormal"> msvcp110d.dll!std::basic_istream<char,std::char_traits<char> >::read(char * _Str, __int64 _Count) Line 742 C++<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!MetaImage::M_ReadElementData(std::basic_ifstream<char,std::char_traits<char> > * _fstream, void * _data, __int64 _dataQuantity) Line 3493 C++<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!MetaImage::M_ReadElements(std::basic_ifstream<char,std::char_traits<char> > * _fstream, void * _data, __int64 _dataQuantity) Line 2553 C++<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!MetaImage::ReadStream(int _nDims, std::basic_ifstream<char,std::char_traits<char> > * _stream, bool _readElements, void * _buffer) Line 1533 C++<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!MetaImage::Read(const char * _headerName, bool _readElements, void * _buffer) Line 1252 C++<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!itk::MetaImageIO::Read(void * buffer) Line 476 C++<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!itk::ImageFileReader<itk::Image<short,3>,itk::DefaultConvertPixelTraits<short> >::GenerateData() Line 448 C++<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!itk::ProcessObject::UpdateOutputData(itk::DataObject * __formal) Line 1739 C++<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!itk::DataObject::UpdateOutputData() Line 419 C++<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!itk::ImageBase<3>::UpdateOutputData() Line 291 C++<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!itk::ProcessObject::UpdateOutputData(itk::DataObject * __formal) Line 1711 C++<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!itk::DataObject::UpdateOutputData() Line 419 C++<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!itk::ImageBase<3>::UpdateOutputData() Line 291 C++<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!itk::ProcessObject::UpdateOutputData(itk::DataObject * __formal) Line 1703 C++<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!itk::DataObject::UpdateOutputData() Line 419 C++<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!itk::ImageBase<3>::UpdateOutputData() Line 291 C++<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!itk::ImageFileWriter<itk::Image<short,3> >::Write() Line 336 C++<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!itk::ImageFileWriter<itk::Image<short,3> >::Update() Line 166 C++<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!main(int argc, char * * argv) Line 96 C++<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!__tmainCRTStartup() Line 536 C<o:p></o:p></p>
<p class="MsoNormal"> Resample.exe!mainCRTStartup() Line 377 C<o:p></o:p></p>
<p class="MsoNormal"> kernel32.dll!0000000076ba5a4d() Unknown<o:p></o:p></p>
<p class="MsoNormal"> ntdll.dll!0000000076cdb831() Unknown<o:p></o:p></p>
<p class="MsoNormal"><o:p></o:p></p>
<p class="MsoNormal">Thank you<o:p></o:p></p>
<p class="MsoNormal">Livia <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:7.5pt;font-family:"Verdana","sans-serif";color:#6D6D6D;mso-fareast-language:EN-GB">Livia Barazzetti<br>
Ph.D. Student - Medical Image Analysis<br>
Institute for Surgical Technology and Biomechanics<br>
University of Bern<br>
Stauffacherstrasse 78<br>
CH-3014 Bern<br>
Tel +41 31 631 59 48<br>
</span><span style="color:#0D1C7F;mso-fareast-language:EN-GB"><a href="http://www.istb.unibe.ch/"><span style="font-size:7.5pt;font-family:"Verdana","sans-serif";color:blue">http://www.istb.unibe.ch</span></a></span><span style="mso-fareast-language:EN-GB"><o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>