Skip to content

Commit

Permalink
Merge pull request #254 from kerautret/volCComponentCounterFix
Browse files Browse the repository at this point in the history
fix bug reading option in volCComponentCounter
  • Loading branch information
kerautret committed Mar 21, 2016
2 parents 41196dd + 8a405d4 commit f58d126
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 54 deletions.
9 changes: 7 additions & 2 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# DGtalTools 0.9.2
# DGtalTools 0.9.2

- *global*:
- fix uses of temporaries when ConstAlias is needed.
(Roland Denis, [#253](https://github.com/DGtal-team/DGtalTools/pull/253))

# DGtalTools 0.9.1
- *volumetric*:
- fix reading options bug in volCComponentCounter and sdp2vol.
(Bertrand Kerautret,
[#254](https://github.com/DGtal-team/DGtalTools/pull/254)

# DGtalTools 0.9.1

- *converters*:
- img2freeman: new option to sort the resulting contours by increasing size
Expand Down
6 changes: 3 additions & 3 deletions converters/sdp2vol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ int main( int argc, char** argv )
if( !parseOK || vm.count("help"))
{
std::cout << "Usage: " << argv[0] << " [input-file] [output]\n"
<< "Convert volumetric file into a digital set of points from a given threshold."
<< "Convert digital set of points into a volumic file."
<< general_opt << "\n";
std::cout << "Example:\n"
<< "vol2sdp -i ${DGtal}/examples/samples/lobster.vol -o volumeList.p3d \n";
<< "sdp2vol -i volumePoints.sdp -o volume.vol -d 0 0 0 10 10 10 \n";
return 0;
}
if(! vm.count("sdp") ||! vm.count("output") || !vm.count("domain") )
if(! vm.count("input") ||! vm.count("output") || !vm.count("domain") )
{
trace.error() << " Input/ output filename and domain are needed to be defined" << endl;
return 0;
Expand Down
98 changes: 49 additions & 49 deletions volumetric/volCComponentCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,44 +71,44 @@ void CCCounter(Rank& r, Parent& p, const Image& elements, const unsigned int con
e !=elements.domain().end(); ++e)
{
if ( elements.domain().isInside(*e+decx) &&
(elements(*e) == elements(*e+decx)))
dsets.union_set(*e,*e+decx);
(elements(*e) == elements(*e+decx)))
dsets.union_set(*e,*e+decx);

if ( elements.domain().isInside(*e+decy) &&
(elements(*e) == elements(*e+decy)))
dsets.union_set(*e,*e+decy);
(elements(*e) == elements(*e+decy)))
dsets.union_set(*e,*e+decy);

if ( elements.domain().isInside(*e+decz) &&
(elements(*e) == elements(*e+decz)))
dsets.union_set(*e,*e+decz);
(elements(*e) == elements(*e+decz)))
dsets.union_set(*e,*e+decz);

if (connectivity > 6)
{
if ( elements.domain().isInside(*e+decx+decy) &&
(elements(*e) == elements(*e+decx+decy)))
dsets.union_set(*e,*e+decx+decy);
{
if ( elements.domain().isInside(*e+decx+decy) &&
(elements(*e) == elements(*e+decx+decy)))
dsets.union_set(*e,*e+decx+decy);

if ( elements.domain().isInside(*e+decx+decz) &&
(elements(*e) == elements(*e+decx+decz)))
dsets.union_set(*e,*e+decx+decz);
if ( elements.domain().isInside(*e+decx+decz) &&
(elements(*e) == elements(*e+decx+decz)))
dsets.union_set(*e,*e+decx+decz);

if ( elements.domain().isInside(*e+decy+decz) &&
(elements(*e) == elements(*e+decy+decz)))
dsets.union_set(*e,*e+decy+decz);
if ( elements.domain().isInside(*e+decy+decz) &&
(elements(*e) == elements(*e+decy+decz)))
dsets.union_set(*e,*e+decy+decz);

if (connectivity == 26)
if ( elements.domain().isInside(*e+decy+decz+decx) &&
(elements(*e) == elements(*e+decy+decz+decx)))
dsets.union_set(*e,*e+decy+decz+decx);
if (connectivity == 26)
if ( elements.domain().isInside(*e+decy+decz+decx) &&
(elements(*e) == elements(*e+decy+decz+decx)))
dsets.union_set(*e,*e+decy+decz+decx);

}
}

}
trace.endBlock();
std::cout << "Number of disjoint "<<connectivity<<"-components = "
<<dsets.count_sets(elements.domain().begin(),
elements.domain().end())
<< std::endl;
<<dsets.count_sets(elements.domain().begin(),
elements.domain().end())
<< std::endl;
}


Expand All @@ -130,38 +130,38 @@ int main( int argc, char** argv )
trace.info()<< "Error checking program options: "<< ex.what()<< endl;
}
po::notify(vm);
if( parseOK || !vm.count("help")||argc<=1)
if( !parseOK || vm.count("help")||argc<=1)
{
std::cout << "Usage: " << argv[0] << " [input]\n"
<< "Count the number of connected component (same values) in a volume (Vol) file image\n"
<< general_opt << "\n";
<< "Count the number of connected component (same values) in a volume (Vol) file image\n"
<< general_opt << "\n";
return 0;
}
string inputFilename = vm["input"].as<std::string>();
unsigned int connectivity = vm["connectivity"].as<unsigned int>();
string inputFilename = vm["input"].as<std::string>();
unsigned int connectivity = vm["connectivity"].as<unsigned int>();

if ((connectivity != 6) && (connectivity != 18) && (connectivity != 26))
{
trace.error() << "Bard connectivity value.";
trace.info() << std::endl;
exit(1);
}

typedef ImageSelector<Domain, unsigned char>::Type Image;
Image image = VolReader<Image>::importVol( inputFilename );

trace.info() << "Image loaded: "<<image<< std::endl;

typedef std::map<Point,std::size_t> rank_t; // => order on Element
typedef std::map<Point,Point> parent_t;
rank_t rank_map;
parent_t parent_map;
if ((connectivity != 6) && (connectivity != 18) && (connectivity != 26))
{
trace.error() << "Bad connectivity value.";
trace.info() << std::endl;
exit(1);
}

typedef ImageSelector<Domain, unsigned char>::Type Image;
Image image = VolReader<Image>::importVol( inputFilename );

trace.info() << "Image loaded: "<<image<< std::endl;

typedef std::map<Point,std::size_t> rank_t; // => order on Element
typedef std::map<Point,Point> parent_t;
rank_t rank_map;
parent_t parent_map;

boost::associative_property_map<rank_t> rank_pmap(rank_map);
boost::associative_property_map<parent_t> parent_pmap(parent_map);
boost::associative_property_map<rank_t> rank_pmap(rank_map);
boost::associative_property_map<parent_t> parent_pmap(parent_map);

CCCounter(rank_pmap, parent_pmap, image, connectivity);
CCCounter(rank_pmap, parent_pmap, image, connectivity);


return 0;
return 0;
}

0 comments on commit f58d126

Please sign in to comment.