<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="font-family: Monaco; font-size: 10px; ">Hello, </span><div style="font-family: Monaco; font-size: 10px; "><br></div><div style="font-family: Monaco; font-size: 10px; ">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:</div><div style="font-family: Monaco; font-size: 10px; "><br></div><div style="font-family: Monaco; font-size: 10px; "><div>WaterShedFilter_SBS(5879,0xa0689720) malloc: *** error for object 0x48c187c: Non-aligned pointer being freed</div><div>*** set a breakpoint in malloc_error_break to debug</div><div>...</div></div><div style="font-family: Monaco; font-size: 10px; "><br></div><div style="font-family: Monaco; font-size: 10px; ">I have read the article on the slice-by-slice filter <a href="http://www.insight-journal.org/browse/publication/133">http://www.insight-journal.org/browse/publication/133</a> 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.</div><div style="font-family: Monaco; font-size: 10px; "><br></div><div style="font-family: Monaco; font-size: 10px; ">Thanks,</div><div style="font-family: Monaco; font-size: 10px; ">Sara</div><div style="font-family: Monaco; font-size: 10px; "><br></div><div style="font-family: Monaco; font-size: 10px; "><br></div><div style="font-family: Monaco; font-size: 10px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: rgb(170, 13, 145); ">const</span> <span style="color: rgb(170, 13, 145); ">int</span> inputDim =<span style="color: rgb(28, 0, 207); ">3</span>; </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: rgb(170, 13, 145); ">const</span> <span style="color: rgb(170, 13, 145); ">int</span> sliceDim =<span style="color: rgb(28, 0, 207); ">2</span>; </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: rgb(170, 13, 145); ">typedef</span> itk::Image<<span style="color: rgb(170, 13, 145); ">float</span>, inputDim><span class="Apple-tab-span" style="white-space: pre; ">                                                                                                        </span>InputImageType;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: rgb(170, 13, 145); ">typedef</span> itk::Image<<span style="color: rgb(170, 13, 145); ">unsigned</span> <span style="color: rgb(170, 13, 145); ">long</span>, inputDim><span class="Apple-tab-span" style="white-space: pre; ">                                                                                                </span>OutputImageType;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: rgb(170, 13, 145); ">typedef</span> itk::Image<<span style="color: rgb(170, 13, 145); ">float</span>, sliceDim><span class="Apple-tab-span" style="white-space: pre; ">                                                                                                        </span>SliceFloatImageType;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: rgb(170, 13, 145); ">typedef</span> itk::ImageFileReader< InputImageType ><span class="Apple-tab-span" style="white-space: pre; ">                                                                                                </span>ReaderType;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: rgb(170, 13, 145); ">typedef</span> itk::GradientMagnitudeImageFilter< SliceFloatImageType, </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space: pre; ">        </span>SliceFloatImageType ><span class="Apple-tab-span" style="white-space: pre; ">                                                                                                                </span>GradientMagnitudeImageFilterType;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: rgb(170, 13, 145); ">typedef</span> itk::WatershedImageFilter<SliceFloatImageType><span class="Apple-tab-span" style="white-space: pre; ">                                                                                        </span>WatershedFilterType;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: rgb(170, 13, 145); ">typedef</span> itk::SliceBySliceImageFilter< InputImageType,</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space: pre; ">        </span>OutputImageType,GradientMagnitudeImageFilterType,</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space: pre; ">        </span>WatershedFilterType ><span class="Apple-tab-span" style="white-space: pre; ">                                                                                                                </span>SliceBySliceFilterType;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space: pre; ">        </span>InputImageType::Pointer inputImage = reader->GetOutput();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space: pre; ">        </span>GradientMagnitudeImageFilterType::Pointer gradientMagnitudeImageFilter = GradientMagnitudeImageFilterType::New();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space: pre; ">        </span>WatershedFilterType::Pointer watershedFilter = WatershedFilterType::New();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space: pre; ">        </span>watershedFilter->SetThreshold(threshold);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space: pre; ">        </span>watershedFilter->SetLevel(level);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space: pre; ">        </span>watershedFilter->SetInput(gradientMagnitudeImageFilter->GetOutput());</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><span class="Apple-tab-span" style="white-space: pre; ">        </span><br class="webkit-block-placeholder"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space: pre; ">        </span>SliceBySliceFilterType::Pointer sliceBySliceFilter = SliceBySliceFilterType::New();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space: pre; ">        </span>sliceBySliceFilter -> SetInput(inputImage);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space: pre; ">        </span>sliceBySliceFilter -> SetInputFilter(gradientMagnitudeImageFilter);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space: pre; ">        </span>sliceBySliceFilter -> SetOutputFilter(watershedFilter);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><span class="Apple-tab-span" style="white-space: pre; ">        </span>sliceBySliceFilter->Update();</div><div><br></div></div></div></body></html>