<div>I was trying to use GraftOutput() to set the output of CannyEdgeDetectionImageFilter. However, I find that the image does not change. I did same thing for other filters like Sigmoid and AnisotropicDiffusion, and they worked well. If I use g_OutputImage=cannyFilter->GetOutput(); g_OutputImage->DisconnectPipeline(); it worked well.
</div>
<div> </div>
<div>I read the CannyEdgeDetection code for a while. Because I am still not familiar with the ITK architecture, I am not sure about my findings. But it seems to me that the beginning of the GenerateData() function just re-allocate the output buffer:
</div>
<div>template< class TInputImage, class TOutputImage ><br>void<br>CannyEdgeDetectionImageFilter< TInputImage, TOutputImage ><br>::GenerateData()<br>{<br> // Need to allocate output buffer<br> typename OutputImageType::Pointer output = this->GetOutput();
<br> output->SetBufferedRegion(output->GetRequestedRegion());<br> output->Allocate();<br> </div>
<div> </div>
<div>And at last line</div>
<div> <br> this->GraftOutput(m_UpdateBuffer);</div>
<div> </div>
<div>Sets the output buffer to be m_UpdateBuffer.</div>
<div>Both m_UpdateBuffer and m_UpdateBuffer1 was allocated in AllocateUpdateBuffer():</div>
<div> </div>
<div>
<p>template <class TInputImage, class TOutputImage><br>void<br>CannyEdgeDetectionImageFilter<TInputImage, TOutputImage><br>::AllocateUpdateBuffer()<br>{<br> // The update buffer looks just like the input.</p>
<p> typename TInputImage::ConstPointer input = this->GetInput();</p>
<p> m_UpdateBuffer->CopyInformation( input );<br> m_UpdateBuffer->SetRequestedRegion(input->GetRequestedRegion());<br> m_UpdateBuffer->SetBufferedRegion(input->GetBufferedRegion());<br> m_UpdateBuffer->Allocate();
<br> <br> m_UpdateBuffer1->CopyInformation( input );<br> m_UpdateBuffer1->SetRequestedRegion(input->GetRequestedRegion());<br> m_UpdateBuffer1->SetBufferedRegion(input->GetBufferedRegion());<br> m_UpdateBuffer1->Allocate();
<br>}</p>
<p>Can anyone from development team confirm it is sth wrong with the code? Or it just I use it incorrectly.</p>
<p> </p></div>
<div> </div>
<div> </div>