<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"><<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>></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'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 <<a href="mailto:step.fischer@gmail.com">step.fischer@gmail.com</a>> wrote:<br>
<br>
> Hi Everyone,<br>
><br>
> i have an issue using the itk::GradientAnisotropicDiffusionImageFilter, which ends up crashing in an access violation.<br>
><br>
> 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>
><br>
> 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>
><br>
> iterator begin()<br>
> { // return iterator for beginning of mutable sequence<br>
> return (iterator(_Lmost(), this)); //_Lmost() causes an access violation caused by NULL-Pointer reference<br>
> }<br>
><br>
> I'am using the version 4.3 of ITK.<br>
><br>
> Any help or advices are appreciated.<br>
> Best regards.<br>
><br>
> P.S.:<br>
><br>
> The code i am using is the following:<br>
><br>
> void PeronaMalikFilter(Mat *source, Mat *destination, int iterations, float conductance)<br>
> {<br>
> typedef float PixelType;<br>
> const unsigned int Dimension = 2;<br>
> typedef itk::Image< PixelType, Dimension > ImageType;<br>
><br>
> typedef itk::ImportImageFilter< PixelType, Dimension > ImportFilterType;<br>
> ImportFilterType::Pointer importFilter = ImportFilterType::New();<br>
><br>
> ImportFilterType::SizeType size;<br>
> size[0] = source->cols; // size along X<br>
> size[1] = source->rows; // size along Y<br>
> ImportFilterType::IndexType start;<br>
> start.Fill( 0 );<br>
> ImportFilterType::RegionType region;<br>
> region.SetIndex( start );<br>
> region.SetSize( size );<br>
> importFilter->SetRegion( region );<br>
><br>
> double origin[ Dimension ];<br>
> origin[0] = 0.0; // X coordinate<br>
> origin[1] = 0.0; // Y coordinate<br>
> importFilter->SetOrigin( origin );<br>
><br>
> const unsigned int numberOfPixels = size[0] * size[1];<br>
> PixelType * localBuffer = new PixelType[ numberOfPixels ];<br>
><br>
> PixelType * it = localBuffer;<br>
> for(unsigned int y=0; y < size[1]; y++)<br>
> {<br>
> const double dy = static_cast<double>( y ) - static_cast<double>(size[1])/2.0;<br>
> for(unsigned int x=0; x < size[0]; x++)<br>
> {<br>
> *it++ = source->at<float>(y,x);<br>
> }<br>
> }<br>
><br>
> const bool importImageFilterWillOwnTheBuffer = true;<br>
> importFilter->SetImportPointer( localBuffer, numberOfPixels, importImageFilterWillOwnTheBuffer );<br>
> importFilter->Update();<br>
><br>
> typedef itk::GradientAnisotropicDiffusionImageFilter< ImageType,ImageType > FilterType;<br>
> FilterType::Pointer filter = FilterType::New();<br>
> filter->SetInput(importFilter->GetOutput());<br>
> const itk::Image< PixelType, Dimension >* test = filter->GetInput();<br>
> filter->SetNumberOfIterations(iterations);<br>
> filter->SetTimeStep(0.125);<br>
> filter->SetConductanceParameter(conductance);<br>
> filter->Update();<br>
><br>
> //Fill OpenCV image with ITK image data.<br>
> ImageType::IndexType pixelIndex;<br>
> for(int x= 0; x < destination->cols; x++)<br>
> for(int y = 0; y < destination->rows; y++)<br>
> {<br>
> pixelIndex[0]=x; pixelIndex[1]=y;<br>
> destination->at<float>(y,x) = filter->GetOutput()->GetPixel(pixelIndex);<br>
> }<br>
><br>
> importFilter->Delete();<br>
> filter->Delete();<br>
> }<br>
><br>
</div></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://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>