<div dir="ltr">Thanks all for getting back to me.  I put in a call to update the importFilter and upon debugging found that the image variable is getting the correct size settings and number of elements (or at least it is the same as the importFilter finds).  I tried casting the imageSize to unsigned int and got the same numbers throughout, and still had the exception at castImage->Update().  Here is the stack trace at the exception:<div><br></div><div><div>><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>BING_Andrew.exe!std::_Transform<unsigned char const *,float *,itk::ImageAlgorithm::StaticCast<unsigned char,float> >(unsigned char* _First, unsigned char* _Last, float* _Dest, itk::ImageAlgorithm::StaticCast<unsigned char,float> _Func) Line 950 + 0x9 bytes<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>C++</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">  </span>BING_Andrew.exe!std::_Transform1<unsigned char const *,float *,itk::ImageAlgorithm::StaticCast<unsigned char,float> >(unsigned char* _First, unsigned char* _Last, float* _Dest, itk::ImageAlgorithm::StaticCast<unsigned char,float> _Func, std::random_access_iterator_tag __unnamed004, std::random_access_iterator_tag __unnamed005) Line 988 + 0x2b bytes<span class="gmail-Apple-tab-span" style="white-space:pre">      </span>C++</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">  </span>BING_Andrew.exe!std::_Transform1<unsigned char const *,float *,itk::ImageAlgorithm::StaticCast<unsigned char,float> >(unsigned char* _First, unsigned char* _Last, float* _Dest, itk::ImageAlgorithm::StaticCast<unsigned char,float> _Func, std::integral_constant<bool,0> __unnamed004) Line 1012 + 0x6d bytes<span class="gmail-Apple-tab-span" style="white-space:pre">      </span>C++</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">  </span>BING_Andrew.exe!std::transform<unsigned char const *,float *,itk::ImageAlgorithm::StaticCast<unsigned char,float> >(unsigned char* _First, unsigned char* _Last, float* _Dest, itk::ImageAlgorithm::StaticCast<unsigned char,float> _Func) Line 1026 + 0x48 bytes<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>C++</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">  </span>BING_Andrew.exe!itk::ImageAlgorithm::CopyHelper<unsigned char,float>(unsigned char* first, unsigned char* last, float* result) Line 213 + 0x14 bytes<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>C++</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">  </span>BING_Andrew.exe!itk::ImageAlgorithm::DispatchedCopy<itk::Image<unsigned char,3>,itk::Image<float,3> >(itk::Image<unsigned char,3>* inImage, itk::Image<float,3>* outImage, itk::ImageRegion<3>& inRegion, itk::ImageRegion<3>& outRegion, std::integral_constant<bool,1> __unnamed004) Line 136 + 0x12 bytes<span class="gmail-Apple-tab-span" style="white-space:pre">  </span>C++</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">  </span>BING_Andrew.exe!itk::ImageAlgorithm::Copy<unsigned char,float,3>(itk::Image<unsigned char,3>* inImage, itk::Image<float,3>* outImage, itk::ImageRegion<3>& inRegion, itk::ImageRegion<3>& outRegion) Line 113<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>C++</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">  </span>BING_Andrew.exe!itk::CastImageFilter<itk::Image<unsigned char,3>,itk::Image<float,3> >::ThreadedGenerateData(itk::ImageRegion<3>& outputRegionForThread, unsigned int threadId) Line 73 + 0x13 bytes<span class="gmail-Apple-tab-span" style="white-space:pre">      </span>C++</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">  </span>[External Code]<span class="gmail-Apple-tab-span" style="white-space:pre">       </span></div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">     </span>BING_Andrew.exe!itk::ImageSource<itk::Image<float,3> >::ThreaderCallback(void* arg) Line 316<span class="gmail-Apple-tab-span" style="white-space:pre">      </span>C++</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">  </span>BING_Andrew.exe!itk::MultiThreader::SingleMethodProxy(void * arg)  Line 437 + 0xe bytes<span class="gmail-Apple-tab-span" style="white-space:pre">      </span>C++</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">  </span>msvcr120d.dll!03573651() <span class="gmail-Apple-tab-span" style="white-space:pre">     </span></div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">     </span>[Frames below may be incorrect and/or missing, no symbols loaded for msvcr120d.dll]<span class="gmail-Apple-tab-span" style="white-space:pre">   </span></div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">     </span>msvcr120d.dll!03573861() <span class="gmail-Apple-tab-span" style="white-space:pre">     </span></div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">     </span>kernel32.dll!74c738f4() <span class="gmail-Apple-tab-span" style="white-space:pre">      </span></div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">     </span>ntdll.dll!776d5de3() <span class="gmail-Apple-tab-span" style="white-space:pre"> </span></div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">     </span>ntdll.dll!776d5dae() <span class="gmail-Apple-tab-span" style="white-space:pre"> </span></div></div><div><br></div><div>I'm attaching this as a txt file also because the formatting looks a little weird in my email client, it might be easier to read as plain text.  One other thing I forgot to mention, the window generated by the exception has the following text as well:</div><div>Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.<br></div><div><br></div><div>Thanks again for the help.</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><p>--</p><p>AH<br></p><p><br></p><p>-----------------------------------------------------------------------------------------------</p><p><i>This email and any attachments thereto may contain private, confidential, and privileged materials for the sole use of the intended recipient. Any reviewing, copying, or distribution of this email (or any attachments thereto) by other than the intended recipient is strictly prohibited. If you are not the intended recipient, please contact the sender immediately and permanently destroy this email and any attachments thereto.</i></p></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Jul 28, 2016 at 9:01 AM, Bradley Lowekamp <span dir="ltr"><<a href="mailto:brad@lowekamp.net" target="_blank">brad@lowekamp.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Hello,</div><div><br></div><div>I noticed you are using type int for you imageSiize. How big is your image? You may be overflowing when computing the number of pixels.</div><div><br></div><div>I don’t think you have provided a stack trace of when the error occurs. That would be helpful too.</div><div><br></div><div>Brad</div><div><div class="h5"><div><br><div><blockquote type="cite"><div>On Jul 28, 2016, at 8:29 AM, Dženan Zukić <<a href="mailto:dzenanz@gmail.com" target="_blank">dzenanz@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Have you tried calling Update on the import filter? That might be the problem. Cast filter is simple and non-special, I doubt it is the problem.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 27, 2016 at 8:26 PM, Andrew Harris <span dir="ltr"><<a href="mailto:aharr8@uwo.ca" target="_blank">aharr8@uwo.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks Dženan, as I said in my previous email running Update() on the castFilter pointer returns the same error.  I did put in a try/catch block to update it though. </div><div class="gmail_extra"><span><br clear="all"><div><div data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><p>--</p><p>AH<br></p><p><br></p><p>-----------------------------------------------------------------------------------------------</p><p><i>This email and any attachments thereto may contain private, confidential, and privileged materials for the sole use of the intended recipient. Any reviewing, copying, or distribution of this email (or any attachments thereto) by other than the intended recipient is strictly prohibited. If you are not the intended recipient, please contact the sender immediately and permanently destroy this email and any attachments thereto.</i></p></div></div></div></div></div></div></div></div></div>
<br></span><div><div><div class="gmail_quote">On Wed, Jul 27, 2016 at 5:16 PM, Dženan Zukić <span dir="ltr"><<a href="mailto:dzenanz@gmail.com" target="_blank">dzenanz@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Hi Andrew,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">I think that line 62 of .cpp should be:</div><div class="gmail_default"><font face="monospace, monospace">castFilter->Update();</font><br></div><div class="gmail_default"><font face="verdana, sans-serif">I don't see the pipeline updated elsewhere.</font></div><div class="gmail_default"><font face="verdana, sans-serif"><br></font></div><div class="gmail_default"><font face="verdana, sans-serif">Regards,</font></div><div class="gmail_default"><font face="verdana, sans-serif">Dženan</font></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 27, 2016 at 3:54 PM, Andrew Harris <span dir="ltr"><<a href="mailto:aharr8@uwo.ca" target="_blank">aharr8@uwo.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks for getting back to me, after conferring with a colleague I tried using the output of the cast filter directly in the subsequent pipeline rather than writing it to a new image object of the filter's output type. I got the same error doing that, and also got the same error just running Update() on the cast filter, which leads me to believe I'm doing something wrong in setting up the cast filter.  I'm attaching my code for the class I'm writing, hope it's something simple I'm doing wrong. Currently it's throwing the exception at line 85 when the registration transform initializer is activated.</div><div class="gmail_extra"><span><br clear="all"><div><div data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><p>--</p><p>AH<br></p><p><br></p><p>-----------------------------------------------------------------------------------------------</p><p><i>This email and any attachments thereto may contain private, confidential, and privileged materials for the sole use of the intended recipient. Any reviewing, copying, or distribution of this email (or any attachments thereto) by other than the intended recipient is strictly prohibited. If you are not the intended recipient, please contact the sender immediately and permanently destroy this email and any attachments thereto.</i></p></div></div></div></div></div></div></div></div></div>
<br></span><div><div><div class="gmail_quote">On Tue, Jul 26, 2016 at 7:09 PM, Bradley Lowekamp <span dir="ltr"><<a href="mailto:brad@lowekamp.net" target="_blank">brad@lowekamp.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div></div><div>Hello,</div><div><br></div><div>The most common mistake here would be forgetting to call Allocate on your image. Beyond that sharing your code would be helpful. </div><div><br></div><div>Brad</div><div><div><div><br>On Jul 26, 2016, at 1:43 PM, Andrew Harris <<a href="mailto:aharr8@uwo.ca" target="_blank">aharr8@uwo.ca</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">Hello,<div>I am attempting to use the CastImageFilter to convert between unsigned char and float image types, and am getting a System.AccessViolationException at runtime.  I have seen reference to this being caused by referring to a pointer that is out of scope, but in this case both the image and the cast filter are delcared in the same method, so I’m not sure how it can be going out of scope.  I can include the header and definition files if that would be helpful.<br clear="all"><div><div data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><p>--</p><p>AH<br></p><p><br></p><p>-----------------------------------------------------------------------------------------------</p><p><i>This email and any attachments thereto may contain private, confidential, and privileged materials for the sole use of the intended recipient. Any reviewing, copying, or distribution of this email (or any attachments thereto) by other than the intended recipient is strictly prohibited. If you are not the intended recipient, please contact the sender immediately and permanently destroy this email and any attachments thereto.</i></p></div></div></div></div></div></div></div></div></div>
</div></div>
</div></blockquote></div></div><blockquote type="cite"><div><span>_____________________________________</span><br><span>Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a></span><br><span></span><br><span>Visit other Kitware open-source projects at</span><br><span><a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a></span><br><span></span><br><span>Kitware offers ITK Training Courses, for more information visit:</span><br><span><a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a></span><br><span></span><br><span>Please keep messages on-topic and check the ITK FAQ at:</span><br><span><a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a></span><br><span></span><br><span>Follow this link to subscribe/unsubscribe:</span><br><span><a href="http://public.kitware.com/mailman/listinfo/insight-users" target="_blank">http://public.kitware.com/mailman/listinfo/insight-users</a></span><br></div></blockquote></div></blockquote></div><br></div></div></div>
<br>_____________________________________<br>
Powered by <a href="http://www.kitware.com/" rel="noreferrer" 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" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div>
</blockquote></div><br></div>
_____________________________________<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>Kitware offers ITK Training Courses, for more information visit:<br><a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br><br>Please keep messages on-topic and check the ITK FAQ at:<br><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://public.kitware.com/mailman/listinfo/insight-users" target="_blank">http://public.kitware.com/mailman/listinfo/insight-users</a><br></div></blockquote></div><br></div></div></div></div></blockquote></div><br></div>