Skip to content

Commit fd75673

Browse files
committed
sh2peaks: further cleanup
1 parent 700d30d commit fd75673

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

cmd/sh2peaks.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ class Item { MEMALIGN(Item)
122122
class DataLoader { MEMALIGN(DataLoader)
123123
public:
124124
DataLoader (Image<value_type>& sh_data,
125-
Image<bool>* mask_data) :
125+
const Image<bool>& mask_data) :
126126
sh (sh_data),
127+
mask (mask_data),
127128
loop (Loop("estimating peak directions", 0, 3) (sh)) { }
128129

129130
bool operator() (Item& item) {
@@ -133,9 +134,9 @@ class DataLoader { MEMALIGN(DataLoader)
133134
item.pos[1] = sh.index(1);
134135
item.pos[2] = sh.index(2);
135136

136-
if (mask) {
137-
assign_pos_of(sh).to(*mask);
138-
if (!mask->value()) {
137+
if (mask.valid()) {
138+
assign_pos_of(sh).to(mask);
139+
if (!mask.value()) {
139140
for (auto l = Loop(3) (sh); l; ++l)
140141
item.data[sh.index(3)] = NaN;
141142
}
@@ -154,7 +155,7 @@ class DataLoader { MEMALIGN(DataLoader)
154155

155156
private:
156157
Image<value_type> sh;
157-
std::unique_ptr<Image<bool> > mask;
158+
Image<bool> mask;
158159
LoopAlongAxisRangeProgress::Run<Image<value_type> > loop;
159160
};
160161

@@ -308,9 +309,9 @@ void run ()
308309

309310
auto opt = get_options ("mask");
310311

311-
std::unique_ptr<Image<bool> > mask_data;
312+
Image<bool> mask_data;
312313
if (opt.size())
313-
mask_data.reset (new Image<bool>(Image<bool>::open (opt[0][0])));
314+
mask_data = Image<bool>::open (opt[0][0]);
314315

315316
opt = get_options ("seeds");
316317
Eigen::Matrix<value_type, Eigen::Dynamic, 2> dirs;
@@ -344,15 +345,15 @@ void run ()
344345
if (true_peaks.size())
345346
throw Exception ("you can't specify both a peaks file and orientations to be estimated at the same time");
346347
if (opt.size())
347-
ipeaks_data = Image<value_type> (Image<value_type>::open(opt[0][0]));
348+
ipeaks_data = Image<value_type>::open(opt[0][0]);
348349

349350
check_dimensions (SH_data, ipeaks_data, 0, 3);
350351
npeaks = ipeaks_data.size (3) / 3;
351352
}
352353
header.size(3) = 3 * npeaks;
353354
auto peaks = Image<value_type>::create (argument[1], header);
354355

355-
DataLoader loader (SH_data, mask_data.get());
356+
DataLoader loader (SH_data, mask_data);
356357
Processor processor (peaks, dirs, Math::SH::LforN (SH_data.size (3)),
357358
npeaks, true_peaks, threshold, ipeaks_data, get_options("fast").size());
358359

0 commit comments

Comments
 (0)