[Insight-users] Coupling level set segmentation filters

Miller, James V (Research) millerjv at crd.ge.com
Tue May 3 11:42:05 EDT 2005


Nils,

This is very cool.

To create "cycles" in ITK, where an output becomes a filters input, you
need to jump through a few extra hoops.


OutputImageType::Pointer iterationOutput;
while (!this->Halt()) {
  for(unsigned int idx = 0; idx < this->GetNumberOfOutputs(); ++idx) {
    m_LevelSetSegmentationFilter[idx]->Update();

    iterationOutput = m_LevelSetSegmentationFilter[idx]->GetOutput();
    iterationOutput->DisconnectPipeline();
    m_LevelSetSegmentationFilter[idx]->SetInput(iterationOutput);
  }

The call to DisconnectPipeline() disconnects the image from the pipeline
and forces the pipeline to generate a new valid output data object.

Jim



-----Original Message-----
From: insight-users-bounces at itk.org
[mailto:insight-users-bounces at itk.org]On Behalf Of Nils H. Busch
Sent: Tuesday, May 03, 2005 10:58 AM
To: insight-users at itk.org
Subject: [Insight-users] Coupling level set segmentation filters


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
_______________________________________________
Insight-users mailing list
Insight-users at itk.org
http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list