<div dir="ltr">Which Update()?<br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 30, 2013 at 10:48 AM, Bradley Lowekamp <span dir="ltr">&lt;<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I am suspicion that this is related to how you are importing the buffer from OpenCV. Although I don&#39;t see anything obvious.<br>
<br>
Do you have a full call stack when of when the seg-fault occurs?<br>
<br>
Brad<br>
<div><div class="h5"><br>
On May 30, 2013, at 3:08 AM, Stephan Fischer &lt;<a href="mailto:step.fischer@gmail.com">step.fischer@gmail.com</a>&gt; wrote:<br>
<br>
&gt; Hi Everyone,<br>
&gt;<br>
&gt; i have an issue using the itk::GradientAnisotropicDiffusionImageFilter, which ends up crashing in an access violation.<br>
&gt;<br>
&gt; The function is used to convert an OpenCV image to an itk::Image, smoothing the image with the Perona-Malik-Filter and convert it back to an OpenCV image.<br>
&gt;<br>
&gt; When i run the Update() function the program ended up in an access violation, caused by a NULL-Pointer in the xtree-file in line 807:<br>
&gt;<br>
&gt; iterator begin()<br>
&gt;               {       // return iterator for beginning of mutable sequence<br>
&gt;               return (iterator(_Lmost(), this)); //_Lmost() causes an access violation caused by NULL-Pointer reference<br>
&gt;               }<br>
&gt;<br>
&gt; I&#39;am using the version 4.3 of ITK.<br>
&gt;<br>
&gt; Any help or advices are appreciated.<br>
&gt; Best regards.<br>
&gt;<br>
&gt; P.S.:<br>
&gt;<br>
&gt; The code i am using is the following:<br>
&gt;<br>
&gt; void PeronaMalikFilter(Mat *source, Mat *destination, int iterations, float conductance)<br>
&gt; {<br>
&gt;       typedef float PixelType;<br>
&gt;       const unsigned int Dimension = 2;<br>
&gt;       typedef itk::Image&lt; PixelType, Dimension &gt; ImageType;<br>
&gt;<br>
&gt;       typedef itk::ImportImageFilter&lt; PixelType, Dimension &gt; ImportFilterType;<br>
&gt;       ImportFilterType::Pointer importFilter = ImportFilterType::New();<br>
&gt;<br>
&gt;       ImportFilterType::SizeType size;<br>
&gt;       size[0] = source-&gt;cols; // size along X<br>
&gt;       size[1] = source-&gt;rows; // size along Y<br>
&gt;       ImportFilterType::IndexType start;<br>
&gt;       start.Fill( 0 );<br>
&gt;       ImportFilterType::RegionType region;<br>
&gt;       region.SetIndex( start );<br>
&gt;       region.SetSize( size );<br>
&gt;       importFilter-&gt;SetRegion( region );<br>
&gt;<br>
&gt;       double origin[ Dimension ];<br>
&gt;       origin[0] = 0.0; // X coordinate<br>
&gt;       origin[1] = 0.0; // Y coordinate<br>
&gt;       importFilter-&gt;SetOrigin( origin );<br>
&gt;<br>
&gt;       const unsigned int numberOfPixels = size[0] * size[1];<br>
&gt;       PixelType * localBuffer = new PixelType[ numberOfPixels ];<br>
&gt;<br>
&gt;       PixelType * it = localBuffer;<br>
&gt;       for(unsigned int y=0; y &lt; size[1]; y++)<br>
&gt;       {<br>
&gt;               const double dy = static_cast&lt;double&gt;( y ) - static_cast&lt;double&gt;(size[1])/2.0;<br>
&gt;               for(unsigned int x=0; x &lt; size[0]; x++)<br>
&gt;               {<br>
&gt;                       *it++ = source-&gt;at&lt;float&gt;(y,x);<br>
&gt;               }<br>
&gt;       }<br>
&gt;<br>
&gt;       const bool importImageFilterWillOwnTheBuffer = true;<br>
&gt;       importFilter-&gt;SetImportPointer( localBuffer, numberOfPixels, importImageFilterWillOwnTheBuffer );<br>
&gt;       importFilter-&gt;Update();<br>
&gt;<br>
&gt;       typedef itk::GradientAnisotropicDiffusionImageFilter&lt; ImageType,ImageType &gt; FilterType;<br>
&gt;       FilterType::Pointer filter = FilterType::New();<br>
&gt;       filter-&gt;SetInput(importFilter-&gt;GetOutput());<br>
&gt;       const itk::Image&lt; PixelType, Dimension &gt;* test = filter-&gt;GetInput();<br>
&gt;       filter-&gt;SetNumberOfIterations(iterations);<br>
&gt;       filter-&gt;SetTimeStep(0.125);<br>
&gt;       filter-&gt;SetConductanceParameter(conductance);<br>
&gt;       filter-&gt;Update();<br>
&gt;<br>
&gt;       //Fill OpenCV image with ITK image data.<br>
&gt;       ImageType::IndexType pixelIndex;<br>
&gt;       for(int x= 0; x &lt; destination-&gt;cols; x++)<br>
&gt;               for(int y = 0; y &lt; destination-&gt;rows; y++)<br>
&gt;               {<br>
&gt;                       pixelIndex[0]=x; pixelIndex[1]=y;<br>
&gt;                       destination-&gt;at&lt;float&gt;(y,x) = filter-&gt;GetOutput()-&gt;GetPixel(pixelIndex);<br>
&gt;               }<br>
&gt;<br>
&gt;       importFilter-&gt;Delete();<br>
&gt;       filter-&gt;Delete();<br>
&gt; }<br>
&gt;<br>
</div></div>&gt; _____________________________________<br>
&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;<br>
&gt; Visit other Kitware open-source projects at<br>
&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;<br>
&gt; Kitware offers ITK Training Courses, for more information visit:<br>
&gt; <a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
&gt;<br>
&gt; Please keep messages on-topic and check the ITK FAQ at:<br>
&gt; <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
&gt;<br>
&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><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>
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://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Unpaid intern in BillsBasement at noware dot com<br>
</div>