Skip to content

Commit

Permalink
~1.3 sec pipeline (excluding io)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Brooks committed Dec 13, 2016
1 parent 99ead6e commit a829055
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 209 deletions.
39 changes: 17 additions & 22 deletions src/align.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ Func align(const Image<uint16_t> imgs) {

Var tx, ty, n;

// mirror input image with overlapping edges
// mirror input with overlapping edges

Func imgs_mirror = BoundaryConditions::mirror_interior(imgs);
Func imgs_mirror = BoundaryConditions::mirror_interior(imgs, 0, imgs.width(), 0, imgs.height());

// downsampled layers for alignment

Expand All @@ -85,42 +85,37 @@ Func align(const Image<uint16_t> imgs) {

// min and max search regions

Point search = P(4, 4);
Point min_search = P(-4, -4);
Point max_search = P(3, 3);

Point min_2 = -search;
Point min_1 = 4 * min_2 - search;
Point min_0 = 4 * min_1 - search;
Point min_3 = P(0, 0);
Point min_2 = 4 * min_3 + min_search;
Point min_1 = 4 * min_2 + min_search;

Point max_2 = search;
Point max_1 = 4 * max_2 + search;
Point max_0 = 4 * max_1 + search;
Point max_3 = P(0, 0);
Point max_2 = 4 * max_3 + max_search;
Point max_1 = 4 * max_2 + max_search;

// initial alignment of previous layer is 0, 0

alignment_3(tx, ty, n) = P(0, 0);

// hierarchal alignment functions

Func alignment_2 = align_layer(layer_2, alignment_3, min_2, max_2);
Func alignment_1 = align_layer(layer_1, alignment_2, min_1, max_1);
Func alignment_0 = align_layer(layer_0, alignment_1, min_0, max_0);
Func alignment_2 = align_layer(layer_2, alignment_3, min_3, max_3);
Func alignment_1 = align_layer(layer_1, alignment_2, min_2, max_2);
Func alignment_0 = align_layer(layer_0, alignment_1, min_1, max_1);

// number of tiles in the x and y dimensions

int num_tx = imgs.width() / T_SIZE_2 - 1;
int num_ty = imgs.height() / T_SIZE_2 - 1;

// final alignment offsets for the original mosaic image
// final alignment offsets for the original mosaic image; tiles outside of the bounds use the nearest alignment offset

alignment(tx, ty, n) = 2 * P(alignment_0(clamp(tx, 0, num_tx), clamp(ty, 0, num_ty), n));
alignment(tx, ty, n) = 2 * P(alignment_0(tx, ty, n));

///////////////////////////////////////////////////////////////////////////
// schedule
///////////////////////////////////////////////////////////////////////////

alignment_3.compute_root().parallel(ty).vectorize(tx, 16);

alignment.compute_root().parallel(ty).vectorize(tx, 16);
Func alignment_repeat = BoundaryConditions::repeat_edge(alignment, 0, num_tx, 0, num_ty);

return alignment;
return alignment_repeat;
}
3 changes: 3 additions & 0 deletions src/align.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#define T_SIZE 32
#define T_SIZE_2 16

#define MIN_OFFSET -168
#define MAX_OFFSET 126

#include "Halide.h"

/*
Expand Down
Loading

0 comments on commit a829055

Please sign in to comment.