| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkBinaryCrossStructuringElement.txx.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:33 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 8 |
|
|
| 9 |
|
Copyright (c) Insight Software Consortium. All rights reserved. |
| 10 |
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. |
| 11 |
|
|
| 12 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 13 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 |
|
PURPOSE. See the above copyright notices for more information. |
| 15 |
|
|
| 16 |
|
=========================================================================*/ |
| 17 |
DEF |
#ifndef _itkBinaryCrossStructuringElement_txx |
| 18 |
DEF |
#define _itkBinaryCrossStructuringElement_txx |
| 19 |
|
#include "itkBinaryCrossStructuringElement.h" |
| 20 |
|
|
| 21 |
|
#include "itkNumericTraits.h" |
| 22 |
|
|
| 23 |
|
namespace itk |
| 24 |
|
{ |
| 25 |
|
|
| 26 |
|
// Create the structuring element |
| 27 |
|
template <class TPixel, unsigned int VDimension, class TAllocator> |
| 28 |
|
void |
| 29 |
|
BinaryCrossStructuringElement<TPixel, VDimension, TAllocator> |
| 30 |
|
::CreateStructuringElement() |
| 31 |
|
{ |
| 32 |
|
// Structuring element is defined to be 3x3x3... |
| 33 |
|
RadiusType radius; |
| 34 |
|
radius.Fill(1); |
| 35 |
|
this->SetRadius(radius); |
| 36 |
|
|
| 37 |
|
// |
| 38 |
|
// Zero out the neighborhood |
| 39 |
|
// |
| 40 |
|
Iterator kernel_it; |
| 41 |
|
for (kernel_it=this->Begin(); kernel_it != this->End(); ++kernel_it) |
| 42 |
|
{ |
| 43 |
|
*kernel_it = NumericTraits<TPixel>::Zero; |
| 44 |
|
} |
| 45 |
|
|
| 46 |
|
// |
| 47 |
|
// Set the face connected neighbors |
| 48 |
|
// |
| 49 |
|
unsigned int d; |
| 50 |
|
OffsetValueType i; |
| 51 |
|
OffsetType offset; |
| 52 |
|
offset.Fill(0); |
| 53 |
|
(*this)[offset] = NumericTraits<TPixel>::One; |
| 54 |
|
for (d=0; d < VDimension; ++d) |
| 55 |
|
{ |
| 56 |
|
for (i=-1; i<=1; i+=2) |
| 57 |
|
{ |
| 58 |
|
offset[d] = i; |
| 59 |
LEN |
(*this)[offset] = NumericTraits<TPixel>::One; // a neighbor pixel in dimension d |
| 60 |
|
} |
| 61 |
|
offset[d] = 0; |
| 62 |
|
} |
| 63 |
|
} |
| 64 |
|
|
| 65 |
|
} // namespace itk |
| 66 |
|
|
| 67 |
|
#endif |
| 68 |
|
|