[Insight-users] CannyEdgeDetectionImageFilter GraftOutput() bug?
Quan Chen
quanchen at gmail.com
Tue Nov 8 20:34:19 EST 2005
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.
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:
template< class TInputImage, class TOutputImage >
void
CannyEdgeDetectionImageFilter< TInputImage, TOutputImage >
::GenerateData()
{
// Need to allocate output buffer
typename OutputImageType::Pointer output = this->GetOutput();
output->SetBufferedRegion(output->GetRequestedRegion());
output->Allocate();
And at last line
this->GraftOutput(m_UpdateBuffer);
Sets the output buffer to be m_UpdateBuffer.
Both m_UpdateBuffer and m_UpdateBuffer1 was allocated in
AllocateUpdateBuffer():
template <class TInputImage, class TOutputImage>
void
CannyEdgeDetectionImageFilter<TInputImage, TOutputImage>
::AllocateUpdateBuffer()
{
// The update buffer looks just like the input.
typename TInputImage::ConstPointer input = this->GetInput();
m_UpdateBuffer->CopyInformation( input );
m_UpdateBuffer->SetRequestedRegion(input->GetRequestedRegion());
m_UpdateBuffer->SetBufferedRegion(input->GetBufferedRegion());
m_UpdateBuffer->Allocate();
m_UpdateBuffer1->CopyInformation( input );
m_UpdateBuffer1->SetRequestedRegion(input->GetRequestedRegion());
m_UpdateBuffer1->SetBufferedRegion(input->GetBufferedRegion());
m_UpdateBuffer1->Allocate();
}
Can anyone from development team confirm it is sth wrong with the code? Or
it just I use it incorrectly.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20051108/5ce889a6/attachment.htm
More information about the Insight-users
mailing list