Commit 11658a73 authored by Andrey Filippov's avatar Andrey Filippov

CLAUDE: Update filterConv5dROI to use vel_suppr_rad neighbourhood

Replace fixed ±1 pixel/velocity loops and indx_center_3d3/indx_margins_3d3
with configurable vel_suppr_rad loops and indx_center_vsupp/indx_margins_vsupp.
Co-authored-by: 's avatarClaude <claude@elphel.com>
parent 1ea8ea53
...@@ -1506,13 +1506,13 @@ public class CuasRTUtils { ...@@ -1506,13 +1506,13 @@ public class CuasRTUtils {
/** /**
* 4D non-maximum suppression on a ROI fine-velocity result. * 4D non-maximum suppression on a ROI fine-velocity result.
* For each (pixel, velocity) point, find the maximum M over the ±1 neighbourhood * For each (pixel, velocity) point, find the maximum M over the ±vel_suppr_rad neighbourhood
* in both pixel space (3×3) and velocity space (3×3 in vx/vy), then: * in both pixel space and velocity space (vx/vy), then:
* if M >= athresh AND val < rthresh * M → zero the point (sidelobe suppression) * thresh = max(athresh, M*rthresh); suppress if (M - val) >= thresh
* otherwise keep val unchanged (including the weak-signal passthrough when M < athresh). * otherwise keep val unchanged (including the weak-signal passthrough when M < athresh).
* *
* Uses indx_center_3d3 / indx_margins_3d3 for bit-reversed multithreaded iteration * Uses indx_center_vsupp / indx_margins_vsupp for bit-reversed multithreaded iteration
* (same kernel radius = 1 as the pixel neighbourhood here). * (kernel radius = vel_suppr_rad matches both pixel and velocity neighbourhood).
* *
* @param data [roi_npix][nsub][nvel] — ROI-indexed output of convolve3d(roi) * @param data [roi_npix][nsub][nvel] — ROI-indexed output of convolve3d(roi)
* @param roi pixel rectangle (full-image coordinates) * @param roi pixel rectangle (full-image coordinates)
...@@ -1537,8 +1537,8 @@ public class CuasRTUtils { ...@@ -1537,8 +1537,8 @@ public class CuasRTUtils {
// Center pixels: all 8 pixel neighbours are within image bounds; only ROI check needed. // Center pixels: all 8 pixel neighbours are within image bounds; only ROI check needed.
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { public void run() { threads[ithread] = new Thread() { public void run() {
for (int nPix = ai.getAndIncrement(); nPix < indx_center_3d3.length; nPix = ai.getAndIncrement()) { for (int nPix = ai.getAndIncrement(); nPix < indx_center_vsupp.length; nPix = ai.getAndIncrement()) {
int ipix = indx_center_3d3[nPix]; int ipix = indx_center_vsupp[nPix];
int px = ipix % width, py = ipix / width; int px = ipix % width, py = ipix / width;
if (px < roi_x0 || px >= roi_x1 || py < roi_y0 || py >= roi_y1) continue; if (px < roi_x0 || px >= roi_x1 || py < roi_y0 || py >= roi_y1) continue;
int roi_pix = (py - roi_y0) * roi.width + (px - roi_x0); int roi_pix = (py - roi_y0) * roi.width + (px - roi_x0);
...@@ -1547,16 +1547,16 @@ public class CuasRTUtils { ...@@ -1547,16 +1547,16 @@ public class CuasRTUtils {
double val = data[roi_pix][sub_idx][v_out_idx]; double val = data[roi_pix][sub_idx][v_out_idx];
int vy = v_out_idx / vout_dim, vx = v_out_idx % vout_dim; int vy = v_out_idx / vout_dim, vx = v_out_idx % vout_dim;
double M = 0; double M = 0;
for (int dpy = -1; dpy <= 1; dpy++) { for (int dpy = -vel_suppr_rad; dpy <= vel_suppr_rad; dpy++) {
int ny = py + dpy; int ny = py + dpy;
for (int dpx = -1; dpx <= 1; dpx++) { for (int dpx = -vel_suppr_rad; dpx <= vel_suppr_rad; dpx++) {
int nx = px + dpx; int nx = px + dpx;
if (nx < roi_x0 || nx >= roi_x1 || ny < roi_y0 || ny >= roi_y1) continue; if (nx < roi_x0 || nx >= roi_x1 || ny < roi_y0 || ny >= roi_y1) continue;
int nroi = (ny - roi_y0) * roi.width + (nx - roi_x0); int nroi = (ny - roi_y0) * roi.width + (nx - roi_x0);
for (int dvy = -1; dvy <= 1; dvy++) { for (int dvy = -vel_suppr_rad; dvy <= vel_suppr_rad; dvy++) {
int nvy = vy + dvy; int nvy = vy + dvy;
if (nvy < 0 || nvy >= vout_dim) continue; if (nvy < 0 || nvy >= vout_dim) continue;
for (int dvx = -1; dvx <= 1; dvx++) { for (int dvx = -vel_suppr_rad; dvx <= vel_suppr_rad; dvx++) {
int nvx = vx + dvx; int nvx = vx + dvx;
if (nvx < 0 || nvx >= vout_dim) continue; if (nvx < 0 || nvx >= vout_dim) continue;
double d = data[nroi][sub_idx][nvy * vout_dim + nvx]; double d = data[nroi][sub_idx][nvy * vout_dim + nvx];
...@@ -1578,8 +1578,8 @@ public class CuasRTUtils { ...@@ -1578,8 +1578,8 @@ public class CuasRTUtils {
ai.set(0); ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { public void run() { threads[ithread] = new Thread() { public void run() {
for (int nPix = ai.getAndIncrement(); nPix < indx_margins_3d3.length; nPix = ai.getAndIncrement()) { for (int nPix = ai.getAndIncrement(); nPix < indx_margins_vsupp.length; nPix = ai.getAndIncrement()) {
int ipix = indx_margins_3d3[nPix]; int ipix = indx_margins_vsupp[nPix];
int px = ipix % width, py = ipix / width; int px = ipix % width, py = ipix / width;
if (px < roi_x0 || px >= roi_x1 || py < roi_y0 || py >= roi_y1) continue; if (px < roi_x0 || px >= roi_x1 || py < roi_y0 || py >= roi_y1) continue;
int roi_pix = (py - roi_y0) * roi.width + (px - roi_x0); int roi_pix = (py - roi_y0) * roi.width + (px - roi_x0);
...@@ -1588,18 +1588,18 @@ public class CuasRTUtils { ...@@ -1588,18 +1588,18 @@ public class CuasRTUtils {
double val = data[roi_pix][sub_idx][v_out_idx]; double val = data[roi_pix][sub_idx][v_out_idx];
int vy = v_out_idx / vout_dim, vx = v_out_idx % vout_dim; int vy = v_out_idx / vout_dim, vx = v_out_idx % vout_dim;
double M = 0; double M = 0;
for (int dpy = -1; dpy <= 1; dpy++) { for (int dpy = -vel_suppr_rad; dpy <= vel_suppr_rad; dpy++) {
int ny = py + dpy; int ny = py + dpy;
if (ny < 0 || ny >= height) continue; if (ny < 0 || ny >= height) continue;
for (int dpx = -1; dpx <= 1; dpx++) { for (int dpx = -vel_suppr_rad; dpx <= vel_suppr_rad; dpx++) {
int nx = px + dpx; int nx = px + dpx;
if (nx < 0 || nx >= width) continue; if (nx < 0 || nx >= width) continue;
if (nx < roi_x0 || nx >= roi_x1 || ny < roi_y0 || ny >= roi_y1) continue; if (nx < roi_x0 || nx >= roi_x1 || ny < roi_y0 || ny >= roi_y1) continue;
int nroi = (ny - roi_y0) * roi.width + (nx - roi_x0); int nroi = (ny - roi_y0) * roi.width + (nx - roi_x0);
for (int dvy = -1; dvy <= 1; dvy++) { for (int dvy = -vel_suppr_rad; dvy <= vel_suppr_rad; dvy++) {
int nvy = vy + dvy; int nvy = vy + dvy;
if (nvy < 0 || nvy >= vout_dim) continue; if (nvy < 0 || nvy >= vout_dim) continue;
for (int dvx = -1; dvx <= 1; dvx++) { for (int dvx = -vel_suppr_rad; dvx <= vel_suppr_rad; dvx++) {
int nvx = vx + dvx; int nvx = vx + dvx;
if (nvx < 0 || nvx >= vout_dim) continue; if (nvx < 0 || nvx >= vout_dim) continue;
double d = data[nroi][sub_idx][nvy * vout_dim + nvx]; double d = data[nroi][sub_idx][nvy * vout_dim + nvx];
......
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