Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions ConvertImageND.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,19 @@ ::ProcessCommand(int argc, char *argv[])
else if (cmd == "-connected-components" || cmd == "-connected" || cmd == "-comp")
{
ConnectedComponents<TPixel, VDim> adapter(this);
adapter();
return 0;
bool fullyConnected = false;
int np = 0;
if (argc > 1 && argv[1][0] != '-')
{
switch (atoi(argv[1])) {
case 0: break;
case 1: fullyConnected = true; break;
default: throw ConvertException("Valid value for option -comp [0|1] (fully connected = false|true)");
}
np = 1;
}
adapter(fullyConnected);
return np;
}

else if (cmd == "-clear")
Expand Down
4 changes: 2 additions & 2 deletions adapters/ConnectedComponents.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
template <class TPixel, unsigned int VDim>
void
ConnectedComponents<TPixel, VDim>
::operator() ()
::operator() (bool fullyConnected)
{
// The image is assumed to be binary. If background is non-zero, call binarize
// to map the background to zero
Expand Down Expand Up @@ -61,7 +61,7 @@ ::operator() ()
// Plug in the filter's components
typename CCFilter::Pointer fltConnect = CCFilter::New();
fltConnect->SetInput(image);
fltConnect->SetFullyConnected(false);
fltConnect->SetFullyConnected(fullyConnected);
fltConnect->Update();

// Describe what we are doing
Expand Down
2 changes: 1 addition & 1 deletion adapters/ConnectedComponents.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ConnectedComponents : public ConvertAdapter<TPixel, VDim>

ConnectedComponents(Converter *c) : c(c) {}

void operator() ();
void operator() (bool fullyConnected);

private:
Converter *c;
Expand Down