Public Member Functions | Public Attributes | Private Attributes
i3d::LabeledImage3d< LABEL, VOXEL > Class Template Reference

#include <regions.h>

List of all members.

Public Member Functions

 LabeledImage3d (const Offset *off_=0, const Resolution *res_=0)
void CreateRegionsOld (Image3d< VOXEL > &, const Neighbourhood &nb=nb3D_6)
void CreateRegions (Image3d< VOXEL > &img, const Neighbourhood &nb=nb3D_6)
void CreateRegionsFF (const Image3d< VOXEL > &img, const Neighbourhood &nb=nb3D_6)
void CreateForegroundRegionsFF (const Image3d< VOXEL > &img, const Neighbourhood &nb=nb3D_6)
void RemoveComponent (LABEL label)
template<class Predicate >
void MergeComponents (LABEL comp, Predicate pred)
void MergeComponents (LABEL comp1, LABEL comp2)
template<class T >
bool Convert (Image3d< T > &img)
size_t NumberOfComponents () const
Vector3d< int > GetDisplacement () const
void SetDisplacement (const Vector3d< int > &d)
LABEL get_max_label (void) const
size_t FindAndSetMaxLabel ()
LABEL AddNewComponent (const Image3d< bool > &mask)
void UpdateComponent (LABEL lbl, const Image3d< bool > &mask)
void GetComponentMask (LABEL lbl, Image3d< bool > &mask) const
void SaveImage (const char *filename, i3d::FileFormat format=IMG_ICSv2) const
void ReadImage (const char *filename, const VOI< PIXELS > *voi=NULL, bool isregexp=0, size_t channel=-1)

Public Attributes

ComponentInfo< LABEL, VOXEL >
::Container 
components

Private Attributes

LABEL max_label
Vector3d< int > displacement

Detailed Description

template<class LABEL, class VOXEL>
class i3d::LabeledImage3d< LABEL, VOXEL >

class LabeledImage3d implements a labeled image


Constructor & Destructor Documentation

template<class LABEL , class VOXEL >
i3d::LabeledImage3d< LABEL, VOXEL >::LabeledImage3d ( const Offset *  off_ = 0,
const Resolution *  res_ = 0 
) [inline, explicit]

Empty image:


Member Function Documentation

template<class LABEL , class VOXEL >
void i3d::LabeledImage3d< LABEL, VOXEL >::CreateRegionsOld ( Image3d< VOXEL > &  img,
const Neighbourhood nb = nb3D_6 
)

CreateRegions performs region labeling algorithm on an input Image3d<VOXEL> image.

Size of *this LabeledImage3d will be same as of the input image. Information about regions is stored into this->components container. Neigbourhood nb is expected to be symetric. If it is not, the algorithm create symetric neigbourhood from offsets (x, y, z) of nb where (x <= 0 && y == 0 && z == 0) || (y < 0 && z == 0) || (y <= 0 && z < 0)

template<class LABEL , class VOXEL >
void i3d::LabeledImage3d< LABEL, VOXEL >::CreateRegions ( Image3d< VOXEL > &  img,
const Neighbourhood nb = nb3D_6 
)

The function CreateRegions performs Rosenfeld's region labelling algortihm on an input image.

This implementation is done in more effective way than the above one and gives the same results. In contrast to CreateRegionsOld function, the output sequence of labels is in ascending order (without spaces) and starts with label 1.

template<class LABEL , class VOXEL >
void i3d::LabeledImage3d< LABEL, VOXEL >::CreateRegionsFF ( const Image3d< VOXEL > &  img,
const Neighbourhood nb = nb3D_6 
)

The results are same as for CreateRegions function.

Different algorithm (based on FloodFill) is used. Neighbourhood nb3D_6 is imlicitly assumed

template<class LABEL , class VOXEL >
void i3d::LabeledImage3d< LABEL, VOXEL >::CreateForegroundRegionsFF ( const Image3d< VOXEL > &  img,
const Neighbourhood nb = nb3D_6 
)

If we know the background needn't be labeled we can speed up the labeling process.

The foreground is formed by nonzero pixels.

template<class LABEL , class VOXEL >
void i3d::LabeledImage3d< LABEL, VOXEL >::RemoveComponent ( LABEL  label)

Remove component with given label.

If such a component does not exist, the i3d::InternalException is thrown.

template<class LABEL , class VOXEL >
template<class Predicate >
void i3d::LabeledImage3d< LABEL, VOXEL >::MergeComponents ( LABEL  comp,
Predicate  pred 
) [inline]

Component comp is merged with all components for which pred holds.

template<class LABEL , class VOXEL >
void i3d::LabeledImage3d< LABEL, VOXEL >::MergeComponents ( LABEL  comp1,
LABEL  comp2 
)

components comp1 and comp2 are merged

template<class LABEL , class VOXEL >
template<class T >
bool i3d::LabeledImage3d< LABEL, VOXEL >::Convert ( Image3d< T > &  img) [inline]

function converts LabeledImage3d to Image3d if it is possible (i.e number of components < max value of Image3d type) List of components is lost.

Returned value indicate whether conversion was successful.

template<class LABEL , class VOXEL >
size_t i3d::LabeledImage3d< LABEL, VOXEL >::NumberOfComponents ( ) const [inline]

return number of components

template<class LABEL , class VOXEL >
Vector3d<int> i3d::LabeledImage3d< LABEL, VOXEL >::GetDisplacement ( ) const [inline]

get the image displacement

template<class LABEL , class VOXEL >
void i3d::LabeledImage3d< LABEL, VOXEL >::SetDisplacement ( const Vector3d< int > &  d) [inline]

set the image displacement

template<class LABEL , class VOXEL >
LABEL i3d::LabeledImage3d< LABEL, VOXEL >::get_max_label ( void  ) const [inline]
template<class LABEL , class VOXEL >
size_t i3d::LabeledImage3d< LABEL, VOXEL >::FindAndSetMaxLabel ( )
template<class LABEL , class VOXEL >
LABEL i3d::LabeledImage3d< LABEL, VOXEL >::AddNewComponent ( const Image3d< bool > &  mask)

Add a new component to this labelled image.

The new component is defined using mask in the given input image

template<class LABEL , class VOXEL >
void i3d::LabeledImage3d< LABEL, VOXEL >::UpdateComponent ( LABEL  lbl,
const Image3d< bool > &  mask 
)

Update component of the labelled image.

The new component is defined using mask in the given input image. It is assumed that the mask was created by GetComponentMask, especially that the voi of the mask is the same. Warning: function can replace labels of other components and create inconsistency. If mask grasped only background voxels it should be safe.

template<class LABEL , class VOXEL >
void i3d::LabeledImage3d< LABEL, VOXEL >::GetComponentMask ( LABEL  lbl,
Image3d< bool > &  mask 
) const

Create the binary mask of given component.

template<class LABEL , class VOXEL >
void i3d::LabeledImage3d< LABEL, VOXEL >::SaveImage ( const char *  filename,
i3d::FileFormat  format = IMG_ICSv2 
) const

Save LabeledImage3d to a given file - creates filename.l3d containing the name of a file with the 3d data and list of components.

3d data is converted to GRAY8 or GRAY16 image (depending on the number of components) and saved in usual way. Throws an IOException on error. l3d file format: 3d image filename displacement vector number of components - n max_label components list 1..n (label voi volume border voxel_value)

template<class LABEL , class VOXEL >
void i3d::LabeledImage3d< LABEL, VOXEL >::ReadImage ( const char *  filename,
const VOI< PIXELS > *  voi = NULL,
bool  isregexp = 0,
size_t  channel = -1 
)

Load LabeledImage3d from .l3d file.


Member Data Documentation

template<class LABEL , class VOXEL >
LABEL i3d::LabeledImage3d< LABEL, VOXEL >::max_label [private]
template<class LABEL , class VOXEL >
Vector3d<int> i3d::LabeledImage3d< LABEL, VOXEL >::displacement [private]

Displacement in voxels according to the original image.

We can have an indexed image for a part of the original image or even an indexed image which is not fully covered by the original image (for instance, if it has black voxels added at borders to allow fast binary functions).

template<class LABEL , class VOXEL >
ComponentInfo<LABEL, VOXEL>::Container i3d::LabeledImage3d< LABEL, VOXEL >::components

container of ComponentInfo structures:


The documentation for this class was generated from the following files: