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

Wrapper for displacement field #111

Merged
merged 27 commits into from
Nov 1, 2019
Merged
Changes from 3 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6647251
WIP: Abstracting away the displacement field to allow composite trans…
simeks Oct 28, 2019
e598ea8
Less template arguments
simeks Oct 29, 2019
ddb8051
Test
simeks Oct 29, 2019
4715584
Nope
simeks Oct 29, 2019
efaf985
Update STK
simeks Oct 29, 2019
b948ad1
WIP: DisplacementField class
simeks Oct 29, 2019
7606857
Update STK
simeks Oct 29, 2019
8bac21c
Update STK
simeks Oct 29, 2019
7017e5c
Transform
simeks Oct 29, 2019
f734b4d
Update STK
simeks Oct 29, 2019
7642e39
WIP: DisplacementField class for GPU
simeks Oct 29, 2019
48e9837
Last details
simeks Oct 30, 2019
3cd3396
DisplacementField class for GPU
simeks Oct 30, 2019
ccd808e
Small fixes to cost function kernel
simeks Oct 30, 2019
c3e3576
Fixes
simeks Oct 30, 2019
cc2ad9f
Initialize displacement field
simeks Oct 30, 2019
ef51c05
Merge branch 'displacement-field' of https://github.com/simeks/deform…
simeks Oct 30, 2019
ea27bcc
Update STK
simeks Oct 30, 2019
b057297
A lot of small fixes
simeks Oct 30, 2019
e908d06
Fixed bug where delta wasn't applied properly
simeks Oct 31, 2019
993298b
Bugfix
simeks Oct 31, 2019
c1504b4
Fix
simeks Oct 31, 2019
fddb4b5
Temporary fix for the update problem
simeks Oct 31, 2019
605090d
Refactored the registration loop to mirror the GPU loop
simeks Nov 1, 2019
55e7f3c
Buffering displacement field for composition
simeks Nov 1, 2019
cbde172
Loop change lowered the precision in tests
simeks Nov 1, 2019
5399032
Merge branch 'displacement-field' of https://github.com/simeks/deform…
simeks Nov 1, 2019
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
76 changes: 26 additions & 50 deletions src/deform_lib/registration/blocked_graph_cut_optimizer.inl
Original file line number Diff line number Diff line change
@@ -118,6 +118,15 @@ void BlockedGraphCutOptimizer<TUnaryTerm, TBinaryTerm, TSolver>
PROFILER_SCOPE("red_black", 0xFF339955);
int num_blocks = real_block_count.x * real_block_count.y * real_block_count.z;

for (int3 n : _neighborhood) {

// delta in [mm]
float3 delta {
step_size.x * n.x,
step_size.y * n.y,
step_size.z * n.z
};

#pragma omp parallel for schedule(dynamic) reduction(+:num_blocks_changed)
for (int block_idx = 0; block_idx < num_blocks; ++block_idx) {
PROFILER_SCOPE("block", 0xFFAA623D);
@@ -136,8 +145,8 @@ void BlockedGraphCutOptimizer<TUnaryTerm, TBinaryTerm, TSolver>
int3 block_p{block_x, block_y, block_z};

bool need_update = change_flags.is_block_set(block_p, use_shift == 1);
for (int3 n : _neighborhood) {
int3 neighbor = block_p + n;
for (int3 n2 : _neighborhood) {
int3 neighbor = block_p + n2;
if (0 <= neighbor.x && neighbor.x < real_block_count.x &&
0 <= neighbor.y && neighbor.y < real_block_count.y &&
0 <= neighbor.z && neighbor.z < real_block_count.z) {
@@ -151,31 +160,27 @@ void BlockedGraphCutOptimizer<TUnaryTerm, TBinaryTerm, TSolver>

bool block_changed = false;

for (int3 n : _neighborhood) {
// delta in [mm]
float3 delta {
step_size.x * n.x,
step_size.y * n.y,
step_size.z * n.z
};

block_changed |= do_block(
unary_fn,
binary_fn,
block_p,
block_dims,
block_offset,
delta,
df,
df_buffer
);
}
block_changed |= do_block(
unary_fn,
binary_fn,
block_p,
block_dims,
block_offset,
delta,
df,
df_buffer
);

if (block_changed)
++num_blocks_changed;

change_flags.set_block(block_p, block_changed, use_shift == 1);
}

if (df.update_rule() == Settings::UpdateRule_Compositive) {
df.copy_from(df_buffer);
}
}
}
}

@@ -356,37 +361,8 @@ bool BlockedGraphCutOptimizer<TUnaryTerm, TBinaryTerm, TSolver>
}
}
}

// Do the actual update of the real displacement field, since we cannot do
// that in the previous loop due to dependenceis
if (df.update_rule() == Settings::UpdateRule_Compositive) {
for (int sub_z = 0; sub_z < block_dims.z; sub_z++) {
for (int sub_y = 0; sub_y < block_dims.y; sub_y++) {
for (int sub_x = 0; sub_x < block_dims.x; sub_x++) {
// Global coordinates
int gx = block_p.x * block_dims.x - block_offset.x + sub_x;
int gy = block_p.y * block_dims.y - block_offset.y + sub_y;
int gz = block_p.z * block_dims.z - block_offset.z + sub_z;

// Skip voxels outside volume
if (gx < 0 || gx >= int(dims.x) ||
gy < 0 || gy >= int(dims.y) ||
gz < 0 || gz >= int(dims.z))
{
continue;
}

int3 p{gx, gy, gz};

df.set(p, df_tmp.get(p));
changed_flag = true;
}
}
}
}
}


return changed_flag;
}