<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hello,<div><br></div><div>I am not sure what you mean by crash. Segfault? Exception?</div><div><br></div><div>I believe I have fixed the issue in the patch I have submitted to gerrit for review [1]. The CannyEdgeDectionImageFilter is unfortunately not very memory efficient in ITK.</div><div><br></div><div>Brad</div><div><br></div><div>[1] <a href="http://review.source.kitware.com/#/c/19795/">http://review.source.kitware.com/#/c/19795/</a></div><div><br><div><div>On May 14, 2015, at 8:46 PM, Weldon <<a href="mailto:zagwin@gmail.com">zagwin@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="ltr">Hello All,<div><br></div><div>I have a simple Canny Edge detection pipeline, since the data is very big, I used ReleaseDataFlag in the pipeline. However, it will crash with Flag on. The code runs ok when I comments the flagon two lines. My codes are as following, could anybody tell me why? thanks </div><div><br></div><div>int main(<span class="" style="font-size:13px;color:rgb(96,64,32);font-family:monospace,fixed;line-height:13px;white-space:pre-wrap;background-color:rgb(251,252,253)">int</span><span style="font-size: 13px; font-family: monospace, fixed; line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);"> argc, </span><span class="" style="font-size:13px;color:rgb(96,64,32);font-family:monospace,fixed;line-height:13px;white-space:pre-wrap;background-color:rgb(251,252,253)">char</span><span style="font-size: 13px; font-family: monospace, fixed; line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);">* argv[]</span>)</div><div>{</div><div><div class="" style="font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px;"><span class="" style="color:rgb(0,128,0)"> typedef</span> <span class="" style="color:rgb(96,64,32)">signed</span> <span class="" style="color:rgb(96,64,32)">short</span> InputPixelType;</div><div class="" style="font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px;"><span class="" style="color:rgb(0,128,0)"> typedef</span> un<span class="" style="color:rgb(96,64,32)">signed</span> <span class="" style="color:rgb(96,64,32)">char</span> OutputPixelType;<br></div><div class="" style="font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px;"> <span class="" style="color:rgb(0,128,0)">const</span> <span class="" style="color:rgb(96,64,32)">unsigned</span> <span class="" style="color:rgb(96,64,32)">int</span> Dimension = 3;</div></div><div class="" style="font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px;"> <span class="" style="color:rgb(0,128,0);background-color:rgb(251,252,253)">typedef</span><span style="background-color:rgb(251,252,253)"> </span><a name="_a0" style="color:rgb(61,87,140);background-color:rgb(251,252,253)"></a>itk::Image< InputPixelType, Dimension ><span style="background-color:rgb(251,252,253)"> InputImageType;</span></div><div class="" style="font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px;"><span class="" style="color:rgb(0,128,0);background-color:rgb(251,252,253)"> typedef</span><span style="background-color:rgb(251,252,253)"> </span><a name="_a0" style="color:rgb(61,87,140);background-color:rgb(251,252,253)"></a>itk::Image< OutputPixelType, Dimension ><span style="background-color:rgb(251,252,253)"> OutputImageType;</span><span style="background-color:rgb(251,252,253)"><br></span></div><div class="" style="font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px;"><span style="background-color:rgb(251,252,253)"> </span><span class="" style="line-height:1;color:rgb(0,128,0)">typedef</span><span style="line-height:1"> </span><a name="_a1" style="line-height:1;color:rgb(61,87,140)"></a>itk::ImageFileReader< InputImageType ><span style="line-height:1"> ReaderType;</span></div><div class="" style="font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px;"></div><div class="" style="font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px;"> ReaderType::Pointer reader = ReaderType::New();</div><div class="" style="font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px;"> reader->SetFileName( argv[1] );</div><div class="" style="font-stretch:normal;font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px"><span class="" style="line-height:1"> </span><span class="" style="color:rgb(0,128,0);line-height:1">typedef</span><span style="line-height: 1;"> </span><span style="line-height:1"><a name="_a2" style="line-height:1;color:rgb(61,87,140)"></a></span>itk::GDCMImageIO<span style="line-height: 1;"> ImageIOType;</span></div><div class="" style="font-stretch:normal;font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px"><span style="line-height: 1;"> ImageIOType::Pointer gdcmImageIO = ImageIOType::New();</span></div><div class="" style="font-stretch:normal;font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px"><span style="line-height: 1;"> reader->SetImageIO( gdcmImageIO );</span></div><div class="" style="font-stretch:normal;font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px"><span style="line-height: 1;"> reader->update();</span></div><div class="" style="font-stretch:normal;font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px"><span style="line-height: 1;"> </span></div><div class="" style="font-stretch:normal;font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px"><span style="line-height: 1;"> InputImageType::Pointer pimg = reader->GetOutput();</span></div><div class="" style="font-stretch:normal;font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px"><span style="line-height: 1;"> </span></div><div class="" style="font-stretch:normal;font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px"><span style="line-height: 1;"> OutputImageType::Pointer pmask = OutputImageType::New();</span></div><div class="" style="font-stretch:normal;font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px"><span style="line-height: 1;"><br></span></div><div class="" style="font-stretch:normal;font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px"><span style="line-height: 1;"> CannyEdgeDetection(pimg.GetPointer(), pmask.GetPointer());</span></div><div>}</div><div><br></div><div>template<typename TInput, typename TOutput></div><div>void CannyEdgeDetection(typename TInput *inImage, typename TOutput *outImage)</div><div>{</div><div><div> <span class="" style="font-family:monospace,fixed;font-size:13px;line-height:1;white-space:pre-wrap;color:rgb(0,128,0)">typedef</span><span style="font-family: monospace, fixed; font-size: 13px; line-height: 1; white-space: pre-wrap;"> </span><span class="" style="font-family:monospace,fixed;font-size:13px;line-height:1;white-space:pre-wrap;color:rgb(96,64,32)">float</span><span style="font-family: monospace, fixed; font-size: 13px; line-height: 1; white-space: pre-wrap;"> PixelType;</span></div><div><div class="" style="font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px;"><span class="" style="color:rgb(0,128,0)"> </span><span style="line-height:1"> </span><span class="" style="line-height:1;color:rgb(0,128,0)">const</span><span style="line-height:1"> </span><span class="" style="line-height:1;color:rgb(96,64,32)">unsigned</span><span style="line-height:1"> </span><span class="" style="line-height:1;color:rgb(96,64,32)">int</span><span style="line-height:1"> Dimension = 3;</span></div></div><div class="" style="font-size: 13px; line-height: 1; font-family: monospace, fixed; min-height: 13px; white-space: pre-wrap; word-wrap: break-word; padding-left: 53px; padding-bottom: 0px; margin: 0px;"> <span class="" style="color:rgb(0,128,0);background-color:rgb(251,252,253)">typedef</span><span style="background-color:rgb(251,252,253)"> </span><a name="_a0" style="color:rgb(61,87,140);background-color:rgb(251,252,253)"></a>itk::Image< PixelType, Dimension ><span style="background-color:rgb(251,252,253)"> InternalImageType;</span></div><div> typedef itk::CastImageFilter< TInput, <span style="font-family: monospace, fixed; font-size: 13px; line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);">InternalImageType</span>> CastFilterType;</div><div><span class="" style="white-space:pre"> </span>typedef itk::CannyEdgeDetectionImageFilter <<span style="font-family: monospace, fixed; font-size: 13px; line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);">InternalImageType</span>, <span style="font-family: monospace, fixed; font-size: 13px; line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);">InternalImageType</span>> FilterType;</div><div><span class="" style="white-space:pre"> </span>typedef itk::RescaleIntensityImageFilter< <span style="font-family: monospace, fixed; font-size: 13px; line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);">InternalImageType</span>, TOutput > RescaleType;</div><div><br></div><div><span class="" style="white-space:pre"> </span>CastFilterType::Pointer castFilter = CastFilterType::New();</div><div><span class="" style="white-space:pre"> </span>FilterType::Pointer cannyFilter = FilterType::New();</div><div><span class="" style="white-space:pre"> </span>RescaleType::Pointer rescaler = RescaleType::New();</div><div><br></div><div><span class="" style="white-space:pre"> </span>cannyFilter->SetVariance( 2.0 );</div><div><span class="" style="white-space:pre"> </span>cannyFilter->SetUpperThreshold( 10.0);</div><div><span class="" style="white-space:pre"> </span>cannyFilter->SetLowerThreshold( 0.5);</div><div><br></div><div><span class="" style="white-space:pre"> </span>rescaler->SetOutputMinimum( 0 );</div><div><span class="" style="white-space:pre"> </span>rescaler->SetOutputMaximum( 255 );</div><div><br></div><div><span class="" style="white-space:pre"> </span>castFilter->ReleaseDataFlagOn();</div><div><span class="" style="white-space:pre"> </span>cannyFilter->ReleaseDataFlagOn();<span class="" style="white-space:pre"> <b>//When </b></span><b>rescaler->Update() exec, it will crash</b><span style="white-space:pre"> </span></div><div><br></div><div><span class="" style="white-space:pre"> </span>castFilter->SetInput(inImage);</div><div><span class="" style="white-space:pre"> </span>cannyFilter->SetInput(castFilter->GetOutput());</div><div><span class="" style="white-space:pre"> </span>rescaler->SetInput( cannyFilter->GetOutput() );</div><div><br></div><div><span class="" style="white-space:pre"> </span>rescaler->Update(); <b>//crash here</b></div></div><div><br></div><div> //deepcopy codes to copy data from rescaler to outImage</div><div>}</div><div><br></div><div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Yours sincerely,<br>Weldon</div></div>
</div></div>
_____________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Kitware offers ITK Training Courses, for more information visit:<br>http://www.kitware.com/products/protraining.php<br><br>Please keep messages on-topic and check the ITK FAQ at:<br>http://www.itk.org/Wiki/ITK_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://public.kitware.com/mailman/listinfo/insight-users<br>_______________________________________________<br>Community mailing list<br>Community@itk.org<br>http://public.kitware.com/mailman/listinfo/community<br></blockquote></div><br></div></body></html>