...
 
Commits (5)
......@@ -11,6 +11,9 @@ public class ColorProcParameters {
public boolean lwir_islwir = false;
public double lwir_low = 27000;
public double lwir_high = 31000;
public boolean lwir_autorange = true;
public double lwir_too_cold = 100.0; // discard this number of pixels too cold
public double lwir_too_hot = 3.0; // discard this number of pixels too hot
public int lwir_palette = 0; // 0 - white - hot, 1 - black - hot, 2+ - colored
public boolean lwir_subtract_dc = false;
public boolean lwir_eq_chn = true; // adjust average temperature between channels
......@@ -65,11 +68,23 @@ public class ColorProcParameters {
public boolean use8; // use 8 neighbors (false - only 4)
public boolean isMonochrome() {
return lwir_islwir; // for now it is the only reason to be monochrome
}
public boolean isLwir() {
return lwir_islwir;
}
private ColorProcParameters() {}
public ColorProcParameters(
boolean lwir_islwir, // false;
double lwir_low, // 27000;
double lwir_high, // 31000;
boolean lwir_autorange, // true;
double lwir_too_cold, // 100.0; // discard this number of pixels too cold
double lwir_too_hot, // 3.0; // discard this number of pixels too hot
int lwir_palette, // 0 - white - hot, 1 - black - hot, 2+ - colored
boolean lwir_subtract_dc, // = false;
boolean lwir_eq_chn, // true
......@@ -124,6 +139,11 @@ public class ColorProcParameters {
this.lwir_islwir = lwir_islwir;
this.lwir_low = lwir_low;
this.lwir_high = lwir_high;
this.lwir_autorange = lwir_autorange;
this.lwir_too_cold = lwir_too_cold;
this.lwir_too_hot = lwir_too_hot;
this.lwir_palette = lwir_palette;
this.lwir_subtract_dc = lwir_subtract_dc;
this.lwir_eq_chn =lwir_eq_chn;
......@@ -179,6 +199,11 @@ public class ColorProcParameters {
properties.setProperty(prefix+"lwir_islwir", this.lwir_islwir+"");
properties.setProperty(prefix+"lwir_low", this.lwir_low+"");
properties.setProperty(prefix+"lwir_high", this.lwir_high+"");
properties.setProperty(prefix+"lwir_autorange", this.lwir_autorange+"");
properties.setProperty(prefix+"lwir_too_cold", this.lwir_too_cold+"");
properties.setProperty(prefix+"lwir_too_hot", this.lwir_too_hot+"");
properties.setProperty(prefix+"lwir_palette", this.lwir_palette+"");
properties.setProperty(prefix+"lwir_subtract_dc", this.lwir_subtract_dc+"");
properties.setProperty(prefix+"lwir_eq_chn", this.lwir_eq_chn+"");
......@@ -240,9 +265,14 @@ public class ColorProcParameters {
}
public boolean getProperties(String prefix,Properties properties){
if (properties.getProperty(prefix+"lwir_islwir")!=null) this.lwir_islwir=Boolean.parseBoolean(properties.getProperty(prefix+"lwir_islwir"));
if (properties.getProperty(prefix+"lwir_low")!=null) this.lwir_low=Double.parseDouble(properties.getProperty(prefix+"lwir_low"));
if (properties.getProperty(prefix+"lwir_high")!=null) this.lwir_high=Double.parseDouble(properties.getProperty(prefix+"lwir_high"));
if (properties.getProperty(prefix+"lwir_islwir")!=null) this.lwir_islwir=Boolean.parseBoolean(properties.getProperty(prefix+"lwir_islwir"));
if (properties.getProperty(prefix+"lwir_low")!=null) this.lwir_low=Double.parseDouble(properties.getProperty(prefix+"lwir_low"));
if (properties.getProperty(prefix+"lwir_high")!=null) this.lwir_high=Double.parseDouble(properties.getProperty(prefix+"lwir_high"));
if (properties.getProperty(prefix+"lwir_autorange")!=null) this.lwir_autorange=Boolean.parseBoolean(properties.getProperty(prefix+"lwir_autorange"));
if (properties.getProperty(prefix+"lwir_too_cold")!=null) this.lwir_too_cold=Double.parseDouble(properties.getProperty(prefix+"lwir_too_cold"));
if (properties.getProperty(prefix+"lwir_too_hot")!=null) this.lwir_too_hot=Double.parseDouble(properties.getProperty(prefix+"lwir_too_hot"));
if (properties.getProperty(prefix+"lwir_palette")!=null) this.lwir_palette=Integer.parseInt(properties.getProperty(prefix+"lwir_palette"));
if (properties.getProperty(prefix+"lwir_subtract_dc")!=null) this.lwir_subtract_dc=Boolean.parseBoolean(properties.getProperty(prefix+"lwir_subtract_dc"));
if (properties.getProperty(prefix+"lwir_eq_chn")!=null) this.lwir_eq_chn=Boolean.parseBoolean(properties.getProperty(prefix+"lwir_eq_chn"));
......@@ -312,8 +342,13 @@ public class ColorProcParameters {
}
gd.addMessage("--- Parameters related to thermal imaging ---");
gd.addCheckbox ("These sensors are thermal vision with absolute temperature", this.lwir_islwir);
gd.addNumericField("Lowest value (temperature) to display", this.lwir_low, 3); //0.53
gd.addNumericField("Highest value (temperature) to display", this.lwir_high, 3); //0.53
gd.addNumericField("Lowest value (temperature) to display", this.lwir_low, 6); //0.53
gd.addNumericField("Highest value (temperature) to display", this.lwir_high, 6); //0.53
gd.addCheckbox ("Autorange LWIR low/high temperatures (within limits above)", this.lwir_autorange); // true
gd.addNumericField("Number of too cold pixels/image to ignore during autorange", this.lwir_too_cold, 4); // 100.0
gd.addNumericField("Number of too hot pixels/image to ignore during autorange", this.lwir_too_hot, 4); // 0.53
gd.addNumericField("LWIR pallet (0-white hot, 1-black hot, 2+ - pseudo colors ", this.lwir_palette, 0);
gd.addCheckbox ("Subtract each image DC when conditioning", this.lwir_subtract_dc);
gd.addCheckbox ("Adjust average temperature between cameras", this.lwir_eq_chn);
......@@ -397,6 +432,11 @@ public class ColorProcParameters {
this.lwir_islwir= gd.getNextBoolean();
this.lwir_low= gd.getNextNumber();
this.lwir_high= gd.getNextNumber();
this.lwir_autorange = gd.getNextBoolean();
this.lwir_too_cold= gd.getNextNumber();
this.lwir_too_hot= gd.getNextNumber();
this.lwir_palette= (int) gd.getNextNumber();
this.lwir_subtract_dc= gd.getNextBoolean();
this.lwir_eq_chn= gd.getNextBoolean();
......@@ -458,6 +498,11 @@ public class ColorProcParameters {
cp.lwir_islwir = this.lwir_islwir;
cp.lwir_low = this.lwir_low;
cp.lwir_high = this.lwir_high;
cp.lwir_autorange = this.lwir_autorange;
cp.lwir_too_cold = this.lwir_too_cold;
cp.lwir_too_hot = this.lwir_too_hot;
cp.lwir_palette = this.lwir_palette;
cp.lwir_subtract_dc = this.lwir_subtract_dc;
cp.lwir_eq_chn = this.lwir_eq_chn;
......@@ -517,6 +562,11 @@ public class ColorProcParameters {
this.lwir_islwir = cp.lwir_islwir;
this.lwir_low = cp.lwir_low;
this.lwir_high = cp.lwir_high;
this.lwir_autorange = cp.lwir_autorange;
this.lwir_too_cold = cp.lwir_too_cold;
this.lwir_too_hot = cp.lwir_too_hot;
this.lwir_palette = cp.lwir_palette;
this.lwir_subtract_dc = cp.lwir_subtract_dc;
this.lwir_eq_chn = cp.lwir_eq_chn;
......
......@@ -1247,7 +1247,9 @@ public class EyesisCorrectionParameters {
String [] extensions = getSourceSuffixes();// ={this.sourceSuffix};
String [] prefixes = getSourcePrefixes();
int num_chn_files = numSubCameras + ((aux_camera != null)?aux_camera.numSubCameras : 0);
int num_chn_main = numSubCameras;
int num_chn_aux = ((aux_camera != null)?aux_camera.numSubCameras : 0);
int num_chn_files = num_chn_main + num_chn_aux;
extensions[0] = sourceSuffix;
prefixes[0] = sourcePrefix;
MultipleExtensionsFileFilter setFilter = new MultipleExtensionsFileFilter(prefixes,extensions,"Image sets");
......@@ -1281,7 +1283,10 @@ public class EyesisCorrectionParameters {
// String [] setChnFiles = files[nFile].list(setFilter);
File [] setChnFiles = files[nFile].listFiles(setFilter);
int num_match = setChnFiles.length;
if (num_match == num_chn_files) { // only use sets of exact number of files
if ( (num_match == num_chn_files) || // all files for main and aux
(num_match == num_chn_main) || // only main camera files
(num_match == num_chn_aux)) // only aux camera files
{ // only use sets of exact number of files
setDirList.add(files[nFile]);
for (File f: setChnFiles) {
setFilesList.add(f);
......
......@@ -26,11 +26,11 @@ public class ThermalColor {
public double [] getRGB(double v) { // Get R,G,B (0..255) triplet for input value in the range 0..1
double k = out_range/PALETTE_RANGE;
double value = (v-min)/(max-min);
int ivalue = (int) (value/(this.palette.length - 1));
double value = (v-min)/(max-min) * (this.palette.length - 1);
int ivalue = (int) (value);
if (ivalue < 0) return this.palette[0];
if (ivalue >= (this.palette.length -1)) return this.palette[this.palette.length -1];
double a = (value-ivalue)*(this.palette.length - 1); // 0..1
double a = (value-ivalue); // 0..1
double [] rslt = {
k*((1 - a) * this.palette[ivalue][0] + a * this.palette[ivalue+1][0]),
k*((1 - a) * this.palette[ivalue][1] + a * this.palette[ivalue+1][1]),
......@@ -97,7 +97,8 @@ public class ThermalColor {
0xfff285, 0xfff28a, 0xfff38e, 0xfff492, 0xfff496, 0xfff49a, 0xfff59e, 0xfff5a2,
0xfff5a6, 0xfff6aa, 0xfff6af, 0xfff7b3, 0xfff7b6, 0xfff8ba, 0xfff8bd, 0xfff8c1,
0xfff8c4, 0xfff9c7, 0xfff9ca, 0xfff9cd, 0xfffad1, 0xfffad4, 0xfffbd8, 0xfffcdb,
0xfffcdf, 0xfffde2, 0xfffde5, 0xfffde8, 0xfffeeb, 0xfffeee, 0xfffef1, 0xfffef4, 0xfffff};
0xfffcdf, 0xfffde2, 0xfffde5, 0xfffde8, 0xfffeeb, 0xfffeee, 0xfffef1, 0xfffef4,
0xffffff};
int [][] palettes = {white_hot_palette, black_hot_palette, iron_palette};
if (indx <0) indx = 0;
else if (indx >= palettes.length) indx = palettes.length - 1;
......
......@@ -1838,6 +1838,57 @@ public class EyesisCorrections {
return imp;
}
public static ImagePlus convertRGBAFloatToRGBA32(
ImageStack stackFloat, //r,g,b,a
String title,
double r_min,
double r_max,
double g_min,
double g_max,
double b_min,
double b_max,
double alpha_min,
double alpha_max){
double [] mins= {r_min,g_min,b_min,alpha_min};
double [] maxs= {r_max,g_max,b_max,alpha_max};
int i;
int length=stackFloat.getWidth()*stackFloat.getHeight();
int numSlices = stackFloat.getSize();
if (numSlices > 4) numSlices = 4;
float [][] fpixels=new float[numSlices][];
int [] sliceSeq = new int [numSlices];
for (int j = 0; j < numSlices; j++) sliceSeq[j] = (j + ((numSlices > 3)? 3:0)) % 4;
int [] pixels=new int[length];
int c,d;
double [] scale=new double[numSlices];
for (c = 0; c < numSlices; c++) {
scale[c]=256.0/(maxs[c]-mins[c]);
}
for (i = 0; i < numSlices; i++) {
fpixels[i]= (float[])stackFloat.getPixels(i+1);
}
for (i = 0; i < length; i++) {
pixels[i]=0;
for (int j=0; j < numSlices; j++) {
c = sliceSeq[j];
d=(int)((fpixels[c][i]-mins[c])*scale[c]);
if (d > 255) d=255;
else if (d < 0) d=0;
pixels[i]= d | (pixels[i] << 8);
}
}
ColorProcessor cp=new ColorProcessor(stackFloat.getWidth(),stackFloat.getHeight());
cp.setPixels(pixels);
ImagePlus imp=new ImagePlus(title,cp);
return imp;
}
public ImageStack convertRGB48toRGBA24Stack(
ImageStack stack16,
double [] dalpha, // alpha pixel array 0..1.0 or null
......
......@@ -1220,7 +1220,7 @@ public class EyesisDCT {
}
if (this.correctionsParameters.deconvolve) { // process with DCT, otherwise use simple debayer
ImageDtt image_dtt = new ImageDtt(false); // Bayer, not monochrome
ImageDtt image_dtt = new ImageDtt(false, 1.0); // Bayer( not monochrome), scale correlation strengths
double [][][][] dct_data = image_dtt.mdctStack(
stack,
channel,
......
......@@ -1775,7 +1775,8 @@ B = |+dy0 -dy1 -2*dy3 |
final int hist_min_samples,
final boolean hist_norm_center, // if there are more tiles that fit than min_samples, replace with
final double inf_fraction, // fraction of the weight for the infinity tiles
CLTParameters clt_parameters,
final boolean right_left, // equalize weights of right/left FoV (use with horizon in both halves and gross infinity correction)
CLTParameters clt_parameters,
double [][] scans_14,
double [][] target_disparity, // null or programmed disparity (1 per each 14 entries of scans_14)
int tilesX,
......@@ -1878,7 +1879,8 @@ B = |+dy0 -dy1 -2*dy3 |
}
if (debugLevel > -2) {
System.out.println("lazyEyeCorrection() 1: removing tiles with residual disparity absoulte value > "+lazyEyeCompDiff);
System.out.println("lazyEyeCorrection().a 1: removing tiles with residual disparity absolute value > "+lazyEyeCompDiff);
// System.out.println("lazyEyeCorrection().a 1: removing tiles with residual disparity absolute value > "+(2*lazyEyeCompDiff));
}
double [][] combo_mismatch = new double [NUM_SLICES][num_tiles];
......@@ -1891,6 +1893,7 @@ B = |+dy0 -dy1 -2*dy3 |
double w = filtered_scans[ns * NUM_SLICES + 1][nTile];
if (w > 0.0){
double disp = filtered_scans[ns * NUM_SLICES + 0][nTile];
// if (Math.abs(disp) <= 2.0*lazyEyeCompDiff) {
if (Math.abs(disp) <= lazyEyeCompDiff) {
for (int i = 2; i < NUM_SLICES; i++) if (i != 1){
combo_mismatch[i][nTile] += filtered_scans[ns * NUM_SLICES + i][nTile] * w;
......@@ -2214,6 +2217,29 @@ B = |+dy0 -dy1 -2*dy3 |
System.out.println("lazyEyeCorrection(): number of all samples="+inf_samples_list.size()+", total weight = "+inf_weight);
}
if (right_left) {
System.out.println("Balancing right/left part of FoV weights, width = "+tilesX+" tiles");
double [] right_left_weights = {0.0, 0.0};
for (Sample s: inf_samples_list) {
int rl = (s.tile % tilesX) / (tilesX/2);
right_left_weights[rl] += s.weight;
}
System.out.println("Weights: left:"+ right_left_weights[0]+", right:"+ right_left_weights[1]);
for (Sample s: inf_samples_list) {
int rl = (s.tile % tilesX) / (tilesX/2);
s.weight *= right_left_weights[1 - rl];
}
// just verifying
right_left_weights[0] = 0.0;
right_left_weights[1] = 0.0;
for (Sample s: inf_samples_list) {
int rl = (s.tile % tilesX) / (tilesX/2);
right_left_weights[rl] += s.weight;
}
System.out.println("Weights after balancing: left:"+ right_left_weights[0]+", right:"+ right_left_weights[1]);
}
if (debugLevel > 0) {
String [] prefixes = {"disparity", "strength", "dx0", "dy0", "dx1", "dy1", "dx2", "dy2", "dx3", "dy3"};
......@@ -3369,6 +3395,11 @@ B = |+dy0 -dy1 -2*dy3 |
int dbg_height = qc.tp.getTilesY()*qc.tp.getTileSize();
int dbg_owidth = dbg_width/dbg_decimate;
int dbg_oheight = dbg_height/dbg_decimate;
while (dbg_owidth < 40) {
dbg_decimate /= 2;
dbg_owidth = dbg_width/dbg_decimate;
dbg_oheight = dbg_height/dbg_decimate;
}
int dbg_length = dbg_owidth*dbg_oheight;
String [] dbg_titles_sym= {"sym0","sym1","sym2","sym3","sym4","sym5","sroll0","sroll1","sroll2","sroll3", "zoom0", "zoom1", "zoom2"};
String [] dbg_titles_xy= {"dx0","dy0","dx1","dy1","dx2","dy2","dx3","y3"};
......
......@@ -244,6 +244,7 @@ public class Correlation2d {
* @param clt_data1 [3][4][transform_len] first operand data. First index - RBG color
* @param clt_data2 [3][4][transform_len] first operand data. First index - RBG color
* @param lpf optional [transform_len] LPF filter data
* @param scale_value scale correlation results to compensate for lpf changes and other factors
* @param col_weights [3] - color weights {R, B, G} - green is last, normalized to sum =1.0
* @param fat_zero fat zero for phase correlation (0 seems to be OK)
* @return correlation result [(2*transform_size-1) * (2*transform_size-1)]
......@@ -252,6 +253,7 @@ public class Correlation2d {
double [][][] clt_data1,
double [][][] clt_data2,
double [] lpf,
double scale_value, // scale correlation value
double [] col_weights_in, // should have the same dimension as clt_data1 and clt_data2
double fat_zero) {
......@@ -266,13 +268,18 @@ public class Correlation2d {
s+=col_weights[i];
}
for (int i = 0; i < col_weights.length; i++) {
if (col_weights[i] != 0.0) col_weights[i]/=s; // will have 1.0 for the single color
if (col_weights[i] != 0.0) col_weights[i] *= scale_value;
}
if (clt_data1.length == 1) { // monochrome
col_weights = new double[1];
col_weights[0] = 1.0;
}
for (int i = 0; i < col_weights.length; i++) {
if (col_weights[i] != 0.0) col_weights[i]/=s; // will have 1.0 for the single color
}
double [][][]tcorr = new double [clt_data1.length][4][transform_len];
int first_col = -1;
for (int col = 0; col < tcorr.length; col++) if (col_weights[col] > 0.0 ) {
......@@ -280,7 +287,7 @@ public class Correlation2d {
clt_data1[col],
clt_data2[col],
tcorr[col],
fat_zero);
fat_zero/scale_value);
if (first_col < 0) {// accummulate all channels in frst non-null color ( 0 for color, 2 for mono?)
first_col = col; // first non-empty color (2, green) or 0 for color images
......@@ -320,6 +327,7 @@ public class Correlation2d {
* @param tileY tile to extract Y index
* @param pairs_mask bimask of required pairs
* @param lpf optional low-pass filter
* @param scale_value scale correlation results to compensate for lpf changes and other factors
* @param col_weights RBG color weights
* @param fat_zero fat zero for phase correlations
* @return [pair][corr_index]
......@@ -330,6 +338,7 @@ public class Correlation2d {
int tileY,
int pairs_mask,
double [] lpf,
double scale_value, // scale correlation value
double [] col_weights,
double fat_zero) {
double [][][][] clt_data_tile = new double[clt_data.length][][][];
......@@ -343,6 +352,7 @@ public class Correlation2d {
clt_data_tile,
pairs_mask, // already decoded so bit 0 - pair 0
lpf,
scale_value,
col_weights,
fat_zero);
}
......@@ -352,6 +362,7 @@ public class Correlation2d {
* @param clt_data aberration-corrected FD CLT data for one tile [camera][color][quadrant][index]
* @param pairs_mask bimask of required pairs
* @param lpf optional low-pass filter
* @param scale_value scale correlation results to compensate for lpf changes and other factors
* @param col_weights RBG color weights
* @param fat_zero fat zero for phase correlations
* @return [pair][corr_index]
......@@ -360,6 +371,7 @@ public class Correlation2d {
double [][][][] clt_data_tile,
int pairs_mask, // already decoded so bit 0 - pair 0
double [] lpf,
double scale_value, // scale correlation value
double [] col_weights,
double fat_zero) {
if (clt_data_tile == null) return null;
......@@ -372,6 +384,7 @@ public class Correlation2d {
clt_data_tile[ncam1], // double [][][] clt_data1,
clt_data_tile[ncam2], // double [][][] clt_data2,
lpf, // double [] lpf,
scale_value,
col_weights, // double [] col_weights,
fat_zero); // double fat_zero)
}
......@@ -385,6 +398,7 @@ public class Correlation2d {
* @param clt_data_tile_main aberration-corrected FD CLT data for one tile of the main quad camera [sub-camera][color][quadrant][index]
* @param clt_data_tile_aux aberration-corrected FD CLT data for one tile of the auxiliary quad camera [sub-camera][color][quadrant][index]
* @param lpf optional low-pass filter
* @param scale_value scale correlation results to compensate for lpf changes and other factors
* @param col_weights RBG color weights
* @param fat_zero fat zero for phase correlations
* @return 2-d correlation array in line scan order
......@@ -393,6 +407,7 @@ public class Correlation2d {
double [][][][] clt_data_tile_main,
double [][][][] clt_data_tile_aux,
double [] lpf,
double scale_value, // scale correlation value
double [] col_weights,
double fat_zero) {
if ((clt_data_tile_main == null) || (clt_data_tile_aux == null)) return null;
......@@ -402,6 +417,7 @@ public class Correlation2d {
clt_mix_main, // double [][][] clt_data1,
clt_mix_aux, // double [][][] clt_data2,
lpf, // double [] lpf,
scale_value, // scale correlation value
col_weights, // double [] col_weights,
fat_zero); // double fat_zero)
return inter_cam_corr;
......
......@@ -1340,8 +1340,8 @@ public class GeometryCorrection {
sv[i] = sym_vect[i]*1000.0*distortionRadius/pixelSize; // zooms
}
s = String.format("tilt (up): %8.5fpx %8.5fpx %8.5fpx %8.5fpx (shift of he image center)\n" , v[0], v[1], v[2], -(v[0] + v[1] + v[2]) );
s += String.format("azimuth (right): %8.5fpx %8.5fpx %8.5fpx %8.5fpx (shift of he image center)\n" , v[3], v[4], v[5], -(v[3] + v[4] + v[5]) );
s = String.format("tilt (up): %8.5fpx %8.5fpx %8.5fpx %8.5fpx (shift of the image center)\n" , v[0], v[1], v[2], -(v[0] + v[1] + v[2]) );
s += String.format("azimuth (right): %8.5fpx %8.5fpx %8.5fpx %8.5fpx (shift of the image center)\n" , v[3], v[4], v[5], -(v[3] + v[4] + v[5]) );
s += String.format("roll (CW): %8.5fpx %8.5fpx %8.5fpx %8.5fpx (shift at the image half-width from the center)\n" , v[6], v[7], v[8], v[9] );
s += String.format("diff zoom (in): %8.5fpx %8.5fpx %8.5fpx %8.5fpx (shift at the image half-width from the center)\n" , v[10], v[11], v[12], -(v[10] + v[11] + v[12]) );
s += "Symmetrical vector:\n";
......
......@@ -202,6 +202,7 @@ public class ImageDtt {
static String [] TCORR_TITLES = {"combo","sum","hor","vert"};
private final boolean monochrome;
private final double scale_strengths; // scale all correlation strengths (to compensate for LPF sigma changes)
public static int getImgMask (int data){ return (data & 0xf);} // which images to use
......@@ -213,8 +214,11 @@ public class ImageDtt {
public static boolean getOrthoLines (int data){return (data & 0x200) != 0;}
public static int setOrthoLines (int data, boolean force) {return (data & ~0x200) | (force?0x200:0);}
public ImageDtt(boolean mono){
monochrome = mono;
public ImageDtt(
boolean mono,
double scale_strengths){
this.monochrome = mono;
this.scale_strengths = scale_strengths;
}
public boolean isMonochrome() {
......@@ -2110,14 +2114,16 @@ public class ImageDtt {
// calculate all selected pairs correlations
int all_pairs = imgdtt_params.dbg_pair_mask; //TODO: use tile tasks
double [][] corrs = corr2d.correlateCompositeFD( // now works with nulls for some clt_data colors
clt_data, // double [][][][][][] clt_data,
tileX, // int tileX,
tileY, // int tileY,
all_pairs, // int pairs_mask,
filter, // double [] lpf,
col_weights, // double [] col_weights,
corr_fat_zero); // double fat_zero)
double [][] corrs = corr2d.correlateCompositeFD( // now works with nulls for some clt_data colors
clt_data, // double [][][][][][] clt_data,
tileX, // int tileX,
tileY, // int tileY,
all_pairs, // int pairs_mask,
filter, // double [] lpf,
scale_strengths, // double scale_value, // scale correlation value
col_weights, // double [] col_weights,
corr_fat_zero); // double fat_zero)
// calculate interpolated "strips" to match different scales and orientations (ortho/diagonal) on the
// fine (0.5 pix) grid. ortho for scale == 1 provide even/even samples (1/4 of all), diagonal ones -
......@@ -2233,8 +2239,8 @@ public class ImageDtt {
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];
disparity_map[DISPARITY_INDEX_HOR][tIndex] = -hor_pair1[0];
disparity_map[DISPARITY_INDEX_HOR_STRENGTH][tIndex] = hor_pair1[1];
}
double [] vert_pair1 = corr2d.getMaxXSOrtho(
......@@ -6208,7 +6214,7 @@ public class ImageDtt {
// Create window to select center correlation strip using
// ortho_height - full width of non-zero elements
// ortho_eff_height - effective height (ration of the weighted column sum to the center value)
// ortho_eff_height - effective height (ratio of the weighted column sum to the center value)
int wcenter = transform_size - 1;
final double [] ortho_weights = new double [corr_size]; // [15]
for (int i = 0; i < corr_size; i++){
......@@ -7372,6 +7378,7 @@ public class ImageDtt {
clt_data_tile_main, // double [][][][] clt_data_tile_main,
clt_data_tile_aux, // double [][][][] clt_data_tile_aux,
filter, // double [] lpf,
scale_strengths,
col_weights, // double [] col_weights,
fatzero); // double fat_zero)
......@@ -7627,6 +7634,7 @@ public class ImageDtt {
clt_data, // double [][][][] clt_data, // aberration-corrected FD CLT data for one tile [camera][color][quadrant][index]
all_pairs, // int pairs_mask,
filter, // double [] lpf,
scale_strengths,
col_weights, // double [] col_weights,
fatzero); // double fat_zero)
......@@ -8063,13 +8071,13 @@ public class ImageDtt {
final double [] filter_direct= new double[transform_len];
if (clt_parameters.corr_sigma == 0) {
if (clt_parameters.getCorrSigma(isMonochrome()) == 0) {
filter_direct[0] = 1.0;
for (int i= 1; i<filter_direct.length;i++) filter_direct[i] =0;
} else {
for (int i = 0; i < clt_parameters.transform_size; i++){
for (int j = 0; j < clt_parameters.transform_size; j++){
filter_direct[i * clt_parameters.transform_size+j] = Math.exp(-(i*i+j*j)/(2*clt_parameters.corr_sigma)); // FIXME: should be sigma*sigma !
filter_direct[i * clt_parameters.transform_size+j] = Math.exp(-(i*i+j*j)/(2*clt_parameters.getCorrSigma(isMonochrome()))); // FIXME: should be sigma*sigma !
}
}
}
......@@ -8466,6 +8474,7 @@ public class ImageDtt {
clt_data_main, // double [][][][] clt_data_tile_main,
clt_data_aux, // double [][][][] clt_data_tile_aux,
filter, // double [] lpf,
scale_strengths,
col_weights, // double [] col_weights,
fatzero); // double fat_zero)
......@@ -8864,13 +8873,13 @@ public class ImageDtt {
final double [] filter_direct= new double[transform_len];
if (clt_parameters.corr_sigma == 0) {
if (clt_parameters.getCorrSigma(isMonochrome()) == 0) {
filter_direct[0] = 1.0;
for (int i= 1; i<filter_direct.length;i++) filter_direct[i] =0;
} else {
for (int i = 0; i < clt_parameters.transform_size; i++){
for (int j = 0; j < clt_parameters.transform_size; j++){
filter_direct[i * clt_parameters.transform_size+j] = Math.exp(-(i*i+j*j)/(2*clt_parameters.corr_sigma)); // FIXME: should be sigma*sigma !
filter_direct[i * clt_parameters.transform_size+j] = Math.exp(-(i*i+j*j)/(2*clt_parameters.getCorrSigma(isMonochrome()))); // FIXME: should be sigma*sigma !
}
}
}
......@@ -9242,6 +9251,7 @@ public class ImageDtt {
clt_data_main, // double [][][][] clt_data_tile_main,
clt_data_aux, // double [][][][] clt_data_tile_aux,
filter, // double [] lpf,
scale_strengths,
col_weights, // double [] col_weights,
fatzero); // double fat_zero)
......@@ -9594,13 +9604,13 @@ public class ImageDtt {
final double [] filter_direct= new double[transform_len];
if (clt_parameters.corr_sigma == 0) {
if (clt_parameters.getCorrSigma(isMonochrome()) == 0) {
filter_direct[0] = 1.0;
for (int i= 1; i<filter_direct.length;i++) filter_direct[i] =0;
} else {
for (int i = 0; i < clt_parameters.transform_size; i++){
for (int j = 0; j < clt_parameters.transform_size; j++){
filter_direct[i * clt_parameters.transform_size+j] = Math.exp(-(i*i+j*j)/(2*clt_parameters.corr_sigma)); // FIXME: should be sigma*sigma !
filter_direct[i * clt_parameters.transform_size+j] = Math.exp(-(i*i+j*j)/(2*clt_parameters.getCorrSigma(isMonochrome()))); // FIXME: should be sigma*sigma !
}
}
}
......@@ -9630,7 +9640,7 @@ public class ImageDtt {
System.out.println("max_corr_radius= "+clt_parameters.max_corr_radius);
System.out.println("max_search_radius= "+max_search_radius);
System.out.println("max_search_radius_poly="+max_search_radius_poly);
System.out.println("corr_fat_zero= "+clt_parameters.fat_zero);
System.out.println("corr_fat_zero= "+clt_parameters.getFatZero(isMonochrome()));
System.out.println("disparity_array[0][0]= "+disparity_array[0][0]);
......
......@@ -63,6 +63,7 @@ public class MacroCorrelation {
tileSize, // int tileSize,
tp.superTileSize, // int superTileSize,
tp.isMonochrome(),
tp.isAux(),
tp.getMagicScale(), // double scale,
trusted_correlation, // double trustedCorrelation,
0.0, // double maxOverexposure,
......@@ -305,7 +306,9 @@ public class MacroCorrelation {
// double [][][][] texture_tiles = save_textures ? new double [tilesY][tilesX][][] : null; // ["RGBA".length()][];
ImageDtt image_dtt = new ImageDtt(this.mtp.isMonochrome());
ImageDtt image_dtt = new ImageDtt(
this.mtp.isMonochrome(),
clt_parameters.getScaleStrength(this.mtp.isAux()));
image_dtt.clt_aberrations_quad_corr(
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
8, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
......@@ -321,12 +324,12 @@ public class MacroCorrelation {
disparity_map, // [12][tp.tilesY * tp.tilesX]
null, // [tp.tilesY][tp.tilesX]["RGBA".length()][];
mTilesX * clt_parameters.transform_size, // imp_quad[0].getWidth(), // final int width,
clt_parameters.fat_zero, // add to denominator to modify phase correlation (same units as data1, data2). <0 - pure sum
clt_parameters.getFatZero(image_dtt.isMonochrome()), // add to denominator to modify phase correlation (same units as data1, data2). <0 - pure sum
clt_parameters.corr_sym,
clt_parameters.corr_offset,
clt_parameters.corr_red,
clt_parameters.corr_blue,
clt_parameters.corr_sigma,
clt_parameters.getCorrSigma(image_dtt.isMonochrome()),
clt_parameters.corr_normalize, // normalize correlation results by rms
min_corr_selected, // 0.0001; // minimal correlation value to consider valid
clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional
......
......@@ -2723,7 +2723,7 @@ public class PoleProcessor {
disparity_array, // double [][] disparity_array,
null, // double [][] ml_data, // data for ML - 10 layers - 4 center areas (3x3, 5x5,..) per camera-per direction, 1 - composite, and 1 with just 1 data (target disparity)
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
clt_parameters.fat_zero, // double fatzero,
clt_parameters.getFatZero(quadCLT_main.isMonochrome()), // double fatzero,
notch_mode, // final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
lt_rad, // final int // low texture mode - inter-correlation is averaged between the neighbors before argmax-ing, using
true, // boolean no_int_x0, // do not offset window to integer maximum - used when averaging low textures to avoid "jumps" for very wide
......
......@@ -75,6 +75,7 @@ public class TileProcessor {
public double [][] main_ds_ml = null; // main camera DSI restored from the COMBO-DSI file to generate ML test files
public boolean monochrome = false; // these are monochrome images
private boolean is_aux = false; // this camera is aux
public int clt_3d_passes_size = 0; //clt_3d_passes size after initial processing
public int clt_3d_passes_rig_size = 0; //clt_3d_passes size after initial processing and rig processing
private int tilesX;
......@@ -104,6 +105,7 @@ public class TileProcessor {
int tileSize,
int superTileSize,
boolean monochrome,
boolean is_aux,
double scale,
double trustedCorrelation,
double maxOverexposure,
......@@ -114,12 +116,15 @@ public class TileProcessor {
this.tileSize = tileSize;
this.superTileSize = superTileSize;
this.monochrome = monochrome;
this.is_aux = is_aux;
this.corr_magic_scale = scale;
this.trustedCorrelation = trustedCorrelation;
this.maxOverexposure = maxOverexposure;
this.threadsMax = threadsMax;
}
public boolean isMonochrome() {return monochrome;}
public boolean isAux() {return is_aux;}
public int getTilesX() {return tilesX;}
public int getTilesY() {return tilesY;}
public int getTileSize() {return tileSize;}
......@@ -3055,7 +3060,7 @@ public class TileProcessor {
dbg_img[3][i] = disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX][i];
dbg_img[4][i] = disparity_map[disparity_index][i];
}
sdfa_instance.showArrays(dbg_img, tilesX, tilesY, true, "bgnd_nonbgnd",titles);
sdfa_instance.showArrays(dbg_img, tilesX, tilesY, true, "bgnd_nonbgnd_new",titles);
}
for (int gain = 1; gain > 0;){
......@@ -4062,19 +4067,53 @@ public class TileProcessor {
}
public int [][] setSameTileOp(
int op){
return setSameTileOp(
0,
tilesX,
0,
tilesY,
op,
-1);
}
public int [][] setSameTileOp(
CLTParameters clt_parameters,
int op,
int debugLevel
)
{
int [][] tile_op = new int [tilesY][tilesX]; // all zero
int debugLevel){
int txl = clt_parameters.tile_task_wl;
int txr = txl + clt_parameters.tile_task_ww;
int tyt = clt_parameters.tile_task_wt;
int tyb = tyt + clt_parameters.tile_task_wh;
if (debugLevel > -1){
System.out.println("clt_parameters.tile_task_wl="+clt_parameters.tile_task_wl );
System.out.println("clt_parameters.tile_task_wt="+clt_parameters.tile_task_wt );
System.out.println("clt_parameters.tile_task_ww="+clt_parameters.tile_task_ww );
System.out.println("clt_parameters.tile_task_wh="+clt_parameters.tile_task_wh );
}
return setSameTileOp(
txl,
txr,
tyt,
tyb,
op,
debugLevel);
}
public int [][] setSameTileOp(
// CLTParameters clt_parameters,
int txl, // = clt_parameters.tile_task_wl;
int txr, // = txl + clt_parameters.tile_task_ww;
int tyt, // = clt_parameters.tile_task_wt;
int tyb, // = tyt + clt_parameters.tile_task_wh;
int op,
int debugLevel
)
{
int [][] tile_op = new int [tilesY][tilesX]; // all zero
if (txl < 0) txl = 0;
else if (txl >= tilesX) txl = tilesX - 1;
......@@ -4093,10 +4132,6 @@ public class TileProcessor {
}
}
if (debugLevel > -1){
System.out.println("clt_parameters.tile_task_wl="+clt_parameters.tile_task_wl );
System.out.println("clt_parameters.tile_task_wt="+clt_parameters.tile_task_wt );
System.out.println("clt_parameters.tile_task_ww="+clt_parameters.tile_task_ww );
System.out.println("clt_parameters.tile_task_wh="+clt_parameters.tile_task_wh );
System.out.println("getImgMask("+op+")="+ImageDtt.getImgMask(op) );
System.out.println("getPairMask("+op+")="+ImageDtt.getPairMask(op) );
System.out.println("getForcedDisparity("+op+")="+ImageDtt.getForcedDisparity(op) );
......@@ -5165,12 +5200,11 @@ public class TileProcessor {
public double [][] assignTilesToSurfaces(
CLTParameters clt_parameters,
CLTParameters clt_parameters,
GeometryCorrection geometryCorrection,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
// final boolean batch_mode,
final int debugLevel)
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
{
final boolean batch_mode = clt_parameters.batch_run;
final int debugLevelInner = batch_mode ? -5: debugLevel;
......@@ -5185,7 +5219,7 @@ public class TileProcessor {
// show testure_tiles
double [][][][] texture_tiles = scan_prev.getTextureTiles();
ImageDtt image_dtt = new ImageDtt(isMonochrome());
ImageDtt image_dtt = new ImageDtt(isMonochrome(), clt_parameters.getScaleStrength(is_aux));
double [][][] dispStrength = st.getDisparityStrengths(
clt_parameters.stMeasSel); // int stMeasSel) // = 1; // Select measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert)
......