Commit 0246d531 authored by Andrey Filippov's avatar Andrey Filippov

debugging artifacts in vert/hor correlations caused by pixel-locking for

polynomial argmax and residual Bayer modulation
parent fa4f3beb
......@@ -296,9 +296,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.14</version>
<!-- <version>2.14</version>-->
<version>3.6.1</version>
<configuration>
<configLocation>config/sun_checks.xml</configLocation>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
......
......@@ -1414,7 +1414,8 @@ 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");
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
......
......@@ -89,6 +89,7 @@ import com.elphel.imagej.jp4.JP46_Reader_camera;
import com.elphel.imagej.lwir.LwirReader;
import com.elphel.imagej.readers.EyesisTiff;
import com.elphel.imagej.tensorflow.TensorflowInferModel;
import com.elphel.imagej.tileprocessor.Clt1d;
import com.elphel.imagej.tileprocessor.DttRad2;
import com.elphel.imagej.tileprocessor.ErsCorrection;
import com.elphel.imagej.tileprocessor.ImageDtt;
......@@ -707,7 +708,9 @@ private Panel panel1,
addButton("Inter Series", panelClt5, color_process);
addButton("Inter Accumulate", panelClt5, color_process);
addButton("Inter Noise", panelClt5, color_process);
addButton("Inter Debug Noise", panelClt5, color_report);
addButton("Noise Stats", panelClt5, color_process);
addButton("Test 1D", panelClt5, color_process);
addButton("Colorize Depth", panelClt5, color_process);
plugInFrame.add(panelClt5);
}
......@@ -5144,7 +5147,15 @@ private Panel panel1,
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
CLT_PARAMETERS.batch_run = true;
intersceneNoise();
intersceneNoise(false); // boolean bayer_artifacts_debug);
return;
/* ======================================================================== */
} else if (label.equals("Inter Debug Noise")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
CLT_PARAMETERS.batch_run = true;
intersceneNoise(true); // boolean bayer_artifacts_debug);
return;
/* ======================================================================== */
......@@ -5161,6 +5172,13 @@ private Panel panel1,
CLT_PARAMETERS.batch_run = true;
coloriseDepthMap();
return;
/* ======================================================================== */
} else if (label.equals("Test 1D")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
CLT_PARAMETERS.batch_run = true;
test1d();
return;
/* ======================================================================== */
} else if (label.equals("Inter LMA")) {
......@@ -6821,7 +6839,7 @@ private Panel panel1,
return true;
}
public boolean intersceneNoise() {
public boolean intersceneNoise(boolean bayer_artifacts_debug) {
long startTime=System.nanoTime();
// load needed sensor and kernels files
if (!prepareRigImages()) return false;
......@@ -6869,8 +6887,9 @@ private Panel panel1,
RGB_PARAMETERS, //EyesisCorrectionParameters.RGBParameters rgbParameters,
EQUIRECTANGULAR_PARAMETERS, // EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
PROPERTIES, // Properties properties,
THREADS_MAX, //final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, //final boolean updateStatus,
bayer_artifacts_debug, // boolean bayer_artifacts_debug
THREADS_MAX, // final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, // final boolean updateStatus,
DEBUG_LEVEL);
} catch (Exception e) {
// TODO Auto-generated catch block
......@@ -6956,6 +6975,11 @@ private Panel panel1,
Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
return true;
}
public boolean test1d() {
Clt1d clt1d = new Clt1d(CLT_PARAMETERS.transform_size); // CLT_PARAMETERS
clt1d.test1d(CLT_PARAMETERS);
return true;
}
public boolean coloriseDepthMap() {
ImagePlus imp_sel = WindowManager.getCurrentImage();
......
......@@ -1867,7 +1867,23 @@ public class GPUTileProcessor {
public void execCorr2D_combine(
boolean init_corr, // initialize output tiles (false - add to current)
int num_pairs_in, // typically 6 - number of pairs per tile (tile task should have same number per each tile
int pairs_mask // selected pairs (0x3 - horizontal, 0xc - vertical, 0xf - quad, 0x30 - cross)
int pairs_mask) // selected pairs (0x3 - horizontal, 0xc - vertical, 0xf - quad, 0x30 - cross)
{
execCorr2D_combine (init_corr, num_pairs_in, pairs_mask, false);
}
/**
* Combine intra-scene correlations in transform domain (possible to accumulate more)
* @param init_corr - true: init output to 0 before accumulating, false: add to current value
* @param num_pairs_in - typically ==6 - number of pairs per tile (tile task should have same number per each tile).
* This number should match correlations in tasks
* @param pairs_mask - selected pairs (0x3 - horizontal, 0xc - vertical, 0xf - quad, 0x30 - cross)
* @param no_transpose_vertical - do not transpose vertical/diagonal
*/
public void execCorr2D_combine(
boolean init_corr, // initialize output tiles (false - add to current)
int num_pairs_in, // typically 6 - number of pairs per tile (tile task should have same number per each tile
int pairs_mask, // selected pairs (0x3 - horizontal, 0xc - vertical, 0xf - quad, 0x30 - cross)
boolean no_transpose_vertical
) {
if (GPU_CORR2D_COMBINE_kernel == null)
{
......@@ -1881,16 +1897,17 @@ public class GPUTileProcessor {
int [] GridFullWarps = {1, 1, 1};
int [] ThreadsFullWarps = {1, 1, 1};
int init_corr_combo = (init_corr ? 1 : 0) + (no_transpose_vertical ? 2 : 0);
Pointer kernelParameters = Pointer.to(
Pointer.to(new int[] { num_corr_combo_tiles }), // num_task_tiles }), // int num_tiles // number of tiles in task
Pointer.to(new int[] { num_pairs }), // int num_pairs, // num pairs per tile (should be the same)
Pointer.to(new int[] { init_corr ? 1 : 0 }), // int init_output, // 1- reset output tiles to zero before accumulating
Pointer.to(new int[] { init_corr_combo }), // int init_output, // 1- reset output tiles to zero before accumulating
Pointer.to(new int[] { pairs_mask }), // int pairs_mask, // selected pairs
Pointer.to(gpu_corr_indices), // int * gpu_corr_indices, // packed tile+pair
Pointer.to(gpu_corr_combo_indices), // int * gpu_combo_indices, // output if not null: packed tile+pairs_mask
Pointer.to(new int[] { corr_stride_td }), // const size_t corr_stride, // (in floats) stride for the input TD correlations
Pointer.to(gpu_corrs_td), // float * gpu_corrs, // input correlation tiles
Pointer.to(new int[] { corr_stride_combo_td }),// const size_t corr_stride_combo, // (in floats) stride for the output TD
Pointer.to(new int[] { corr_stride_combo_td }), // const size_t corr_stride_combo, // (in floats) stride for the output TD
Pointer.to(gpu_corrs_combo_td)); // float * gpu_corrs_combo); // combined correlation output (one per tile)
cuCtxSynchronize();
// Call the kernel function
......
This diff is collapsed.
......@@ -514,11 +514,28 @@ public class Correlation2d {
double [][][] corr_combo_td, // vertical will be transposed, other diagonal flipped vertically (should be separate)
int pairs_mask // vertical
) {
return combineCorrelationsTD(corr_combo_td, pairs_mask, false);
}
/**
* Combine compatible correlations in TD (for 6 pairs requires 2 calls): vertical will be transposed,
* (all quadrants transposed, quadrants 1 and 2 - swapped), "diagonal other" (#5) will be flipped
* vertically (quadrants 2 and 3 - negated)
* @param corr_combo_td per-pair array of the TD representation of correlation pairs, mixed color components
* @param pairs_mask bitmask of the pairs to combinde
* @param no_transpose_vertical Do not transpose vertical pairs (used when combining just vertical together)
* @return TD representation of the combined 2D correlation
*/
public double [][] combineCorrelationsTD(
double [][][] corr_combo_td, // vertical will be transposed, other diagonal flipped vertically (should be separate)
int pairs_mask, // vertical
boolean no_transpose_vertical
) {
if (corr_combo_td != null) {
double [][]tcorr = new double [4][transform_len];
int num_combined = 0;
for (int npair = 0; npair < corr_combo_td.length; npair++) if ((((pairs_mask >> npair) & 1) != 0 ) && (corr_combo_td[npair] !=null)) {
if (isHorizontalPair(npair) || isDiagonalMainPair(npair)) {
if (isHorizontalPair(npair) || isDiagonalMainPair(npair) || (isVerticalPair(npair) && no_transpose_vertical)) {
for (int q = 0; q < 4; q++) {
for (int i = 0; i < transform_len; i++) {
tcorr[q][i] += corr_combo_td[npair][q][i];
......
......@@ -63,6 +63,34 @@ public class DttRad2 {
return fold_k;
}
/*
public double [] fold1D(double [] x, double offs) {
int n2 = x.length;
int n = n2/2;
int nh = n/2; // 4
int t = ilog2(n)-1;
double [] y = new double[n];
double [] w = new double [n2];
for (int i = 0; i < n2; i++) {
w[i]=Math.sin(Math.PI*i/n2 + 0.5 + offs); // sign?
}
for (int i = 0; i < nh; i++) { // 0.. 3
int icr = n + nh - 1 - i;
int id = n + nh + i;
int ia = i;
int ibr = n -1 -i;
y[i] = -x[icr]*w[icr] - x[id]* w[id];
y[i+nh] = x[ia]* w[ia] - x[ibr]*w[ibr];
}
return y;
}
*/
public DttRad2 (int maxN){ // n - maximal
setup_arrays(maxN); // always setup arrays for fast calculations
}
......@@ -482,12 +510,54 @@ public class DttRad2 {
qdata[3][(i-1)*transform_size + j - 1]);
}
}
return rslt;
}
public double [] corr_unfold_tile1(
double [][] qdata, // [4][transform_size*transform_size] data after DCT2 (pixel domain)
int transform_size
)
{
int corr_pixsize = transform_size * 2 - 1;
double corr_pixscale = 0.25;
double [] rslt = new double [corr_pixsize*corr_pixsize];
rslt[corr_pixsize*transform_size - transform_size] = corr_pixscale * qdata[0][0]; // center
for (int j = 1; j < transform_size; j++) { // for i == 0
rslt[corr_pixsize*transform_size - transform_size + j] = corr_pixscale * (qdata[0][j] + qdata[1][j-1]);
rslt[corr_pixsize*transform_size - transform_size - j] = corr_pixscale * (qdata[0][j] - qdata[1][j-1]);
}
for (int i = 1; i < transform_size; i++) {
rslt[corr_pixsize*(transform_size + i) - transform_size] =
corr_pixscale * (qdata[0][i*transform_size] + qdata[2][(i-1)*transform_size]);
rslt[corr_pixsize*(transform_size - i) - transform_size] =
corr_pixscale * (qdata[0][i*transform_size] - qdata[2][(i-1)*transform_size]);
for (int j = 1; j < transform_size; j++) {
rslt[corr_pixsize*(transform_size + i) - transform_size + j] =
corr_pixscale * (qdata[0][i* transform_size + j] +
qdata[1][i* transform_size + j - 1] +
qdata[2][(i-1)*transform_size + j] +
qdata[3][(i-1)*transform_size + j - 1]);
rslt[corr_pixsize*(transform_size + i) - transform_size - j] =
corr_pixscale * ( qdata[0][i* transform_size + j] +
-qdata[1][i* transform_size + j - 1] +
qdata[2][(i-1)*transform_size + j] +
-qdata[3][(i-1)*transform_size + j - 1]);
rslt[corr_pixsize*(transform_size - i) - transform_size + j] =
corr_pixscale * (qdata[0][i* transform_size + j] +
qdata[1][i* transform_size + j - 1] +
-qdata[2][(i-1)*transform_size + j] +
-qdata[3][(i-1)*transform_size + j - 1]);
rslt[corr_pixsize*(transform_size - i) - transform_size - j] =
corr_pixscale * (qdata[0][i* transform_size + j] +
-qdata[1][i* transform_size + j - 1] +
-qdata[2][(i-1)*transform_size + j] +
qdata[3][(i-1)*transform_size + j - 1]);
}
}
return rslt;
}
......
......@@ -102,6 +102,7 @@ public class ImageDttParameters {
public double corr_wndx_blur = 5.0; // 100% to 0 % vertical transition range
public boolean pcorr_use = false; // use group phase correlation for disparity calculation in existing code
public boolean pcorr_use_hv = true; // use group phase correlation to combine hor and vert pairs
public double pcorr_sigma_mono = 0.15; // correlation sigma for monochrome images (after normalization)
public double pcorr_sigma = 0.8; // correlation sigma for Bayder images (after normalization)
public double pcorr_sigma_rb = 0.5; // correlation sigma extra for R and B (before normalization)
......@@ -343,6 +344,8 @@ public class ImageDttParameters {
gd.addCheckbox ("Use group phase correlation for disparity calculation", this.pcorr_use,
"Default false, for compatibility with existing code/ old configs");
gd.addCheckbox ("Use group phase correlation to combine hor and vert pairs separately", this.pcorr_use_hv,
"Use even when hor are not combined with vert");
gd.addNumericField("Correlation sigma for monochrome images", this.pcorr_sigma_mono, 3, 6, "pix",
"after normalization");
gd.addNumericField("Correlation sigma for Bayer images", this.pcorr_sigma, 3, 6, "pix",
......@@ -588,6 +591,7 @@ public class ImageDttParameters {
this.corr_wndx_blur = gd.getNextNumber();
this.pcorr_use= gd.getNextBoolean();
this.pcorr_use_hv= gd.getNextBoolean();
this.pcorr_sigma_mono = gd.getNextNumber();
this.pcorr_sigma = gd.getNextNumber();
this.pcorr_sigma_rb = gd.getNextNumber();
......@@ -739,6 +743,7 @@ public class ImageDttParameters {
properties.setProperty(prefix+"corr_wndx_blur", this.corr_wndx_blur +"");
properties.setProperty(prefix+"pcorr_use", this.pcorr_use +"");
properties.setProperty(prefix+"pcorr_use_hv", this.pcorr_use_hv +"");
properties.setProperty(prefix+"pcorr_sigma_mono", this.pcorr_sigma_mono +"");
properties.setProperty(prefix+"pcorr_sigma", this.pcorr_sigma +"");
properties.setProperty(prefix+"pcorr_sigma_rb", this.pcorr_sigma_rb +"");
......@@ -896,6 +901,7 @@ public class ImageDttParameters {
if (properties.getProperty(prefix+"corr_wndx_blur")!=null) this.corr_wndx_blur=Double.parseDouble(properties.getProperty(prefix+"corr_wndx_blur"));
if (properties.getProperty(prefix+"pcorr_use")!=null) this.pcorr_use=Boolean.parseBoolean(properties.getProperty(prefix+"pcorr_use"));
if (properties.getProperty(prefix+"pcorr_use_hv")!=null) this.pcorr_use_hv=Boolean.parseBoolean(properties.getProperty(prefix+"pcorr_use_hv"));
if (properties.getProperty(prefix+"pcorr_sigma_mono")!=null) this.pcorr_sigma_mono=Double.parseDouble(properties.getProperty(prefix+"pcorr_sigma_mono"));
if (properties.getProperty(prefix+"pcorr_sigma")!=null) this.pcorr_sigma=Double.parseDouble(properties.getProperty(prefix+"pcorr_sigma"));
if (properties.getProperty(prefix+"pcorr_sigma_rb")!=null) this.pcorr_sigma_rb=Double.parseDouble(properties.getProperty(prefix+"pcorr_sigma_rb"));
......@@ -1048,6 +1054,7 @@ public class ImageDttParameters {
idp.corr_wndx_blur = this.corr_wndx_blur;
idp.pcorr_use = this.pcorr_use;
idp.pcorr_use_hv = this.pcorr_use_hv;
idp.pcorr_sigma_mono = this.pcorr_sigma_mono;
idp.pcorr_sigma = this.pcorr_sigma;
idp.pcorr_sigma_rb = this.pcorr_sigma_rb;
......
......@@ -8350,7 +8350,7 @@ public class QuadCLTCPU {
if (update_disp_from_latest) {
tp.clt_3d_passes.get(combo_scan).updateDisparity();
}
if (clt_parameters.ly_lma_ers) {
if (clt_parameters.ly_lma_ers) { // next is implemented in both QuadCLTCPU and QuadCLT !
CLTMeasureLY( // perform single pass according to prepared tiles operations and disparity // USED in lwir
clt_parameters,
combo_scan, // final int scanIndex,
......
......@@ -8671,6 +8671,7 @@ if (debugLevel > -100) return true; // temporarily !
EyesisCorrectionParameters.RGBParameters rgbParameters,
EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
Properties properties,
boolean bayer_artifacts_debug,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel) throws Exception
......@@ -8681,7 +8682,7 @@ if (debugLevel > -100) return true; // temporarily !
// double [] noise_sigma_level = {3.0, 1.5, 1.0}; // amount, sigma, offset
// double [] noise_sigma_level = {5.0, 1.5, 1.0}; // amount, sigma, offset
double [] noise_sigma_level = null;
if (clt_parameters.inp.noise_scale > 0.0) {
if (clt_parameters.inp.noise_scale >= 0.0) {// <0 - will generate no-noise data
noise_sigma_level = new double[] {
clt_parameters.inp.noise_scale,
clt_parameters.inp.noise_sigma,
......@@ -8743,14 +8744,23 @@ if (debugLevel > -100) return true; // temporarily !
OpticalFlow opticalFlow = new OpticalFlow(
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus); // boolean updateStatus);
opticalFlow.IntersceneNoise(
if (bayer_artifacts_debug) {
opticalFlow.intersceneNoiseDebug(
clt_parameters, // CLTParameters clt_parameters,
ref_only, // boolean ref_only, // process only reference frame (false - inter-scene)
colorProcParameters, // ColorProcParameters colorProcParameters,
ref_quadCLT, // QuadCLT [] scenes, // ordered by increasing timestamps
noise_sigma_level, // double [] noise_sigma_level,
clt_parameters.inp.noise_debug_level); // clt_parameters.ofp.debug_level_optical - 1); // 1); // -1); // int debug_level);
} else {
opticalFlow.intersceneNoise(
clt_parameters, // CLTParameters clt_parameters,
ref_only, // boolean ref_only, // process only reference frame (false - inter-scene)
colorProcParameters, // ColorProcParameters colorProcParameters,
ref_quadCLT, // QuadCLT [] scenes, // ordered by increasing timestamps
noise_sigma_level, // double [] noise_sigma_level,
clt_parameters.inp.noise_debug_level); // clt_parameters.ofp.debug_level_optical - 1); // 1); // -1); // int debug_level);
}
System.out.println("End of intersceneNoise()");
}
......
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