[Insight-developers] Re: on segmentation & connectedness

Joshua Cates cates@sci.utah.edu
Mon, 14 Oct 2002 12:13:44 -0600 (MDT)


There are several options for expanding the neighborhood iterators to
handle arbitrary connectedness.  

One way is to slice the neighborhood iterator array using a container
that holds array offsets (which has the advantage of being fully
customizable to non-traditionally-shaped neighborhoods).  I do this sort 
of thing in the watersheds code:

class ConnectednessObjectBase {
  std::size_t GetSize() {return m_Offsets.size();}
  
  unsigned GetOffset(unsigned i) { return m_Offsets(i); }

  std::vector<unsigned> m_Offsets;
};

class CityBlockConnectedness {
  CityBlockConnectedness(dimensionality) {
  for (i = 0; i < 2*dimensionality; i++)
     m_Offsets.push_back(this->CalculateIthOffset(i, dimensionality));
  }
  CalculateIthOffset(unsigned i, unsigned dimensionality) {
   ....
  }

};


- or drop the container -

class ConnectedObjectBase {
  virtual std::size_t GetSize() = 0;
  virtual unsigned CalculateIthOffset(unsigned, unsigned) = 0;
  virtual unsigned GetOffset(unsigned i, dimensionality) 
    { return this->CalculateIthOffset(i, dimensionality)} ;
}

To iterate over the connected pixels in a neighborhood becomes:

CityBlockConnectedNess c(3);
SmartNeighborhoodIterator(neighborhoodRadius, image, imageRegion) it;

//Print the connected pixels in a neighborhood
for (unsigned i = 0; i < c->GetSize(); ++i)
{
  std::cout << it->GetPixel(c->GetOffset(i));
}


Another option is to use an actual slice iterator directly on the 
neighborhood container itself.  Examples of doing this can be found by 
looking through the code which does inner products on neighborhoods.  
There is a mechanism to take an inner product with a slice of a 
neighborhood, for example.

A third option is to create special NeighborhoodIterators which only keep
track of the requested neighbor pixels.  You then iterate through the
indicies directly.  This is the most efficient way.  I plan to backfill
this functionality into the neighborhood iterators sometime in the coming
months.  Any design ideas or API suggestions would be helpful.

Josh.






______________________________
 Josh Cates			
 School of Computer Science	
 University of Utah
 Email: cates@sci.utah.edu
 Phone: (801) 587-7697
 URL:   www.cs.utk.edu/~cates


On Fri, 11 Oct 2002, Luis Ibanez wrote:

> Hi cspl,
> 
> The current implementation of the itk::ConfidenceConnectedImageFitler
> uses the FloodFillFunctionConditionalIterator class.
> 
> This class consider neighbors only the closest pixels in every dimension.
> That is:
> 
>   2 connectedness in 1D
>   4 connectedness in 2D
>   6 connectedness in 3D
>   8 connectedness in 4 D
> ...
> 2N connectedness in N-D.
> 
> 
> The code that decides the connectivity is in lines 162 to 207 in
> Insight/Code/Common/itkFloodFilledFunctionConditionalConstIterator.txx
> 
> it is basically:
> 
>    for ( each dimension )
>         for( j=-1; j<=2; j+=2 )            // try the neighbor at each side
> 
> 
> Probably the best way to modify this code and make several connectivities
> possible is to use the SmartNeighborhood iterator in order to have access
> to the neighbor pixels.
> 
> You may want to modify the code in this iterator in order to get
> 26 connectedness....
> 
> 
> Please let us know if you need further details,
> 
> 
> Thanks
> 
>    Luis
> 
> ==================================================
> 
> cspl wrote:
> 
> > Dear Mr.Luis,
> >
> >  
> >
> > I am working on Segmentaion.I used  the following class to get 
> > segmentation o/p.
> > itk::ConfidenceConnectedImageFilter.
> > I am getting for one image not volume.If I have to get for a volume 
> > how connect 26 .
> > I think now it is 8 connected How to specify 26 connected in 
> > volume.Please give me suggestion.
> >
> >  
> >
> > I have written code as follows.
> >
> >  
> >
> >
> >  typedef itk::ConfidenceConnectedImageFilter<myImage,myImage> FilterType;
> >   FilterType::Pointer filter = FilterType::New();
> >   filter->SetInput(image1);
> >
> >  
> >
> >  FilterType::IndexType seed; seed[0] = vol->width/2;seed[1] 
> > =vol->height/2 ;
> >  filter->SetSeed(seed);
> >  filter->SetMultiplier(2.5);
> >  filter->SetReplaceValue(255);
> >  filter->SetNumberOfIterations(1);
> >  
> >   try
> >     {   
> >     filter->Update();
> >  
> >     }
> >   catch (itk::ExceptionObject& e)
> >     {
> >     AfxMessageBox(e.GetDescription());
> >
> >  
> >
> >     }
> >  
> >  image1 = filter->GetOutput();
> >  
> >
> >  
> >
> > }
> >
> >  
> >
> > Please see the o/p of a single slice .I attached herewith o/p of a one 
> > image.
> >
> >  
> >
> > Thanking you,
> >
> >  
> >
> > Regards,
> > Ramakrishna
> >
> >
> > ------------------------------------------------------------------------
> >
> > <cid:part1.05010202.08040906@kitware.com>
> >
> 
> 
>