Commit e12c624a authored by Andrey Filippov's avatar Andrey Filippov

Tested GPU building DSI with multi-tile mode for low-contrast areas

parent 8a3c05ba
......@@ -1413,10 +1413,10 @@ Panel panel1,panel2;
}
/* Filter pattern coefficients to make sure they all match between quadrtants (match to the center one?)*/
boolean patternsMatchedInitially=matchPatterns(quarter_patterns,quarter_patterns[4]); // uses pattern in the center quadrant
if (DEBUG_LEVEL>1) {
System.out.println(patternsMatchedInitially?"Sim: All quadrant wave vectors matched initially, no correction needed":
"Some quadrant wave vectors were adjusted to match");
}
// if (DEBUG_LEVEL>1) {
// System.out.println(patternsMatchedInitially?"Sim: All quadrant wave vectors matched initially, no correction needed":
// "Some quadrant wave vectors were adjusted to match");
// }
patternCorr=calcPatternNonLinear(quarter_patterns); // divide results by ,(FFTSize/2)^2
if (DEBUG_LEVEL>1) { /* increase LEVEL later */
......
......@@ -337,6 +337,8 @@ public class CLTParameters {
// not used anywhere so far
public double min_smth = 0.25; // 0.25 minimal noise-normalized pixel difference in a channel to suspect something
public double sure_smth = 2.0; // reliable noise-normalized pixel difference in a channel to have something
public double rsure_smth = 0.5; // reliable noise-normalized pixel difference in a channel to have something
public double cold_sky_above = 50.0; // "Cold sky" - LWIR only, bgnd for all colder than found BG by this value
public double bgnd_range = 0.3; // disparity range to be considered background
public double other_range = 2.0; // disparity difference from center (provided) disparity to trust
......@@ -1239,6 +1241,8 @@ public class CLTParameters {
properties.setProperty(prefix+"min_smth", this.min_smth +"");
properties.setProperty(prefix+"sure_smth", this.sure_smth +"");
properties.setProperty(prefix+"rsure_smth", this.rsure_smth +"");
properties.setProperty(prefix+"cold_sky_above", this.cold_sky_above +"");
properties.setProperty(prefix+"bgnd_range", this.bgnd_range +"");
properties.setProperty(prefix+"other_range", this.other_range +"");
......@@ -2059,6 +2063,8 @@ public class CLTParameters {
if (properties.getProperty(prefix+"min_smth")!=null) this.min_smth=Double.parseDouble(properties.getProperty(prefix+"min_smth"));
if (properties.getProperty(prefix+"sure_smth")!=null) this.sure_smth=Double.parseDouble(properties.getProperty(prefix+"sure_smth"));
if (properties.getProperty(prefix+"rsure_smth")!=null) this.rsure_smth=Double.parseDouble(properties.getProperty(prefix+"rsure_smth"));
if (properties.getProperty(prefix+"cold_sky_above")!=null) this.cold_sky_above=Double.parseDouble(properties.getProperty(prefix+"cold_sky_above"));
if (properties.getProperty(prefix+"bgnd_range")!=null) this.bgnd_range=Double.parseDouble(properties.getProperty(prefix+"bgnd_range"));
if (properties.getProperty(prefix+"other_range")!=null) this.other_range=Double.parseDouble(properties.getProperty(prefix+"other_range"));
......@@ -2991,6 +2997,11 @@ public class CLTParameters {
gd.addNumericField("Minimal noise-normalized pixel difference in a channel to suspect something", this.min_smth, 3);
gd.addNumericField("Reliable noise-normalized pixel difference in a channel to have something ", this.sure_smth, 3);
gd.addNumericField("Relative inter-channel variation meaning there is something non-bg", this.rsure_smth, 4,6,"",
"Absolute difference ratio to average of mean and max meaning that there is something there");
gd.addNumericField("Cold sky", this.cold_sky_above, 4,6,"counts",
"LWIR-only: tiles that are higher than the lowest BG and are colder by this value than BG");
gd.addNumericField("Disparity range to be considered background", this.bgnd_range, 3);
gd.addNumericField("Disparity difference from the center (provided) disparity to trust", this.other_range, 3);
......@@ -3933,6 +3944,8 @@ public class CLTParameters {
this.debug_filters= gd.getNextBoolean();
this.min_smth= gd.getNextNumber();
this.sure_smth= gd.getNextNumber();
this.rsure_smth= gd.getNextNumber();
this.cold_sky_above= gd.getNextNumber();
this.bgnd_range= gd.getNextNumber();
this.other_range= gd.getNextNumber();
......
......@@ -6757,8 +6757,6 @@ private Panel panel1,
try {
TWO_QUAD_CLT.batchLwirRig(
// GPU_QUAD, // GPUTileProcessor.GpuQuad gpuQuad_main, // may be null if GPU for MAIN is not use3d
// GPU_QUAD_AUX, // GPUTileProcessor.GpuQuad gpuQuad_aux, // may be null if GPU for AUX is not use3d
QUAD_CLT, // QuadCLT quadCLT_main,
QUAD_CLT_AUX, // QuadCLT quadCLT_aux,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
......
......@@ -34,7 +34,7 @@ public class ExportForGPUDevelopment {
// int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt, getNumSensors());
TpTask[] tp_tasks = GpuQuad.setTasks(
quadCLT.getNumSensors(), // final int num_cams,
clt_parameters.transform_size, // final int transform_size,
// clt_parameters.transform_size, // final int transform_size,
disparity_array, // final double [][] disparity_array, // [tilesY][tilesX] - individual per-tile expected disparity
disparity_corr, // final double disparity_corr,
tile_op, // final int [][] tile_op, // [tilesY][tilesX] - what to do - 0 - nothing for this tile
......
......@@ -38,7 +38,7 @@ public class TpTask {
}
/**
* Initialize from the float array (read from the GPU)
* @param num_sensors number of sesnors in an array
* @param num_sensors number of sensors in an array
* @param flt float array containing tasks data
* @param indx task number to use
* @param use_aux (always false now)
......@@ -101,24 +101,6 @@ public class TpTask {
}
return ddisp_dist;
}
@Deprecated
public float [][] getXY(boolean use_aux){
return use_aux? xy_aux : xy;
}
@Deprecated
public double [][] getDoubleXY(boolean use_aux){
float [][] fXY = getXY(use_aux);
if (fXY == null) {
return null;
}
double [][] dXY = new double [fXY.length][fXY[0].length];
for (int nsens = 0; nsens < fXY.length; nsens++) {
for (int i = 0; i < fXY[nsens].length; i++) {
dXY[nsens][i] = fXY[nsens][i];
}
}
return dXY;
}
public float [][] getXY(){
return xy;
......@@ -149,6 +131,11 @@ public class TpTask {
public double getTargetDisparity() {
return target_disparity;
}
public void updateTargetDisparity(float td) {
target_disparity = td;
}
public float [] getCenterXY() {
return centerXY;
......@@ -188,15 +175,6 @@ public class TpTask {
indx+= 2;
}
}
/*
for (int i = 0; i < num_sensors; i++) { // actually disp_dist will be initialized by the GPU
indx+= 4;
flt[indx++] = disp_dist[i][0];
flt[indx++] = disp_dist[i][1];
flt[indx++] = disp_dist[i][2];
flt[indx++] = disp_dist[i][3];
}
*/
return flt;
}
}
\ No newline at end of file
......@@ -1027,7 +1027,37 @@ public class CLTPass3d{
}
return num_op_tiles;
}
public void setTileOp(
int tile_op)
{
final int tilesX = tileProcessor.getTilesX();
final int tilesY = tileProcessor.getTilesY();
this.tile_op = new int [tilesY][tilesX];
for (int ty = 0; ty < tilesY; ty++) for (int tx = 0; tx <tilesX; tx++){
this.tile_op[ty][tx] = tile_op;
}
}
public double [] getDA() {
final int tilesX = tileProcessor.getTilesX();
final int tilesY = tileProcessor.getTilesY();
double [] da = new double [tilesX*tilesY];
for (int ty = 0; ty < tilesY; ty++) for (int tx = 0; tx <tilesX; tx++){
da[tilesX * ty + tx] = this.disparity[ty][tx];
}
return da;
}
public void setDA(double [] da) {
final int tilesX = tileProcessor.getTilesX();
final int tilesY = tileProcessor.getTilesY();
for (int ty = 0; ty < tilesY; ty++) for (int tx = 0; tx <tilesX; tx++){
this.disparity[ty][tx] = da[tilesX * ty + tx];
}
}
/**
* Set next measurement disparity from last calculated
*/
......
......@@ -500,7 +500,7 @@ public class Corr2dLMA {
if ((disp_str[nTile] != null) && (disp_str[nTile][1] > 0.0) && used_tiles[nTile]) {
this.all_pars[DISP_INDEX + nTile*tile_params] = -disp_str[nTile][0]; // disp0;
} else {
this.all_pars[DISP_INDEX + nTile*tile_params] = 0.0; // disp0;
this.all_pars[DISP_INDEX + nTile*tile_params] = 0.0; // disp0; // null pointer
}
}
}
......@@ -2535,10 +2535,13 @@ public class Corr2dLMA {
}
}
Matrix y_minus_fx_weighted = new Matrix(this.last_ymfx, this.last_ymfx.length);
Matrix wjtjlambda = new Matrix(getWJtJlambda(
double [][] awjtjlambda = getWJtJlambda( // null
lambda, // *10, // temporary
this.last_jt)); // double [][] jt)
this.last_jt); // double [][] jt)
if ((awjtjlambda == null) || (awjtjlambda.length==0)) {
return null;
}
Matrix wjtjlambda = new Matrix(awjtjlambda); // double [][] jt)
if (debug_level>2) {
System.out.println("JtJ + lambda*diag(JtJ");
wjtjlambda.print(18, 6);
......
......@@ -1594,7 +1594,7 @@ public class Correlation2d {
* @param lpf optional final low-pass filter applied to mixed colors
* @param lpf_rb optional low-pass filter (extra) for R,B components only
* @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 col_weights [3] - color weights {R, B, G} - green is last, normalized to sum =1.0
* @return correlation result (Transform Domain) [quadrant][index]
*/
public double[][] correlateCompositeTD(
......@@ -4069,7 +4069,7 @@ public class Correlation2d {
if (disp != null) {
disp_str2[0] = disp;
lma.initDisparity( // USED in lwir
lma.initDisparity( // USED in lwir null pointer
disp_str2); // double [][] disp_str // initial value of disparity
if (debug_level > 1) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -282,6 +282,15 @@ public class ImageDttParameters {
return (numSens > mcorr_multi) ? mcorr_topis0_multi : mcorr_topis0;
}
public int getMcorr(int numSens) {
return (getMcorrAll (numSens) ? 1 : 0) |
(getMcorrDia (numSens) ? 2 : 0) |
(getMcorrSq (numSens) ? 8 : 0) |
(getMcorrNeib(numSens) ? 16 : 0) |
(getMcorrHor (numSens) ? 32 : 0) |
(getMcorrVert(numSens) ? 64 : 0);
}
public boolean getMcorrAll(int numSens) {
return (numSens > mcorr_multi) ? mcorr_all_multi : mcorr_all;
}
......@@ -310,6 +319,42 @@ public class ImageDttParameters {
return (numSens > mcorr_multi) ? mcorr_sel_ly_multi : mcorr_sel_ly;
}
public void setMcorr(int numSens, int sel ) {
setMcorrAll (numSens, (sel & (1 << 0)) != 0);
setMcorrDia (numSens, (sel & (1 << 1)) != 0);
setMcorrSq (numSens, (sel & (1 << 2)) != 0);
setMcorrNeib(numSens, (sel & (1 << 3)) != 0);
setMcorrHor (numSens, (sel & (1 << 4)) != 0);
setMcorrVert(numSens, (sel & (1 << 5)) != 0);
}
public void setMcorrAll(int numSens, boolean b) {
if (numSens > mcorr_multi) mcorr_all_multi = b; else mcorr_all = b;
}
public void setMcorrDia(int numSens, boolean b) {
if (numSens > mcorr_multi) mcorr_dia_multi = b; else mcorr_dia = b;
}
public void setMcorrSq(int numSens, boolean b) {
if (numSens > mcorr_multi) mcorr_sq_multi = b; else mcorr_sq = b;
}
public void setMcorrNeib(int numSens, boolean b) {
if (numSens > mcorr_multi) mcorr_neib_multi = b; else mcorr_neib = b;
}
public void setMcorrHor(int numSens, boolean b) {
if (numSens > mcorr_multi) mcorr_hor_multi = b; else mcorr_hor = b;
}
public void setMcorrVert(int numSens, boolean b) {
if (numSens > mcorr_multi) mcorr_vert_multi = b; else mcorr_vert = b;
}
public void dialogQuestions(GenericJTabbedDialog gd) {
gd.addCheckbox ("Debug CPU->GPU matching", this.gpu_mode_debug,
......
......@@ -283,7 +283,7 @@ 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.getDisparityTitles(geometryCorrection.getNumSensors()).length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging)
double [][] disparity_map = new double [ImageDtt.getDisparityTitles(geometryCorrection.getNumSensors(), this.mtp.isMonochrome()).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}};
......
......@@ -1399,12 +1399,12 @@ public class TwoQuadCLT {
double [][] sub_disparity_map = new double [sub_titles.length][];
for (int ncam = 0; ncam < numSensors; ncam++) {
sub_disparity_map[ncam] = disparity_map[ncam + ImageDtt.IMG_DIFF0_INDEX];
sub_titles[ncam] = ImageDtt.getDisparityTitles(numSensors)[ncam + ImageDtt.IMG_DIFF0_INDEX];
sub_titles[ncam] = ImageDtt.getDisparityTitles(numSensors, quadCLT_main.isMonochrome())[ncam + ImageDtt.IMG_DIFF0_INDEX];
for (int ncol = 0; ncol < num_colors_main; ncol++) {
sub_disparity_map[ncam + (ncol + 1)* numSensors] =
disparity_map[ncam +ncol* numSensors+ ImageDtt.getImgToneRGB(numSensors)];
sub_titles[ncam + (ncol + 1)* numSensors] =
ImageDtt.getDisparityTitles(numSensors)[ncam +ncol* numSensors+ ImageDtt.getImgToneRGB(numSensors)];
ImageDtt.getDisparityTitles(numSensors,quadCLT_main.isMonochrome())[ncam +ncol* numSensors+ ImageDtt.getImgToneRGB(numSensors)];
}
}
(new ShowDoubleFloatArrays()).showArrays(
......@@ -8253,8 +8253,8 @@ if (debugLevel > -100) return true; // temporarily !
QuadCLT.SetChannels [] set_channels=quadCLT_main.setChannels(debugLevel);
// String set_name = set_channels[0].set_name;
// QuadCLT [] quadCLTs = new QuadCLT [set_channels.length];
QuadCLTCPU [] quadCLTs = new QuadCLTCPU [set_channels.length];
QuadCLT [] quadCLTs = new QuadCLT [set_channels.length]; // Was line below
// QuadCLTCPU [] quadCLTs = new QuadCLTCPU [set_channels.length];
for (int i = 0; i < quadCLTs.length; i++) {
quadCLTs[i] = quadCLT_main.spawnQuadCLT(
set_channels[i].set_name,
......@@ -11176,15 +11176,6 @@ if (debugLevel > -100) return true; // temporarily !
}
for (int nSet = 0; nSet < set_channels.length; nSet++){
// check it is the same set for both cameras
/*
if ((set_channels_aux != null) && (set_channels_aux.length <= nSet )) {
throw new Exception ("Set names for cameras do not match: main camera: '"+set_channels_main[nSet].name()+"', aux. camera: nothing");
}
if (!set_channels_main[nSet].name().equals(set_channels_aux[nSet].name())) {
throw new Exception ("Set names for cameras do not match: main camera: '"+set_channels_main[nSet].name()+"', aux. camera: '"+set_channels_main[nSet].name()+"'");
}
*/
// nset -> name - n1, n2 (in
String set_name = set_channels[nSet].set_name;
int nSet_main = -1, nSet_aux = -1;
......@@ -11358,7 +11349,6 @@ if (debugLevel > -100) return true; // temporarily !
debugLevel); // final int debugLevel);
} else {
if (updateStatus) IJ.showStatus("CPU: Rendering 4 image set (disparity = 0) for "+quadCLT_main.image_name+ "and a thumb nail");
quadCLT_main.processCLTQuadCorrCPU( // returns ImagePlus, but it already should be saved/shown
// imp_srcs_main, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_main, // boolean [][] saturation_imp, // (near) saturated pixels or null
......@@ -11652,23 +11642,39 @@ if (debugLevel > -100) return true; // temporarily !
}
// Generate 4 AUX camera images and thumbnail
if (quadCLT_main.correctionsParameters.clt_batch_4img_aux){
if (updateStatus) IJ.showStatus("Rendering 4 AUX image set (disparity = 0) for "+quadCLT_aux.image_name);
quadCLT_aux.processCLTQuadCorrCPU( // returns ImagePlus, but it already should be saved/shown
// imp_srcs_aux, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_aux, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters,
debayerParameters,
colorProcParameters_aux,
channelGainParameters,
rgbParameters,
scaleExposures_aux,
false, // calculate and apply additional fine geometry correction
false, // calculate and apply geometry correction at infinity
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
quadCLT_aux.tp.resetCLTPasses();
if (clt_parameters.gpu_use_aux) {
if (updateStatus) IJ.showStatus("GPU: Rendering 4 AUX image set (disparity = 0) for "+quadCLT_aux.image_name+ "and a thumb nail");
quadCLT_aux.processCLTQuadCorrGPU(
imp_srcs_aux, // ImagePlus [] imp_quad,
saturation_imp_aux, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters, // CLTParameters clt_parameters,
debayerParameters, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
colorProcParameters_aux, // ColorProcParameters colorProcParameters,
channelGainParameters,
rgbParameters, // EyesisCorrectionParameters.RGBParameters rgbParameters,
scaleExposures_aux, // double [] scaleExposures, // probably not needed here - restores brightness of the final image
false, // boolean only4slice,
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel);
} else {
if (updateStatus) IJ.showStatus("CPU: Rendering 4 AUX image set (disparity = 0) for "+quadCLT_aux.image_name);
quadCLT_aux.processCLTQuadCorrCPU( // returns ImagePlus, but it already should be saved/shown
// imp_srcs_aux, // [srcChannel], // should have properties "name"(base for saving results), "channel","path"
saturation_imp_aux, // boolean [][] saturation_imp, // (near) saturated pixels or null
clt_parameters,
debayerParameters,
colorProcParameters_aux,
channelGainParameters,
rgbParameters,
scaleExposures_aux,
false, // calculate and apply additional fine geometry correction
false, // calculate and apply geometry correction at infinity
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
quadCLT_aux.tp.resetCLTPasses();
}
}
// Currently - no LWIR 3D model generation, maybe it will be added later
// Generate AUX DS
......
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