00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
#ifndef _itkVoronoiSegmentationImageFilterBase_h
00018
#define _itkVoronoiSegmentationImageFilterBase_h
00019
00020
#include "itkImageToImageFilter.h"
00021
#include "itkVoronoiDiagram2D.h"
00022
#include "itkVoronoiDiagram2DGenerator.h"
00023
#include "itkImage.h"
00024
00025
namespace itk
00026 {
00027
00058
template <
class TInputImage,
class TOutputImage>
00059 class ITK_EXPORT VoronoiSegmentationImageFilterBase:
00060
public ImageToImageFilter<TInputImage,TOutputImage>
00061 {
00062
public:
00064 typedef VoronoiSegmentationImageFilterBase
Self;
00065 typedef ImageToImageFilter<TInputImage,TOutputImage> Superclass;
00066 typedef SmartPointer <Self>
Pointer;
00067 typedef SmartPointer<const Self> ConstPointer;
00068
00070
itkNewMacro(
Self);
00071
00073
itkTypeMacro(VoronoiSegmentationImageFilterBase,
ImageToImageFilter);
00074
00076
itkStaticConstMacro(ImageDimension,
unsigned int,
00077 TInputImage::ImageDimension);
00078
00080 typedef TInputImage
InputImageType;
00081 typedef typename TInputImage::Pointer
InputImagePointer;
00082 typedef typename TInputImage::ConstPointer
InputImageConstPointer;
00083 typedef TOutputImage
OutputImageType;
00084 typedef typename TInputImage::IndexType
IndexType;
00085 typedef typename TInputImage::SizeType
SizeType;
00086 typedef typename TInputImage::RegionType
RegionType;
00087 typedef typename TInputImage::PixelType
PixelType;
00088 typedef typename TOutputImage::PixelType
OutputPixelType;
00089 typedef VoronoiDiagram2D<double> VoronoiDiagram;
00090 typedef VoronoiDiagram2DGenerator<double> VoronoiDiagramGenerator;
00091 typedef typename VoronoiDiagram::PointType
PointType;
00092 typedef typename VoronoiDiagram::CellType
CellType;
00093 typedef typename VoronoiDiagram::CellAutoPointer
CellAutoPointer;
00094 typedef typename VoronoiDiagram::Pointer
VoronoiPointer;
00095 typedef typename CellType::PointIdIterator
PointIdIterator;
00096 typedef typename VoronoiDiagram::SeedsType
SeedsType;
00097 typedef typename VoronoiDiagram::SeedsIterator
SeedsIterator;
00098 typedef typename VoronoiDiagram::NeighborIdIterator
NeighborIdIterator;
00099 typedef typename VoronoiDiagram::VoronoiEdgeIterator
EdgeIterator;
00100 typedef typename VoronoiDiagram::VoronoiEdge
EdgeInfo;
00101 typedef std::vector<PointType>
PointTypeVector;
00102 typedef std::deque<PointType>
PointTypeDeque;
00103 typedef Image<bool,2> BinaryObjectImage;
00104 typedef typename BinaryObjectImage::Pointer
BinaryObjectImagePointer;
00105 typedef std::vector<IndexType>
IndexList;
00106
00108 typedef Image<unsigned char,2> VDImage;
00109 typedef typename VDImage::Pointer
VDImagePointer;
00110
00112
itkSetMacro(NumberOfSeeds,
int);
00113
itkGetMacro(NumberOfSeeds,
int);
00114
00116
itkSetMacro(MinRegion,
int);
00117
itkGetMacro(MinRegion,
int);
00118
00121
itkSetMacro(Steps,
int);
00122
itkGetMacro(Steps,
int);
00123
00125
itkGetMacro(LastStepSeeds,
int);
00126
00128
itkGetMacro(NumberOfSeedsToAdded,
int);
00129
00131
itkSetMacro(UseBackgroundInAPrior,
bool);
00132
itkGetMacro(UseBackgroundInAPrior,
bool);
00133
00135
itkSetMacro(OutputBoundary,
bool);
00136
itkGetMacro(OutputBoundary,
bool);
00137
00140
itkSetMacro(InteractiveSegmentation,
bool);
00141
itkGetMacro(InteractiveSegmentation,
bool);
00142
itkBooleanMacro(InteractiveSegmentation);
00143
00145
itkSetMacro(MeanDeviation,
double);
00146
itkGetMacro(MeanDeviation,
double);
00147
00150
virtual void TakeAPrior(
BinaryObjectImage*){};
00151
00153
void RunSegment(
void);
00154
00156
void RunSegmentOneStep(
void);
00157
00159
virtual void MakeSegmentBoundary(
void);
00160
virtual void MakeSegmentObject(
void);
00161
00163
VoronoiPointer GetVoronoiDiagram(
void)
00164 {
return m_WorkingVD; }
00165
00169
void SetSeeds(
int num, SeedsIterator begin)
00170 {
00171 m_NumberOfSeeds = num;
00172 m_WorkingVD->SetSeeds(num,begin);
00173 };
00174
00176 PointType GetSeed(
int SeedID)
00177 {
return m_WorkingVD->GetSeed(SeedID); }
00178
00180
void DrawDiagram(VDImagePointer result,
unsigned char incolor,
00181
unsigned char outcolor,
unsigned char boundcolor);
00182
00183
void BeforeNextStep(
void);
00184
00187
virtual void GenerateInputRequestedRegion();
00188
00191
virtual void EnlargeOutputRequestedRegion(
DataObject *output);
00192
00193
protected:
00194 VoronoiSegmentationImageFilterBase();
00195 ~VoronoiSegmentationImageFilterBase();
00196
virtual void PrintSelf(std::ostream& os,
Indent indent)
const;
00197
00198
void GenerateData(
void);
00199
00200 SizeType m_Size;
00201
int m_NumberOfSeeds;
00202
int m_MinRegion;
00203
int m_Steps;
00204
int m_LastStepSeeds;
00205
int m_NumberOfSeedsToAdded;
00206
int m_NumberOfBoundary;
00207 std::vector<int> m_NumberOfPixels;
00208 std::vector<unsigned char> m_Label;
00209 double m_MeanDeviation;
00210 bool m_UseBackgroundInAPrior;
00211 bool m_OutputBoundary;
00212 bool m_InteractiveSegmentation;
00213
00214 typename VoronoiDiagram::Pointer m_WorkingVD;
00215 typename VoronoiDiagramGenerator::Pointer m_VDGenerator;
00216
00217 std::vector<PointType> m_SeedsToAdded;
00218
00219
00220
00221 virtual void ClassifyDiagram(
void);
00222
00223
00224 virtual void GenerateAddingSeeds(
void);
00225
00226
00227
void GetPixelIndexFromPolygon(
PointTypeDeque VertList,
IndexList *PixelPool);
00228
virtual bool TestHomogeneity(
IndexList&){
return 1;}
00229
00230
void FillPolygon(PointTypeDeque vertlist, OutputPixelType color=1);
00231
00232
00233
void drawLine(PointType p1,PointType p2);
00234
00235
00236
void drawVDline(VDImagePointer result,PointType p1,PointType p2,
unsigned char color);
00237
00238
private:
00239 VoronoiSegmentationImageFilterBase(
const Self&);
00240
void operator=(
const Self&);
00241
00242 };
00243
00244 }
00245
00246
00247
#ifndef ITK_MANUAL_INSTANTIATION
00248
#include "itkVoronoiSegmentationImageFilterBase.txx"
00249
#endif
00250
00251
#endif
00252
00253
00254
00255