[Insight-developers] new binary morphologicla erosion and dia lation filters

Miller, James V (CRD) millerjv@crd.ge.com
Fri, 10 Aug 2001 08:39:22 -0400


Jisung,

I'll take a look at whether the regions are being handled properly.

I think the subclasses could be named BinaryErosionImageFilter and BinaryDilationImageFilter.  The
superclass could be named BinaryMorphologyImageFilter.



-----Original Message-----
From: Jisung Kim [mailto:bahrahm@yahoo.com]
Sent: Friday, August 10, 2001 6:30 AM
To: insight-dev-list
Subject: [Insight-developers] new binary morphologicla erosion and
dialation filters


Hi.

I just checked in the binary erosion and dialation
filters. I ran tests on VC++ and Cygwin-gcc. And they
look like working. However, I am not sure if they
correctly adjust the input image's requested region. 

The class name for the binary erosion filter is
BinaryMorphologicalErosionFilter, and
BinaryMorphologicalDialationFilter for the dialation
filter. Both classes are derived from the
BinaryMorphologicalFilterBase class which is derived
from the ImageToImageFilter class.

I don't think these filters are completed. So, I will
keep working on it.

here is an example code for erosion:
=====================================
#include "itkBinaryMorphologicalErosionFilter.h"

// The DummyKernel class definition is at the bottom
// of this message
DummyKernel<ImageType> kernel;
kernel.SetRadius(radius) ;
kernel.Fill(kernel.GenerateCoefficients()) ;

typedef itk::BinaryMorphologicalErosionFilter<
ImageType, ImageType, 
DummyKernel<ImageType> > Filter ;
     
Filter::Pointer filter = Filter::New() ;
// set the kernel (structuring element)
filter->SetKernel(&kernel) ;
// set the threshold value that will be used 
// to separate background pixels from forground(?)
// pixels
filter->SetThreshold((ImageType::PixelType) 1.0);
// just like an ImageToImage filter
filter->SetInput(input) ;
filter->SetOutput(output) ;
filter->Update() ;


======== DummyKernel class ========
template<class TImage>
class DummyKernel : 
  public itk::NeighborhoodOperator< typename
TImage::PixelType, 
  TImage::ImageDimension >
{
public:
  typedef typename TImage::PixelType PixelType ;
  typedef PixelType ValueType ;

  enum { ImageDimension = TImage::ImageDimension } ;
  /**
   * Standard "Self" typedef support.
   */
  typedef DummyKernel Self;
  
  /**
   * Standard Superclass typedef support
   */
  typedef itk::NeighborhoodOperator<PixelType,
ImageDimension> Superclass;
  
  /**
   * Constructor.
   */
  DummyKernel() {}

  /**
   * Copy constructor
   */
  DummyKernel(const Self& other)
    : itk::NeighborhoodOperator<PixelType,
ImageDimension>(other)
  {  }

  typedef Superclass::Iterator Iterator ;
  typedef Superclass::ConstIterator ConstIterator ;

  /**
   * Assignment operator
   */
  Self &operator=(const Self& other)
  {
    Superclass::operator=(other);
    return *this;
  }

  /**
   * Necessary to work around a compiler bug in VC++.
   */
  typedef typename Superclass::CoefficientVector
CoefficientVector;

  /**
   * Calculates operator coefficients.
   */
  CoefficientVector GenerateCoefficients()
  {
    unsigned long dim = this->GetDimension() ;
    unsigned long totalSize = 1 ;
    SizeType radius = this->GetRadius() ;
    for (unsigned long i = 0 ; i < dim ; i++)
      totalSize *= (radius[i] * 2 + 1) ;
    std::vector<PixelType> coeff(totalSize, 1) ; 

    return coeff;
  }

  /**
   * Arranges coefficients spatially in the memory
buffer.
   */
  void Fill(const CoefficientVector &coeff)
  {    
    for (unsigned int i = 0; i< this->Size(); ++i)
       {
         this->operator[](i) = coeff[i] ;
       }
  }
  
};







=====
Jisung Kim
bahrahm@yahoo.com
106 Mason Farm Rd.
129 Radiology Research Lab., CB# 7515
Univ. of North Carolina at Chapel Hill
Chapel Hill, NC 27599-7515

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

_______________________________________________
Insight-developers mailing list
Insight-developers@public.kitware.com
http://public.kitware.com/mailman/listinfo/insight-developers