Commit 5df977ab authored by Andrey Filippov's avatar Andrey Filippov

CLAUDE: CUAS cleanup pt2 — scrub dead 3d3/MF leftover symbols

Dead after the 3d3/matched-filter removal (predecessor at tag cuas-layer1):
render3d3Hyperstack, get3d3Radius + the 3d3 kernel state (kernel3d3_rad, indx_*_3d3)
with its constructor param/setup/call-site; TemporalKernelGenerator.generateKernelMatched/Direct;
CuasDetectRT SUFFIX_CONV3D3, CONV3D3_MODES, bilinearFrame. No live callers; build OK.
Co-authored-by: 's avatarClaude Opus 4.8 (1M context) <noreply@anthropic.com>
parent 4abf02b0
...@@ -22,14 +22,14 @@ public class CuasDetectRT { ...@@ -22,14 +22,14 @@ public class CuasDetectRT {
public static final String SUFFIX_SYNTH_TIFF = "-CUAS-SYNTHETIC-CUAS.tiff"; // synthetic input (curt_synth_src) // By Claude on 06/11/2026 public static final String SUFFIX_SYNTH_TIFF = "-CUAS-SYNTHETIC-CUAS.tiff"; // synthetic input (curt_synth_src) // By Claude on 06/11/2026
public static final String SUFFIX_LOG = "-LoG"; public static final String SUFFIX_LOG = "-LoG";
public static final String SUFFIX_CONV2D = "-CONV2D"; public static final String SUFFIX_CONV2D = "-CONV2D";
public static final String SUFFIX_CONV3D3 = "-CONV3D3"; // SUFFIX_CONV3D3 removed 2026-06-20 (dead after 3d3/MF cleanup); see tag cuas-layer1. // By Claude
public static final String SUFFIX_CONV5D = "-CONV5D"; public static final String SUFFIX_CONV5D = "-CONV5D";
public static final String SUFFIX_RECUR = "-RECUR"; // By Claude on 06/09/2026 public static final String SUFFIX_RECUR = "-RECUR"; // By Claude on 06/09/2026
// ROI override for synthetic input: covers the radial 11x11 target block of // By Claude on 06/11/2026 // ROI override for synthetic input: covers the radial 11x11 target block of // By Claude on 06/11/2026
// gen_synth_cuas.py (center (320.5,256.5), step 30 -> +/-150 px) + kernel // gen_synth_cuas.py (center (320.5,256.5), step 30 -> +/-150 px) + kernel
// margin, so the stored curt_save_select parameter keeps matching the REAL image. // margin, so the stored curt_save_select parameter keeps matching the REAL image.
public static final Rectangle SYNTH_ROI = new Rectangle(160, 96, 320, 320); // By Claude on 06/11/2026 public static final Rectangle SYNTH_ROI = new Rectangle(160, 96, 320, 320); // By Claude on 06/11/2026
public static final String [] CONV3D3_MODES = {"plain", "winner", "power"}; // CONV3D3_MODES removed 2026-06-20 (dead after 3d3/MF cleanup); see tag cuas-layer1. // By Claude
public static final int CONV3D3_MODE_PLAIN = 0; public static final int CONV3D3_MODE_PLAIN = 0;
public static final int CONV3D3_MODE_WINNER = 1; public static final int CONV3D3_MODE_WINNER = 1;
public static final int CONV3D3_MODE_POWER = 2; public static final int CONV3D3_MODE_POWER = 2;
...@@ -301,14 +301,7 @@ public class CuasDetectRT { ...@@ -301,14 +301,7 @@ public class CuasDetectRT {
// grid distribution-vote method (voteScatterGrid) removed 2026-06-20; predecessor code at git tag cuas-layer1. // By Claude on 06/20/2026 // grid distribution-vote method (voteScatterGrid) removed 2026-06-20; predecessor code at git tag cuas-layer1. // By Claude on 06/20/2026
/** Bilinear sample of a full-frame float buffer at (x,y); 0 outside (off-frame = absent). By Claude on 06/19/2026 */ // bilinearFrame removed 2026-06-20 (dead after 3d3/MF cleanup); see tag cuas-layer1. // By Claude
static double bilinearFrame(float[] f, int w, int h, double x, double y) {
int x0 = (int) Math.floor(x), y0 = (int) Math.floor(y);
if (x0 < 0 || x0 >= w - 1 || y0 < 0 || y0 >= h - 1) return 0.0;
double fx = x - x0, fy = y - y0;
return (1 - fy) * ((1 - fx) * f[y0 * w + x0] + fx * f[y0 * w + x0 + 1])
+ fy * ((1 - fx) * f[(y0 + 1) * w + x0] + fx * f[(y0 + 1) * w + x0 + 1]);
}
/** Head (T0) map straight from the CLEAN vote accumulator - the inverse of the vote scatter, but /** Head (T0) map straight from the CLEAN vote accumulator - the inverse of the vote scatter, but
* driven by the accumulated (robust) consensus velocity, not the soft per-pixel refine. Each tail * driven by the accumulated (robust) consensus velocity, not the soft per-pixel refine. Each tail
...@@ -718,12 +711,10 @@ public class CuasDetectRT { ...@@ -718,12 +711,10 @@ public class CuasDetectRT {
} }
// Initialize LoG and other kernel parameters, calculate LoG first, show results // Initialize LoG and other kernel parameters, calculate LoG first, show results
int kernel3d3_rad = 1; // kernel3d3_rad local + arg removed 2026-06-20 (dead after 3d3/MF cleanup); see tag cuas-layer1. // By Claude
CuasRTUtils cuasRTUtils = new CuasRTUtils ( CuasRTUtils cuasRTUtils = new CuasRTUtils (
curt_psf_radius, // double psf_radius, curt_psf_radius, // double psf_radius,
curt_n_sigma, // double n_sigma, curt_n_sigma, // double n_sigma,
kernel3d3_rad, // int kernel3d3_rad,
curt_temp_weights, // double[] temporal_weights, curt_temp_weights, // double[] temporal_weights,
curt_pix_decimate, // int pixel_decimate, curt_pix_decimate, // int pixel_decimate,
curt_vel_decimate, // int velocity_decimate, curt_vel_decimate, // int velocity_decimate,
......
...@@ -24,11 +24,7 @@ public class CuasRTUtils { ...@@ -24,11 +24,7 @@ public class CuasRTUtils {
final private int [] indx_margins_2d; final private int [] indx_margins_2d;
// all pixels indices // all pixels indices
final private int [] indx_all_2d; final private int [] indx_all_2d;
// same for 3x3 velocities // 3x3-velocity kernel STATE (kernel3d3_rad + indx_*_3d3) removed 2026-06-20 (dead after 3d3/MF cleanup); see tag cuas-layer1. // By Claude
final private int kernel3d3_rad;
final private int [] indx_all_3d3;
final private int [] indx_center_3d3;
final private int [] indx_margins_3d3;
final private int pixel_decimate; final private int pixel_decimate;
final private int velocity_decimate; final private int velocity_decimate;
...@@ -58,7 +54,7 @@ public class CuasRTUtils { ...@@ -58,7 +54,7 @@ public class CuasRTUtils {
public CuasRTUtils ( public CuasRTUtils (
double psf_radius, double psf_radius,
double n_sigma, double n_sigma,
int kernel3d3_rad, // kernel3d3_rad ctor arg removed 2026-06-20 (dead after 3d3/MF cleanup); see tag cuas-layer1. // By Claude
double[] temporal_weights, double[] temporal_weights,
int pixel_decimate, int pixel_decimate,
int velocity_decimate, int velocity_decimate,
...@@ -82,16 +78,7 @@ public class CuasRTUtils { ...@@ -82,16 +78,7 @@ public class CuasRTUtils {
indx_center_2d = indices[1]; indx_center_2d = indices[1];
indx_margins_2d = indices[2]; indx_margins_2d = indices[2];
// Setup 3D kernel to generate coarse velocities and input to the next pyramid level (center output) // 3x3 coarse-velocity kernel setup (kernel3d3_rad + indx_*_3d3) removed 2026-06-20 (dead after 3d3/MF cleanup); see tag cuas-layer1. // By Claude
this.kernel3d3_rad = kernel3d3_rad;
indices = getIndices(
kernel3d3_rad,
width,
height);
indx_all_3d3 = indices[0];
indx_center_3d3 = indices[1];
indx_margins_3d3 = indices[2];
// Setup 5D kernel for generating fine velocities at increased spatial resolution // Setup 5D kernel for generating fine velocities at increased spatial resolution
this.temporal_weights = temporal_weights.clone(); this.temporal_weights = temporal_weights.clone();
normalize1d (this.temporal_weights); normalize1d (this.temporal_weights);
...@@ -131,9 +118,7 @@ public class CuasRTUtils { ...@@ -131,9 +118,7 @@ public class CuasRTUtils {
return kernel2d_rad; return kernel2d_rad;
} }
public int get3d3Radius() { // get3d3Radius() removed 2026-06-20 (dead after 3d3/MF cleanup); see tag cuas-layer1. // By Claude
return kernel3d3_rad;
}
public int getNumHist() { public int getNumHist() {
return kernel5d.length; return kernel5d.length;
...@@ -704,36 +689,8 @@ public class CuasRTUtils { ...@@ -704,36 +689,8 @@ public class CuasRTUtils {
return render_sliced; return render_sliced;
} }
public ImagePlus render3d3Hyperstack( // render3d3Hyperstack removed 2026-06-20 (dead after 3d3/MF cleanup); see tag cuas-layer1. // By Claude
double [][][] coarse_vel_seq, // [nser][npix][nvel]
String [] scene_names,
String title) {
String [] arrows9 = get9Arrows();
double [][][] render_sliced = new double [arrows9.length][coarse_vel_seq.length][width * height];
for (double [][] slices:render_sliced) {
for (double [] slice:slices) {
Arrays.fill(slice, Double.NaN);
}
}
for (int nseq = 0; nseq < coarse_vel_seq.length; nseq++) {
for (int npix=0; npix < coarse_vel_seq[nseq].length; npix++) if (coarse_vel_seq[nseq][npix] !=null){
for (int s = 0; s < coarse_vel_seq[nseq][npix].length; s++) {
render_sliced[s][nseq][npix] = coarse_vel_seq[nseq][npix][s];
}
}
}
ImagePlus imp = ShowDoubleFloatArrays.showArraysHyperstack(
render_sliced, // double[][][] pixels,
width, // int width,
title, // String title, "time_derivs-rt"+diff_time_rt+"-rxy"+diff_time_rxy,
scene_names, // all slices*frames titles or just slice titles or null
arrows9, // String [] frame_titles, // frame titles or null
false); // boolean show)
imp.setDisplayRange(IMP_MINMAX[0],IMP_MINMAX[1]);
return imp;
}
public String [] get9Arrows() { public String [] get9Arrows() {
String [] arrows= { String [] arrows= {
"\u2191\u2190", // Up-Left "\u2191\u2190", // Up-Left
......
...@@ -71,159 +71,7 @@ public class TemporalKernelGenerator { ...@@ -71,159 +71,7 @@ public class TemporalKernelGenerator {
return (a >= 1.5) ? 0.0 : Math.cos(Math.PI / 3.0 * a); return (a >= 1.5) ? 0.0 : Math.cos(Math.PI / 3.0 * a);
} }
/** // generateKernelMatched + generateKernelDirect removed 2026-06-20 (dead after 3d3/MF cleanup); see tag cuas-layer1. // By Claude
* Matched-filter variant: the velocity-channel kernel IS the canonical // By Claude on 06/12/2026
* half-cosine target bump swept along the velocity trajectory - the optimal
* linear detector for a clean bump input, with no optical-blur model (the
* trapezoid in generateKernel/Direct was an analogy, found inaccurate). LoG/
* LReLU are deliberately out of the template (LoG on a zero-background bump ~
* passes it; tune LoG radius separately). Same projection convention as
* generateKernelDirect (proj = dx + 0.5 + (v/vd)*t) so it plugs into
* convolve3dDirect unchanged; trapezoid CDF replaced by a bump SAMPLE at the
* source-pixel offset. Each frame's spatial weights are normalized to the
* frame's temporal weight, so a constant-amplitude target reads out its
* amplitude at its velocity channel (energy-preserving across sub-pixel phase).
*/
public static ConsolidationKernel generateKernelMatched( // By Claude on 06/12/2026
double[] temporal_weights,
int pixel_decimate,
int velocity_decimate,
int velocity_radius
) {
int num_history = temporal_weights.length;
int num_subpixels = pixel_decimate * pixel_decimate;
int v_dim = 2 * velocity_radius + 1;
int num_velocities = v_dim * v_dim;
double max_time = num_history > 0 ? num_history - 1 : 0;
double max_shift = ((double) velocity_radius / velocity_decimate) * max_time;
int spatial_radius = (int) Math.ceil(max_shift + 1.5); // + bump half-extent
ConsolidationKernel kernel = new ConsolidationKernel(num_history, num_velocities, num_subpixels, spatial_radius);
int sdim = 2 * spatial_radius + 1;
double[][] tmp = new double[sdim][sdim];
for (int vx = -velocity_radius; vx <= velocity_radius; vx++) {
for (int vy = -velocity_radius; vy <= velocity_radius; vy++) {
int v_out_idx = (vy + velocity_radius) * v_dim + (vx + velocity_radius);
kernel.coarseVIdx[v_out_idx] = 0; // unused in the direct (scalar frames) path
for (int t = 0; t < num_history; t++) {
double time_weight = temporal_weights[t];
if (time_weight == 0) continue;
for (int sy = 0; sy < pixel_decimate; sy++) {
for (int sx = 0; sx < pixel_decimate; sx++) {
int sub_idx = sy * pixel_decimate + sx;
double sub_cx = (sx + 0.5) / pixel_decimate;
double sub_cy = (sy + 0.5) / pixel_decimate;
double sum_sp = 0;
for (int dy = -spatial_radius; dy <= spatial_radius; dy++) {
double dist_y = (dy + 0.5 + ((double) vy / velocity_decimate) * t) - sub_cy;
double by = halfcos(dist_y);
for (int dx = -spatial_radius; dx <= spatial_radius; dx++) {
double dist_x = (dx + 0.5 + ((double) vx / velocity_decimate) * t) - sub_cx;
double w = by * halfcos(dist_x);
tmp[dy + spatial_radius][dx + spatial_radius] = w;
sum_sp += w;
}
}
if (sum_sp <= 0) continue;
double scale = time_weight / sum_sp; // per-frame normalization
for (int dy = 0; dy < sdim; dy++) {
for (int dx = 0; dx < sdim; dx++) {
double w = tmp[dy][dx] * scale;
if (w > 0) kernel.weights[t][v_out_idx][sub_idx][dy][dx] = w;
}
}
}
}
}
}
}
return kernel;
}
/**
* Direct pixel-domain variant: the kernel convolves scalar (LoG+LReLU) frames // By Claude on 06/11/2026
* directly, bypassing the 3x3 coarse-velocity stage - a single-stage velocity-
* matched filter (optimal in the low-SNR linear regime where convolve3D3LReLU
* only adds noise). Identical trapezoid-CDF projection math; differences from
* generateKernel(): no coarse 3x3 plane mapping (coarseVIdx unused, set to 0,
* no tracking-limit exclusion) and t counts FRAMES of the level sequence
* (pass temporal_weights one entry longer to span the same temporal extent
* as num_hist 3d3 pair-steps).
*/
public static ConsolidationKernel generateKernelDirect( // By Claude on 06/11/2026
double[] temporal_weights,
int pixel_decimate,
int velocity_decimate,
int velocity_radius
) {
int num_history = temporal_weights.length;
int num_subpixels = pixel_decimate * pixel_decimate;
int v_dim = 2 * velocity_radius + 1;
int num_velocities = v_dim * v_dim;
double max_time = num_history > 0 ? num_history - 1 : 0;
double max_vel = (double) velocity_radius / velocity_decimate;
double max_shift = max_vel * max_time;
double max_width = 1.0 + max_time / velocity_decimate;
int spatial_radius = (int) Math.ceil(max_shift + max_width / 2.0);
ConsolidationKernel kernel = new ConsolidationKernel(num_history, num_velocities, num_subpixels, spatial_radius);
for (int vx = -velocity_radius; vx <= velocity_radius; vx++) {
for (int vy = -velocity_radius; vy <= velocity_radius; vy++) {
int v_out_idx = (vy + velocity_radius) * v_dim + (vx + velocity_radius);
kernel.coarseVIdx[v_out_idx] = 0; // unused in the direct (scalar frames) path
for (int t = 0; t < num_history; t++) {
double time_weight = temporal_weights[t];
if (time_weight == 0) continue;
double blur_width = (double) t / velocity_decimate;
double w_bot = 1.0 + blur_width;
double w_top = Math.abs(1.0 - blur_width);
double total_area = 0.5 * (w_bot + w_top);
for (int dy = -spatial_radius; dy <= spatial_radius; dy++) {
for (int dx = -spatial_radius; dx <= spatial_radius; dx++) {
double proj_x = dx + 0.5 + ((double) vx / velocity_decimate) * t;
double proj_y = dy + 0.5 + ((double) vy / velocity_decimate) * t;
for (int sy = 0; sy < pixel_decimate; sy++) {
for (int sx = 0; sx < pixel_decimate; sx++) {
int sub_idx = sy * pixel_decimate + sx;
double left_x = (double) sx / pixel_decimate;
double right_x = (double) (sx + 1) / pixel_decimate;
double top_y = (double) sy / pixel_decimate;
double bot_y = (double) (sy + 1) / pixel_decimate;
double weight_x = (trapezoidCDF(right_x - proj_x, w_top, w_bot) -
trapezoidCDF(left_x - proj_x, w_top, w_bot)) / total_area;
double weight_y = (trapezoidCDF(bot_y - proj_y, w_top, w_bot) -
trapezoidCDF(top_y - proj_y, w_top, w_bot)) / total_area;
double final_weight = weight_x * weight_y * time_weight;
if (final_weight > 0) {
kernel.weights[t][v_out_idx][sub_idx][dy + spatial_radius][dx + spatial_radius] = final_weight;
}
}
}
}
}
}
}
}
return kernel;
}
/** /**
* Generates the multi-dimensional consolidation tensor. * Generates the multi-dimensional consolidation tensor.
......
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