[Insight-users] error using SliceBySliceImageFilter and WatershedFilter

Bradley Lowekamp blowekamp at mail.nih.gov
Thu Oct 11 15:15:33 EDT 2012


Hello Sara,

At first glance I don't see any thing wrong with your code. You may have encountered a bug with itk::WatershedImageFilter when it is heavily re-use, but that would require some detailed checking.

As a quick fix you could try the itk::MorphologicalWatershedImageFilter which is in review instead and see if you get the results you are looking for.

Brad

On Oct 11, 2012, at 2:54 PM, Sara Rolfe <smrolfe at u.washington.edu> wrote:

> Hello, 
> 
> I am attempting to do a slice-by-slice watershed segmentation of a 3D image.  First, I got the watershed segmentation working correctly on a 2D image.  Next, I tried to implement it with the SliceBySliceImageFilter.  I connected the SliceBySliceImageFilter to a pipeline with the gradient filter as the input filter and the watershed filter as the output.  Running gave me a continuous output of the following error:
> 
> WaterShedFilter_SBS(5879,0xa0689720) malloc: *** error for object 0x48c187c: Non-aligned pointer being freed
> *** set a breakpoint in malloc_error_break to debug
> ...
> 
> I have read the article on the slice-by-slice filter http://www.insight-journal.org/browse/publication/133 and have gotten it working with the gradient filter alone and a pipeline of two gradient filters.  However, when I put in the watershed filter alone or with the gradient filter, I get the above error.  I'd appreciate any advice.  An excerpt of my code is below.
> 
> Thanks,
> Sara
> 
> 
> const int inputDim =3; 
> const int sliceDim =2; 
> typedef itk::Image<float, inputDim>													InputImageType;
> typedef itk::Image<unsigned long, inputDim>												OutputImageType;
> typedef itk::Image<float, sliceDim>													SliceFloatImageType;
> typedef itk::ImageFileReader< InputImageType >												ReaderType;
> typedef itk::GradientMagnitudeImageFilter< SliceFloatImageType, 
> 	SliceFloatImageType >														GradientMagnitudeImageFilterType;
> typedef itk::WatershedImageFilter<SliceFloatImageType>											WatershedFilterType;
> typedef itk::SliceBySliceImageFilter< InputImageType,
> 	OutputImageType,GradientMagnitudeImageFilterType,
> 	WatershedFilterType >														SliceBySliceFilterType;
> 
> 	InputImageType::Pointer inputImage = reader->GetOutput();
> 
> 	GradientMagnitudeImageFilterType::Pointer gradientMagnitudeImageFilter = GradientMagnitudeImageFilterType::New();
> 
> 	WatershedFilterType::Pointer watershedFilter = WatershedFilterType::New();
> 	watershedFilter->SetThreshold(threshold);
> 	watershedFilter->SetLevel(level);
> 	watershedFilter->SetInput(gradientMagnitudeImageFilter->GetOutput());
> 	
> 	SliceBySliceFilterType::Pointer sliceBySliceFilter = SliceBySliceFilterType::New();
> 	sliceBySliceFilter -> SetInput(inputImage);
> 	sliceBySliceFilter -> SetInputFilter(gradientMagnitudeImageFilter);
> 	sliceBySliceFilter -> SetOutputFilter(watershedFilter);
> 	sliceBySliceFilter->Update();
> 
> _____________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
> 
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20121011/7cab3122/attachment.htm>


More information about the Insight-users mailing list