<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;color:rgb(0,0,0);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;color:rgb(0,0,0);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-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;color:rgb(0,0,0)"><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-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;color:rgb(0,0,0)"><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-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;color:rgb(0,0,0)"> <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-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;color:rgb(0,0,0)"> <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-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;color:rgb(0,0,0)"><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-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;color:rgb(0,0,0)"><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-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;color:rgb(0,0,0)"></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;color:rgb(0,0,0)"> ReaderType::Pointer reader = ReaderType::New();</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;color:rgb(0,0,0)"> 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"><font color="#000000"> </font></span><span class="" style="color:rgb(0,128,0);line-height:1">typedef</span><span style="color:rgb(0,0,0);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="color:rgb(0,0,0);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;color:rgb(0,0,0)"> 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;color:rgb(0,0,0)"> 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;color:rgb(0,0,0)"> 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;color:rgb(0,0,0)"> </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;color:rgb(0,0,0)"> 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;color:rgb(0,0,0)"> </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;color:rgb(0,0,0)"> 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;color:rgb(0,0,0)"><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;color:rgb(0,0,0)"> 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="color:rgb(0,0,0);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="color:rgb(0,0,0);font-family:monospace,fixed;font-size:13px;line-height:1;white-space:pre-wrap"> PixelType;</span></div><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;color:rgb(0,0,0)"><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;font-stretch:normal;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;color:rgb(0,0,0)"> <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="color:rgb(0,0,0);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="color:rgb(0,0,0);font-family:monospace,fixed;font-size:13px;line-height:13px;white-space:pre-wrap;background-color:rgb(251,252,253)">InternalImageType</span>, <span style="color:rgb(0,0,0);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="color:rgb(0,0,0);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>