@@ -27,8 +27,8 @@ struct Argument {
27
27
unsigned height;
28
28
unsigned moving_step_size;
29
29
unsigned dilation_factor;
30
- bool sampling1 ;
31
- bool sampling2 ;
30
+ bool sampling ;
31
+ bool random_ ;
32
32
bool multiscale;
33
33
unsigned multiscale_depth;
34
34
double multiscale_factor;
@@ -72,13 +72,13 @@ char usage[] =
72
72
" --multiscale-factor <FACTOR>\n "
73
73
" The scaling factor of resizing when computing multiscale SampEn2D.\n\n "
74
74
" Options:\n "
75
- " --sampling1\n "
76
- " Use sampling method (approach 1).\n "
77
- " --sampling2\n "
78
- " Use sampling method (approach 2).\n "
75
+ " --sampling\n "
76
+ " Use sampling method to estimate SampEn2D.\n "
79
77
" --multiscale\n "
80
78
" Compute multiscale SampEn2D.\n "
81
- " --help\n "
79
+ " -r | --random\n "
80
+ " Set seed randomly.\n "
81
+ " -h | --help\n "
82
82
" Display this message.\n " ;
83
83
// clang-format on
84
84
@@ -99,8 +99,7 @@ void ParseArgument(int argc, char *argv[]) {
99
99
arg.image_filename = parser.getArg (" --input" );
100
100
arg.output_level =
101
101
static_cast <sampen::OutputLevel>(parser.getArgLong (" --output-level" , 0 ));
102
- arg.sampling1 = parser.isOption (" --sampling1" );
103
- arg.sampling2 = parser.isOption (" --sampling2" );
102
+ arg.sampling = parser.isOption (" --sampling" );
104
103
arg.multiscale = parser.isOption (" --multiscale" );
105
104
arg.multiscale_depth = parser.getArgLong (" --multiscale-depth" , 1 );
106
105
arg.multiscale_factor = parser.getArgDouble (" --multiscale-factor" , 0.5 );
@@ -113,9 +112,10 @@ void ParseArgument(int argc, char *argv[]) {
113
112
std::cerr << " Usage: " << argv[0 ] << usage;
114
113
exit (-1 );
115
114
}
116
- if (arg.sampling1 || arg. sampling2 ) {
115
+ if (arg.sampling ) {
117
116
arg.sample_size = parser.getArgLong (" --sample-size" , 1024 );
118
117
arg.sample_num = parser.getArgLong (" --sample-num" , 20 );
118
+ arg.random_ = parser.isOption (" --random" ) || parser.isOption (" -r" );
119
119
}
120
120
}
121
121
@@ -149,7 +149,8 @@ std::vector<double> ComputeMultiscaleSampEn2D(Magick::Image image, double r,
149
149
calculator =
150
150
std::make_shared<SampleEntropyCalculator2DSamplingDirect<int >>(
151
151
data.cbegin (), data.cend (), r, m, width, height, 1 , 1 ,
152
- arg.sample_size , arg.sample_num , 0 ., 0 ., 0 ., arg.output_level );
152
+ arg.sample_size , arg.sample_num , 0 ., 0 ., 0 ., arg.random_ ,
153
+ arg.output_level );
153
154
} else {
154
155
calculator = std::make_shared<SampleEntropyCalculator2DDirect<int >>(
155
156
data.cbegin (), data.cend (), r, m, width, height, 1 , 1 ,
@@ -224,11 +225,12 @@ int main(int argc, char *argv[]) {
224
225
double a_norm = sec2dd.get_a_norm ();
225
226
double b_norm = sec2dd.get_b_norm ();
226
227
227
- if (arg.sampling1 ) {
228
+ if (arg.sampling ) {
228
229
sampen::SampleEntropyCalculator2DSamplingDirect<int > sec2dds (
229
230
data.cbegin (), data.cend (), arg.r , arg.m , arg.width , arg.height ,
230
231
arg.moving_step_size , arg.dilation_factor , arg.sample_size ,
231
- arg.sample_num , sampen2d, a_norm, b_norm, arg.output_level );
232
+ arg.sample_num , sampen2d, a_norm, b_norm, arg.random_ ,
233
+ arg.output_level );
232
234
std::cout << sec2dds.get_result_str ();
233
235
}
234
236
if (arg.multiscale ) {
0 commit comments