62{
63
66 using namespace DGtal;
67 using namespace Z2i;
68
71
72
75
76
77 for (
Image::Iterator it = image.begin(), itend = image.end();it != itend; ++it)
78 (*it)=128;
79
80
81 image.setValue(
Point(16,2), 0);
82 image.setValue(
Point(2,11), 0);
83 image.setValue(
Point(30,15), 0);
85
87
91 Display2DFactory::drawImage<Gray>(board, image, (unsigned int)0, (unsigned int)129);
92 board.
saveSVG(
"toric-inputShape.svg");
93
95
97 PointPredicate predicate(image,0);
99
103
104
105 DTL2 dtL2(image.domain(), predicate, l2Metric);
106
107 DTL2Toric dtL2Toric(image.domain(), predicate, l2Metric, {{true, true}} );
109
113
114
115 DTL2ToricX dtL2ToricX( image.domain(), predicate, l2Metric, {{true, false}} );
116
117 DTL2ToricY dtL2ToricY( image.domain(), predicate, l2Metric, {{false, true}} );
119
120
121 const DTL2::Value maxv2 = * (boost::first_max_element(dtL2.constRange().begin(), dtL2.constRange().end()));
122 const DTL2Toric::Value maxvtoric = * (boost::first_max_element(dtL2Toric.constRange().begin(), dtL2Toric.constRange().end()));
123 const DTL2ToricX::Value maxvtoricX = * (boost::first_max_element(dtL2ToricX.constRange().begin(), dtL2ToricX.constRange().end()));
124 const DTL2ToricY::Value maxvtoricY = * (boost::first_max_element(dtL2ToricY.constRange().begin(), dtL2ToricY.constRange().end()));
125
126
127 const auto maxvall = std::max( { maxv2, maxvtoric, maxvtoricX, maxvtoricY } );
128
130
133
136 Display2DFactory::drawImage<HueTwice>(board, dtL2, 0.0, maxvall + 1);
137 board.
saveSVG (
"toric-example-DT-L2.svg" );
138
139 trace.
warning() <<
"Full toric maxValue= " << maxvtoric << endl;
141 Display2DFactory::drawImage<HueTwice>(board, dtL2Toric, 0.0, maxvall + 1);
142 board.
saveSVG (
"toric-example-DT-L2-toric.svg" );
143
144 trace.
warning() <<
"1th dimension periodic maxValue= " << maxvtoricX << endl;
146 Display2DFactory::drawImage<HueTwice>(board, dtL2ToricX, 0.0, maxvall + 1);
147 board.
saveSVG (
"toric-example-DT-L2-toricX.svg" );
148
149 trace.
warning() <<
"2nd dimension periodic maxValue= " << maxvtoricY << endl;
151 Display2DFactory::drawImage<HueTwice>(board, dtL2ToricY, 0.0, maxvall + 1);
152 board.
saveSVG (
"toric-example-DT-L2-toricY.svg" );
153
154
155
157 ticked.addRegularTicks(3, 0.5);
158 ticked.finalize();
159 ticked.colormap()->addColor( Color::Red );
160 ticked.colormap()->addColor( Color::Black );
162 for ( auto it = dtL2.domain().begin(), itend = dtL2.domain().end();it != itend; ++it)
163 {
165 board << *it;
166 }
167 board.
saveSVG(
"toric-example-DT-L2-ticked.svg");
168
170 for ( auto it = dtL2Toric.domain().begin(), itend = dtL2Toric.domain().end();it != itend; ++it)
171 {
173 board << *it;
174 }
175 board.
saveSVG(
"toric-example-DT-L2-ticked-toric.svg");
176
178 for ( auto it = dtL2ToricX.domain().begin(), itend = dtL2ToricX.domain().end();it != itend; ++it)
179 {
181 board << *it;
182 }
183 board.
saveSVG(
"toric-example-DT-L2-ticked-toricX.svg");
184
186 for ( auto it = dtL2ToricY.domain().begin(), itend = dtL2ToricY.domain().end();it != itend; ++it)
187 {
189 board << *it;
190 }
191 board.
saveSVG(
"toric-example-DT-L2-ticked-toricY.svg");
192
193
195 board << dtL2.domain();
196 for ( auto it = dtL2.domain().begin(), itend = dtL2.domain().end();it != itend; ++it)
197 if ( dtL2.getVoronoiSite(*it) != *it )
198 Display2DFactory::draw(board,dtL2.getVoronoiSite(*it) - (*it), (*it));
199 board.
saveSVG(
"toric-example-Voro-L2.svg");
200
202 board << dtL2Toric.domain();
203 for ( auto it = dtL2Toric.domain().begin(), itend = dtL2Toric.domain().end();it != itend; ++it)
204 if ( dtL2Toric.getVoronoiSite(*it) != *it )
205 Display2DFactory::draw(board, dtL2Toric.getVoronoiSite(*it) - (*it), (*it));
206 board.
saveSVG(
"toric-example-Voro-L2-toric.svg");
207
209 board << dtL2Toric.domain();
210 for ( auto it = dtL2Toric.domain().begin(), itend = dtL2Toric.domain().end();it != itend; ++it)
211 if ( dtL2Toric.getVoronoiSite(*it) != *it )
212 Display2DFactory::draw(board, dtL2Toric.projectPoint(dtL2Toric.getVoronoiSite(*it)) - (*it), (*it));
213 board.
saveSVG(
"toric-example-Voro-L2-toric-projected.svg");
214
216 board << dtL2ToricX.domain();
217 for ( auto it = dtL2ToricX.domain().begin(), itend = dtL2ToricX.domain().end();it != itend; ++it)
218 if ( dtL2ToricX.getVoronoiSite(*it) != *it )
219 Display2DFactory::draw(board, dtL2ToricX.getVoronoiSite(*it) - (*it), (*it));
220 board.
saveSVG(
"toric-example-Voro-L2-toricX.svg");
221
223 board << dtL2ToricY.domain();
224 for ( auto it = dtL2ToricY.domain().begin(), itend = dtL2ToricY.domain().end();it != itend; ++it)
225 if ( dtL2ToricY.getVoronoiSite(*it) != *it )
226 Display2DFactory::draw(board, dtL2ToricY.getVoronoiSite(*it) - (*it), (*it));
227 board.
saveSVG(
"toric-example-Voro-L2-toricY.svg");
228
230 return 0;
231}
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Aim: This class template may be used to (linearly) convert scalar values in a given range into gray l...
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
std::vector< Value >::iterator Iterator
Aim: This class adapts any colormap to add "ticks" in the colormap colors.
void beginBlock(const std::string &keyword="")
Aim: Define a simple Foreground predicate thresholding image values given a single thresold....
void clear(const DGtal::Color &color=DGtal::Color::None)
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
DGtal is the top-level namespace which contains all DGtal functions and types.
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
ImageContainerBySTLVector< Domain, Value > Image
HyperRectDomain< Space > Domain