Commit 2dea0a92 authored by Andrey Filippov's avatar Andrey Filippov

CLAUDE: Add 5D fine-velocity convolution to CuasDetectRT.detectTargets()

Add convolve3d() (kernel5d) at level-0 before the temporal pyramid loop
and at each pyramid level nlev+1 inside the loop, mirroring the existing
3D3 coarse-velocity pattern. Output saved as CONV5D hyperstack when
debugLevel > -4. Add getNumHist() getter to CuasRTUtils.
Co-authored-by: 's avatarClaude <claude@elphel.com>
parent f72079a0
...@@ -19,6 +19,7 @@ public class CuasDetectRT { ...@@ -19,6 +19,7 @@ public class CuasDetectRT {
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"; public static final String SUFFIX_CONV3D3 = "-CONV3D3";
public static final String SUFFIX_CONV5D = "-CONV5D";
public static final String [] CONV3D3_MODES = {"plain", "winner", "power"}; public static final String [] CONV3D3_MODES = {"plain", "winner", "power"};
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;
...@@ -256,12 +257,6 @@ public class CuasDetectRT { ...@@ -256,12 +257,6 @@ public class CuasDetectRT {
title_conv3d3); // String title) title_conv3d3); // String title)
QuadCLTCPU.saveImagePlusInDirectory(imp_3d3, getModelDirectory()); QuadCLTCPU.saveImagePlusInDirectory(imp_3d3, getModelDirectory());
} }
// building pyramid // building pyramid
int pyramid_levels = clt_parameters.imp.curt_pyramid; int pyramid_levels = clt_parameters.imp.curt_pyramid;
...@@ -269,6 +264,7 @@ public class CuasDetectRT { ...@@ -269,6 +264,7 @@ public class CuasDetectRT {
double [][][] dpixels_pyramid = new double [pyramid_levels][][]; double [][][] dpixels_pyramid = new double [pyramid_levels][][];
String [][] ts_pyramid = new String [pyramid_levels][]; String [][] ts_pyramid = new String [pyramid_levels][];
double [][][][] dpixels_3d3_pyramid = new double [pyramid_levels][][][]; double [][][][] dpixels_3d3_pyramid = new double [pyramid_levels][][][];
double [][][][][] dpixels_5d_pyramid = new double [pyramid_levels][][][][];
ts_pyramid[0] = getTimeStamps(1); ts_pyramid[0] = getTimeStamps(1);
dpixels_3d3_pyramid[0] = dpixels_3d3; dpixels_3d3_pyramid[0] = dpixels_3d3;
dpixels_pyramid[0] = new double[dpixels_log.length-1][width*height]; dpixels_pyramid[0] = new double[dpixels_log.length-1][width*height];
...@@ -281,16 +277,31 @@ public class CuasDetectRT { ...@@ -281,16 +277,31 @@ public class CuasDetectRT {
} }
// System.arraycopy(dpixels_log, 1, dpixels_pyramid[0], 0, dpixels_pyramid[0].length); // System.arraycopy(dpixels_log, 1, dpixels_pyramid[0], 0, dpixels_pyramid[0].length);
int center9 = 4; int center9 = 4;
for (int nlev = 0; nlev < pyramid_levels; nlev++) { int num_hist_5d = cuasRTUtils.getNumHist();
/* boolean save_5d_pixels = debugLevel > -4;
// copy centers String title_conv5d = getBaseName()+SUFFIX_CONV5D+"-PSF"+d2s(cuasRTUtils.getPsfRadius())+
dpixels_pyramid[nlev] = new double [dpixels_3d3_pyramid[nlev].length][width*height]; "-KR"+d2s(cuasRTUtils.getKernel2dRadius())+"-NHIST"+num_hist_5d+
for (int nseq = 0; nseq < dpixels_pyramid[nlev].length; nseq++) { "-VELRAD"+curt_vel_radius+"-VELDEC"+curt_vel_decimate;
for (int npix = 0; npix < dpixels_pyramid[nlev][nseq].length; npix++) { // Level-0 5D convolution (fine velocity from coarse-velocity history)
dpixels_pyramid[nlev][nseq][npix] = dpixels_3d3_pyramid[nlev][nseq][npix][center9]; int num_5d_lev0 = Math.max(0, dpixels_3d3.length - num_hist_5d + 1);
} dpixels_5d_pyramid[0] = new double[num_5d_lev0][][][];
String[] ts_5d_lev0 = new String[num_5d_lev0];
for (int n5d = 0; n5d < num_5d_lev0; n5d++) {
double[][][] window = new double[num_hist_5d][][];
for (int h = 0; h < num_hist_5d; h++) {
window[h] = dpixels_3d3[n5d + num_hist_5d - 1 - h];
} }
*/ dpixels_5d_pyramid[0][n5d] = cuasRTUtils.convolve3d(window, null);
ts_5d_lev0[n5d] = ts_pyramid[0][n5d + num_hist_5d - 1];
}
if (save_5d_pixels && num_5d_lev0 > 0) {
ImagePlus imp_5d = cuasRTUtils.showConvKernel5d(
dpixels_5d_pyramid[0],
ts_5d_lev0,
title_conv5d);
QuadCLTCPU.saveImagePlusInDirectory(imp_5d, getModelDirectory());
}
for (int nlev = 0; nlev < pyramid_levels; nlev++) {
if (save_LoG_pixels) { if (save_LoG_pixels) {
String title_conv2d_lev = getBaseName()+SUFFIX_CONV2D+"-PSF"+d2s(cuasRTUtils.getPsfRadius())+ String title_conv2d_lev = getBaseName()+SUFFIX_CONV2D+"-PSF"+d2s(cuasRTUtils.getPsfRadius())+
"-KR"+d2s(cuasRTUtils.getKernel2dRadius())+"-ALPHA0_"+d2s(alpha0)+"-ALPHAPYR_"+d2s(alpha_pyr)+"-LEV"+nlev; "-KR"+d2s(cuasRTUtils.getKernel2dRadius())+"-ALPHA0_"+d2s(alpha0)+"-ALPHAPYR_"+d2s(alpha_pyr)+"-LEV"+nlev;
...@@ -339,6 +350,25 @@ public class CuasDetectRT { ...@@ -339,6 +350,25 @@ public class CuasDetectRT {
title_conv3d3+"-LEV"+(nlev+1)); // String title) title_conv3d3+"-LEV"+(nlev+1)); // String title)
QuadCLTCPU.saveImagePlusInDirectory(imp_3d3, getModelDirectory()); QuadCLTCPU.saveImagePlusInDirectory(imp_3d3, getModelDirectory());
} }
// 5D convolution for pyramid level nlev+1
int num_5d_lev = Math.max(0, dpixels_3d3_pyramid[nlev+1].length - num_hist_5d + 1);
dpixels_5d_pyramid[nlev+1] = new double[num_5d_lev][][][];
String[] ts_5d_lev = new String[num_5d_lev];
for (int n5d = 0; n5d < num_5d_lev; n5d++) {
double[][][] window = new double[num_hist_5d][][];
for (int h = 0; h < num_hist_5d; h++) {
window[h] = dpixels_3d3_pyramid[nlev+1][n5d + num_hist_5d - 1 - h];
}
dpixels_5d_pyramid[nlev+1][n5d] = cuasRTUtils.convolve3d(window, null);
ts_5d_lev[n5d] = ts_pyramid[nlev+1][n5d + num_hist_5d - 1];
}
if (save_5d_pixels && num_5d_lev > 0) {
ImagePlus imp_5d = cuasRTUtils.showConvKernel5d(
dpixels_5d_pyramid[nlev+1],
ts_5d_lev,
title_conv5d+"-LEV"+(nlev+1));
QuadCLTCPU.saveImagePlusInDirectory(imp_5d, getModelDirectory());
}
} }
} }
return null; return null;
......
...@@ -116,8 +116,11 @@ public class CuasRTUtils { ...@@ -116,8 +116,11 @@ public class CuasRTUtils {
public int get3d3Radius() { public int get3d3Radius() {
return kernel3d3_rad; return kernel3d3_rad;
} }
public int getNumHist() {
return kernel5d.length;
}
public double [] getKernel2d() { public double [] getKernel2d() {
return kernel2d; return kernel2d;
} }
......
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