21 #ifndef _HashProbabilisticAtlas_H 23 #define _HashProbabilisticAtlas_H 25 #include "mirtk/Object.h" 27 #include "mirtk/Image.h" 28 #include "mirtk/HashImage.h" 42 class HashProbabilisticAtlas :
public Object
44 typedef HashImage<int> HashIntegerImage;
46 mirtkObjectMacro(HashProbabilisticAtlas);
49 vector<HashRealImage*> _images;
52 int _number_of_voxels;
58 HashIntegerImage *_segmentation;
69 HashProbabilisticAtlas();
72 ~HashProbabilisticAtlas();
75 HashProbabilisticAtlas& operator=(
const HashProbabilisticAtlas &atlas);
78 void SwapImages(
int,
int);
81 template <
class ImageType>
82 void AddImage(ImageType image);
91 RealPixel GetValue(
unsigned int mapnr);
94 RealPixel GetValue(
int x,
int y,
int z,
unsigned int mapnr);
97 void SetValue(
unsigned int mapnr, RealPixel value);
100 void SetValue(
int x,
int y,
int z,
unsigned int mapnr, RealPixel value);
103 int GetNumberOfVoxels()
const;
106 template <
class ImageType>
107 void AddProbabilityMaps(
int, ImageType **atlas);
110 void AddBackground();
113 template <
class ImageType>
114 void AddBackground(ImageType image);
117 bool HasBackground()
const;
120 void NormalizeAtlas();
123 int GetNumberOfMaps()
const;
126 void Write(
int,
const char *);
129 HashIntegerImage ComputeHardSegmentation();
132 void ExtractLabel(
int label, HashByteImage &image);
135 void WriteHardSegmentation(
const char *filename);
138 HashRealImage GetImage(
unsigned int mapnr)
const;
141 HashRealImage::DataIterator Begin(
unsigned int mapnr)
const;
142 HashRealImage::DataIterator End(
unsigned int mapnr)
const;
146 inline void HashProbabilisticAtlas::First(){
150 inline void HashProbabilisticAtlas::Next(){
154 inline RealPixel HashProbabilisticAtlas::GetValue(
unsigned int mapnr){
155 if (mapnr < _images.size())
return _images[mapnr]->
Get(_position);
157 std::cerr <<
"map identificator " << mapnr <<
" out of range." <<std::endl;
162 inline RealPixel HashProbabilisticAtlas::GetValue(
int x,
int y,
int z,
unsigned int mapnr){
163 if (mapnr < _images.size())
return _images[mapnr]->
Get(x,y,z);
165 std::cerr <<
"map identificator " << mapnr <<
" out of range." <<std::endl;
170 inline void HashProbabilisticAtlas::SetValue(
unsigned int mapnr, RealPixel value){
171 if (mapnr < _images.size()) _images[mapnr]->Put(_position, value);
173 std::cerr <<
"map identificator " << mapnr <<
" out of range." <<std::endl;
178 inline void HashProbabilisticAtlas::SetValue(
int x,
int y,
int z,
unsigned int mapnr, RealPixel value){
179 if (mapnr < _images.size()) _images[mapnr]->Put(x,y,z, value);
181 std::cerr <<
"map identificator " << mapnr <<
" out of range." <<std::endl;
186 inline int HashProbabilisticAtlas::GetNumberOfVoxels()
const{
187 return _number_of_voxels;
190 inline int HashProbabilisticAtlas::GetNumberOfMaps()
const{
191 return _number_of_maps;
194 inline bool HashProbabilisticAtlas::HasBackground()
const{
195 return _has_background;
198 template <
class ImageType>
199 inline void HashProbabilisticAtlas::AddBackground(ImageType image){
201 _has_background=
true;
204 inline HashRealImage HashProbabilisticAtlas::GetImage(
unsigned int mapnr)
const{
205 if (mapnr < _images.size())
return *_images[mapnr];
207 std::cerr <<
"map identificator " << mapnr <<
" out of range." <<std::endl;
212 inline HashRealImage::DataIterator HashProbabilisticAtlas::Begin(
unsigned int mapnr)
const 214 if (mapnr < _images.size())
return _images[mapnr]->Begin();
216 std::cerr <<
"map identificator " << mapnr <<
" out of range." <<std::endl;
220 inline HashRealImage::DataIterator HashProbabilisticAtlas::End(
unsigned int mapnr)
const 222 if (mapnr < _images.size())
return _images[mapnr]->End();
224 std::cerr <<
"map identificator " << mapnr <<
" out of range." <<std::endl;
string Get(const ParameterList ¶ms, string name)
Get parameter value from parameters list.