3Copyright Université Paris XI (2014).
5Contributor: Yann Leprince <yann.leprince@ylep.fr>.
7This file is part of highres-cortex, a collection of software designed
8to process high-resolution magnetic resonance images of the cerebral
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/>.
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
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.
34The fact that you are presently reading this means that you have had
35knowledge of the CeCILL licence and that you accept its terms.
41template <typename Tlabel>
43LabelVolume(const carto::VolumeRef<Tlabel> &vol,
45 : m_background_label(background), m_volume(vol), m_bucketmap()
47 const int size_x = m_volume.getSizeX();
48 const int size_y = m_volume.getSizeY();
49 const int size_z = m_volume.getSizeZ();
51 for(int z = 0; z < size_z; ++z)
52 for(int y = 0; y < size_y; ++y)
53 for(int x = 0; x < size_x; ++x)
55 const Tlabel label = m_volume.at(x, y, z);
56 if(label != background) {
57 m_bucketmap[label].insert(Bucket::value_type(Point3d(x, y, z), Void()));
62template <typename Tlabel>
63void LabelVolume<Tlabel>::
64merge_regions(Tlabel eating_label, Tlabel eaten_label)
66 const BucketMap::iterator eating_bucket_it = m_bucketmap.find(eating_label);
67 BucketMap::iterator eaten_bucket_it = m_bucketmap.find(eaten_label);
69 assert(eating_bucket_it != m_bucketmap.end());
70 assert(eaten_bucket_it != m_bucketmap.end());
72 Bucket & eating_bucket = eating_bucket_it->second;
73 Bucket & eaten_bucket = eaten_bucket_it->second;
76 point_it = eaten_bucket.begin(),
77 point_it_end = eaten_bucket.end();
78 point_it != point_it_end;
80 const Point3d & point = point_it->first;
81 const int & x = point[0];
82 const int & y = point[1];
83 const int & z = point[2];
84 m_volume.at(x, y, z) = eating_label;
85 eating_bucket.insert(*point_it);
88 m_bucketmap.erase(eaten_bucket_it);
91template <typename Tlabel>
92void LabelVolume<Tlabel>::
93discard_region(Tlabel label)
95 BucketMap::iterator bucket_it = m_bucketmap.find(label);
96 assert(bucket_it != m_bucketmap.end());
98 Bucket & bucket = bucket_it->second;
101 point_it = bucket.begin(),
102 point_it_end = bucket.end();
103 point_it != point_it_end;
105 const Point3d & point = point_it->first;
106 const int & x = point[0];
107 const int & y = point[1];
108 const int & z = point[2];
109 m_volume.at(x, y, z) = m_background_label;
112 m_bucketmap.erase(bucket_it);