[Insight-users] Coupling level set segmentation filters

Nils H. Busch nilsb at cbs.mpg.de
Tue May 3 10:57:57 EDT 2005


Hi,

I am trying to couple two level set segmenttaion filters. To this end, I
have written a filter derived from ImageToImageFilter that has 2 instances
of custom level set segmentation filters. Each filter needs the current
level set solution of the respective other level set segmentation filter (
the output of
GetOutput at each iteration ). The coupled level set contained in the
image returned by GetOutput is connected to the resp other filter by
storing a pointer to that image.

Then, each filter is run for exactly one iteration, the input is set to
the output of the previous iteration and this cycle is repeated for the
specified number of iterations. It is a rather crude and certainly
inefficient approach, but "seemed" to work. I have added a code snippet
fom the GenerateData() method of this composite segmentation filter.

// set up the pipeline for both filters
for(unsigned int isx = 0; idx < this->GetNumberOfOutputs(); ++idx) {
  // we run each filter only one iteration per update cycle
  m_LevelSetSegmentationFilter[idx]->SetNumberOfIterations(1);

  // connect level sets
    m_LevelSetSegmentationFilter[idx]->SetCoupledLevelSetImage(this->GetOutput((idx+1)%2));

m_LevelSetSegmentationFilter[idx]->GraftOutput (this->GetOutput(idx));
}

// evolve both level sets for number of iterations
m_ElapsedIterations = 0;
typename SegmentationFilterTYpe::TimeStepType dt[2];
while (!this->Halt()) {
  for(unsigned int idx = 0; idx < this->GetNumberOfOutputs(); ++idx) {
    m_LevelSetSegmentationFilter[idx]->Update();
       m_LevelSetSegmentationFilter[idx]->SetInput(m_LevelSetSegmentationFilter[idx]->GetOutput()),

}
++m_ElapsedIterations;

...

for (unsigned int idx = 0; idx < this->GetNumberOfOutputs(), ++idx) {
  this->GraftNthOutput(idx, m_LevelSetSegmentationFilter[idx]->GetOutput());
}
}

When investigating the contribution made by the coupling term, I added an
extra speed term to the underlying level set function object (as in
ShapePriorSegmentationLevelSetFunction) in the ComputeUpdate method.
However, when trying to access the coupled level set image there, I get a
memory access violation. The coupled level set image is allocated and the
requested and largest possible region is set correctly, but the buffered
region is zero and the underlying image container is 0. I had assumed that
when the PropagationSpeed etc methods are called the output buffers are
allocated already. Methods like CopyInputToOutput should have been called
already, so I am puzzled why the coupled filters output is empty.

Do I need to prime my update cycle in the above code ?
Is my approach too primitive and inefficient ?
If so, has anyone ideas of how to integrate the concurrent solving of two
or more level sets into a SparseLevelSetSegmentationFilter ?



-- 
  Nils H. Busch


More information about the Insight-users mailing list