DGtal 1.3.0
Loading...
Searching...
No Matches
Functions
exampleConstImageAdapter.cpp File Reference

An example file for ConstImageAdapter. More...

#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "ConfigExamples.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/io/colormaps/HueShadeColorMap.h"
#include "DGtal/io/colormaps/GrayscaleColorMap.h"
#include "DGtal/images/ImageContainerBySTLVector.h"
#include "DGtal/images/ConstImageAdapter.h"

Go to the source code of this file.

Functions

int main ()
 [LogScaleFunctor] More...
 

Detailed Description

An example file for ConstImageAdapter.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Martial Tola (marti.nosp@m.al.t.nosp@m.ola@l.nosp@m.iris.nosp@m..cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2012/12/4

This file is part of the DGtal library.

Definition in file exampleConstImageAdapter.cpp.

Function Documentation

◆ main()

int main ( void  )

[LogScaleFunctor]

[def]

[def]

[image_creation]

[image_creation]

[image_filling]

[image_filling]

[ConstImageAdapterForSubImage_creation]

[ConstImageAdapterForSubImage_creation]

[specificDomain_creation]

[specificDomain_creation]

[ConstImageAdapterForSpecificImage_creation]

[ConstImageAdapterForSpecificImage_creation]

[ConstImageAdapterForThresholderImage_creation]

[ConstImageAdapterForThresholderImage_creation]

[ConstImageAdapterForLogScale_creation]

[ConstImageAdapterForLogScale_creation]

Definition at line 76 of file exampleConstImageAdapter.cpp.

77{
78 using namespace Z2i;
79
80 Board2D aBoard;
81
83 typedef HueShadeColorMap<unsigned char> HueShade; // a simple HueShadeColorMap varying on 'unsigned char' values
84 typedef HueShadeColorMap<double> HueShadeDouble; // a simple HueShadeColorMap varying on 'double' values
85 typedef GrayscaleColorMap<unsigned char> Gray; // a simple GrayscaleColorMap varying on 'unsigned char' values
86
87 functors::Identity df; // a simple functor that just returns its argument
89
90 trace.beginBlock("image");
91
94 Domain domain(Point(1,1), Point(16,16));
95 Image image(domain);
97
99 unsigned char i = 0;
100 for (Image::Iterator it = image.begin(); it != image.end(); ++it)
101 *it = i++;
103
104 aBoard.clear();
105 Display2DFactory::drawImage<HueShade>(aBoard, image, (unsigned char)0, (unsigned char)255);
106 aBoard.saveSVG("image.svg");
107
108 trace.endBlock();
109
110 trace.beginBlock("subImage");
111
114 Domain subDomain(Point(1,1), Point(8,8));
115 ConstImageAdapterForSubImage subImage(image, subDomain, df, df);
117
118 aBoard.clear();
119 Display2DFactory::drawImage<HueShade>(aBoard, subImage, (unsigned char)0, (unsigned char)255);
120 aBoard.saveSVG("subImage.svg");
121
122 trace.endBlock();
123
124 trace.beginBlock("specificImage");
125
127 DigitalSet set(domain);
128 for( unsigned int y=0; y < 17; y++)
129 for( unsigned int x=0; x < 17; x++)
130 if ((x%2) && (y%2))
131 set.insertNew(Point(x,y));
132
133 DigitalSetDomain<DigitalSet> specificDomain(set);
135
138 ConstImageAdapterForSpecificImage specificImage(image, specificDomain, df, df);
140
141 aBoard.clear();
142 Display2DFactory::drawImage<HueShade>(aBoard, specificImage, (unsigned char)0, (unsigned char)255);
143 aBoard.saveSVG("specificImage.svg");
144
145 trace.endBlock();
146
147 trace.beginBlock("thresholderImage");
148
152 ConstImageAdapterForThresholderImage thresholderImage(image, domain, df, t);
154
155 aBoard.clear();
156 Display2DFactory::drawImage<Gray>(aBoard, thresholderImage, (unsigned char)0, (unsigned char)1);
157 aBoard.saveSVG("thresholderImage.svg");
158
159 trace.endBlock();
160
161 trace.beginBlock("logImage");
162
165 LogScaleFunctor<Image::Value> logScale;
166 ConstImageAdapterForLogScale logImage(image, domain, df, logScale);
168
169 aBoard.clear();
170 Display2DFactory::drawImage<HueShadeDouble>(aBoard, logImage, 0.0, logScale(255));
171 aBoard.saveSVG("logImage.svg");
172
173 trace.endBlock();
174
175 return 0;
176}
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: Constructs a domain limited to the given digital set.
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...
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:70
void beginBlock(const std::string &keyword="")
double endBlock()
Aim: A small functor with an operator () that compares one value to a threshold value according to tw...
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:152
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
Trace trace
Definition: Common.h:154
Aim: Define a simple default functor that just returns its argument.
MyPointD Point
Definition: testClone2.cpp:383
Domain domain

References DGtal::Trace::beginBlock(), LibBoard::Board::clear(), domain, DGtal::Trace::endBlock(), DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::insertNew(), LibBoard::Board::saveSVG(), and DGtal::trace.