Commit 115acc78 authored by Andrey Filippov's avatar Andrey Filippov

Claude: Remove dead code from cuas package + fix targetsAnalyzeMCP

Dead method/constant removal (21 methods across 5 files):
- CuasMotion: addMotionVectors, clearFailByStrongerNeighbor, cloneTargetsSequence,
  filterByHorizon, filterMotionScans, findMatchingTarget, getKeyFrameVelocityScale,
  getTargetImages, getTargetsFromHyperAugment_2025, getVectorFieldHyper, showPxPyDs,
  subtractTargetSequence, trimSuffix; constants INDX_SPEED, INDX_CONFIDENCE, VF_TOP_TITLES
- CorrectionFPN: calculateFPN_old
- CuasCenterLma: getAverageRoll
- CuasMotionLMA: applyWindowToData, copyMotion, getRR0, getFullParametersVector
- CuasTile: setParentIndex, getParentIndex (were already commented out)

targetsAnalyzeMCP fixes:
- Correct PAR constants (add PAR_PXYAR=-2, shift others)
- params array now accepts strings ("pxy","pxyar","vpxy","upxy", or LMA_TITLES names)
  in addition to integer indices; default remains ["pxy"]
- Add missing PAR_PXYAR case (px, py, a, rmse, r)
- Add amplitude to PAR_PXY case
- Default case uses LMA_TITLES[npar] key instead of String.valueOf(npar)
Co-Authored-By: 's avatarClaude Sonnet 4.6 <noreply@anthropic.com>
parent 5defee61
......@@ -615,60 +615,6 @@ public class CorrectionFPN {
return imp;
}
/**
* Calculate sensors FPN in a simple way average each channel/color for a scene sequence. Intended to be
* used in CUAS mode averaging several (normally 2 full periods of rotation.
* TODO: make more accurate and universal by back-propagating the corrected image and subtracting per-sensor
* versions before averaging.
* @param quadCLTs sequence of scenes with conditioned images (getImageData() != null), without FPN applied
* @param range a first_last scene index pair. May be adjusted to include an integer number of rotations.
* @param sensor_mask bitmask which sensors to process (normally -1 - all)
* @param debugLevel debug level
* @return [sensor][color][pixel] average FPN image. May be saved as image_data to a virtual (center) scene
* (a QuadCLT instance).
*/
public static double [][][] calculateFPN_old(
final QuadCLT [] quadCLTs,
final int [] range, // required
final int sensor_mask,
final int debugLevel){
QuadCLT first_scene = quadCLTs[range[0]];
final int num_sens = first_scene.getNumSensors();
final int num_colors = first_scene.getNumColors();
final int width = first_scene.getTilesX()*first_scene.getTileSize();
final int height = first_scene.getTilesY()*first_scene.getTileSize();
final int num_pix = width*height;
final int num_scenes = range[1]-range[0]+1;
final double [][][] fpn = new double [num_sens][num_colors][num_pix];
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nChn = ai.getAndIncrement(); nChn < num_sens; nChn = ai.getAndIncrement()) if (((sensor_mask >> nChn) & 1) != 0) {
for (int nscene = range[0]; nscene <= range[1]; nscene++) {
for (int ncol = 0; ncol < num_colors; ncol++) {
double [] img_slice = quadCLTs[nscene].getImageData()[nChn][ncol];
for (int npix = 0; npix < num_pix; npix++) {
fpn[nChn][ncol][npix] += img_slice[npix];
}
}
}
double scale = 1.0/num_scenes;
for (int ncol = 0; ncol < num_colors; ncol++) {
for (int npix = 0; npix < num_pix; npix++) {
fpn[nChn][ncol][npix] *= scale;
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
return fpn;
}
public static double [][][] calculateFPN(
final QuadCLT [] quadCLTs,
final int [] range, // required
......
......@@ -868,11 +868,6 @@ public class CuasCenterLma {
public double getInitialRMS() {
return initial_rms[0];
}
public double getAverageRoll() {
return roll_average;
}
public double [] getRoll() {
return new double [] {roll_average, roll_omega};
}
......
......@@ -50,9 +50,6 @@ public class CuasMotion {
final static private int INDX_VY = 1;
final static private int INDX_STRENGTH = 2;
final static private int INDX_FRAC = 3;
final static private int INDX_SPEED = 4; // calculated separately
final static private int INDX_CONFIDENCE = 5; // calculated separately
final static String [] VF_TOP_TITLES = {"vX","vY","strength","fraction","speed", "confidence"};
final static public String LEGEND_TITLE = "Legend";
final static public String[] ICON_DESCRIPTIONS = {
"Identified UAS",
......@@ -325,17 +322,6 @@ public class CuasMotion {
public static double getFrameVelocityScale(CLTParameters clt_parameters) {
return 1.0/clt_parameters.imp.cuas_corr_offset;
}
/**
* Multiply raw {@code RSLT_VX}/{@code RSLT_VY} pair displacement by this factor
* to get pixel offset between neighboring keyframe centers.
* @param clt_parameters
* @return coefficient for VX, VY
*/
public static double getKeyFrameVelocityScale(CLTParameters clt_parameters) {
return getCorrIncExact(clt_parameters)/clt_parameters.imp.cuas_corr_offset;
}
public String [] getSceneTitles() {
......@@ -556,30 +542,6 @@ public class CuasMotion {
}
System.out.println();
}
public static double [][][] cloneTargetsSequence(
double [][][] motionScan,
int [] remain){
double [][][] cloned = new double[motionScan.length][motionScan[0].length][];
for (int nseq = 0; nseq<cloned.length; nseq++) {
int n = 0;
for (int ntile = 0; ntile < cloned[nseq].length; ntile++) {
if (motionScan[nseq][ntile] != null) {
cloned[nseq][ntile] = motionScan[nseq][ntile].clone();
n++;
}
}
if (remain != null) remain[nseq] = n;
}
return cloned;
}
public double [] getNoiseMap(
final double scale_window, // 1.0->8, 2.0 - 16.
final float [] fpixels_avg) {
......@@ -773,130 +735,6 @@ public class CuasMotion {
ImageDtt.startAndJoin(threads);
return anew.get();
}
public static double [][][] subtractTargetSequence(
double [][][] scan0,
double [][][] scan1,
int [] remain){ // keep scan0 that is not in scan1
double [][][] comboScan = new double[scan0.length][scan0[0].length][];
for (int nseq = 0; nseq < comboScan.length; nseq++) {
int n = 0;
for (int ntile = 0; ntile < comboScan[nseq].length; ntile++) {
if ((scan0[nseq][ntile] != null) && (scan1[nseq][ntile] == null)) {
comboScan[nseq][ntile] = scan0[nseq][ntile].clone();
n++;
}
}
if (remain != null) remain[nseq] = n;
}
return comboScan;
}
public static double [][][] filterMotionScans(
double [][][] scan0,
double [][][] scan1,
int [] remain){ // keep scan0 that is in scan1
double [][][] comboScan = new double[scan0.length][scan0[0].length][];
for (int nseq = 0; nseq < comboScan.length; nseq++) {
int n = 0;
for (int ntile = 0; ntile < comboScan[nseq].length; ntile++) {
if ((scan0[nseq][ntile] != null) && (scan1[nseq][ntile] != null)) {
comboScan[nseq][ntile] = scan0[nseq][ntile].clone();
n++;
}
}
if (remain != null) remain[nseq] = n;
}
return comboScan;
}
/**
* Add data from the motion vectors to reserved by CuasMotionLMA fields. Will only process tiles that have
* both target (LMA) data and motion vectors data.
* @param targets [frame sequence number][tile number]{target data array CuasMotionLMA.RSLT_LEN length}
* @param motion_vectors motion vectors
*/
public static void addMotionVectors(
final double [][][] targets,
final double [][][] motion_vectors) {
final int num_seq = targets.length;
final int num_tiles = targets[0].length;
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nSeq = ai.getAndIncrement(); nSeq < num_seq; nSeq = ai.getAndIncrement()) {
double [][] tg = targets[nSeq];
double [][] mv = targets[nSeq];
for (int ntile = 0; ntile < num_tiles; ntile++) {
double [] t = tg[ntile];
if (t != null) {
double [] v = mv[ntile];
if (v!= null) {
t[CuasMotionLMA.RSLT_VX] = v[INDX_VX];
t[CuasMotionLMA.RSLT_VY] = v[INDX_VY];
t[CuasMotionLMA.RSLT_VSTR] = v[INDX_STRENGTH];
}
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
}
public static float [][] getTargetImages(
final double [][][] vector_fields, // centers , just null/not null
final float [][] accum_data, // should be around 0, no low-freq
final int tilesX){
final int tile2 = 2 * GPUTileProcessor.DTT_SIZE;
final int num_seq = vector_fields.length; // same as accum_data.length
final int num_tiles = vector_fields[0].length;
final int num_pix = accum_data[0].length;
final int width = GPUTileProcessor.DTT_SIZE * tilesX;
float [][] taret_images = new float[num_seq][num_pix];
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
// may be faster if process only where vector_field[nseq][ntile] is not null
for (int nSeq = ai.getAndIncrement(); nSeq < num_seq; nSeq = ai.getAndIncrement()) {
Arrays.fill(taret_images[nSeq], Float.NaN);
for (int ntile = 0; ntile < num_tiles; ntile++) {
if (vector_fields[nSeq][ntile] != null) {
int tileX = ntile % tilesX;
int tileY = ntile / tilesX;
int px0 = tileX * GPUTileProcessor.DTT_SIZE - GPUTileProcessor.DTT_SIZE/2; // top-left of 16x16 tile
int py0 = tileY * GPUTileProcessor.DTT_SIZE - GPUTileProcessor.DTT_SIZE/2; // top-left of 16x16 tile
// copy 16x16 tile
for (int y = 0; y < tile2; y++) {
System.arraycopy(
accum_data[nSeq],
px0 + (py0 +y) * width,
taret_images[nSeq],
px0 + (py0 +y) * width,
tile2);
}
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
return taret_images;
}
/**
* Probably obsolete, was used with single-target target_sequence (motion sequence)
* @param target_sequence
* @param filter5
* @return
*/
public static double [][][] applyFilter(
double [][][] target_sequence,
int [][] filter5){
......@@ -933,35 +771,8 @@ public class CuasMotion {
}
return filtered_scan;
}
/*
public static void clearFailByStrongerNeighbor(// does not modify "when"
final double [][][] target_sequence){
final int num_seq = target_sequence.length;
final int num_tiles = target_sequence[0].length;
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
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)) {
target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_FAIL] = CuasMotionLMA.FAIL_NONE;
}
}
}
};
}
ImageDtt.startAndJoin(threads);
}
*/
public static double [][][] applyFilter(
final double [][][] target_sequence,
final int index,
......@@ -1033,39 +844,6 @@ public class CuasMotion {
show); // boolean show)
return imp;
}
public static double [][][] getVectorFieldHyper(String path){
int [] wh = new int [2];
String [][] pvf_top_titles = new String[1][];
String [][] pvf_titles = new String[1][];
double [][][] vf_file = ShowDoubleFloatArrays.readDoubleHyperstack(
path, // String path,
wh, // int [] wh, // should be null or int[2]
pvf_top_titles, // String [][] ptop_titles, // should be null or String [1][]
pvf_titles); // String [][] pslice_titles){// should be null or String [1][]
if (vf_file == null) {
return null;
}
int vect_len = INDX_SPEED; // vf_file.length;
int num_seq = vf_file[0].length;
int num_tiles = vf_file[0][0].length;
double [][][] vf = new double [num_seq][num_tiles][];
for (int nseq=0; nseq < num_seq; nseq++) {
for (int ntile = 0; ntile < num_tiles; ntile++) if (!Double.isNaN(vf_file[0][nseq][ntile])){
double [] v = new double[vect_len]; // cut to originally calculated fields
for (int i = 0; i < vect_len; i++) {
v[i] = vf_file[i][nseq][ntile];
}
vf[nseq][ntile] = v;
}
}
return vf;
}
@SuppressWarnings("unchecked")
public static org.json.simple.JSONArray targetsAnalyzeMCP(String target_path, org.json.simple.JSONArray queries) {
String [][] pvf_top_titles = new String[1][];
......@@ -1090,7 +868,7 @@ public class CuasMotion {
int tilesX = wh[0];
int tilesY = wh[1];
final int tileSize = GPUTileProcessor.DTT_SIZE; // 8
final int PAR_UPXY=-3,PAR_VPXY=-2,PAR_PXY=-1;
final int PAR_UPXY=-4,PAR_VPXY=-3,PAR_PXYAR=-2,PAR_PXY=-1; // By Claude on 05/08/2026
for (Object qObj : queries) {
org.json.simple.JSONObject q = (org.json.simple.JSONObject) qObj;
......@@ -1123,11 +901,29 @@ public class CuasMotion {
if (mode == ANLZ_SECT) {
boolean skip_empty = q.get("skip_empty") != null ? (Boolean) q.get("skip_empty") : true;
// By Claude on 05/08/2026: params accepts strings ("RSLT_X","pxy","pxyar","vpxy","upxy")
// or integers (numeric index into LMA_TITLES); default is ["pxy"]
org.json.simple.JSONArray paramsJson = (org.json.simple.JSONArray) q.get("params");
int[] params = new int[paramsJson != null ? paramsJson.size() : 1];
if (paramsJson != null) {
for (int i=0; i<paramsJson.size(); i++) {
params[i] = ((Long)paramsJson.get(i)).intValue();
final String[] COMBO_NAMES = {"upxy", "vpxy", "pxyar", "pxy"};
final int[] COMBO_VALS = {PAR_UPXY, PAR_VPXY, PAR_PXYAR, PAR_PXY};
for (int i = 0; i < paramsJson.size(); i++) {
Object p = paramsJson.get(i);
if (p instanceof Long) {
params[i] = ((Long) p).intValue();
} else if (p instanceof String) {
int idx = Integer.MIN_VALUE;
for (int j = 0; j < COMBO_NAMES.length; j++) {
if (COMBO_NAMES[j].equalsIgnoreCase((String) p)) { idx = COMBO_VALS[j]; break; }
}
if (idx == Integer.MIN_VALUE) {
for (int j = 0; j < CuasMotionLMA.LMA_TITLES.length; j++) {
if (CuasMotionLMA.LMA_TITLES[j].equalsIgnoreCase((String) p)) { idx = j; break; }
}
}
params[i] = idx; // Integer.MIN_VALUE if not found → skipped in default case
}
}
} else {
params[0] = PAR_PXY;
......@@ -1169,13 +965,21 @@ public class CuasMotion {
targObj.put("vy", multi_targets[nseq][ntile][ntarg][CuasMotionLMA.RSLT_VY]);
targObj.put("vconf", multi_targets[nseq][ntile][ntarg][CuasMotionLMA.RSLT_VSTR]);
break;
case PAR_PXYAR: // By Claude on 05/08/2026
targObj.put("px", tileSize * x + tileSize/2.0 + multi_targets[nseq][ntile][ntarg][CuasMotionLMA.RSLT_X]);
targObj.put("py", tileSize * y + tileSize/2.0 + multi_targets[nseq][ntile][ntarg][CuasMotionLMA.RSLT_Y]);
targObj.put("a", multi_targets[nseq][ntile][ntarg][CuasMotionLMA.RSLT_A]);
targObj.put("rmse", multi_targets[nseq][ntile][ntarg][CuasMotionLMA.RSLT_RMS]);
targObj.put("r", multi_targets[nseq][ntile][ntarg][CuasMotionLMA.RSLT_R1]);
break;
case PAR_PXY:
targObj.put("px", tileSize * x + tileSize/2.0 + multi_targets[nseq][ntile][ntarg][CuasMotionLMA.RSLT_X]);
targObj.put("py", tileSize * y + tileSize/2.0 + multi_targets[nseq][ntile][ntarg][CuasMotionLMA.RSLT_Y]);
targObj.put("a", multi_targets[nseq][ntile][ntarg][CuasMotionLMA.RSLT_A]); // By Claude on 05/08/2026
break;
default:
if (npar >= 0 && npar < multi_targets[nseq][ntile][ntarg].length) {
targObj.put(String.valueOf(npar), multi_targets[nseq][ntile][ntarg][npar]);
targObj.put(CuasMotionLMA.LMA_TITLES[npar], multi_targets[nseq][ntile][ntarg][npar]); // By Claude on 05/08/2026
}
}
}
......@@ -1783,51 +1587,7 @@ public class CuasMotion {
null, // String [][] pvf_titles,
path); //String path)
}
public static double [][][] getTargetsFromHyperAugment_2025(
String [][] pvf_top_titles,
String [][] pvf_titles,
String path){ // add empty fields to the end of each target if shorter than CuasMotionLMA.RSLT_LEN
int [] wh = new int [2];
if (pvf_top_titles == null) pvf_top_titles = new String[1][];
if (pvf_titles == null) pvf_titles = new String[1][];
double [][][] targets_file = ShowDoubleFloatArrays.readDoubleHyperstack(
path, // String path,
wh, // int [] wh, // should be null or int[2]
pvf_top_titles, // String [][] ptop_titles, // should be null or String [1][]
pvf_titles); // String [][] pslice_titles){// should be null or String [1][]
if (targets_file == null) {
return null;
}
int num_fields = targets_file.length;
// fix - discarding last slice if it is called CuasMotionLMA.EXTRA_SLICE_DISCARD_ON_LOAD ("Targets")
if (pvf_top_titles[0][pvf_top_titles[0].length-1].equals(CuasMotionLMA.EXTRA_SLICE_DISCARD_ON_LOAD)) {
System.out.println("getTargetsFromHyperAugment(): removing last slice called "+ pvf_top_titles[0][pvf_top_titles[0].length-1]);
num_fields--;
String [] ss = new String[num_fields];
System.arraycopy(pvf_top_titles[0], 0, ss, 0, num_fields);
pvf_top_titles[0] = ss;
}
int num_fields_augmented = Math.max(num_fields, CuasMotionLMA.RSLT_LEN);
int num_seq = targets_file[0].length;
int num_tiles = targets_file[0][0].length;
double [][][] target_sequence = new double [num_seq][num_tiles][];
for (int nseq=0; nseq < num_seq; nseq++) {
for (int ntile = 0; ntile < num_tiles; ntile++) if (!Double.isNaN(targets_file[CuasMotionLMA.RSLT_X][nseq][ntile]) ||
((num_fields >= CuasMotionLMA.RSLT_FL_PX) && !Double.isNaN(targets_file[CuasMotionLMA.RSLT_FL_PX][nseq][ntile]))){
double [] v = new double[num_fields_augmented]; // cut to originally calculated fields
for (int i = 0; i < num_fields; i++) {
v[i] = targets_file[i][nseq][ntile];
}
for (int i = num_fields; i < num_fields_augmented; i++) {
v[i] = Double.NaN;
}
target_sequence[nseq][ntile] = v;
}
}
return target_sequence;
}
public static double [][][] getTargetsFromHyperAugment(
String [][] pvf_top_titles,
......@@ -1882,18 +1642,6 @@ public class CuasMotion {
return target_sequence;
}
public static String trimSuffix(
String name,
String suffix) {
while (name.endsWith(suffix)) {
name = name.substring(0, name.length()-suffix.length());
}
return name;
}
// By Claude on 05/07/2026: pre-populate target_sequence_multi with FAIL_PENDING sentinels from motion_sequence.
// Each sentinel is a clone of the motion entry with RSLT_FAIL=FAIL_PENDING, RSLT_CENTERED=CENTERED_NO,
// RSLT_QSCORE initialized from RSLT_MSCORE. Preserves VX/VY/X/Y and all other motion fields.
......@@ -2196,7 +1944,6 @@ public class CuasMotion {
double [] target = CuasMotionLMA.getEmpty();
// Store the raw displacement over one correlation-pair separation
// (cuas_corr_offset scenes). Convert later with getFrameVelocityScale()
// or getKeyFrameVelocityScale() depending on the consumer.
target[CuasMotionLMA.RSLT_VX] = vector_field[ntile][INDX_VX] * scale_vxy;
target[CuasMotionLMA.RSLT_VY] = vector_field[ntile][INDX_VY] * scale_vxy;
target[CuasMotionLMA.RSLT_VSTR] = vector_field[ntile][INDX_STRENGTH];
......@@ -2689,47 +2436,6 @@ public class CuasMotion {
}
public ImagePlus showPxPyDs(
double [][][] pXpYDs,
int nseq, // center
String title,
boolean show) {
int num_scenes = pXpYDs.length;
int frame_center= getFrameCenter(nseq);
int start_scene = frame_center - (num_scenes + 1)/2;
int num_tiles = pXpYDs[0].length;
String [] titles_slices = {"pX","pY","Disparity"};
String [] titles_scenes = new String[num_scenes];
for (int i = 0; i < num_scenes; i++) {
titles_scenes[i] = getSceneTitles()[i+start_scene];
}
double [][][] data_img = new double [titles_slices.length][num_scenes][num_tiles];
for (int nslice = 0; nslice < data_img.length; nslice++) {
for (int nscene = 0; nscene < num_scenes; nscene++) {
Arrays.fill(data_img[nslice][nscene], Double.NaN);
}
}
for (int nscene = 0; nscene < num_scenes; nscene++) {
for (int ntile = 0; ntile < num_tiles; ntile++) if (pXpYDs[nscene][ntile] != null){
for (int nslice = 0; nslice < data_img.length; nslice++) {
data_img[nslice][nscene][ntile] = pXpYDs[nscene][ntile][nslice];
}
}
}
ImagePlus imp = ShowDoubleFloatArrays.showArraysHyperstack(
data_img, // double[][][] pixels,
tilesX, // int width,
title, // String title, "time_derivs-rt"+diff_time_rt+"-rxy"+diff_time_rxy,
titles_scenes, // String [] titles, // all slices*frames titles or just slice titles or null
titles_slices, // CuasMotionLMA.LMA_TITLES, // String [] frame_titles, // frame titles or null
show); // show); // boolean show)
return imp;
}
/**
* Shift keyframe according to the vector_field, render and return result image. Does not need to reload keyframe image
* if it is already loaded in the GPU
......@@ -5299,31 +5005,6 @@ public class CuasMotion {
// ImagePlus imp_new = new ImagePlus(title2,new_stack);
return; // imp_new;
}
//
private static int findMatchingTarget(
double [][] targets,
double [] uas_pXpYD,
double max_dist) {
double max_dist2 = max_dist * max_dist;
int best_index = -1;
double best_dist2 = max_dist2; // Double.NaN;
if ((targets == null) || (targets.length == 0)) {
return best_index;
}
for (int ntarg = 0; ntarg < targets.length; ntarg++) {
double dx = targets[ntarg][TARGET_X] - uas_pXpYD[0];
double dy = targets[ntarg][TARGET_Y] - uas_pXpYD[1];
double dist2 = dx*dx+dy*dy;
if (!(dist2 > best_dist2)) {
best_dist2 = dist2;
best_index = ntarg;
}
}
return best_index;
}
public static String getSignedDouble(
double d,
String format) {
......@@ -5771,49 +5452,6 @@ public class CuasMotion {
}
public static double [][][] filterByHorizon(
final double [][][] target_sequence,
final double horizon,
final int [] remain,
final int tilesX) {
final int num_seq = target_sequence.length;
final int num_tiles = target_sequence[0].length;
final double [][][] filtered_tiles = new double [num_seq][num_tiles][];
final int tileSize = GPUTileProcessor.DTT_SIZE;
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nSeq = ai.getAndIncrement(); nSeq < num_seq; nSeq = ai.getAndIncrement()) {
if (remain != null) {
remain[nSeq] = 0;
}
for (int ntile = 0; ntile < num_tiles; ntile++) {
double [] target_pos = target_sequence[nSeq][ntile];
if (target_pos != null) { // should be always
int tileY = ntile / tilesX;
double yc = tileSize * tileY + tileSize/2;
double ytk = yc + target_pos[CuasMotionLMA.RSLT_Y];
if (ytk <= horizon) {
filtered_tiles[nSeq][ntile] = target_pos;
if (remain != null) {
remain[nSeq]++;
}
}
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
return filtered_tiles;
}
public static String getParametersSuffix(
CLTParameters clt_parameters,
......
......@@ -182,32 +182,6 @@ public class CuasMotionLMA {
}
}
}
/**
* Multiply (in place) data by window. Used only when stray data (local maximum is not the absolute maximum) is present
* Center data will be multiplied by almost 1.0
* @param tile_data data array, will be modified
* @param xc relative to center =width/2
* @param yc relative to center =width/2
*/
public void applyWindowToData(
double [] tile_data,
double xc, // relative to center =width/2
double yc) { // relative to center =width/2
double x0 = Math.min(Math.max(xc + width/2, 0), width-1);
double y0 = Math.min(Math.max(yc + width/2, 0), width-1);
int ix0 = (int) Math.round(x0);
int iy0 = (int) Math.round(y0);
for (int y = 0; y < width; y++) {
int ay = Math.abs(y-iy0);
for (int x = 0; x < width; x++) {
int ax = Math.abs(x-ix0);
double w = window[ay][ax]; // window to the nearest integer x,y
tile_data[x + y*width] *= w;
}
}
}
public int prepareLMA(
boolean [] param_select,
double [] tile_data,
......@@ -312,24 +286,9 @@ public class CuasMotionLMA {
rslt[RSLT_ITERS] = getIters();
return;
}
public static void copyMotion(
double [] dst,
double [] src) {
dst[RSLT_VX] = src[RSLT_VX];
dst[RSLT_VY] = src[RSLT_VY];
dst[RSLT_VSTR] = src[RSLT_VSTR];
dst[RSLT_VFRAC] = src[RSLT_VFRAC];
}
public double [] getCenter(){
return new double [] {full_vector[INDX_X0] - width/2, full_vector[INDX_Y0]-width/2};
}
public double getRR0() {
return full_vector[INDX_RR0];
}
public double getR0() {
return Math.PI/(2 * full_vector[INDX_RR0]);
}
......@@ -349,11 +308,6 @@ public class CuasMotionLMA {
public int getIters() {
return iters;
}
public double [] getFullParametersVector() {
return full_vector;
}
public double [] getParametersVector() {
double [] vector = new double [pindx.length];
for (int i = 0; i < vector.length; i++) {
......
......@@ -18,13 +18,6 @@ public class CuasTile implements Comparable<CuasTile>, Serializable {
/*
public int parent_index = -1;
public void setParentIndex(int indx) {
parent_index = indx;
}
public int getParentIndex() {
return parent_index;
}
*/
public CuasTile (
int num_colors,
......
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