highres-cortex 6.0.4
label_volume.hh
Go to the documentation of this file.
1/*
2Copyright CEA (2014).
3Copyright Université Paris XI (2014).
4
5Contributor: Yann Leprince <yann.leprince@ylep.fr>.
6
7This file is part of highres-cortex, a collection of software designed
8to process high-resolution magnetic resonance images of the cerebral
9cortex.
10
11This software is governed by the CeCILL licence under French law and
12abiding by the rules of distribution of free software. You can use,
13modify and/or redistribute the software under the terms of the CeCILL
14licence as circulated by CEA, CNRS and INRIA at the following URL:
15<http://www.cecill.info/>.
16
17As a counterpart to the access to the source code and rights to copy,
18modify and redistribute granted by the licence, users are provided only
19with a limited warranty and the software's author, the holder of the
20economic rights, and the successive licensors have only limited
21liability.
22
23In this respect, the user's attention is drawn to the risks associated
24with loading, using, modifying and/or developing or reproducing the
25software by the user in light of its specific status of scientific
26software, that may mean that it is complicated to manipulate, and that
27also therefore means that it is reserved for developers and experienced
28professionals having in-depth computer knowledge. Users are therefore
29encouraged to load and test the software's suitability as regards their
30requirements in conditions enabling the security of their systems and/or
31data to be ensured and, more generally, to use and operate it in the
32same conditions as regards security.
33
34The fact that you are presently reading this means that you have had
35knowledge of the CeCILL licence and that you accept its terms.
36*/
37
38#ifndef YL_LABEL_VOLUME_HH_INCLUDED
39#define YL_LABEL_VOLUME_HH_INCLUDED
40
41#include <cassert>
42#include <functional>
43#include <boost/iterator/transform_iterator.hpp>
44
45#include <cartodata/volume/volume.h>
46#include <aims/bucket/bucketMap.h>
47
48namespace yl
49{
50
52template<typename TPair>
53class select1st : public std::unary_function<TPair, typename TPair::first_type>
54{
55public:
56 typename TPair::first_type&
57 operator()(TPair& pair) const
58 {
59 return pair.first;
60 }
61
62 const typename TPair::first_type&
63 operator()(const TPair& pair) const
64 {
65 return pair.first;
66 }
67};
68
69
70template <typename Tlabel>
72{
73public:
76
77 typedef boost::transform_iterator<select1st<BucketMap::value_type>,
80 typedef boost::transform_iterator<select1st<Bucket::value_type>,
81 Bucket::const_iterator> const_point_iterator;
82
83 explicit LabelVolume(const carto::VolumeRef<Tlabel> &vol, Tlabel background = 0);
84 virtual ~LabelVolume() {};
85
86 void merge_regions(Tlabel eating_label, Tlabel eaten_label);
87 void discard_region(Tlabel label);
88
89 Tlabel background_label() const
90 {
91 return m_background_label;
92 }
93
95 {
96 return m_volume;
97 }
98
99 BucketMap::size_type n_regions() const
100 {
101 return m_bucketmap.size();
102 }
103
106 {
107 return const_regions_iterator(m_bucketmap.begin(),
109 };
110
113 {
114 return const_regions_iterator(m_bucketmap.end(),
116 };
117
118 BucketMap::size_type region_size(Tlabel label) const
119 {
120 const BucketMap::const_iterator region_bucket_it = m_bucketmap.find(label);
121 assert(region_bucket_it != m_bucketmap.end());
122 return region_bucket_it->second.size();
123 };
124
127 {
128 const BucketMap::const_iterator region_bucket_it = m_bucketmap.find(label);
129 assert(region_bucket_it != m_bucketmap.end());
130 return const_point_iterator(region_bucket_it->second.begin(),
132 };
133
136 {
137 const BucketMap::const_iterator region_bucket_it = m_bucketmap.find(label);
138 assert(region_bucket_it != m_bucketmap.end());
139 return const_point_iterator(region_bucket_it->second.end(),
141 };
142
143private:
144 const Tlabel m_background_label;
146 aims::BucketMap<Void> m_bucketmap;
147}; // class LabelVolume
148
149}; // namespace yl
150
151#endif // !defined(YL_LABEL_VOLUME_HH_INCLUDED)
std::map< int, Bucket >::const_iterator const_iterator
std::map< Point3d, T, BucketMapLess > Bucket
BucketMap::Bucket Bucket
const_point_iterator region_end(Tlabel label) const
Iterate through the coordinates of a region's voxels.
const_regions_iterator regions_end() const
Iterate through all region labels.
void discard_region(Tlabel label)
boost::transform_iterator< select1st< Bucket::value_type >, Bucket::const_iterator > const_point_iterator
Iterator through a Bucket's points (yields Point3d)
LabelVolume(const carto::VolumeRef< Tlabel > &vol, Tlabel background=0)
Tlabel background_label() const
virtual ~LabelVolume()
aims::BucketMap< Void > BucketMap
const_point_iterator region_begin(Tlabel label) const
Iterate through the coordinates of a region's voxels.
const_regions_iterator regions_begin() const
Iterate through all region labels.
void merge_regions(Tlabel eating_label, Tlabel eaten_label)
BucketMap::size_type region_size(Tlabel label) const
boost::transform_iterator< select1st< BucketMap::value_type >, BucketMap::const_iterator > const_regions_iterator
const carto::VolumeRef< Tlabel > & volume() const
BucketMap::size_type n_regions() const
Return the first element of a std::pair, like non-standard std::select1st.
const TPair::first_type & operator()(const TPair &pair) const
TPair::first_type & operator()(TPair &pair) const
Definition cortex.hh:41