00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
#ifndef __itkRGBGibbsPriorFilter_h
00018
#define __itkRGBGibbsPriorFilter_h
00019
00020
#include "vnl/vnl_vector.h"
00021
#include "vnl/vnl_matrix.h"
00022
00023
#include "itkImageToImageFilter.h"
00024
#include "itkImageClassifierBase.h"
00025
#include "itkImageRegionIterator.h"
00026
#include "itkMRFImageFilter.h"
00027
00028
namespace itk
00029 {
00030
00046
template <
class TInputImage,
class TClassifiedImage>
00047 class ITK_EXPORT RGBGibbsPriorFilter :
public MRFImageFilter<TInputImage,
00048 TClassifiedImage>
00049 {
00050
public:
00052 typedef RGBGibbsPriorFilter
Self;
00053
00055 typedef MRFImageFilter<TInputImage, TClassifiedImage> Superclass;
00056
00058 typedef SmartPointer<Self> Pointer;
00059 typedef SmartPointer<const Self> ConstPointer;
00060
00062
itkNewMacro(
Self);
00063
00065
itkTypeMacro(RGBGibbsPriorFilter,
MRFImageFilter);
00066
00068 typedef typename Superclass::InputImagePixelType
InputImagePixelType;
00069 typedef typename Superclass::InputImageRegionConstIterator
InputImageRegionConstIterator;
00070 typedef typename Superclass::InputImageRegionIterator
InputImageRegionIterator;
00071 typedef typename Superclass::LabelledImageRegionIterator
LabelledImageRegionIterator;
00072 typedef typename Superclass::LabelledImagePixelType
LabelledImagePixelType;
00073 typedef typename Superclass::IndexValueType
IndexValueType;
00074
00076 typedef TInputImage
InputImageType;
00077 typedef typename TInputImage::Pointer
InputImagePointer;
00078 typedef typename TInputImage::ConstPointer
InputImageConstPointer;
00079
00081 typedef typename TInputImage::PixelType
InputPixelType;
00082
00084 typedef typename TClassifiedImage::Pointer
TrainingImageType;
00085
00088 typedef typename TClassifiedImage::Pointer
LabelledImageType;
00089
00091 typedef typename TClassifiedImage::IndexType
LabelledImageIndexType;
00092
00096 typedef unsigned int LabelType;
00097
00099 typedef ImageClassifierBase<TInputImage,TClassifiedImage> ClassifierType;
00100
00102 typedef typename TInputImage::PixelType
InputImageVecType;
00103 typedef typename TInputImage::IndexType
IndexType;
00104
00106
void SetTrainingImage(
TrainingImageType image);
00107
00109
void SetLabelledImage(
LabelledImageType LabelledImage);
00110
00112 LabelledImageType GetLabelledImage()
00113 {
return m_LabelledImage; }
00114
00116
void SetClassifier(
typename ClassifierType::Pointer ptrToClassifier );
00117
00119
itkSetMacro(NumberOfClasses,
unsigned int);
00120
00122
itkGetMacro(NumberOfClasses,
unsigned int);
00123
00126
itkSetMacro(MaximumNumberOfIterations,
unsigned int);
00127
00130
itkGetMacro(MaximumNumberOfIterations,
unsigned int);
00131
00133
itkSetMacro(ClusterSize,
unsigned int);
00134
00136
itkSetMacro( ObjectLabel, LabelType );
00137
00139
itkStaticConstMacro(ImageDimension,
unsigned int,
00140 TInputImage::ImageDimension);
00141
00142
itkSetMacro(StartPoint, IndexType);
00143
00144
itkSetMacro(BoundaryGradient,
unsigned int);
00145
00146
itkSetMacro(ObjectThreshold,
double);
00147
00149
itkSetMacro(CliqueWeight_1,
double);
00150
itkGetMacro(CliqueWeight_1,
double);
00151
itkSetMacro(CliqueWeight_2,
double);
00152
itkGetMacro(CliqueWeight_2,
double);
00153
itkSetMacro(CliqueWeight_3,
double);
00154
itkGetMacro(CliqueWeight_3,
double);
00155
itkSetMacro(CliqueWeight_4,
double);
00156
itkGetMacro(CliqueWeight_4,
double);
00157
itkSetMacro(CliqueWeight_5,
double);
00158
itkGetMacro(CliqueWeight_5,
double);
00159
itkSetMacro(CliqueWeight_6,
double);
00160
itkGetMacro(CliqueWeight_6,
double);
00161
00162
00164
typedef vnl_matrix<double> MatrixType;
00165
00166
protected:
00167 RGBGibbsPriorFilter();
00168 ~RGBGibbsPriorFilter();
00169
void PrintSelf(std::ostream& os,
Indent indent)
const;
00170
00171
void Allocate();
00173
virtual void MinimizeFunctional();
00174
virtual void GenerateData();
00175
virtual void ApplyGibbsLabeller();
00176
virtual void ApplyGPImageFilter();
00177
00178
00179
private:
00180 RGBGibbsPriorFilter(
const Self&);
00181
void operator=(
const Self&);
00182
00183
typedef typename TInputImage::SizeType InputImageSizeType;
00184
00185
InputImageConstPointer m_InputImage;
00186
TrainingImageType m_TrainingImage;
00187
LabelledImageType m_LabelledImage;
00188
unsigned int m_NumberOfClasses;
00189
unsigned int m_MaximumNumberOfIterations;
00190
typename ClassifierType::Pointer m_ClassifierPtr;
00191
unsigned int m_BoundaryGradient;
00192
double m_BoundaryWeight;
00193
double m_GibbsPriorWeight;
00194
int m_StartRadius;
00195
int m_RecursiveNumber;
00196
LabelType * m_LabelStatus;
00198
InputImagePointer m_MediumImage;
00200
unsigned int m_Temp;
00201
IndexType m_StartPoint;
00203
unsigned int m_ImageWidth;
00204
unsigned int m_ImageHeight;
00205
unsigned int m_ImageDepth;
00206
unsigned int m_ClusterSize;
00207
LabelType m_ObjectLabel;
00208
unsigned int m_VecDim;
00209
InputPixelType m_LowPoint;
00211
unsigned short *m_Region;
00212
unsigned short *m_RegionCount;
00215
double m_CliqueWeight_1;
00216
double m_CliqueWeight_2;
00217
double m_CliqueWeight_3;
00218
double m_CliqueWeight_4;
00219
double m_CliqueWeight_5;
00220
double m_CliqueWeight_6;
00223
void GibbsTotalEnergy(
int i);
00224
00226
double GibbsEnergy(
unsigned int i,
unsigned int k,
unsigned int k1);
00227
00228
int Sim(
int a,
int b);
00229
unsigned int LabelRegion(
int i,
int l,
int change);
00230
void RegionEraser();
00231
void GenerateMediumImage();
00232
void GreyScalarBoundary(
LabelledImageIndexType Index3D);
00234
double m_ObjectThreshold;
00235
00236 };
00237
00238 }
00239
#ifndef ITK_MANUAL_INSTANTIATION
00240
#include "itkRGBGibbsPriorFilter.txx"
00241
#endif
00242
#endif