32 #include "DGtal/base/Common.h"
33 #include "DGtal/helpers/StdDefs.h"
36 #include "DGtal/io/readers/PointListReader.h"
37 #include "DGtal/io/writers/GenericWriter.h"
40 #include "DGtal/geometry/curves/FreemanChain.h"
41 #include "DGtal/topology/helpers/Surfaces.h"
42 #include "DGtal/topology/SurfelSetPredicate.h"
51 using namespace DGtal;
106 int main(
int argc,
char** argv )
111 std::string inputFileName;
112 std::string outputFileName=
"result.pgm";
113 unsigned int border {0};
114 std::vector<int> space;
116 app.description(
"Transform one or several freeman chains into an grayscale image file by filling its interior areas.\nThe transformation can fill shapes with hole by using the freemanchain orientation. The interior is considered on the left according to a freeman chain move, i.e. a clockwise oriented contour represents a hole in the shape. Basic example:\n \t freeman2img -i inputChain.fc -o contourDisplay.pgm -b 5");
117 app.add_option(
"-i,--input,1", inputFileName,
"Input freeman chain file name." )
119 ->check(CLI::ExistingFile);
120 app.add_option(
"-b,--border",border,
"add a border in the resulting image (used only in the automatic mode i.e when --space is not used.");
121 app.add_option(
"-o,--output,2", outputFileName,
"the output fileName",
true);
122 app.add_option(
"-s,--space", space,
"Define the space from its bounding box (lower and upper coordinates) else the space is automatically defined from the freemanchain bounding boxes." )
126 app.get_formatter()->column_width(40);
127 CLI11_PARSE(app, argc, argv);
139 int minx=std::numeric_limits<int>::max();
140 int miny=std::numeric_limits<int>::max();
141 int maxx=std::numeric_limits<int>::min();
142 int maxy=std::numeric_limits<int>::min();
146 for(std::vector< FreemanChain >::const_iterator it = vectFcs.begin(); it!= vectFcs.end(); it++){
148 int t_minx=std::numeric_limits<int>::max();
149 int t_miny=std::numeric_limits<int>::max();
150 int t_maxx=std::numeric_limits<int>::min();
151 int t_maxy=std::numeric_limits<int>::min();
153 minx = t_minx > minx? minx: t_minx;
154 miny = t_miny > miny? miny: t_miny;
155 maxx = t_maxx < maxx? maxx: t_maxx;
156 maxy = t_maxy < maxy? maxy: t_maxy;
158 minx-=border; miny-=border; maxx+=border; maxy+=border;
167 std::set<SCell> boundarySCell;
168 std::set<Cell> interiorCell;
169 for(std::vector< FreemanChain >::const_iterator it = vectFcs.begin(); it!= vectFcs.end(); it++){
176 imageResult >> outputFileName;
int main(int argc, char **argv)
void computeBoundingBox(TInteger &min_x, TInteger &min_y, TInteger &max_x, TInteger &max_y) const
static void getInterPixelLinels(const KhalimskySpaceND< 2, TInteger > &aKSpace, const FreemanChain &fc, typename KhalimskySpaceND< 2, TInteger >::SCellSet &aSCellContour, bool aFlagForAppend=false)
bool init(const Point &lower, const Point &upper, bool isClosed)
unsigned static int uFillInterior(const KSpace &aKSpace, const TSurfelPredicate &aSurfPred, TImageContainer &anImage, const typename TImageContainer::Value &aValue, bool empty_is_inside=false, bool incrementMode=true)