29 #include <DGtal/base/Common.h>
30 #include <DGtal/io/readers/VolReader.h>
31 #include <DGtal/io/writers/VolWriter.h>
32 #include <DGtal/helpers/StdDefs.h>
33 #include <DGtal/images/Image.h>
34 #include <DGtal/images/ImageContainerBySTLVector.h>
40 using namespace DGtal;
112 void missingParam ( std::string param )
114 trace.
error() <<
" Parameter: "<<param<<
" is required..";
119 template<
typename Val,
typename Image,
typename Po
int,
typename Domain>
127 if ( domain.isInside(*it) && image( *it) > v) v=image(*it);
131 template<
typename Val,
typename Image,
typename Po
int,
typename Domain>
139 if ( domain.isInside(*it)&& image( *it) < v) v=image(*it);
143 template<
typename Val,
typename Image,
typename Po
int,
typename Domain>
152 if ( domain.isInside(*it) )
157 return static_cast<unsigned char>( v/nb );
161 int main(
int argc,
char**argv)
167 std::string inputFileName;
168 std::string outputFileName {
"result.vol"};
169 std::string
function {
"mean"};
171 app.description(
"Brutally sub sample a vol file (division by 2 in each direction).\n Basic usage: \n \tvolSubSample <volFileName> <volOutputFileName> ");
174 app.add_option(
"-i,--input,1", inputFileName,
"Input vol file." )
176 ->check(CLI::ExistingFile);
177 app.add_option(
"-o,--output,2", outputFileName,
"Output filename.",
true);
178 app.add_option(
"-f,--function",
function,
"Function used to the down-sampling: {none,max, min, mean}",
true)
179 -> check(CLI::IsMember({
"mean",
"none",
"max",
"min",
"mean"}));
181 app.get_formatter()->column_width(40);
182 CLI11_PARSE(app, argc, argv);
190 MyImageC outputImage(
Z3i::Domain( imageC.domain().lowerBound(),
191 (imageC.domain().upperBound()-imageC.domain().lowerBound())/
Vector().
diagonal(2)));
198 trace.
info()<<
"Function= "<<
function<<std::endl;
199 trace.
info() << outputImage.domain() << std::endl;
201 if (
function ==
"none")
202 for(MyImageC::Domain::ConstIterator it = outputImage.domain().begin(),
203 itend = outputImage.domain().end(); it != itend; ++it)
206 outputImage.setValue( *it , imageC( p ));
209 if (
function ==
"max")
210 for(MyImageC::Domain::ConstIterator it = outputImage.domain().begin(),
211 itend = outputImage.domain().end(); it != itend; ++it)
213 val = maxVal<unsigned char, MyImageC, Point>(imageC, *it, imageC.domain());
214 outputImage.setValue( *it , val );
217 if (
function ==
"min")
218 for(MyImageC::Domain::ConstIterator it = outputImage.domain().begin(),
219 itend = outputImage.domain().end(); it != itend; ++it)
221 val = minVal<unsigned char, MyImageC, Point>(imageC, *it, imageC.domain());
222 outputImage.setValue( *it , val);
226 if (
function ==
"mean")
227 for(MyImageC::Domain::ConstIterator it = outputImage.domain().begin(),
228 itend = outputImage.domain().end(); it != itend; ++it)
230 val = meanVal<unsigned char, MyImageC, Point>(imageC, *it, imageC.domain());
231 outputImage.setValue( *it , val );
242 if (res)
return 0;
else return 1;
int main(int argc, char **argv)
std::vector< Value >::const_iterator ConstIterator
typename Self::Domain Domain
typename Self::Point Point
static Self diagonal(Component val=1)
void beginBlock(const std::string &keyword="")
DGtal::LinearOperator< Calculus, dim, duality, dim, duality > diagonal(const DGtal::KForm< Calculus, dim, duality > &kform)
Trace trace(traceWriterTerm)