Commit 61eb0d79 authored by Andrey Filippov's avatar Andrey Filippov

working, contains debug print

parent 8cdf263c
...@@ -1241,8 +1241,8 @@ public class CuasMotion { ...@@ -1241,8 +1241,8 @@ public class CuasMotion {
param_select[CuasMotionLMA.INDX_C] = lma_fit_c; param_select[CuasMotionLMA.INDX_C] = lma_fit_c;
param_select[CuasMotionLMA.INDX_RR0] = lma_fit_r; param_select[CuasMotionLMA.INDX_RR0] = lma_fit_r;
param_select[CuasMotionLMA.INDX_K] = lma_fit_k; param_select[CuasMotionLMA.INDX_K] = lma_fit_k;
final int dbg_tile = -(33 + 34 * 80); //(38 + 45 * 80); final int dbg_tile = (31 + 45 * 80); //(38 + 45 * 80);
final int dbg_seq = -15; final int dbg_seq = 13;
final boolean use_filters = (lmax_flt_hsigma > 0) && (lmax_flt_lsigma > 0) && (lmax_flt_scale > 0); final boolean use_filters = (lmax_flt_hsigma > 0) && (lmax_flt_lsigma > 0) && (lmax_flt_scale > 0);
// final boolean[] fpn_mask= no_border? (new boolean[0]) : null; // final boolean[] fpn_mask= no_border? (new boolean[0]) : null;
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
...@@ -1267,7 +1267,7 @@ public class CuasMotion { ...@@ -1267,7 +1267,7 @@ public class CuasMotion {
for (int ntile = 0; ntile < num_tiles; ntile++) { for (int ntile = 0; ntile < num_tiles; ntile++) {
if (target_sequence[nSeq][ntile] != null) { if (target_sequence[nSeq][ntile] != null) {
double [] target = target_sequence[nSeq][ntile].clone(); double [] target = target_sequence[nSeq][ntile].clone();
if (ntile == dbg_tile) { // if ((nSeq==dbg_seq) && (ntile == dbg_tile)) { if ((nSeq==dbg_seq) && (ntile == dbg_tile)) {
System.out.println("getAccumulatedCoordinates(): nSeq="+nSeq+", ntile="+ntile); System.out.println("getAccumulatedCoordinates(): nSeq="+nSeq+", ntile="+ntile);
} }
int tileX = ntile % tilesX; int tileX = ntile % tilesX;
...@@ -1328,9 +1328,9 @@ public class CuasMotion { ...@@ -1328,9 +1328,9 @@ public class CuasMotion {
if (sky_mask != null) { if (sky_mask != null) {
for (int row = 0; row < tile2; row++) { for (int row = 0; row < tile2; row++) {
int mask_y = Math.min(height-1, Math.max(0, py0 + y_mask_offs)); int mask_y = Math.min(height-1, Math.max(0, py0 + y_mask_offs + row));
for (int col = 0; col < tile2; col++) { for (int col = 0; col < tile2; col++) {
int mask_x = Math.min(width-1, Math.max(0, px0 + x_mask_offs)); int mask_x = Math.min(width-1, Math.max(0, px0 + x_mask_offs + col));
int pindx = col+row*tile2; int pindx = col+row*tile2;
double mask_val = sky_mask[mask_x + mask_y * width]; double mask_val = sky_mask[mask_x + mask_y * width];
pix_tile[pindx] *= mask_val; pix_tile[pindx] *= mask_val;
...@@ -1339,10 +1339,35 @@ public class CuasMotion { ...@@ -1339,10 +1339,35 @@ public class CuasMotion {
} }
} }
} }
if ((nSeq==dbg_seq) && (ntile == dbg_tile)) {
System.out.println("getAccumulatedCoordinates(): nSeq="+nSeq+", ntile="+ntile+
" py0="+py0+" px0="+px0+", y_mask_offs="+y_mask_offs+", x_mask_offs="+x_mask_offs);
for (int row = 0; row < tile2; row++) {
int mask_y = Math.min(height-1, Math.max(0, py0 + y_mask_offs + row));
for (int col = 0; col < tile2; col++) {
int mask_x = Math.min(width-1, Math.max(0, px0 + x_mask_offs + col));
int pindx = col+row*tile2;
double mask_val = sky_mask[mask_x + mask_y * width];
if (col == 0) {
System.out.println("row="+row+", mask_y="+mask_y+"col="+col+", mask_x="+mask_x+", mask_val="+mask_val+", pindx="+pindx);
}
// pix_tile[pindx] *= mask_val;
// if (mask_val < sky_threshold) {
// disabled[pindx] = true; // disallow maximums in this area
// }
}
}
}
} }
// find absolute maximum (after "hacking" and masking // find absolute maximum (after "hacking" and masking
int ntile_amax = TileNeibs.getAmaxTile( int ntile_amax = TileNeibs.getAmaxTile(
pix_tile); //double [] data) pix_tile); //double [] data)
/*
if (lmax_hack_ridge > 0) { if (lmax_hack_ridge > 0) {
Arrays.fill(disabled,false); Arrays.fill(disabled,false);
disabled = new boolean[pix_tile.length]; disabled = new boolean[pix_tile.length];
...@@ -1367,7 +1392,7 @@ public class CuasMotion { ...@@ -1367,7 +1392,7 @@ public class CuasMotion {
} }
} }
} }
*/
// filtering tile for better maximum selection // filtering tile for better maximum selection
if (pix_tile_filtered != null) { if (pix_tile_filtered != null) {
...@@ -1528,6 +1553,28 @@ public class CuasMotion { ...@@ -1528,6 +1553,28 @@ public class CuasMotion {
target[CuasMotionLMA.RSLT_ITERS] = rslt; // will save -1 (failure) also target[CuasMotionLMA.RSLT_ITERS] = rslt; // will save -1 (failure) also
if (rslt >= 0) { if (rslt >= 0) {
cuasMotionLMA.setResult(target); cuasMotionLMA.setResult(target);
int col = GPUTileProcessor.DTT_SIZE + (int) Math.round(target[CuasMotionLMA.RSLT_X]);
int row = GPUTileProcessor.DTT_SIZE + (int) Math.round(target[CuasMotionLMA.RSLT_Y]);
int pindx = col+row*tile2;
/*
if (pindx > 256) {
System.out.println("nSeq="+nSeq+", ntile="+ntile+
", target[CuasMotionLMA.RSLT_X]="+target[CuasMotionLMA.RSLT_X]+
", target[CuasMotionLMA.RSLT_Y]="+target[CuasMotionLMA.RSLT_Y]+
", row="+row+", col="+col);
}
*/
if (!tn.isInside(pindx)) {
target[CuasMotionLMA.RSLT_ITERS] = -2; // outside of the 16x16 tiles -> LMA failed to converge
} else if (disabled[pindx]) {
target[CuasMotionLMA.RSLT_FAIL] = CuasMotionLMA.FAIL_HORIZON;
/*
if (ntile == dbg_tile) { // if ((nSeq==dbg_seq) && (ntile == dbg_tile)) {
System.out.println("getAccumulatedCoordinates(): nSeq="+nSeq+", ntile="+ntile+
", centered="+centered+", pindx="+pindx);
}
*/
}
if (centered && !Double.isNaN(target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_X])) { if (centered && !Double.isNaN(target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_X])) {
double x0 = target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_X]; double x0 = target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_X];
double y0 = target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_Y]; double y0 = target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_Y];
...@@ -1536,6 +1583,26 @@ public class CuasMotion { ...@@ -1536,6 +1583,26 @@ public class CuasMotion {
target[CuasMotionLMA.RSLT_X] += x0; target[CuasMotionLMA.RSLT_X] += x0;
target[CuasMotionLMA.RSLT_Y] += y0; target[CuasMotionLMA.RSLT_Y] += y0;
} }
if ((ntile == dbg_tile) && (nSeq == dbg_seq)) { // if ((nSeq==dbg_seq) && (ntile == dbg_tile)) {
// px0, py0 - top/left corner of 16x16
int ipx = (int) (px0 + GPUTileProcessor.DTT_SIZE + target[CuasMotionLMA.RSLT_X]);
int ipy = (int) (py0 + GPUTileProcessor.DTT_SIZE + target[CuasMotionLMA.RSLT_Y]);
int mask_x = Math.min(width-1, Math.max(0, ipx));
int mask_y = Math.min(height-1, Math.max(0, ipy));
double mask_val = sky_mask[mask_x + mask_y * width];
System.out.println("getAccumulatedCoordinates(): nSeq="+nSeq+", ntile="+ntile+
", centered="+centered+", pindx="+pindx+
", ipx="+ipx+", ipy="+ipy+
", mask_x="+mask_x + ", mask_y="+mask_y+", mask_val = "+mask_val);
System.out.println();
for (int prow = 0; prow < tile2; prow++) {
for (int pcol=0; pcol<tile2; pcol++) {
System.out.print(disabled[pcol+prow*tile2]?".":"+");
}
System.out.println();
}
}
} }
} }
} }
...@@ -1614,23 +1681,47 @@ public class CuasMotion { ...@@ -1614,23 +1681,47 @@ public class CuasMotion {
return filtered_scan; return filtered_scan;
} }
public static void failByStrongerNeighbor(// does not modify "when" public static void findStrongerNeighbor(// does not modify "when"
final double [][][] target_sequence, final double [][][] target_sequence,
final boolean [][] filter5){ final boolean [][] filter5,
final boolean mark_failed,
final int tilesX) {
final int range = 2;
final int num_seq = target_sequence.length; final int num_seq = target_sequence.length;
final int num_tiles = target_sequence[0].length; final int num_tiles = target_sequence[0].length;
final int tilesY = num_tiles/tilesX;
final Thread[] threads = ImageDtt.newThreadArray(); final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
public void run() { public void run() {
TileNeibs tn = new TileNeibs(tilesX, tilesY);
for (int nSeq = ai.getAndIncrement(); nSeq < num_seq; nSeq = ai.getAndIncrement()) { for (int nSeq = ai.getAndIncrement(); nSeq < num_seq; nSeq = ai.getAndIncrement()) {
for (int ntile = 0; ntile < num_tiles; ntile++) if ((target_sequence[nSeq][ntile] != null) && for (int ntile = 0; ntile < num_tiles; ntile++) if ((target_sequence[nSeq][ntile] != null) &&
(target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NONE) && (target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NONE)) { // &&
!filter5[nSeq][ntile]) { if (filter5[nSeq][ntile]) {
target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_FAIL] = CuasMotionLMA.FAIL_NEIGHBOR; target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_STRONGER] = Double.NaN;
} else { // find first stronger tile index
check_nebs: {
for (int dy = -range; dy <= range; dy++) {
for (int dx = -range; dx <= range; dx++) {
int indx = tn.getNeibIndex(ntile, dx, dy);
if ((indx >= 0) && filter5[nSeq][indx]) {
target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_STRONGER] = indx;
break check_nebs;
}
}
}
System.out.println("findStrongerNeighbor(): FIXME: no selected neighbor in 5x5 vicinity, but this is not selected either. nSeq="+
nSeq+", ntile="+ntile);
target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_STRONGER] = -1; // not found
}
if (mark_failed) {
target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_FAIL] = CuasMotionLMA.FAIL_NEIGHBOR;
}
}
} }
} }
} }
...@@ -1639,6 +1730,7 @@ public class CuasMotion { ...@@ -1639,6 +1730,7 @@ public class CuasMotion {
ImageDtt.startAndJoin(threads); ImageDtt.startAndJoin(threads);
} }
/*
public static void clearFailByStrongerNeighbor(// does not modify "when" public static void clearFailByStrongerNeighbor(// does not modify "when"
final double [][][] target_sequence){ final double [][][] target_sequence){
final int num_seq = target_sequence.length; final int num_seq = target_sequence.length;
...@@ -1651,7 +1743,8 @@ public class CuasMotion { ...@@ -1651,7 +1743,8 @@ public class CuasMotion {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
public void run() { public void run() {
for (int nSeq = ai.getAndIncrement(); nSeq < num_seq; nSeq = ai.getAndIncrement()) { for (int nSeq = ai.getAndIncrement(); nSeq < num_seq; nSeq = ai.getAndIncrement()) {
for (int ntile = 0; ntile < num_tiles; ntile++) if ((target_sequence[nSeq][ntile] != null) && (target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NEIGHBOR)) { for (int ntile = 0; ntile < num_tiles; ntile++) if ((target_sequence[nSeq][ntile] != null) &&
(target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NEIGHBOR)) {
target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_FAIL] = CuasMotionLMA.FAIL_NONE; target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_FAIL] = CuasMotionLMA.FAIL_NONE;
} }
} }
...@@ -1660,7 +1753,7 @@ public class CuasMotion { ...@@ -1660,7 +1753,7 @@ public class CuasMotion {
} }
ImageDtt.startAndJoin(threads); ImageDtt.startAndJoin(threads);
} }
*/
public static double [][][] applyFilter( public static double [][][] applyFilter(
...@@ -1700,32 +1793,28 @@ public class CuasMotion { ...@@ -1700,32 +1793,28 @@ public class CuasMotion {
String title, String title,
boolean show, boolean show,
int tilesX) { int tilesX) {
boolean condense = false; // true;
int num_fields = CuasMotionLMA.LMA_TITLES.length; int num_fields = CuasMotionLMA.LMA_TITLES.length;
int num_scenes = target_scene_sequence.length; int num_scenes = target_scene_sequence.length;
int num_tiles = target_scene_sequence[0].length; int num_tiles = target_scene_sequence[0].length;
String [] frame_titles = new String [CuasMotionLMA.LMA_TITLES.length + 1];
for (int i = 0; i < CuasMotionLMA.LMA_TITLES.length; i++) {
frame_titles[i] = CuasMotionLMA.LMA_TITLES[i];
}
frame_titles[CuasMotionLMA.LMA_TITLES.length] = "Targets";
boolean [] has_non_nans = new boolean[num_fields]; boolean [] has_non_nans = new boolean[num_fields];
double [][][] img_data = new double [num_fields][num_scenes][num_tiles]; double [][][] img_data = new double [num_fields+1][num_scenes][num_tiles];
for (int nscene = 0; nscene < num_scenes; nscene++) { for (int nscene = 0; nscene < num_scenes; nscene++) {
for (int nfiled = 0; nfiled < num_fields; nfiled++) { for (int nfield = 0; nfield < img_data.length; nfield++) {
Arrays.fill(img_data[nfiled][nscene], Double.NaN); Arrays.fill(img_data[nfield][nscene], Double.NaN);
} }
for (int ntile=0; ntile<target_scene_sequence[nscene].length; ntile++) { for (int ntile=0; ntile<target_scene_sequence[nscene].length; ntile++) {
if (target_scene_sequence[nscene][ntile] != null) { double [] target = target_scene_sequence[nscene][ntile];
for (int nfield = 0; nfield < img_data.length; nfield++) { if (target != null) {
double v = target_scene_sequence[nscene][ntile][nfield]; for (int nfield = 0; nfield < num_fields; nfield++) {
img_data[nfield][nscene][ntile] = v; img_data[nfield][nscene][ntile] = target[nfield];
if (condense) {
has_non_nans[nfield] |= !Double.isNaN(v);
}
} }
} img_data[num_fields][nscene][ntile] = ((target[CuasMotionLMA.RSLT_FAIL]==CuasMotionLMA.FAIL_NONE) &&
} Double.isNaN(target[CuasMotionLMA.RSLT_STRONGER]))? 1:0;
}
if (condense) {
for (int nfield = 0; nfield < has_non_nans.length; nfield++) {
if (!has_non_nans[nfield]){
img_data[nfield] = null;
} }
} }
} }
...@@ -1734,7 +1823,7 @@ public class CuasMotion { ...@@ -1734,7 +1823,7 @@ public class CuasMotion {
tilesX, // int width, tilesX, // int width,
title, // String title, "time_derivs-rt"+diff_time_rt+"-rxy"+diff_time_rxy, title, // String title, "time_derivs-rt"+diff_time_rt+"-rxy"+diff_time_rxy,
titles, // String [] titles, // all slices*frames titles or just slice titles or null titles, // String [] titles, // all slices*frames titles or just slice titles or null
CuasMotionLMA.LMA_TITLES, // String [] frame_titles, // frame titles or null frame_titles, // CuasMotionLMA.LMA_TITLES, // String [] frame_titles, // frame titles or null
show); // boolean show) show); // boolean show)
return imp; return imp;
} }
...@@ -2227,7 +2316,7 @@ public class CuasMotion { ...@@ -2227,7 +2316,7 @@ public class CuasMotion {
} }
// now will skip tiles that have stronger neighbors
public static double [][][] extendMotionScan( public static double [][][] extendMotionScan(
final double [][][] motion_scan, final double [][][] motion_scan,
final boolean [][] filtered, // centers, should be non-overlapped . May be [motion_scan.length][] - will be calculated and returned final boolean [][] filtered, // centers, should be non-overlapped . May be [motion_scan.length][] - will be calculated and returned
...@@ -2254,7 +2343,9 @@ public class CuasMotion { ...@@ -2254,7 +2343,9 @@ public class CuasMotion {
boolean [] centers = has_filter ? filtered[nSeq] : new boolean [ms.length]; boolean [] centers = has_filter ? filtered[nSeq] : new boolean [ms.length];
if (!has_filter) { if (!has_filter) {
for (int i = 0; i < centers.length; i++) { for (int i = 0; i < centers.length; i++) {
centers[i] = (ms[i] != null) && (Double.isNaN(ms[i][CuasMotionLMA.RSLT_FAIL]) || (ms[i][CuasMotionLMA.RSLT_FAIL]==CuasMotionLMA.FAIL_NONE)); centers[i] = (ms[i] != null) &&
Double.isNaN(ms[i][CuasMotionLMA.RSLT_STRONGER]) && // should not have stronger neighbor
(Double.isNaN(ms[i][CuasMotionLMA.RSLT_FAIL]) || (ms[i][CuasMotionLMA.RSLT_FAIL]==CuasMotionLMA.FAIL_NONE));
} }
} }
if ((filtered != null) && (filtered[nSeq] == null)) { if ((filtered != null) && (filtered[nSeq] == null)) {
...@@ -5129,10 +5220,12 @@ public class CuasMotion { ...@@ -5129,10 +5220,12 @@ public class CuasMotion {
parentCLT.saveImagePlusInModelDirectory(imp_filter5_lma); parentCLT.saveImagePlusInModelDirectory(imp_filter5_lma);
} }
// apply filter5 to targets_good // apply filter5 to targets_good
failByStrongerNeighbor(// does not modify "when" findStrongerNeighbor(// does not modify "when"
target_sequence, // final double [][][] target_sequence, target_sequence, // final double [][][] target_sequence,
filter5); // final boolean [][] filter5) filter5, // final boolean [][] filter5)
false, // final boolean mark_failed,
cuasMotion.tilesX); // final int tilesX) {
// now failed by neighbors are marked as non-NaN (tile index or -1), not as failed
if (intermed_low) { // save final if (intermed_low) { // save final
ImagePlus imp_good = showTargetSequence( ImagePlus imp_good = showTargetSequence(
...@@ -5143,7 +5236,9 @@ public class CuasMotion { ...@@ -5143,7 +5236,9 @@ public class CuasMotion {
cuasMotion.tilesX); // int tilesX) { cuasMotion.tilesX); // int tilesX) {
parentCLT.saveImagePlusInModelDirectory(imp_good); // ImagePlus imp) parentCLT.saveImagePlusInModelDirectory(imp_good); // ImagePlus imp)
} }
// remove singles here // remove singles here - no, just calculate
// Is it needed here?
calculateMismatchBeforeAfter( calculateMismatchBeforeAfter(
target_sequence, // final double [][][] targets, target_sequence, // final double [][][] targets,
true, // false, // final boolean good_only, ???? why it was false true, // false, // final boolean good_only, ???? why it was false
...@@ -5157,7 +5252,7 @@ public class CuasMotion { ...@@ -5157,7 +5252,7 @@ public class CuasMotion {
cuasMotion.tilesX); // int tilesX) { cuasMotion.tilesX); // int tilesX) {
parentCLT.saveImagePlusInModelDirectory(imp_1); parentCLT.saveImagePlusInModelDirectory(imp_1);
} }
return target_sequence; // non-overlap return target_sequence; // non-overlap if consider marked stronger tiles
} }
...@@ -5167,7 +5262,7 @@ public class CuasMotion { ...@@ -5167,7 +5262,7 @@ public class CuasMotion {
final boolean batch_mode, final boolean batch_mode,
QuadCLT parentCLT, // QuadCLT parentCLT, //
final float [][] fpixels, final float [][] fpixels,
double [][][] target_sequence, // double [][][] target_sequence, // non-overlap only if consider marked stronger tiles
CuasMotion cuasMotion, CuasMotion cuasMotion,
UasLogReader uasLogReader, UasLogReader uasLogReader,
String [] scene_titles, // recreate slice_titles from scene titles? String [] scene_titles, // recreate slice_titles from scene titles?
...@@ -5222,6 +5317,29 @@ public class CuasMotion { ...@@ -5222,6 +5317,29 @@ public class CuasMotion {
boolean cuas_gaussian_ra = clt_parameters.imp.cuas_gaussian_ra; // use temporal Gaussian instead of running average boolean cuas_gaussian_ra = clt_parameters.imp.cuas_gaussian_ra; // use temporal Gaussian instead of running average
boolean center_targ = false; // clt_parameters.imp.cuas_center_targ; boolean center_targ = false; // clt_parameters.imp.cuas_center_targ;
// for getEffectiveStrengthLMA(), may be moved out of this method to resolveTargetsConflicts()
double target_strength = clt_parameters.imp.cuas_target_strength;
double [][] target_frac = new double [clt_parameters.imp.cuas_target_frac.length][2];
double lma_rms = clt_parameters.imp.cuas_lma_rms; // = 1.5; // Maximal RMS, regardless of amplitude
double lma_arms = clt_parameters.imp.cuas_lma_arms; // = 0.06; // Maximal absolute RMS, sufficient for any amplitude
double lma_rrms = clt_parameters.imp.cuas_lma_rrms; // = 0.15; // Maximal relative to A rms. OK is when (RMS < cuas_lma_arms) || (RMS < cuas_lma_rrms * A)
double lma_mina = clt_parameters.imp.cuas_lma_mina; // = 1.0; // Minimal A (amplitude)
double lma_maxr = clt_parameters.imp.cuas_lma_maxr; // = 5.0; // Maximal radius (>3.8)
double lma_minr1 = clt_parameters.imp.cuas_lma_minr1; // = 1.0; // Maximal inner radius
double lma_mink = clt_parameters.imp.cuas_lma_mink; // = 0.0; // Minimal K (overshoot) <0.007
double lma_maxk = clt_parameters.imp.cuas_lma_maxk; // = 5.0; // Minimal K (overshoot) > 3.8
double lma_a2a = clt_parameters.imp.cuas_lma_a2a; // = 0.7; // Minimal ratio of the maximal pixel to the amplitude
double target_horizon= clt_parameters.imp.cuas_horizon;
// end of for getEffectiveStrengthLMA(), may be moved out of this method to resolveTargetsConflicts()
// for getScore(), may be moved out of this method to resolveTargetsConflicts()
double min_score_lma = clt_parameters.imp.cuas_score_lma;
double factor_lim = clt_parameters.imp.cuas_factor_lim;
double factor_pow = clt_parameters.imp.cuas_factor_pow;
double [] score_coeff = clt_parameters.imp.cuas_score_coeff.clone();
// end of for getScore(), may be moved out of this method to resolveTargetsConflicts()
int start_frame = 0; int start_frame = 0;
int seq_length = corr_offset + corr_pairs; int seq_length = corr_offset + corr_pairs;
final int frame0 = start_frame + seq_length/2; final int frame0 = start_frame + seq_length/2;
...@@ -5230,6 +5348,7 @@ public class CuasMotion { ...@@ -5230,6 +5348,7 @@ public class CuasMotion {
double interseq_scale = 0.5* corr_inc/corr_offset; // multiply target velocity to get offset in the middle between the key frames double interseq_scale = 0.5* corr_inc/corr_offset; // multiply target velocity to get offset in the middle between the key frames
final int num_corr_samples = target_sequence.length; final int num_corr_samples = target_sequence.length;
int [] filter5_remain = new int [num_corr_samples];
int [] num_all = new int [num_corr_samples]; int [] num_all = new int [num_corr_samples];
int [] num_undef = new int [num_corr_samples]; int [] num_undef = new int [num_corr_samples];
int [] num_good = new int [num_corr_samples]; int [] num_good = new int [num_corr_samples];
...@@ -5293,7 +5412,7 @@ public class CuasMotion { ...@@ -5293,7 +5412,7 @@ public class CuasMotion {
min_seq_fl, // final int min_seq_length_fl,// < min_seq_length minimal sequence length that includes first/last keyframes min_seq_fl, // final int min_seq_length_fl,// < min_seq_length minimal sequence length that includes first/last keyframes
max_mismatch, // final double max_mismatch, // if <=0, do not calculate mismatch_ba and filter max_mismatch, // final double max_mismatch, // if <=0, do not calculate mismatch_ba and filter
cuasMotion.tilesX); // int tilesX) { cuasMotion.tilesX); // int tilesX) {
if (intermed_low) { if (intermed_low) {
ImagePlus imp_no_singles_lma= showTargetSequence( ImagePlus imp_no_singles_lma= showTargetSequence(
target_sequence, // double [][][] target_scene_sequence, target_sequence, // double [][][] target_scene_sequence,
...@@ -5304,11 +5423,116 @@ public class CuasMotion { ...@@ -5304,11 +5423,116 @@ public class CuasMotion {
parentCLT.saveImagePlusInModelDirectory(imp_no_singles_lma); // ImagePlus imp) parentCLT.saveImagePlusInModelDirectory(imp_no_singles_lma); // ImagePlus imp)
if (debugLevel > -4) System.out.println(); if (debugLevel > -4) System.out.println();
} }
// re-calculate score after removing short sequences
calculateMismatchBeforeAfter( // fills fields in the target_sequence tiles
target_sequence, // final double [][][] targets,
true, // final boolean good_only,
cuasMotion.tilesX); // final int tilesX)
getEffectiveStrengthLMA(
target_sequence, // final double [][][] target_coords, // LMA
target_strength, // final double target_strength,
target_frac, // final double [][] target_frac, // pairs - strength, minimal fraction for that strength
lma_rms, // final double lma_rms, // = 1.5; // Maximal RMS (should always match, regardless if A)
lma_arms, // final double lma_arms, // = 0.06; // Maximal absolute RMS (should match one of cuas_lma_arms OR cuas_lma_rrms (0.484)
lma_rrms, // final double lma_rrms, // = 0.15; // Maximal relative to A rms. OK is when (RMS < cuas_lma_arms) || (RMS < cuas_lma_rrms * A)
lma_mina, // final double lma_mina, // = 1.0; // Minimal A (amplitude)
lma_maxr, // final double lma_maxr, // = 5.0; // Minimal K (overshoot) = 3.0
lma_minr1, // final double lma_minr1,// = 1.0; // Minimal R1 (radius of positive peak)
lma_mink, // final double lma_mink, // = 0.0; // Minimal K (overshoot) = 1.0
lma_maxk, // final double lma_maxk, // = 5.0; // Minimal K (overshoot) = 3.0
lma_a2a, // final double lma_a2a,
max_mismatch, // final double max_mismatch,
false, // fail_mismatch, // final boolean fail_mismatch,
target_horizon, // final double lma_horizon, // target below horizon
cuasMotion.tilesX); // final int tilesX,
// int [] remain_es2 =
getScore( // calculates composite sceres
target_sequence, // final double [][][] target_sequence, // modifies certain fields (scores)
factor_lim, // final double importance_limit,
factor_pow, // final double importance_power, // Raise each factor to this power before combining
score_coeff, // final double [] importance, // for now (each - squared?): [0] - Amplitude (A/A0), 1 - RMS (RMS0/RMS), 2 - RRMS((RMS/A0) / (RMS/A)
cuasMotion.tilesX); // final int tilesX,
if (intermed_low) {
ImagePlus imp_final_score = showTargetSequence(
target_sequence, // double [][][] vector_fields_sequence,
slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null
model_prefix+"-FINAL_SCORE",// String title,
!batch_mode, // boolean show,
cuasMotion.tilesX); // int tilesX) {
parentCLT.saveImagePlusInModelDirectory(imp_final_score);
}
// getRemain(target_sequence, num_all, num_undef, num_good, num_bad);
getRemain(target_sequence, null, null, num_good, null);
if (debugLevel > -4) printStats ("After final score", true, null, null, num_good, null);
boolean[][] filter5 = filter5Targets(
target_sequence, // final double [][][] target_sequence,
false, // final boolean use_motion, // true - use motion vectros confidence, false - use target confidence
false, // final boolean select_new, // true - use only untested tiles, false - use good tiles
min_score_lma, // min_mv_strength, // double min_confidence,
target_horizon, // final double lma_horizon, // target below horizon
cuasMotion.tilesX, // final int tilesX,
2, // max_range, // final int range, // 1 or 2
filter5_remain, // final int [] remain){
null, // passes, // final int [] passes, // debugging - number of passes required
debugLevel); // final int debugLevel)
if (debugLevel > -4) printStatsLine("After filter5 remaining non-conflicting targets", true,filter5_remain);
// apply filter5 to targets_good
findStrongerNeighbor(// does not modify "when"
target_sequence, // final double [][][] target_sequence,
filter5, // final boolean [][] filter5)
true, // final boolean mark_failed,
cuasMotion.tilesX); // final int tilesX) {
// now failed by neighbors are marked as non-NaN (tile index or -1), not as failed
getRemain(target_sequence, null, null, num_good, null);
if (debugLevel > -4) printStats ("After removing by neighbors", true, null, null, num_good, null);
if (intermed_low) {
ImagePlus imp_neibs = showTargetSequence(
target_sequence, // double [][][] vector_fields_sequence,
slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null
model_prefix+"-NO_CONFLICTS",// String title,
!batch_mode, // boolean show,
cuasMotion.tilesX); // int tilesX) {
parentCLT.saveImagePlusInModelDirectory(imp_neibs);
}
calculateMismatchBeforeAfter( // fills fields in the target_sequence tiles
target_sequence, // final double [][][] targets,
true, // final boolean good_only,
cuasMotion.tilesX); // final int tilesX)
filterIsolatedTargets( // overwrites "good", does not change "when"
target_sequence, // final double [][][] targets,
min_seq, // final int min_seq_length, // minimal sequence length not including first/last keyframes (may include)
min_seq_fl, // final int min_seq_length_fl,// < min_seq_length minimal sequence length that includes first/last keyframes
max_mismatch, // final double max_mismatch, // if <=0, do not calculate mismatch_ba and filter
cuasMotion.tilesX); // int tilesX) {
if (intermed_low) {
ImagePlus imp_no_singles_lma= showTargetSequence(
target_sequence, // double [][][] target_scene_sequence,
slice_titles, // String [] titles, // all slices*frames titles or just slice titles or null
model_prefix+"-NOSINGLES3", // String title,
!batch_mode, // boolean show,
cuasMotion.tilesX); // int tilesX) {
parentCLT.saveImagePlusInModelDirectory(imp_no_singles_lma); // ImagePlus imp)
if (debugLevel > -4) System.out.println();
}
} }
getRemain(target_sequence, num_all, num_undef, num_good, num_bad); getRemain(target_sequence, num_all, num_undef, num_good, num_bad);
if (debugLevel > -4) printStats ("generateExtractFilterMovingTargets(): after isolated removal", true,num_all, num_undef, num_good, num_bad); if (debugLevel > -4) printStats ("generateExtractFilterMovingTargets(): after isolated removal", true,num_all, num_undef, num_good, num_bad);
// create larger, 5x5 vector field for accumulation -> 3x3 // create larger, 5x5 vector field for accumulation -> 3x3
double [][][] extended_targets = extendMotionScan( double [][][] extended_targets = extendMotionScan(
target_sequence, // final double [][][] motion_scan, target_sequence, // final double [][][] motion_scan,
...@@ -5493,6 +5717,8 @@ public class CuasMotion { ...@@ -5493,6 +5717,8 @@ public class CuasMotion {
final boolean [][] good_tiles = new boolean [num_seq][num_tiles]; final boolean [][] good_tiles = new boolean [num_seq][num_tiles];
final Thread[] threads = ImageDtt.newThreadArray(); final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0); final AtomicInteger ai = new AtomicInteger(0);
final int dbg_tile = 38+46*80;
// final int dbg_seq=14;
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
public void run() { public void run() {
...@@ -5502,21 +5728,28 @@ public class CuasMotion { ...@@ -5502,21 +5728,28 @@ public class CuasMotion {
&& (targets[nSeq][ntile][CuasMotionLMA.RSLT_FAIL]==CuasMotionLMA.FAIL_NONE) && && (targets[nSeq][ntile][CuasMotionLMA.RSLT_FAIL]==CuasMotionLMA.FAIL_NONE) &&
(targets[nSeq][ntile][CuasMotionLMA.RSLT_MISMATCH_DIRS]>0)) { (targets[nSeq][ntile][CuasMotionLMA.RSLT_MISMATCH_DIRS]>0)) {
double [] ba = {targets[nSeq][ntile][CuasMotionLMA.RSLT_MISMATCH_BEFORE],targets[nSeq][ntile][CuasMotionLMA.RSLT_MISMATCH_AFTER]}; double [] ba = {targets[nSeq][ntile][CuasMotionLMA.RSLT_MISMATCH_BEFORE],targets[nSeq][ntile][CuasMotionLMA.RSLT_MISMATCH_AFTER]};
int [] dirs = decodeDirs(targets[nSeq][ntile][CuasMotionLMA.RSLT_MISMATCH_DIRS]); int [] dirs = decodeDirs(targets[nSeq][ntile][CuasMotionLMA.RSLT_MISMATCH_DIRS]);
for (int i = 0; i < ba.length; i++) { for (int i = 0; i < ba.length; i++) {
if ((dirs[i] ==0) || (ba[i] > max_mismatch)) { if ((dirs[i] < 0) || (ba[i] > max_mismatch)) {
ba[i] = Double.NaN; ba[i] = Double.NaN;
} }
} }
boolean has_fl = (nSeq==0) || (nSeq == (num_seq-1)); boolean has_fl = (nSeq==0) || (nSeq == (num_seq-1));
int seq_len = 1; int seq_len = 1;
if (Double.isNaN(ba[0]) && Double.isNaN(ba[1])) { // no connections either way if (Double.isNaN(ba[0]) && Double.isNaN(ba[1])) { // no connections either way
if (ntile== dbg_tile) {
System.out.println("filterIsolatedTargets():1: nSeq="+nSeq+", ntile="+ntile);
}
continue; continue;
} }
int nseq1 = nSeq; int nseq1 = nSeq;
int ntile1 = ntile; int ntile1 = ntile;
check_long_enough: { check_long_enough: {
if ((seq_len >= min_seq_length) || (has_fl && (seq_len >= min_seq_length_fl))) { if ((seq_len >= min_seq_length) || (has_fl && (seq_len >= min_seq_length_fl))) {
if (ntile== dbg_tile) {
System.out.println("filterIsolatedTargets():2: nSeq="+nSeq+", ntile="+ntile);
}
break check_long_enough; break check_long_enough;
} }
// check after // check after
...@@ -5526,25 +5759,31 @@ public class CuasMotion { ...@@ -5526,25 +5759,31 @@ public class CuasMotion {
if ( (targets[nseq1][ntile1] == null) || if ( (targets[nseq1][ntile1] == null) ||
(targets[nseq1][ntile1][CuasMotionLMA.RSLT_FAIL] != CuasMotionLMA.FAIL_NONE) || (targets[nseq1][ntile1][CuasMotionLMA.RSLT_FAIL] != CuasMotionLMA.FAIL_NONE) ||
!(targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_AFTER] <= max_mismatch)) { !(targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_AFTER] <= max_mismatch)) {
/* if (ntile== dbg_tile) { // && (nSeq==dbg_seq)) {
if (targets[nseq1][ntile1] == null) { if (targets[nseq1][ntile1] == null) {
System.out.println("check after: targets["+nseq1+"]["+ntile1+"] == null, nSeq="+nSeq+", ntile="+ntile+", seq_len="+seq_len); System.out.println("check after: nSeq="+nSeq+", ntile="+ntile+
} else if (!(targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_AFTER] <= max_mismatch)){ ", targets["+nseq1+"]["+ntile1+"] == null, nSeq="+nSeq+", ntile="+ntile+", seq_len="+seq_len);
System.out.println("check after: targets["+nseq1+"]["+ntile1+"]["+ } else if (!(targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_AFTER] <= max_mismatch)){
CuasMotionLMA.RSLT_MISMATCH_BEFORE+"] = "+targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_BEFORE]+ System.out.println("check after: nSeq="+nSeq+", ntile="+ntile+
", ...["+CuasMotionLMA.RSLT_MISMATCH_AFTER+"] = "+targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_AFTER]+ ", targets["+nseq1+"]["+ntile1+"]["+
", ...["+CuasMotionLMA.RSLT_MISMATCH_DIRS+"] = "+targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_DIRS]+ CuasMotionLMA.RSLT_MISMATCH_BEFORE+"] = "+targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_BEFORE]+
", seq_len="+seq_len); ", ...["+CuasMotionLMA.RSLT_MISMATCH_AFTER+"] = "+targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_AFTER]+
} else { ", ...["+CuasMotionLMA.RSLT_MISMATCH_DIRS+"] = "+targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_DIRS]+
System.out.println("check after: targets["+nseq1+"]["+ntile1+"] == null, nSeq="+nSeq+", ntile="+ntile+ ", seq_len="+seq_len);
"targets[nseq1][ntile1][CuasMotionLMA.RSLT_FAIL]="+targets[nseq1][ntile1][CuasMotionLMA.RSLT_FAIL]+", seq_len="+seq_len); } else {
System.out.println("check after: nSeq="+nSeq+", ntile="+ntile+
", targets["+nseq1+"]["+ntile1+"] == null, nSeq="+nSeq+", ntile="+ntile+
"targets[nseq1][ntile1][CuasMotionLMA.RSLT_FAIL]="+targets[nseq1][ntile1][CuasMotionLMA.RSLT_FAIL]+", seq_len="+seq_len);
}
} }
*/
break; break;
} }
int dir = decodeDirs(targets[nSeq][ntile][CuasMotionLMA.RSLT_MISMATCH_DIRS])[ba_index]; // direction to the tile in the next/previous keyframe int dir = decodeDirs(targets[nSeq][ntile][CuasMotionLMA.RSLT_MISMATCH_DIRS])[ba_index]; // direction to the tile in the next/previous keyframe
if (ntile== dbg_tile) {
System.out.println("filterIsolatedTargets():3: nSeq="+nSeq+", ntile="+ntile+", dir="+dir+", seq_len="+seq_len);
}
if (dir < 0) { if (dir < 0) {
System.out.println("check after: nseq1="+nseq1+", ntile1="+ntile1+", dir="+dir+ System.out.println("check after: nseq1="+nseq1+", ntile1="+ntile1+", dir="+dir+
", targets[nSeq][ntile][CuasMotionLMA.RSLT_MISMATCH_DIRS]="+ ", targets[nSeq][ntile][CuasMotionLMA.RSLT_MISMATCH_DIRS]="+
...@@ -5568,6 +5807,10 @@ public class CuasMotion { ...@@ -5568,6 +5807,10 @@ public class CuasMotion {
" has_fl="+has_fl+", min_seq_length="+min_seq_length+", min_seq_length_fl="+min_seq_length_fl); " has_fl="+has_fl+", min_seq_length="+min_seq_length+", min_seq_length_fl="+min_seq_length_fl);
break check_long_enough; break check_long_enough;
} }
if (ntile== dbg_tile) {
System.out.println("filterIsolatedTargets():4: nSeq="+nSeq+", ntile="+ntile+", dir="+dir+", seq_len="+seq_len);
}
} }
// check before // check before
nseq1 = nSeq; nseq1 = nSeq;
...@@ -5577,23 +5820,30 @@ public class CuasMotion { ...@@ -5577,23 +5820,30 @@ public class CuasMotion {
if ( (targets[nseq1][ntile1] == null) || if ( (targets[nseq1][ntile1] == null) ||
(targets[nseq1][ntile1][CuasMotionLMA.RSLT_FAIL]!=CuasMotionLMA.FAIL_NONE) || (targets[nseq1][ntile1][CuasMotionLMA.RSLT_FAIL]!=CuasMotionLMA.FAIL_NONE) ||
!(targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_BEFORE] <= max_mismatch)) { !(targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_BEFORE] <= max_mismatch)) {
/* if (ntile== dbg_tile) {
if (targets[nseq1][ntile1] == null) { if (targets[nseq1][ntile1] == null) {
System.out.println("check after: targets["+nseq1+"]["+ntile1+"] == null, nSeq="+nSeq+", ntile="+ntile+", seq_len="+seq_len); System.out.println("check before: nSeq="+nSeq+", ntile="+ntile+
} else if (!(targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_BEFORE] <= max_mismatch)){ ", targets["+nseq1+"]["+ntile1+"] == null, nSeq="+nSeq+", ntile="+ntile+", seq_len="+seq_len);
System.out.println("check before: targets["+nseq1+"]["+ntile1+"]["+ } else if (!(targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_BEFORE] <= max_mismatch)){
CuasMotionLMA.RSLT_MISMATCH_BEFORE+"] = "+targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_BEFORE]+ System.out.println("check before: nSeq="+nSeq+", ntile="+ntile+
", ...["+CuasMotionLMA.RSLT_MISMATCH_AFTER+"] = "+targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_AFTER]+ ", targets["+nseq1+"]["+ntile1+"]["+
", ...["+CuasMotionLMA.RSLT_MISMATCH_DIRS+"] = "+targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_DIRS]+ CuasMotionLMA.RSLT_MISMATCH_BEFORE+"] = "+targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_BEFORE]+
", seq_len="+seq_len); ", ...["+CuasMotionLMA.RSLT_MISMATCH_AFTER+"] = "+targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_AFTER]+
} else { ", ...["+CuasMotionLMA.RSLT_MISMATCH_DIRS+"] = "+targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_DIRS]+
System.out.println("check after: targets["+nseq1+"]["+ntile1+"] == null, nSeq="+nSeq+", ntile="+ntile+ ", seq_len="+seq_len);
"targets[nseq1][ntile1][CuasMotionLMA.RSLT_FAIL]="+targets[nseq1][ntile1][CuasMotionLMA.RSLT_FAIL]+", seq_len="+seq_len); } else {
System.out.println("check before: nSeq="+nSeq+", ntile="+ntile+
", targets["+nseq1+"]["+ntile1+"] == null, nSeq="+nSeq+", ntile="+ntile+
"targets[nseq1][ntile1][CuasMotionLMA.RSLT_FAIL]="+targets[nseq1][ntile1][CuasMotionLMA.RSLT_FAIL]+", seq_len="+seq_len);
}
} }
*/
break; break;
} }
int dir = decodeDirs(targets[nSeq][ntile][CuasMotionLMA.RSLT_MISMATCH_DIRS])[ba_index]; // direction to the tile in the next/previous keyframe int dir = decodeDirs(targets[nSeq][ntile][CuasMotionLMA.RSLT_MISMATCH_DIRS])[ba_index]; // direction to the tile in the next/previous keyframe
if (ntile== dbg_tile) {
System.out.println("filterIsolatedTargets():5: nSeq="+nSeq+", ntile="+ntile+", dir="+dir+", seq_len="+seq_len);
}
if (dir < 0) { if (dir < 0) {
System.out.println("check before: nseq1="+nseq1+", ntile1="+ntile1+", dir="+dir+ System.out.println("check before: nseq1="+nseq1+", ntile1="+ntile1+", dir="+dir+
", targets[nSeq][ntile][CuasMotionLMA.RSLT_MISMATCH_DIRS]="+ ", targets[nSeq][ntile][CuasMotionLMA.RSLT_MISMATCH_DIRS]="+
...@@ -5617,6 +5867,12 @@ public class CuasMotion { ...@@ -5617,6 +5867,12 @@ public class CuasMotion {
" has_fl="+has_fl+", min_seq_length="+min_seq_length+", min_seq_length_fl="+min_seq_length_fl); " has_fl="+has_fl+", min_seq_length="+min_seq_length+", min_seq_length_fl="+min_seq_length_fl);
break check_long_enough; break check_long_enough;
} }
if (ntile== dbg_tile) {
System.out.println("filterIsolatedTargets():6: nSeq="+nSeq+", ntile="+ntile+", dir="+dir+", seq_len="+seq_len);
}
}
if (ntile== dbg_tile) {
System.out.println("filterIsolatedTargets():7: nSeq="+nSeq+", ntile="+ntile+", seq_len="+seq_len);
} }
continue; // not long enough to match requirements - not a good target continue; // not long enough to match requirements - not a good target
} }
...@@ -5626,6 +5882,9 @@ public class CuasMotion { ...@@ -5626,6 +5882,9 @@ public class CuasMotion {
", seq_len="+seq_len+ ", seq_len="+seq_len+
" has_fl="+has_fl+", min_seq_length="+min_seq_length+", min_seq_length_fl="+min_seq_length_fl); " has_fl="+has_fl+", min_seq_length="+min_seq_length+", min_seq_length_fl="+min_seq_length_fl);
*/ */
if (ntile== dbg_tile) {
System.out.println("filterIsolatedTargets():8: nSeq="+nSeq+", ntile="+ntile+", seq_len="+seq_len);
}
good_tiles [nSeq][ntile] = true; good_tiles [nSeq][ntile] = true;
} }
} }
......
...@@ -74,9 +74,10 @@ public class CuasMotionLMA { ...@@ -74,9 +74,10 @@ public class CuasMotionLMA {
public static final int RSLT_QMATCH = 30; public static final int RSLT_QMATCH = 30;
public static final int RSLT_QCENTER = 31; public static final int RSLT_QCENTER = 31;
public static final int RSLT_QSCORE = 32; public static final int RSLT_QSCORE = 32;
public static final int RSLT_STRONGER =33; // index of stronger neighbor (may be more)
public static final int RSLT_WHEN = 33; public static final int RSLT_WHEN = 34;
public static final int RSLT_FAIL = 34; public static final int RSLT_FAIL = 35;
public static final int RSLT_LEN = RSLT_FAIL+1; public static final int RSLT_LEN = RSLT_FAIL+1;
...@@ -88,6 +89,7 @@ public class CuasMotionLMA { ...@@ -88,6 +89,7 @@ public class CuasMotionLMA {
"ERR-BEFORE", "ERR-AFTER", "BA-DIRS", // before dir + 16*after dir "ERR-BEFORE", "ERR-AFTER", "BA-DIRS", // before dir + 16*after dir
"*MOTION-SCORE", "*MOTION-SCORE",
"*Q-AMPL","*Q-RMSE","*Q-RMSE/A","*Q-MATCH","*Q-CENTER","*Q-SCORE", "*Q-AMPL","*Q-RMSE","*Q-RMSE/A","*Q-MATCH","*Q-CENTER","*Q-SCORE",
"Stronger",
"WHEN", "FAILURE"}; "WHEN", "FAILURE"};
public static final int FAIL_NONE = 0; public static final int FAIL_NONE = 0;
......
...@@ -168,7 +168,13 @@ public class TileNeibs{ ...@@ -168,7 +168,13 @@ public class TileNeibs{
if (indx < 0) return false; if (indx < 0) return false;
int y = indx / sizeX; int y = indx / sizeX;
int x = indx % sizeX; int x = indx % sizeX;
return (y >= roi.y) && (x >= roi.x) || (y < roi.y + roi.height) || (x < roi.x + roi.width); return (y >= roi.y) && (x >= roi.x) && (y < roi.y + roi.height) && (x < roi.x + roi.width);
}
public boolean isInside (int indx) {
if (indx < 0) return false;
int y = indx / sizeX;
int x = indx % sizeX;
return (y >= 0) && (x >= 0) && (y < sizeY) && (x < sizeX);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment