Commit e6a1d91b authored by Andrey Filippov's avatar Andrey Filippov

center-of-mass for 16, propagated changes (4->16) for disparity_map

parent d8b8ffdc
......@@ -1971,6 +1971,7 @@ public class Correlation2d {
}
return getMaxXYInt( // find integer pair or null if below threshold // USED in lwir
data, // [data_size * data_size]
null,
data_width,
center_row,
axis_only,
......@@ -1992,12 +1993,14 @@ public class Correlation2d {
public int [] getMaxXYInt( // find integer pair or null if below threshold // USED in lwir
double [] data, // [data_size * data_size]
double [] disp_str, // if not null, will return {disparity, strength}
int data_width,
int center_row,
boolean axis_only,
double minMax, // minimal value to consider (at integer location, not interpolated)
boolean debug)
{
//mcorr_comb_disp
// int data_width = 2 * transform_size - 1;
// int data_height = data.length / data_width;
int center = data_width / 2; // transform_size - 1;
......@@ -2034,6 +2037,10 @@ public class Correlation2d {
if (debug){
System.out.println("getMaxXYInt() -> "+rslt[0]+"/"+rslt[1]);
}
if (disp_str != null) {
disp_str[0] = -rslt[0] * mcorr_comb_disp;
disp_str[1] = data[imx];
}
return rslt;
}
......@@ -2108,10 +2115,14 @@ public class Correlation2d {
*/
public double [] getMaxXCm( // get fractional center as a "center of mass" inside circle/square from the integer max // USED in lwir
double [] data, // [data_size * data_size]
int data_width, // = 2 * transform_size - 1;
int center_row,
int ixcenter, // integer center x
boolean debug) {
return getMaxXCm( // get fractional center as a "center of mass" inside circle/square from the integer max
data, // double [] data, // [data_size * data_size]
data_width, // int data_width, // = 2 * transform_size - 1;
center_row, // int center_row,
ixcenter, // int ixcenter, // integer center x
this.corr_wndy, // double [] window_y, // (half) window function in y-direction(perpendicular to disparity: for row0 ==1
this.corr_wndx, // double [] window_x, // half of a window function in x (disparity) direction
......@@ -2120,27 +2131,63 @@ public class Correlation2d {
public double [] getMaxXCmNotch( // get fractional center as a "center of mass" inside circle/square from the integer max // not used in lwir
double [] data, // [data_size * data_size]
int data_width, // = 2 * transform_size - 1;
int center_row,
int ixcenter, // integer center x
boolean debug) {
return getMaxXCm( // get fractional center as a "center of mass" inside circle/square from the integer max
data, // double [] data, // [data_size * data_size]
data_width, // int data_width, // = 2 * transform_size - 1;
center_row, // int center_row,
ixcenter, // int ixcenter, // integer center x
this.corr_wndy_notch, // double [] window_y, // (half) window function in y-direction(perpendicular to disparity: for row0 ==1
this.corr_wndx, // double [] window_x, // half of a window function in x (disparity) direction
debug); // boolean debug);
}
@Deprecated
public double [] getMaxXCm( // get fractional center as a "center of mass" inside circle/square from the integer max // not used in lwir
double [] data, // [data_size * data_size]
int ixcenter, // integer center x
boolean debug) {
return getMaxXCm( // get fractional center as a "center of mass" inside circle/square from the integer max // not used in lwir
data, // [data_size * data_size]
2 * transform_size - 1, // int data_width,
transform_size - 1, // int center_row,
ixcenter, // integer center x
debug);
}
@Deprecated
public double [] getMaxXCmNotch( // get fractional center as a "center of mass" inside circle/square from the integer max // not used in lwir
double [] data, // [data_size * data_size]
int ixcenter, // integer center x
boolean debug) {
return getMaxXCmNotch( // get fractional center as a "center of mass" inside circle/square from the integer max // not used in lwir
data, // [data_size * data_size]
2 * transform_size - 1, // int data_width,
transform_size - 1, // int center_row,
ixcenter, // integer center x
debug);
}
// No shift by 0.5 for 2021
public double [] getMaxXCm( // get fractional center as a "center of mass" inside circle/square from the integer max // USED in lwir
double [] data, // rectangular strip of 1/2 of the correlation are with odd rows shifted by 1/2 pixels
int data_width, // = 2 * transform_size - 1;
int center_row,
int ixcenter, // integer center x
double [] window_y, // (half) window function in y-direction(perpendicular to disparity: for row0 ==1
double [] window_x, // half of a window function in x (disparity) direction
boolean debug) {
int center = transform_size - 1;
int data_width = 2 * transform_size - 1;
int data_height = data.length/data_width;
double wy_scale = 1.0;
int center_x = (data_width - 1)/2; // = transform_size - 1;
int x0 = center_x + ixcenter; // index of the argmax, starting with 0
// int data_width = 2 * transform_size - 1;
// int data_height = data.length/data_width;
// double wy_scale = 1.0;
/*
if (data_height > window_y.length) {
data_height = window_y.length;
} else if (data_height < window_y.length) { // re- // not used in lwir
......@@ -2148,70 +2195,58 @@ public class Correlation2d {
for (int i = 1; i < data_height; i++) swy += window_y[i];
wy_scale = 1.0/swy;
}
double [][]dbg_data = null;
if (debug) {
String [] dbg_titles = {"strip","*wnd_y"};
dbg_data = new double [2][];
dbg_data[0] = debugStrip3(data);
double [] data_0 = data.clone();
*/
double w_scale = 1.0;
if ((center_row + window_y.length > data_height) || (center_row - window_y.length < 0)) {
double sw = 0.0;
for (int i = 0; i < data_height; i++) {
for (int j = 0; j < data_width; j++) {
data_0[i * data_width + j] *= (i < window_y.length) ? (wy_scale * window_y[i]): 0.0;
int dy = i - center_row;
int ady = (dy > 0) ? dy : -dy;
if (ady < window_y.length) {
sw += window_y[ady];
}
}
dbg_data[1] = debugStrip3(data_0);
int long_width = 2 * (2 * transform_size-1);
if (dbg_data[0] != null) {
(new ShowDoubleFloatArrays()).showArrays(
dbg_data,
long_width,
dbg_data[0].length/long_width,
true,
"Strip",
dbg_titles);
}
w_scale /= sw;
}
System.out.println("getMaxXCm(), ixcenter = "+ixcenter);
for (int dy = 0; dy < data_height; dy++) {
if ((dy & 1) != 0) System.out.print(" ");
for (int dx = 0; dx < data_width; dx++) {
System.out.print(String.format(" %8.5f", data[dy * data_width + dx]));
if ((x0 + window_x.length > data_width) || (x0 - window_x.length < 0)) {
double sw = 0.0;
for (int i = 0; i < data_width; i++) {
int dx = i - x0;
int adx = (dx > 0) ? dx : -dx;
if (adx < window_x.length) {
sw += window_x[adx];
}
System.out.println();
}
System.out.println();
w_scale /= sw;
}
// double [][]dbg_data = null;
double s0=0.0, sx=0.0, sx2 = 0.0;
int x0 = center + ixcenter; // index of the argmax, starting with 0
for (int dy = 0; dy < data_height; dy++) {
int odd = dy & 1;
double wy = ((dy == 0)? wy_scale: (2.0 * wy_scale))*window_y[dy];
int indx0 = data_width * dy;
for (int adx = odd; adx < window_x.length; adx+=2) { // index in window_x
for (int dir = (adx == 0)?1:-1; dir <= 1; dir+=2) {
// calculate data index
int idx = (adx * dir) >> 1;
int x = 2 * idx + odd;
int x1 = x0 + idx; // correct
if (debug) System.out.print(String.format(" %2d:%2d:%d %3d", dy,adx,dir,x));
if ((x1 >= 0 ) && (x1 < data_width)) {
double d = data[indx0+x1];
/// if (!Double.isNaN(d)) {
for (int iy = 0; iy < data_height; iy++) {
int dy = iy - center_row;
int ady = (dy > 0) ? dy : -dy;
if (ady < window_y.length) {
double wy = w_scale * window_y[ady];
int indx0 = data_width * iy;
for (int ix = 0; ix < data_width; ix++) {
int dx = ix - x0; // 0 at argmax
int adx = (dx > 0) ? dx : -dx;
if (adx < window_x.length) {
double d = data[indx0 + ix];
if (debug) System.out.print(String.format(" %2d:%2d:%8.5f ", dy, dx, d));
if (!Double.isNaN(d) && (d > 0.0)) { // with negative d s0 can get very low value (or even negative)
d*= wy*window_x[adx];
s0+= d;
sx += d * x; // result x is twice larger (corresponds to window_x)
sx2 += d * x * x;
if (debug) System.out.print(String.format("%8.5f", data[indx0+x1])); //d));
}
} else {
if (debug) System.out.print("********");
double w = wy * window_x[adx];
d*= w;
s0+= d;
sx += d * dx;
sx2 += d * dx * dx;
}
}
}
}
if (debug) System.out.println();
}
if (debug){
System.out.println("getMaxXCm() -> s0="+s0+", sx="+sx+", sx2="+sx2+", ixcenter="+ixcenter);
......@@ -2220,16 +2255,16 @@ public class Correlation2d {
if (s0 == 0.0) return null;
double [] rslt = {
ixcenter + sx/s0/2, // new center in disparity units, relative to the correlation center
s0, // total "weight"
Math.sqrt(s0*sx2 - sx*sx)/s0/2}; // standard deviation in disparity units (divide weight by the standard deviation for quality?)
(ixcenter + sx/s0)* mcorr_comb_disp, // /2, // new center in disparity units, relative to the correlation center
s0, // total "weight"
(Math.sqrt(s0*sx2 - sx*sx)/s0)* mcorr_comb_disp}; // /2}; // standard deviation in disparity units (divide weight by the standard deviation for quality?)
if (debug){
System.out.println("getMaxXCm() -> "+rslt[0]+"/"+rslt[1]+"/"+rslt[2]);
}
return rslt;
}
/*
public double [] getMaxXCm( // get fractional center as a "center of mass" inside circle/square from the integer max // USED in lwir
double [] data, // rectangular strip of 1/2 of the correlation are with odd rows shifted by 1/2 pixels
int center, // = transform_size - 1;
......@@ -2328,7 +2363,7 @@ public class Correlation2d {
}
return rslt;
}
*/
......
......@@ -225,19 +225,26 @@ public class ImageDtt extends ImageDttCPU {
boolean need_corr = (clt_mismatch != null) || (fcorr_combo_td !=null) || (fcorr_td !=null) ; // (not the only reason)
// skipping DISPARITY_VARIATIONS_INDEX - it was not used
if (disparity_map != null){
for (int i = 0; i<disparity_map.length;i++) if ((disparity_modes & (1 << i)) != 0){
if ((i == OVEREXPOSED) && (saturation_imp == null)) {
continue;
}
disparity_map[i] = new double [tilesY*tilesX];
if ((i >= IMG_TONE_RGB) || ((i >= IMG_DIFF0_INDEX) && (i < (IMG_DIFF0_INDEX + 4)))) {
for (int i = 0; i<disparity_map.length;i++) {
if (isSliceBit(i) && ((disparity_modes & (1 << i)) != 0)) {
if ((i == OVEREXPOSED) && (saturation_imp == null)) {
continue;
}
disparity_map[i] = new double [tilesY*tilesX];
if (isCorrBit (i)) {
need_corr = true;
}
} else if (isDiffIndex(i) && needImgDiffs(disparity_modes)){
disparity_map[i] = new double [tilesY*tilesX];
need_macro = true;
} else if (isToneRGBIndex(i) && needTonesRGB(disparity_modes)){
disparity_map[i] = new double [tilesY*tilesX];
need_macro = true;
}
if (i <=DISPARITY_STRENGTH_INDEX) {
need_corr = true;
}
}
}
if (clt_mismatch != null){
for (int i = 0; i<clt_mismatch.length;i++){
......@@ -373,11 +380,12 @@ public class ImageDtt extends ImageDttCPU {
dust_remove, // boolean dust_remove, // Do not reduce average weight when only one image differs much from the average
false, // boolean calc_textures,
true); // boolean calc_extra)
float [][] extra = gpuQuad.getExtra();
float [][] extra = gpuQuad.getExtra(); // now 4*numSensors
int num_cams = gpuQuad.getNumCams();
for (int ncam = 0; ncam < num_cams; ncam++) {
int indx = ncam + IMG_DIFF0_INDEX;
if ((disparity_modes & (1 << indx)) != 0){
// if ((disparity_modes & (1 << indx)) != 0){
if (needImgDiffs(disparity_modes)){
disparity_map[indx] = new double [extra[ncam].length];
for (int i = 0; i < extra[ncam].length; i++) {
disparity_map[indx][i] = extra[ncam][i];
......@@ -386,6 +394,7 @@ public class ImageDtt extends ImageDttCPU {
}
for (int nc = 0; nc < (extra.length - num_cams); nc++) {
int sindx = nc + num_cams;
/*
int indx = nc + IMG_TONE_RGB;
if ((disparity_modes & (1 << indx)) != 0){
disparity_map[indx] = new double [extra[sindx].length];
......@@ -393,6 +402,17 @@ public class ImageDtt extends ImageDttCPU {
disparity_map[indx][i] = extra[sindx][i];
}
}
*/
int indx = nc + getImgToneRGB(); // IMG_TONE_RGB;
// if ((disparity_modes & (1 << indx)) != 0){
if (needTonesRGB(disparity_modes)){
disparity_map[indx] = new double [extra[sindx].length];
for (int i = 0; i < extra[sindx].length; i++) {
disparity_map[indx][i] = extra[sindx][i];
}
}
}
}
// does it need non-overlapping texture tiles
......@@ -1019,6 +1039,7 @@ public class ImageDtt extends ImageDttCPU {
boolean need_macro = false;
boolean need_corr = (clt_mismatch != null) || (fcorr_combo_td !=null) || (fcorr_td !=null) ; // (not the only reason)
// skipping DISPARITY_VARIATIONS_INDEX - it was not used
/*
if (disparity_map != null){
for (int i = 0; i<disparity_map.length;i++) if ((disparity_modes & (1 << i)) != 0){
if ((i == OVEREXPOSED) && (saturation_imp == null)) {
......@@ -1033,6 +1054,28 @@ public class ImageDtt extends ImageDttCPU {
}
}
}
*/
if (disparity_map != null){
for (int i = 0; i<disparity_map.length;i++) {
if (isSliceBit(i) && ((disparity_modes & (1 << i)) != 0)) {
if ((i == OVEREXPOSED) && (saturation_imp == null)) {
continue;
}
disparity_map[i] = new double [tilesY*tilesX];
if (isCorrBit (i)) {
need_corr = true;
}
} else if (isDiffIndex(i) && needImgDiffs(disparity_modes)){
disparity_map[i] = new double [tilesY*tilesX];
need_macro = true;
} else if (isToneRGBIndex(i) && needTonesRGB(disparity_modes)){
disparity_map[i] = new double [tilesY*tilesX];
need_macro = true;
}
}
}
if (clt_mismatch != null){
for (int i = 0; i<clt_mismatch.length;i++){
......@@ -1201,7 +1244,8 @@ public class ImageDtt extends ImageDttCPU {
int num_cams = gpuQuad.getNumCams();
for (int ncam = 0; ncam < num_cams; ncam++) {
int indx = ncam + IMG_DIFF0_INDEX;
if ((disparity_modes & (1 << indx)) != 0){
// if ((disparity_modes & (1 << indx)) != 0){
if (needImgDiffs(disparity_modes)){
disparity_map[indx] = new double [extra[ncam].length];
for (int i = 0; i < extra[ncam].length; i++) {
disparity_map[indx][i] = extra[ncam][i];
......@@ -1210,8 +1254,9 @@ public class ImageDtt extends ImageDttCPU {
}
for (int nc = 0; nc < (extra.length - num_cams); nc++) {
int sindx = nc + num_cams;
int indx = nc + IMG_TONE_RGB;
if ((disparity_modes & (1 << indx)) != 0){
int indx = nc + getImgToneRGB(); // IMG_TONE_RGB;
// if ((disparity_modes & (1 << indx)) != 0){
if (needTonesRGB(disparity_modes)){
disparity_map[indx] = new double [extra[sindx].length];
for (int i = 0; i < extra[sindx].length; i++) {
disparity_map[indx][i] = extra[sindx][i];
......
......@@ -99,9 +99,40 @@ public class ImageDttCPU {
static int DISPARITY_INDEX_POLY = 8; // index of disparity value in disparity_map == 2 (0,2 or 4)
static int DISPARITY_STRENGTH_INDEX = 10; // index of strength data in disparity map ==6
static int DISPARITY_VARIATIONS_INDEX = 11; // index of strength data in disparity map ==6
static int IMG_DIFF0_INDEX = 12; // index of noise- normalized image difference for port 0 in disparity map
static int OVEREXPOSED = 16; // index of overexposed fraction of all pixels
static int IMG_TONE_RGB = 17; // 12 entries of r0,r1,r2,r3,g0,g1,g2,g3,b0,b1,b2,b3
// static int IMG_DIFF0_INDEX = 12; // index of noise- normalized image difference for port 0 in disparity map
// static int OVEREXPOSED = 16; // index of overexposed fraction of all pixels
static int OVEREXPOSED = 12; // index of overexposed fraction of all pixels
static int IMG_DIFF0_INDEX = 13; // index of noise- normalized image difference for port 0 in disparity map
// static int IMG_TONE_RGB = 17; // 12 entries of r0,r1,r2,r3,g0,g1,g2,g3,b0,b1,b2,b3
static int IMG_DIFFS = 16;
static int IMG_TONES_RGB = 17;
static boolean isCorrBit (int indx) {
return indx <= DISPARITY_STRENGTH_INDEX; // maybe use DISPARITY_VARIATIONS_INDEX?
}
static boolean isSliceBit(int indx) {
return indx < IMG_DIFFS;
}
static int getImgToneRGB(int numSensors) {
return IMG_DIFF0_INDEX + numSensors;
}
static boolean needImgDiffs(int mode) {
return ((mode >> IMG_DIFFS) & 1) != 0;
}
static boolean needTonesRGB(int mode) {
return ((mode >> IMG_TONES_RGB) & 1) != 0;
}
public boolean isDiffIndex(int indx) {
return (indx >= IMG_DIFF0_INDEX) && (indx < (IMG_DIFF0_INDEX + numSensors));
}
public boolean isToneRGBIndex(int indx) {
return (indx >= (IMG_DIFF0_INDEX + numSensors)) && (indx < (IMG_DIFF0_INDEX + 4 * numSensors));
}
public int getImgToneRGB() {
return getImgToneRGB(numSensors);
}
// remove when not needed
static int BITS_ALL_DISPARITIES = (
(3 << DISPARITY_INDEX_INT) | // 0 - disparity from correlation integer pixels, 1 - ortho
......@@ -113,20 +144,45 @@ public class ImageDttCPU {
(3 << DISPARITY_INDEX_POLY) | // 8; // index of disparity value in disparity_map == 2 (0,2 or 4)
(1 << DISPARITY_STRENGTH_INDEX) | // 10; // index of strength data in disparity map ==6
(1 << DISPARITY_VARIATIONS_INDEX)); // 11; // index of strength data in disparity map ==6
static int BITS_ALL_DIFFS = (0xf << IMG_DIFF0_INDEX);
// TODO - use 1 bit per type
static int BITS_OVEREXPOSED = (1 << OVEREXPOSED);
/*
static int BITS_ALL_DIFFS = (0xf << IMG_DIFF0_INDEX);
static int BITS_TONE_RGB = (0xfff << IMG_TONE_RGB);
static int BITS_FROM_GPU = BITS_ALL_DIFFS | BITS_TONE_RGB;
*/
// TODO: modify decoding of bits - turns on/off all channels simultaneously
static int BITS_ALL_DIFFS = (0x1 << IMG_DIFFS);
static int BITS_TONE_RGB = (0x1 << IMG_TONES_RGB);
static int BITS_FROM_GPU = BITS_ALL_DIFFS | BITS_TONE_RGB;
static String [] DISPARITY_TITLES = {
static String [] DISPARITY_TITLES4 = {
"int_disp","int_y_disp","cm_disp","cm_y_disp","hor_disp","hor_strength","vert_disp","vert_strength",
"poly_disp", "poly_y_disp", "strength_disp", "vary_disp","diff0","diff1","diff2","diff3","overexp",
"poly_disp", "poly_y_disp", "strength_disp", "vary_disp","overexp","diff0","diff1","diff2","diff3",
"r0","r1","r2","r3",
"g0","g1","g2","g3",
"b0","b1","b2","b3",
};
static String [] getDisparityTitles(int numSensors) {
String [] disparity_titles0 = {
"int_disp","int_y_disp","cm_disp","cm_y_disp","hor_disp","hor_strength","vert_disp","vert_strength",
"poly_disp", "poly_y_disp", "strength_disp", "vary_disp","overexp"};
String [] disparity_titles = new String [disparity_titles0.length + 4* numSensors];
int indx = 0;
for (String s: disparity_titles0) {
disparity_titles[indx++] = s;
}
for (int i = 0; i < numSensors; i++) disparity_titles[indx++] = "diff"+i;
for (int i = 0; i < numSensors; i++) disparity_titles[indx++] = "r"+i;
for (int i = 0; i < numSensors; i++) disparity_titles[indx++] = "b"+i;
for (int i = 0; i < numSensors; i++) disparity_titles[indx++] = "g"+i;
return disparity_titles;
}
String [] getDisparityTitles() {
return getDisparityTitles(numSensors);
}
static public String[] CORR_TITLES = {
"top","bottom","left","right","diag-m","diag-o",
"quad","cross","hor","vert",
......@@ -313,7 +369,7 @@ public class ImageDttCPU {
this.numSensors, // int numSensors,
this.imgdtt_params, // ImageDttParameters imgdtt_params,
this.transform_size, // int transform_size,
2.0, // double wndx_scale, // (wndy scale is always 1.0)
1.0, // 2.0, // double wndx_scale, // (wndy scale is always 1.0)
this.monochrome, // boolean monochrome,
false); // boolean debug)
}
......@@ -1745,12 +1801,13 @@ public class ImageDttCPU {
// add optional initialization of debug layers here
if (disparity_map != null){
for (int i = 0; i<disparity_map.length;i++){
if (i < OVEREXPOSED) {
disparity_map[i] = new double [tilesY*tilesX];
} else if (i == OVEREXPOSED) {
if (i == OVEREXPOSED) {
if (saturation_imp!= null) {
disparity_map[i] = new double [tilesY*tilesX];
disparity_map[i] = new double [tilesY*tilesX];
}
// } else if (i < OVEREXPOSED) { // includes diffs?
} else if (isSliceBit(i)) { // includes diffs?
disparity_map[i] = new double [tilesY*tilesX];
}
}
}
......@@ -2704,10 +2761,9 @@ public class ImageDttCPU {
System.out.println("max_search_radius_poly="+max_search_radius_poly);
System.out.println("corr_fat_zero= "+corr_fat_zero);
System.out.println("disparity_array[0][0]= "+disparity_array[0][0]);
}
// add optional initialization of debug layers here
/*
if (disparity_map != null){
for (int i = 0; i<disparity_map.length;i++){
if (i < OVEREXPOSED) {
......@@ -2723,6 +2779,24 @@ public class ImageDttCPU {
}
}
}
*/
if (disparity_map != null){
for (int i = 0; i<disparity_map.length;i++){
if (i == OVEREXPOSED) {
if (saturation_imp!= null) {
disparity_map[i] = new double [tilesY*tilesX];
}
} else if (isSliceBit(i)) {
disparity_map[i] = new double [tilesY*tilesX];
} else if (isDiffIndex(i)) {
disparity_map[i] = new double [tilesY*tilesX];
} else if (isToneRGBIndex(i)) {
if (texture_tiles != null) { // for now - enable 12 tone layers only together with texture tiles
disparity_map[i] = new double [tilesY*tilesX];
}
}
}
}
DttRad2 dtt = new DttRad2(transform_size);
dtt.set_window(window_type);
final double [] lt_window = dtt.getWin2d(); // [256]
......@@ -3175,8 +3249,13 @@ public class ImageDttCPU {
imgdtt_params.min_corr, // double minMax, // minimal value to consider (at integer location, not interpolated)
tile_lma_debug_level > 0); // boolean debug);
*/
if (debugTile0) {
System.out.println("tileX = "+tileX+", tileY = "+tileY);
}
double [] disp_str_int = new double[2];
int [] ixy = correlation2d.getMaxXYInt( // find integer pair or null if below threshold // USED in lwir
corr_combo_max, // double [] data, // [data_size * data_size]
disp_str_int,
correlation2d.getCombWidth(), // data_width,
correlation2d.getCombHeight()/2 - correlation2d.getCombOffset(), // int center_row, ??????????????
true, // boolean axis_only,
......@@ -3184,55 +3263,66 @@ public class ImageDttCPU {
tile_lma_debug_level > 0); // boolean debug);
double [] corr_stat = null;
/*
// if integer argmax was strong enough, calculate CM argmax
// will not fill out DISPARITY_INDEX_INT+1, DISPARITY_INDEX_CM+1, DISPARITY_INDEX_POLY+1
// use clt_mismatch for that
double [] disp_str = new double[2];
if (ixy != null) { //TODO - for CM use magic!
disp_str[1] = strip_combo[ixy[0]+transform_size-1]; // strength at integer max on axis
disparity_map[DISPARITY_INDEX_INT][tIndex] = -ixy[0];
// disp_str[1] = strip_combo[ixy[0]+transform_size-1]; // strength at integer max on axis
disp_str = disp_str_int;
disparity_map[DISPARITY_INDEX_INT][tIndex] = disp_str[0]; // -ixy[0];
disparity_map[DISPARITY_STRENGTH_INDEX][tIndex] = disp_str[1];
if (Double.isNaN(disparity_map[DISPARITY_STRENGTH_INDEX][tIndex])) {
System.out.println("BUG: 1. disparity_map[DISPARITY_STRENGTH_INDEX]["+tIndex+"] should not be NaN");
}
corr_stat = corr2d.getMaxXCm( // get fractional center as a "center of mass" inside circle/square from the integer max
strip_combo, // double [] data, // [data_size * data_size]
ixy[0], // int ixcenter, // integer center x
corr_stat = correlation2d.getMaxXCm( // get fractional center as a "center of mass" inside circle/square from the integer max
corr_combo_max, // double [] data, // [data_size * data_size]
correlation2d.getCombWidth(), // int data_width, // = 2 * transform_size - 1;
correlation2d.getCombHeight()/2 - correlation2d.getCombOffset(),// int center_row,
ixy[0], // int ixcenter, // integer center x
// corr_wndy, // double [] window_y, // (half) window function in y-direction(perpendicular to disparity: for row0 ==1
// corr_wndx, // double [] window_x, // half of a window function in x (disparity) direction
(tile_lma_debug_level > 0)); // boolean debug);
if (corr_stat != null) {
disparity_map[DISPARITY_INDEX_CM][tIndex] = -corr_stat[0]; // -ixy[0];
disparity_map[DISPARITY_STRENGTH_INDEX][tIndex] = corr_stat[1];
}
}
double [] corr_combo_hor = corr_combo[Correlation2d.MCORR_COMB.HOR.ordinal()];
double [] corr_combo_vert = corr_combo[Correlation2d.MCORR_COMB.VERT.ordinal()];
if (imgdtt_params.pcorr_use_hv) { // use combined horizontal and vertical pairs (vertical not transposed)
// for compatibility with old code executed unconditionally. TODO: Move to if (corr_stat != null) ... condition below
double [] hor_pair1 = corr2d.getMaxXSOrtho(
corrs, // double [][] correlations,
0x100, // corrs[8] Correlation2d.getMaskHorizontal(1), // int pairs_mask,
imgdtt_params.corr_offset, // double corr_offset,
true, // boolean symmetric, // for comparing with old implementation average with symmetrical before multiplication
false, // boolean is_vert, // transpose X/Y
tile_lma_debug_level > 0); // boolean debug);
if (hor_pair1 != null) {
disparity_map[DISPARITY_INDEX_HOR][tIndex] = -hor_pair1[0];
disparity_map[DISPARITY_INDEX_HOR_STRENGTH][tIndex] = hor_pair1[1];
}
if ((corr_combo_hor != null) && (ixy != null)) {
double [] hor_pair1 = correlation2d.getMaxXCmNotch(
corr_combo_hor, // double [] data, // [data_size * data_size]
correlation2d.getCombWidth(), // int data_width, // = 2 * transform_size - 1;
correlation2d.getCombHeight()/2 - correlation2d.getCombOffset(),// int center_row,
ixy[0], // int ixcenter, // integer center x
(tile_lma_debug_level > 0)); // boolean debug);
if (hor_pair1 != null) {
disparity_map[DISPARITY_INDEX_HOR][tIndex] = -hor_pair1[0];
disparity_map[DISPARITY_INDEX_HOR_STRENGTH][tIndex] = hor_pair1[1];
}
double [] vert_pair1 = corr2d.getMaxXSOrtho(
corrs, // double [][] correlations,
0x200, // corrs[9] Correlation2d.getMaskVertical(1), // int pairs_mask,
imgdtt_params.corr_offset, // double corr_offset,
true, // boolean symmetric, // for comparing with old implementation average with symmetrical before multiplication
// change to true, un-rotate source
true, // false, // already transposed // true, // boolean is_vert, // transpose X/Y
tile_lma_debug_level > 0); // boolean debug);
if (vert_pair1 != null) {
disparity_map[DISPARITY_INDEX_VERT][tIndex] = -vert_pair1[0];
disparity_map[DISPARITY_INDEX_VERT_STRENGTH][tIndex] = vert_pair1[1];
}
if ((corr_combo_vert != null) && (ixy != null)) {
double [] vert_pair1 = correlation2d.getMaxXCmNotch(
corr_combo_vert, // double [] data, // [data_size * data_size]
correlation2d.getCombWidth(), // int data_width, // = 2 * transform_size - 1;
correlation2d.getCombHeight()/2 - correlation2d.getCombOffset(),// int center_row,
ixy[0], // int ixcenter, // integer center x
(tile_lma_debug_level > 0)); // boolean debug);
if (vert_pair1 != null) {
disparity_map[DISPARITY_INDEX_VERT][tIndex] = -vert_pair1[0];
disparity_map[DISPARITY_INDEX_VERT_STRENGTH][tIndex] = vert_pair1[1];
}
}
} else {
// for compatibility with old code executed unconditionally. TODO: Move to if (corr_stat != null) ... condition below
/*
double [] hor_pair1 = corr2d.getMaxXSOrtho(
corrs, // double [][] correlations,
Correlation2d.getMaskHorizontal(1), // int pairs_mask,
......@@ -3256,9 +3346,9 @@ public class ImageDttCPU {
disparity_map[DISPARITY_INDEX_VERT][tIndex] = -vert_pair1[0];
disparity_map[DISPARITY_INDEX_VERT_STRENGTH][tIndex] = vert_pair1[1];
}
*/
}
/*
// proceed only if CM correlation result is non-null // for compatibility with old code we need it to run regardless of the strength of the normal correlation
if (corr_stat != null) {
// skipping DISPARITY_VARIATIONS_INDEX - it was not used
......@@ -3864,7 +3954,7 @@ public class ImageDttCPU {
max_diff = new double[numSensors];
}
int ports_rgb_len = numSensors*numcol; // 12
if ((disparity_map != null) && (disparity_map.length >= (IMG_TONE_RGB + ports_rgb_len))) {
if ((disparity_map != null) && (disparity_map.length >= (getImgToneRGB() + ports_rgb_len))) {
ports_rgb = new double[ports_rgb_len];
}
texture_tiles[tileY][tileX] = tile_combine_rgba(
......@@ -3906,7 +3996,7 @@ public class ImageDttCPU {
}
if (ports_rgb != null) {
for (int i = 0; i < ports_rgb.length; i++){
disparity_map[IMG_TONE_RGB + i][tIndex] = ports_rgb[i];
disparity_map[getImgToneRGB() + i][tIndex] = ports_rgb[i];
}
}
}
......@@ -10380,7 +10470,7 @@ public class ImageDttCPU {
final int debug_tileY = clt_parameters.tileY;
final int quad_main = image_data_main.length; // number of subcameras
final int quad_aux = image_data_aux.length; // number of subcameras
final int quad = 4; // number of subcameras
final int quad = getNumSensors(); // 4; // number of subcameras
final int numcol = 3; // number of colors
final int nChn = image_data_main[0].length;
final int height=image_data_main[0][0].length/width;
......@@ -10444,6 +10534,7 @@ public class ImageDttCPU {
// add optional initialization of debug layers here
/*
if (disparity_map != null){
for (int i = 0; i<disparity_map.length;i++){
if (i < OVEREXPOSED) {
......@@ -10459,7 +10550,27 @@ public class ImageDttCPU {
}
}
}
*/
if (disparity_map != null){
for (int i = 0; i<disparity_map.length;i++){
if (i == OVEREXPOSED) {
// if (saturation_imp!= null) {
// disparity_map[i] = new double [tilesY*tilesX];
// }
} else if (isSliceBit(i)) {
disparity_map[i] = new double [tilesY*tilesX];
} else if (isDiffIndex(i)) {
disparity_map[i] = new double [tilesY*tilesX];
} else if (isToneRGBIndex(i)) {
// if (texture_tiles != null) { // for now - enable 12 tone layers only together with texture tiles
disparity_map[i] = new double [tilesY*tilesX];
// }
}
}
}
......@@ -11029,7 +11140,7 @@ public class ImageDttCPU {
double [] ports_rgb = null;
int ports_rgb_len = quad*numcol; // 12
if ((disparity_map != null) && (disparity_map.length >= (IMG_TONE_RGB + ports_rgb_len))) {
if ((disparity_map != null) && (disparity_map.length >= (getImgToneRGB() + ports_rgb_len))) {
ports_rgb = new double[ports_rgb_len];
}
......@@ -11105,7 +11216,7 @@ public class ImageDttCPU {
}
if (ports_rgb != null) {
for (int i = 0; i < ports_rgb.length; i++){
disparity_map[IMG_TONE_RGB + i][tIndex] = ports_rgb[i];
disparity_map[getImgToneRGB() + i][tIndex] = ports_rgb[i];
}
}
......@@ -12505,6 +12616,7 @@ public class ImageDttCPU {
}
// add optional initialization of debug layers here
/*
if (disparity_map != null){
for (int i = 0; i<disparity_map.length;i++){
if (i < OVEREXPOSED) {
......@@ -12520,6 +12632,28 @@ public class ImageDttCPU {
}
}
}
*/
if (disparity_map != null){
for (int i = 0; i<disparity_map.length;i++){
if (i == OVEREXPOSED) {
if (saturation_imp!= null) {
disparity_map[i] = new double [tilesY*tilesX];
}
} else if (isSliceBit(i)) {
disparity_map[i] = new double [tilesY*tilesX];
} else if (isDiffIndex(i)) {
disparity_map[i] = new double [tilesY*tilesX];
} else if (isToneRGBIndex(i)) {
if (texture_tiles != null) { // for now - enable 12 tone layers only together with texture tiles
disparity_map[i] = new double [tilesY*tilesX];
}
}
}
}
if (clt_mismatch != null){
for (int i = 0; i<clt_mismatch.length;i++){
clt_mismatch[i] = new double [tilesY*tilesX]; // will use only "center of mass" centers
......@@ -13832,7 +13966,7 @@ public class ImageDttCPU {
max_diff = new double[numSensors];
}
int ports_rgb_len = numSensors*numcol; // 12
if ((disparity_map != null) && (disparity_map.length >= (IMG_TONE_RGB + ports_rgb_len))) {
if ((disparity_map != null) && (disparity_map.length >= (getImgToneRGB() + ports_rgb_len))) {
ports_rgb = new double[ports_rgb_len];
}
texture_tiles[tileY][tileX] = tile_combine_rgba(
......@@ -13874,7 +14008,7 @@ public class ImageDttCPU {
}
if (ports_rgb != null) {
for (int i = 0; i < ports_rgb.length; i++){
disparity_map[IMG_TONE_RGB + i][tIndex] = ports_rgb[i];
disparity_map[getImgToneRGB() + i][tIndex] = ports_rgb[i];
}
}
}
......
......@@ -62,6 +62,7 @@ public class MacroCorrelation {
mTilesY, // int tilesY,
tileSize, // int tileSize,
tp.superTileSize, // int superTileSize,
tp.getNumSensors(),
tp.isMonochrome(),
tp.isLwir(),
tp.isAux(),
......@@ -80,7 +81,7 @@ public class MacroCorrelation {
final double macro_disparity_step,
final int debugLevel){
int numSensors = geometryCorrection.getNumSensors();
double [][][] input_data = CLTMacroSetData( // perform single pass according to prepared tiles operations and disparity
src_scan); // final CLTPass3d src_scan, // results of the normal correlations (now expecting infinity)
if (debugLevel > 0) {
......@@ -144,6 +145,8 @@ public class MacroCorrelation {
final int mTilesY = (pTilesY + tileSize - 1) / tileSize;
final int mTiles = mTilesX * mTilesY;
final int num_chn = 3;
final int numSensors = tp.getNumSensors();
final int toneRGB = ImageDtt.getImgToneRGB(numSensors);
double corr_red = 0.5; // Red to green correlation weight
double corr_blue = 0.2; // Blue to green correlation weight
double [] col_weights = new double[3];
......@@ -152,10 +155,10 @@ public class MacroCorrelation {
col_weights[1] = corr_blue * col_weights[2];
final double [][][] input_data = new double [ImageDtt.QUAD][num_chn][mTiles*tileSize*tileSize];
final int INDX_R0 = ImageDtt.IMG_TONE_RGB;
final int INDX_B0 = ImageDtt.IMG_TONE_RGB + ImageDtt.QUAD;
final int INDX_G0 = ImageDtt.IMG_TONE_RGB + 2 * ImageDtt.QUAD;
final double [][][] input_data = new double [numSensors][num_chn][mTiles*tileSize*tileSize];
final int INDX_R0 = toneRGB;
final int INDX_B0 = toneRGB + numSensors;
final int INDX_G0 = toneRGB + 2 * numSensors;
for (int sub_cam =0; sub_cam < input_data.length; sub_cam++){
for (int pty = 0; pty < pTilesY; pty++){
......@@ -279,34 +282,14 @@ public class MacroCorrelation {
}
double min_corr_selected = clt_parameters.min_corr;
double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging)
// double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging)
double [][] disparity_map = new double [ImageDtt.getDisparityTitles(geometryCorrection.getNumSensors()).length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging)
double [][] shiftXY = {{0.0,0.0},{0.0,0.0},{0.0,0.0},{0.0,0.0}};
double [][][][] clt_corr_combo = null; // new double [ImageDtt.TCORR_TITLES.length][mTilesY][mTilesX][]; // needed always
double [][][][][] clt_corr_partial = null; // [tp.tilesY][tp.tilesX][pair][color][(2*transform_size-1)*(2*transform_size-1)]
/*
if (show_corr_partial) {
clt_corr_partial = new double [mTilesY][mTilesX][][][];
for (int i = 0; i < mTilesY; i++){
for (int j = 0; j < mTilesX; j++){
clt_corr_partial[i][j] = null;
}
}
}
if (show_corr_combo) {
clt_corr_combo = new double [ImageDtt.TCORR_TITLES.length][mTilesY][mTilesX][]; // needed always
for (int i = 0; i < mTilesY; i++){
for (int j = 0; j < mTilesX; j++){
for (int k = 0; k<clt_corr_combo.length; k++){
clt_corr_combo[k][i][j] = null;
}
}
}
}
*/
ImageDtt image_dtt = new ImageDtt(
geometryCorrection.getNumSensors(),
......
......@@ -3227,7 +3227,7 @@ public class OpticalFlow {
tilesY,
true,
"accumulated_disparity_map-"+nrefine,
ImageDtt.DISPARITY_TITLES
ImageDtt.getDisparityTitles(ref_scene.getNumSensors()) // ImageDtt.DISPARITY_TITLES
);
// update disparities
final int disparity_index = ImageDtt.DISPARITY_INDEX_CM; // 2
......@@ -3426,7 +3426,7 @@ public class OpticalFlow {
tilesY,
true,
"accumulated_disparity_map-"+nrefine,
ImageDtt.DISPARITY_TITLES
ImageDtt.getDisparityTitles(ref_scene.getNumSensors()) // ImageDtt.DISPARITY_TITLES
);
}
// update disparities
......@@ -3637,7 +3637,7 @@ public class OpticalFlow {
tilesY,
true,
"accumulated_disparity_map-"+nrefine,
ImageDtt.DISPARITY_TITLES
ImageDtt.getDisparityTitles(ref_scene.getNumSensors()) // ImageDtt.DISPARITY_TITLES
);
}
// update disparities
......@@ -3907,7 +3907,7 @@ public class OpticalFlow {
ref_scene.isLwir(),
clt_parameters.getScaleStrength(ref_scene.isAux()),
ref_scene.getGPU());
double[][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
double[][] disparity_map = new double [image_dtt.getDisparityTitles().length][];
int disparity_modes =
ImageDtt.BITS_ALL_DISPARITIES |
......@@ -4818,7 +4818,7 @@ public class OpticalFlow {
ref_scene.isLwir(),
clt_parameters.getScaleStrength(ref_scene.isAux()),
ref_scene.getGPU());
double[][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
double[][] disparity_map = new double [image_dtt.getDisparityTitles().length][];
int disparity_modes =
ImageDtt.BITS_ALL_DISPARITIES |
......
......@@ -3009,10 +3009,10 @@ public class QuadCLT extends QuadCLTCPU {
// undecided, so 2 modes of combining alpha - same as rgb, or use center tile only
double [][][][] clt_corr_combo = new double [ImageDtt.TCORR_TITLES.length][tilesY][tilesX][]; // will only be used inside?
// double min_corr_selected = clt_parameters.min_corr; // 0.02 was not used !
// yes, needed (for macro)
double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging)
//if ((i >= IMG_TONE_RGB) || ((i >= IMG_DIFF0_INDEX) && (i < (IMG_DIFF0_INDEX + 4)))) {
// double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging)
double [][] disparity_map = new double [ImageDtt.getDisparityTitles(getNumSensors()).length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging)
/*
double [][] shiftXY = new double [4][2];
// not used
......@@ -3269,7 +3269,8 @@ public class QuadCLT extends QuadCLTCPU {
}
}
}
double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
// double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
double [][] disparity_map = new double [ImageDtt.getDisparityTitles(getNumSensors()).length][];
/*
double [][] shiftXY = new double [4][2];
// not used
......@@ -3421,7 +3422,9 @@ public class QuadCLT extends QuadCLTCPU {
}
}
}
double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
// double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
double [][] disparity_map = new double [ImageDtt.getDisparityTitles(getNumSensors()).length][];
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
......@@ -3729,8 +3732,11 @@ public class QuadCLT extends QuadCLTCPU {
}
}
double[][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
double[][] disparity_map_fake = new double [ImageDtt.DISPARITY_TITLES.length][];
// double[][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
// double[][] disparity_map_fake = new double [ImageDtt.DISPARITY_TITLES.length][];
double [][] disparity_map = new double [ImageDtt.getDisparityTitles(getNumSensors()).length][];
double [][] disparity_map_fake = new double [ImageDtt.getDisparityTitles(getNumSensors()).length][];
int disparity_modes =
ImageDtt.BITS_ALL_DISPARITIES |
ImageDtt.BITS_ALL_DIFFS | // needs max_diff?
......@@ -4134,7 +4140,8 @@ public class QuadCLT extends QuadCLTCPU {
}
}
}
double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
// double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
double [][] disparity_map = new double [ImageDtt.getDisparityTitles(getNumSensors()).length][];
/*
double [][] shiftXY = new double [4][2];
// not used
......@@ -4283,7 +4290,9 @@ public class QuadCLT extends QuadCLTCPU {
clt_corr_partial1[i][j] = null;
}
}
double [][] disparity_map1 = new double [ImageDtt.DISPARITY_TITLES.length][];
// double [][] disparity_map1 = new double [ImageDtt.DISPARITY_TITLES.length][];
double [][] disparity_map1 = new double [ImageDtt.getDisparityTitles(getNumSensors()).length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging)
float [][][][] corr_td_blur = image_dtt.blur_corr_GPU( // convert to pixel domain and process correlations already prepared in fcorr_td and/or fcorr_combo_td
// final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
......
......@@ -520,17 +520,22 @@ public class QuadCLTCPU {
if (tp == null) return null;
return tp.rig_disparity_strength;
}
public void setTiles (ImagePlus imp, // set tp.tilesX, tp.tilesY // USED in lwir
public void setTiles (
ImagePlus imp, // set tp.tilesX, tp.tilesY // USED in lwir
int numSensors,
CLTParameters clt_parameters,
int threadsMax
){
setTiles(clt_parameters,
setTiles(
numSensors,
clt_parameters,
imp.getWidth()/clt_parameters.transform_size,
imp.getHeight()/clt_parameters.transform_size,
threadsMax);
}
public void setTiles ( // USED in lwir
int numSensors,
CLTParameters clt_parameters,
int tilesX,
int tilesY,
......@@ -542,6 +547,7 @@ public class QuadCLTCPU {
tilesY,
clt_parameters.transform_size,
clt_parameters.stSize,
numSensors,
isMonochrome(),
isLwir(),
isAux(),
......@@ -4077,8 +4083,9 @@ public class QuadCLTCPU {
}
}
setTiles (imp_srcs[0], // set global tp.tilesX, tp.tilesY
clt_parameters,
threadsMax); // where to get it? Use instance member
getNumSensors(), // tp.getNumSensors(),
clt_parameters,
threadsMax); // where to get it? Use instance member
tp.setTrustedCorrelation(clt_parameters.grow_disp_trust);
tp.resetCLTPasses();
return imp_srcs;
......@@ -4674,7 +4681,8 @@ public class QuadCLTCPU {
clt_combo_dbg = new double [num_pairs][][][];
}
} // clt_parameters.corr_mismatch = false
disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging) last 4 - max pixel differences
// disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging) last 4 - max pixel differences
disparity_map = new double [ImageDtt.getDisparityTitles(getNumSensors()).length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging)
}
// Includes all 3 colors - will have zeros in unused
......@@ -4866,7 +4874,18 @@ public class QuadCLTCPU {
}
}
}
// visualize correlation results
if (disparity_map != null){
if (!batch_mode && clt_parameters.show_map && (debugLevel > -2)){
sdfa_instance.showArrays(
disparity_map,
tilesX,
tilesY,
true,
image_name+sAux()+"-DISP_MAP-D"+clt_parameters.disparity,
ImageDtt.getDisparityTitles(getNumSensors())); // ImageDtt.DISPARITY_TITLES);
}
}
/*
// visualize correlation results
......@@ -5340,7 +5359,8 @@ public class QuadCLTCPU {
} // clt_parameters.corr_mismatch = false
}
// Includes all 3 colors - will have zeros in unused
double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging) last 4 - max pixel differences
// double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging) last 4 - max pixel differences
double [][] disparity_map = new double [ImageDtt.getDisparityTitles(getNumSensors()).length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging)
double min_corr_selected = clt_parameters.min_corr;
double [][] shiftXY = new double [getNumSensors()][2];
......@@ -6176,7 +6196,8 @@ public class QuadCLTCPU {
}
}
// Includes all 3 colors - will have zeros in unused
double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging) last 4 - max pixel differences
// double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging) last 4 - max pixel differences
double [][] disparity_map = new double [ImageDtt.getDisparityTitles(getNumSensors()).length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging)
double min_corr_selected = clt_parameters.min_corr;
double [][] shiftXY = new double [4][2];
......@@ -6296,7 +6317,7 @@ public class QuadCLTCPU {
tilesY,
true,
name+sAux()+"-DISP_MAP-D"+clt_parameters.disparity,
ImageDtt.DISPARITY_TITLES);
ImageDtt.getDisparityTitles(getNumSensors()));// ImageDtt.DISPARITY_TITLES);
}
/*
if (clt_mismatch != null) {
......@@ -7342,7 +7363,9 @@ public class QuadCLTCPU {
}
}
setTiles (imp_quad[0], // set global tp.tilesX, tp.tilesY
setTiles (
imp_quad[0], // set global tp.tilesX, tp.tilesY
tp.getNumSensors(),
clt_parameters,
threadsMax);
final int tilesX = tp.getTilesX();
......@@ -7356,7 +7379,9 @@ public class QuadCLTCPU {
// undecided, so 2 modes of combining alpha - same as rgb, or use center tile only
double min_corr_selected = clt_parameters.min_corr;
double [][][] disparity_maps = new double [clt_parameters.disp_scan_count][ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging)
// double [][][] disparity_maps = new double [clt_parameters.disp_scan_count][ImageDtt.DISPARITY_TITLES.length][];
double [][][] disparity_maps = new double [clt_parameters.disp_scan_count][ImageDtt.getDisparityTitles(getNumSensors()).length][];
double [][][] clt_mismatches = new double [clt_parameters.disp_scan_count][12][];
for (int scan_step = 0; scan_step < clt_parameters.disp_scan_count; scan_step++) {
double disparity = clt_parameters.disp_scan_start + scan_step * clt_parameters.disp_scan_step;
......@@ -7556,8 +7581,8 @@ public class QuadCLTCPU {
ImageDtt.DISPARITY_STRENGTH_INDEX,
ImageDtt.DISPARITY_VARIATIONS_INDEX};
String [] disparity_titles = new String [disp_indices.length];
for (int i = 0; i < disparity_titles.length; i++ ) disparity_titles[i] = ImageDtt.DISPARITY_TITLES[i];
// for (int i = 0; i < disparity_titles.length; i++ ) disparity_titles[i] = ImageDtt.DISPARITY_TITLES[i];
for (int i = 0; i < disparity_titles.length; i++ ) disparity_titles[i] = ImageDtt.getDisparityTitles(getNumSensors())[i];
// 2,4,6,7};
String [] disparities_titles = new String [disparity_titles.length * clt_parameters.disp_scan_count];
double [][] disparities_maps = new double [disparity_titles.length * clt_parameters.disp_scan_count][];
......@@ -11618,8 +11643,8 @@ public class QuadCLTCPU {
double min_corr_selected = clt_parameters.min_corr; // 0.02
double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging)
// double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging)
double [][] disparity_map = new double [ImageDtt.getDisparityTitles(getNumSensors()).length][];
double [][] shiftXY = new double [4][2];
if (!clt_parameters.fine_corr_ignore) {
double [][] shiftXY0 = {
......@@ -11856,7 +11881,8 @@ public class QuadCLTCPU {
}
double min_corr_selected = clt_parameters.min_corr;
double [][] disparity_map = save_corr ? new double [ImageDtt.DISPARITY_TITLES.length][] : null; //[0] -residual disparity, [1] - orthogonal (just for debugging)
// double [][] disparity_map = save_corr ? new double [ImageDtt.DISPARITY_TITLES.length][] : null; //[0] -residual disparity, [1] - orthogonal (just for debugging)
double [][] disparity_map = save_corr ? new double [ImageDtt.getDisparityTitles(getNumSensors()).length][] : null; //[0] -residual disparity, [1] - orthogonal (just for debugging)
double [][] shiftXY = new double [4][2];
if (!clt_parameters.fine_corr_ignore) {
......@@ -11993,7 +12019,8 @@ public class QuadCLTCPU {
}
}
double min_corr_selected = clt_parameters.min_corr;
double [][] disparity_map = save_corr ? new double [ImageDtt.DISPARITY_TITLES.length][] : null; //[0] -residual disparity, [1] - orthogonal (just for debugging)
// double [][] disparity_map = save_corr ? new double [ImageDtt.DISPARITY_TITLES.length][] : null; //[0] -residual disparity, [1] - orthogonal (just for debugging)
double [][] disparity_map = save_corr ? new double [ImageDtt.getDisparityTitles(getNumSensors()).length][] : null; //[0] -residual disparity, [1] - orthogonal (just for debugging)
double [][] shiftXY = new double [4][2];
if (!clt_parameters.fine_corr_ignore) {
double [][] shiftXY0 = {
......
......@@ -37,7 +37,7 @@ import com.elphel.imagej.common.PolynomialApproximation;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
public class TileProcessor {
public static String [] SCAN_TITLES = {
public static String [] SCAN_TITLES = { // wrong now !
"tile_op", // 0
"final", // 1 - calculated, filtered, combined disparity
"disparity", // 2
......@@ -80,6 +80,7 @@ public class TileProcessor {
public boolean [] rig_post_poles_sel = null; // Rig tile selection after processing poles
public double [][] main_ds_ml = null; // main camera DSI restored from the COMBO-DSI file to generate ML test files
final int numSensors;
public boolean monochrome = false; // these are monochrome images
public boolean lwir = false; // all monochrome are lwir
private boolean is_aux = false; // this camera is aux
......@@ -98,11 +99,15 @@ public class TileProcessor {
public double [][] dbg_filtered_disp_strength;
// All parameters are set only once, during instantiation
public int getNumSensors() {
return numSensors;
}
public TileProcessor(
int tilesX,
int tilesY,
int tileSize,
int superTileSize,
int numSensors,
boolean monochrome,
boolean lwir,
boolean is_aux,
......@@ -115,6 +120,7 @@ public class TileProcessor {
this.tilesY = tilesY;
this.tileSize = tileSize;
this.superTileSize = superTileSize;
this.numSensors = numSensors;
this.monochrome = monochrome;
this.lwir = lwir;
this.is_aux = is_aux;
......@@ -128,6 +134,7 @@ public class TileProcessor {
this.tilesY = tp.tilesY;
this.tileSize = tp.tileSize;
this.superTileSize = tp.superTileSize;
this.numSensors = tp.numSensors;
this.monochrome = tp.monochrome;
this.lwir = tp.lwir;
this.is_aux = tp.is_aux;
......@@ -1147,7 +1154,9 @@ public class TileProcessor {
}
for (CLTPass3d combo_pass : combo_pass_list) {
combo_pass.tile_op = new int [tilesY][tilesX]; // for just non-zero
combo_pass.disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
// combo_pass.disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
combo_pass.disparity_map = new double [ImageDtt.getDisparityTitles(getNumSensors()).length][];
for (int i = 0; i< ImageDtt.QUAD; i++) combo_pass.disparity_map[ImageDtt.IMG_DIFF0_INDEX + i] = new double[tlen];
if (copyDebug){
combo_pass.disparity_map[ImageDtt.DISPARITY_INDEX_CM] = new double[tlen];
......@@ -1481,7 +1490,8 @@ ImageDtt.startAndJoin(threads);
}
for (CLTPass3d combo_pass : combo_pass_list) {
combo_pass.tile_op = new int [tilesY][tilesX]; // for just non-zero
combo_pass.disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
// combo_pass.disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
combo_pass.disparity_map = new double [ImageDtt.getDisparityTitles(getNumSensors()).length][];
for (int i = 0; i< ImageDtt.QUAD; i++) combo_pass.disparity_map[ImageDtt.IMG_DIFF0_INDEX + i] = new double[tlen];
if (copyDebug){
combo_pass.disparity_map[ImageDtt.DISPARITY_INDEX_CM] = new double[tlen];
......@@ -1798,7 +1808,8 @@ ImageDtt.startAndJoin(threads);
final int tlen = tilesX * tilesY;
final int disparity_index = usePoly ? ImageDtt.DISPARITY_INDEX_POLY : ImageDtt.DISPARITY_INDEX_CM;
combo_pass.tile_op = new int [tilesY][tilesX]; // for just non-zero
combo_pass.disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
// combo_pass.disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
combo_pass.disparity_map = new double [ImageDtt.getDisparityTitles(getNumSensors()).length][];
for (int i = 0; i< ImageDtt.QUAD; i++) combo_pass.disparity_map[ImageDtt.IMG_DIFF0_INDEX + i] = new double[tlen];
if (copyDebug){
combo_pass.disparity_map[ImageDtt.DISPARITY_INDEX_CM] = new double[tlen];
......@@ -3701,6 +3712,7 @@ ImageDtt.startAndJoin(threads);
return ds;
}
// TODO: update for variable length
public double [][] getShowScan(
CLTPass3d scan,
boolean measured_only)
......@@ -3757,7 +3769,7 @@ ImageDtt.startAndJoin(threads);
dbg_img[ 9] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_VERT_STRENGTH];
dbg_img[20] = scan.disparity_map[ImageDtt.OVEREXPOSED];
for (int i = 0; i < 12; i++) {
dbg_img[this_IMG_TONE_RGB+i] = scan.disparity_map[ImageDtt.IMG_TONE_RGB + i];
dbg_img[this_IMG_TONE_RGB+i] = scan.disparity_map[ImageDtt.getImgToneRGB(numSensors) + i];
}
}
dbg_img[1] = scan.calc_disparity_combo;
......@@ -4025,7 +4037,8 @@ ImageDtt.startAndJoin(threads);
block_propagate, // tiles,
null); // prohibit);
if ((debugLevel > -1) && show_bgnd_nonbgnd){
new ShowDoubleFloatArrays().showArrays(bgnd_data.disparity_map, tilesX, tilesY, true, "bgnd_map",ImageDtt.DISPARITY_TITLES);
// new ShowDoubleFloatArrays().showArrays(bgnd_data.disparity_map, tilesX, tilesY, true, "bgnd_map",ImageDtt.DISPARITY_TITLES);
new ShowDoubleFloatArrays().showArrays(bgnd_data.disparity_map, tilesX, tilesY, true, "bgnd_map",ImageDtt.getDisparityTitles(getNumSensors()));
new ShowDoubleFloatArrays().showArrays(dbg_worst2, tilesX, tilesY, "worst2");
}
// TODO: check if minimal cluster strengh should be limited here
......
......@@ -1404,7 +1404,8 @@ public class TwoQuadCLT {
double [][][] port_xy_main_dbg = new double [tilesX*tilesY][][];
double [][][] port_xy_aux_dbg = new double [tilesX*tilesY][][];
// double [][][] corr2ddata = new double [1][][];
double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
// double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
double [][] disparity_map = new double [image_dtt.getDisparityTitles().length][];
final double [][][][][][][] clt_bidata = // new double[2][quad][nChn][tilesY][tilesX][][]; // first index - main/aux
image_dtt.clt_bi_quad_dbg (
......@@ -1443,17 +1444,19 @@ public class TwoQuadCLT {
port_xy_aux_dbg); // final double [][][] port_xy_aux_dbg) // for each tile/port save x,y pixel coordinates (gpu code development)
///// double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging)
String [] sub_titles = new String [GPUTileProcessor.NUM_CAMS * (GPUTileProcessor.NUM_COLORS+1)];
int numSensors = GPUTileProcessor.NUM_CAMS; // Wrong - different for main and aux
String [] sub_titles = new String [numSensors * (GPUTileProcessor.NUM_COLORS+1)];
double [][] sub_disparity_map = new double [sub_titles.length][];
for (int ncam = 0; ncam < GPUTileProcessor.NUM_CAMS; ncam++) {
for (int ncam = 0; ncam < numSensors; ncam++) {
sub_disparity_map[ncam] = disparity_map[ncam + ImageDtt.IMG_DIFF0_INDEX];
sub_titles[ncam] = ImageDtt.DISPARITY_TITLES[ncam + ImageDtt.IMG_DIFF0_INDEX];
// sub_titles[ncam] = ImageDtt.DISPARITY_TITLES[ncam + ImageDtt.IMG_DIFF0_INDEX];
sub_titles[ncam] = ImageDtt.getDisparityTitles(numSensors)[ncam + ImageDtt.IMG_DIFF0_INDEX];
for (int ncol = 0; ncol < GPUTileProcessor.NUM_COLORS; ncol++) {
sub_disparity_map[ncam + (ncol + 1)* GPUTileProcessor.NUM_CAMS] =
disparity_map[ncam +ncol* GPUTileProcessor.NUM_CAMS+ ImageDtt.IMG_TONE_RGB];
sub_titles[ncam + (ncol + 1)* GPUTileProcessor.NUM_CAMS] =
ImageDtt.DISPARITY_TITLES[ncam +ncol* GPUTileProcessor.NUM_CAMS+ ImageDtt.IMG_TONE_RGB];
sub_disparity_map[ncam + (ncol + 1)* numSensors] =
disparity_map[ncam +ncol* numSensors+ ImageDtt.getImgToneRGB(numSensors)];
sub_titles[ncam + (ncol + 1)* numSensors] =
// ImageDtt.DISPARITY_TITLES[ncam +ncol* numSensors+ ImageDtt.getImgToneRGB(numSensors)];
ImageDtt.getDisparityTitles(numSensors)[ncam +ncol* numSensors+ ImageDtt.getImgToneRGB(numSensors)];
}
}
// String [] sub_titles = {ImageDtt.DISPARITY_TITLES[ImageDtt.IMG_DIFF0_INDEX]
......
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