Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vol add border interior #371

Merged
merged 6 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
(Roland Denis, [#359](https://github.com/DGtal-team/DGtalTools/pull/359/files))
- Using SourceForge to download doxygen sources during Travis CI jobs.
(Roland Denis [#360](https://github.com/DGtal-team/DGtalTools/pull/360))
- volAddBorder: Add an option that sets zero value to domain boundary voxels without
changing the domain extent(Bertrand Kertautret
[#371](https://github.com/DGtal-team/DGtalTools/pull/371))



# DGtalTools 1.0

Expand Down
41 changes: 31 additions & 10 deletions volumetric/volAddBorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace po = boost::program_options;
@code
-h [ --help ] display this message.
-i [ --input ] arg Input vol file.
-inside Sets zero value to domain boundary voxels without changing the domain extent.
-o [ --output ] arg Output filename.

@endcode
Expand Down Expand Up @@ -102,6 +103,7 @@ int main(int argc, char**argv)
general_opt.add_options()
( "help,h", "display this message." )
( "input,i", po::value<std::string>(), "Input vol file." )
( "inside", "Sets zero value to domain boundary voxels without changing the domain extent." )
( "output,o", po::value<string>(),"Output filename." );
bool parseOK=true;
po::variables_map vm;
Expand All @@ -127,19 +129,38 @@ int main(int argc, char**argv)
std::string filename = vm["input"].as<std::string>();
if ( ! ( vm.count ( "output" ) ) ) missingParam ( "--output" );
std::string outputFileName = vm["output"].as<std::string>();

bool addInside = vm.count("inside");

typedef ImageContainerBySTLVector<Z3i::Domain, unsigned char> MyImageC;

MyImageC imageC = VolReader< MyImageC >::importVol ( filename );
MyImageC outputImage( Z3i::Domain( imageC.domain().lowerBound() - Vector().diagonal(1),
imageC.domain().upperBound() + Vector().diagonal(1)));

MyImageC imageC = VolReader< MyImageC >::importVol ( filename );
Z3i::Domain rDom ( imageC.domain().lowerBound() - Vector().diagonal(addInside ? 0: 1),
imageC.domain().upperBound() + Vector().diagonal(addInside ? 0: 1));
MyImageC outputImage(rDom);
Z3i::Domain iDom ( imageC.domain().lowerBound() + Vector().diagonal( 1),
imageC.domain().upperBound() - Vector().diagonal( 1));

//Fast Copy

for(MyImageC::Domain::ConstIterator it = imageC.domain().begin(),
itend = imageC.domain().end(); it != itend; ++it)
outputImage.setValue( *it , imageC(*it));


bool res = VolWriter< MyImageC>::exportVol(outputFileName, outputImage);
itend = imageC.domain().end(); it != itend; ++it){
if(!addInside){
outputImage.setValue( *it , imageC(*it));
}
else
{
if (!iDom.isInside(*it)){
imageC.setValue( *it , 0);
}
}

}
bool res = true;
if (!addInside) {
res= VolWriter< MyImageC>::exportVol(outputFileName, outputImage);
}
else{
res= VolWriter< MyImageC>::exportVol(outputFileName, imageC);
}
if (res) return 0; else return 1;
}