Commit f5a43005 authored by Andrey Filippov's avatar Andrey Filippov

correcting wrongly reported exposure

parent 8d207d39
This diff is collapsed.
......@@ -27,6 +27,7 @@ import java.awt.Rectangle;
import java.util.concurrent.atomic.AtomicInteger;
public class CLTPass3d{
// static double max_overexposed = 0.8; // TODO: make parameter
public double [][] disparity; // per-tile disparity set for the pass[tileY][tileX]
public int [][] tile_op; // what was done in the current pass
private double [][] disparity_sav; // saved disaprity
......@@ -192,8 +193,7 @@ public class CLTPass3d{
*/
public void resetProcessed(){
fixNaNDisparity();
if (disparity_map != null) fixNaNDisparity();
calc_disparity = null; // composite disparity, calculated from "disparity", and "disparity_map" fields
calc_disparity_hor = null; // composite disparity, calculated from "disparity", and "disparity_map" fields
calc_disparity_vert = null; // composite disparity, calculated from "disparity", and "disparity_map" fields
......@@ -356,15 +356,21 @@ public class CLTPass3d{
}
return disparity;
}
public double [] getOverexposedFraction(){
return (disparity_map != null)? disparity_map[ImageDtt.OVEREXPOSED] : null;
}
/**
* Returns per-tile correlation "strength". Initially - copy of the FPGA-generated data, b ut later may be replaced by a combination
* Returns per-tile correlation "strength". Initially - copy of the FPGA-generated data, but later may be replaced by a combination
* of the combined data from 4-sensor (4-pair) correlation and horizontal/vertical pairs only to improve detection of vertical/
* horizontal features
* @return line-scan array of per-tile correlation strength by reference (not a copy), so it can be modified
*/
public double [] getStrength(){
double trustedCorrelation = tileProcessor.getTrustedCorrelation();
double max_overexposure = tileProcessor.getMaxOverexposure();
if (strength == null){
strength = disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX].clone();
if (trustedCorrelation > 0.0){
......@@ -372,6 +378,12 @@ public class CLTPass3d{
if (Math.abs(disparity_map[disparity_index][i]) > trustedCorrelation) strength[i] = 0.0; // too far
}
}
double [] overexposed = disparity_map[ImageDtt.OVEREXPOSED];
if ((max_overexposure > 0.0) && (overexposed != null)){
for (int i = 0; i < strength.length; i++){
if (overexposed[i] > max_overexposure) strength[i] = 0.0; // too overexposed
}
}
}
return strength;
}
......@@ -388,6 +400,7 @@ public class CLTPass3d{
*/
public double [] getHorStrength(){
double trustedCorrelation = tileProcessor.getTrustedCorrelation();
double max_overexposure = tileProcessor.getMaxOverexposure();
if (strength_hor == null) {
strength_hor = disparity_map[ImageDtt.DISPARITY_INDEX_HOR_STRENGTH].clone();
if (trustedCorrelation > 0.0){
......@@ -395,15 +408,23 @@ public class CLTPass3d{
if (Math.abs(disparity_map[ImageDtt.DISPARITY_INDEX_HOR][i]) > trustedCorrelation) strength_hor[i] = 0.0; // too far
}
}
double [] overexposed = disparity_map[ImageDtt.OVEREXPOSED];
if ((max_overexposure > 0.0) && (overexposed != null)){
for (int i = 0; i < strength_hor.length; i++){
if (overexposed[i] > max_overexposure) strength_hor[i] = 0.0; // too overexposed
}
}
}
return strength_hor;
}
/**
* Get veriical pairs correlation strength for horizontal features. Not a copy
* Get vertical pairs correlation strength for horizontal features. Not a copy
* @return line-scan array of per-tile horizontal pairs correlation strength by reference (not a copy)
*/
public double [] getVertStrength(){
double trustedCorrelation = tileProcessor.getTrustedCorrelation();
double max_overexposure = tileProcessor.getMaxOverexposure();
if (strength_vert == null) {
strength_vert = disparity_map[ImageDtt.DISPARITY_INDEX_VERT_STRENGTH].clone();
if (trustedCorrelation > 0.0){
......@@ -411,6 +432,12 @@ public class CLTPass3d{
if (Math.abs(disparity_map[ImageDtt.DISPARITY_INDEX_VERT][i]) > trustedCorrelation) strength_vert[i] = 0.0; // too far
}
}
double [] overexposed = disparity_map[ImageDtt.OVEREXPOSED];
if ((max_overexposure > 0.0) && (overexposed != null)){
for (int i = 0; i < strength_hor.length; i++){
if (overexposed[i] > max_overexposure) strength_vert[i] = 0.0; // too overexposed
}
}
}
return strength_vert;
......@@ -704,6 +731,7 @@ public class CLTPass3d{
selection, // boolean [] selection,
disparity); // double [] disparity)
}
public int setTileOpDisparity(
int tile_op,
boolean [] selection,
......@@ -712,26 +740,39 @@ public class CLTPass3d{
final int tilesX = tileProcessor.getTilesX();
final int tilesY = tileProcessor.getTilesY();
this.disparity = new double [tilesY][tilesX];
this.tile_op = new int [tilesY][tilesX];
if (selection != null) {
this.tile_op = new int [tilesY][tilesX];
}
int num_op_tiles = 0;
for (int ty = 0; ty < tilesY; ty++) for (int tx = 0; tx <tilesX; tx++){
int indx = tilesX * ty + tx;
if (this.selected[indx]) {
this.disparity[ty][tx] = disparity[indx];
this.tile_op[ty][tx] = tile_op;
num_op_tiles ++;
if (selection == null) {
this.disparity[ty][tx] = (disparity == null)? 0.0: disparity[indx];
if (this.tile_op[ty][tx] != 0){
num_op_tiles ++;
}
} else {
this.disparity[ty][tx] = 0.0;
this.tile_op[ty][tx] = 0;
if (selection[indx]) {
this.disparity[ty][tx] = (disparity == null)? 0.0: disparity[indx];
this.tile_op[ty][tx] = tile_op;
num_op_tiles ++;
} else {
this.disparity[ty][tx] = 0.0;
this.tile_op[ty][tx] = 0;
}
}
}
return num_op_tiles;
}
/**
* Set next measurement disparity from last calculated
*/
public void updateDisparity()
{
setTileOpDisparity(null, getDisparity(0));
}
public double [] getSecondMaxDiff (
......
......@@ -78,7 +78,8 @@ private Panel panel1,
panelPostProcessing3,
panelDct1,
panelClt1,
panelClt2
panelClt2,
panelClt3
;
JP46_Reader_camera JP4_INSTANCE=null;
......@@ -370,7 +371,7 @@ private Panel panel1,
instance = this;
addKeyListener(IJ.getInstance());
int menuRows=4 + (ADVANCED_MODE?4:0) + (MODE_3D?3:0) + (DCT_MODE?3:0);
int menuRows=4 + (ADVANCED_MODE?4:0) + (MODE_3D?3:0) + (DCT_MODE?4:0);
setLayout(new GridLayout(menuRows, 1));
panel6 = new Panel();
......@@ -518,16 +519,6 @@ private Panel panel1,
panelClt2 = new Panel();
panelClt2.setLayout(new GridLayout(1, 0, 5, 5)); // rows, columns, vgap, hgap
addButton("Setup CLT parameters", panelClt2, color_configure);
// addButton("Select CLT image", panelClt2, color_configure);
// addButton("CLT stack", panelClt2, color_process);
// addButton("Select second CLT image", panelClt2, color_configure);
// addButton("CLT correlate", panelClt2, color_process);
// addButton("Create CLT kernels", panelClt2, color_process);
// addButton("Read CLT kernels", panelClt2, color_process);
// addButton("Reset CLT kernels", panelClt2, color_stop);
// addButton("CLT process files", panelClt2, color_process);
// addButton("CLT process sets", panelClt2, color_process);
// addButton("CLT process quads", panelClt2, color_process);
addButton("CLT 4 images", panelClt2, color_conf_process);
addButton("CLT disparity scan", panelClt2, color_conf_process);
addButton("CLT reset fine corr", panelClt2, color_stop);
......@@ -539,6 +530,8 @@ private Panel panel1,
addButton("CLT infinity corr", panelClt2, color_conf_process);
addButton("CLT ext infinity corr", panelClt2, color_conf_process);
addButton("CLT reset 3D", panelClt2, color_stop);
addButton("CLT Extrinsics", panelClt2, color_process);
addButton("CLT Poly corr", panelClt2, color_process);
addButton("CLT 3D", panelClt2, color_process);
addButton("CLT planes", panelClt2, color_conf_process);
addButton("CLT ASSIGN", panelClt2, color_process);
......@@ -546,6 +539,14 @@ private Panel panel1,
add(panelClt2);
}
if (DCT_MODE) {
panelClt3 = new Panel();
panelClt3.setLayout(new GridLayout(1, 0, 5, 5)); // rows, columns, vgap, hgap
addButton("Setup CLT Batch parameters", panelClt3, color_configure);
addButton("Setup CLT parameters", panelClt3, color_configure);
addButton("CLT Batch process", panelClt3, color_process);
add(panelClt3);
}
pack();
GUI.center(this);
......@@ -3667,6 +3668,12 @@ private Panel panel1,
// EyesisCorrectionParameters.DCTParameters dCTParameters,
// int srcKernelSize,
EYESIS_DCT.showKernels(); // show restored kernels
/* ======================================================================== */
} else if (label.equals("Setup CLT Batch parameters")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
CORRECTION_PARAMETERS.showCLTDialog("CLT Batch parameters");
return;
/* ======================================================================== */
} else if (label.equals("Setup CLT parameters")) {
CLT_PARAMETERS.showDialog();
......@@ -4762,7 +4769,9 @@ private Panel panel1,
/// ============================================
} else if (label.equals("CLT 3D")) {
} else if (label.equals("CLT 3D") || label.equals("CLT Extrinsics") || label.equals("CLT Poly corr")) {
boolean adjust_extrinsics = label.equals("CLT Extrinsics") || label.equals("CLT Poly corr");
boolean adjust_poly = label.equals("CLT Poly corr");
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
if (QUAD_CLT == null){
......@@ -4834,6 +4843,8 @@ private Panel panel1,
}
QUAD_CLT.processCLTQuads3d(
adjust_extrinsics, // boolean adjust_extrinsics,
adjust_poly, // boolean adjust_poly,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters debayerParameters,
NONLIN_PARAMETERS, //EyesisCorrectionParameters.NonlinParameters nonlinParameters,
......
......@@ -111,6 +111,15 @@ public class GeometryCorrection {
extrinsic_corr = vector;
}
public boolean [] getParMask(
boolean use_disparity,
boolean common_roll)
{
return (new CorrVector()).getParMask(
use_disparity,
common_roll);
}
public class CorrVector{
......@@ -208,10 +217,15 @@ public class GeometryCorrection {
s = String.format("tilt (up): %8.5f° %8.5f° %8.5f° %8.5f°\n" , v[0], v[1], v[2], -(v[0] + v[1] + v[2]) );
s += String.format("azimuth (right): %8.5f° %8.5f° %8.5f° %8.5f°\n" , v[3], v[4], v[5], -(v[3] + v[4] + v[5]) );
s += String.format("roll (CW): %8.5f° %8.5f° %8.5f° %8.5f°\n" , v[6], v[7], v[8], v[9] );
s += "Symmetrical vector first 5 as last 4 (rolls) are the same:\n";
s += " |↘ ↙| |↘ ↗| |↗ ↘| |↙ ↘| |↙ ↗| |↖ ↘|\n";
s += "0: |↗ ↖| 1: |↙ ↖| 2: |↖ ↙| 3: |↖ ↗| 4: |↗ ↙| 5: |↘ ↖|\n";
s += String.format("0: %8.5f° 1:%8.5f° 2:%8.5f° 3:%8.5f° 4:%8.5f° 5:%8.5f°\n" , sv[0], sv[1], sv[2], sv[3], sv[4], sv[5]);
s += "Symmetrical vector:\n";
s += " |↘ ↙| |↘ ↗| |↗ ↘| |↙ ↘| |↙ ↗| |↖ ↘| 6: common roll 7:(r0-r3)/2, \n";
s += "0: |↗ ↖| 1: |↙ ↖| 2: |↖ ↙| 3: |↖ ↗| 4: |↗ ↙| 5: |↘ ↖| 8:(r1-r2)/2 9:(r0+r3-r1-r2)/4\n";
s += String.format("0: %8.5f° 1:%8.5f° 2:%8.5f° 3:%8.5f° 4:%8.5f° 5:%8.5f° 6:%8.5f° 7:%8.5f° 8:%8.5f° 9:%8.5f°\n" ,
sv[0], sv[1], sv[2], sv[3], sv[4], sv[5], sv[6], sv[7], sv[8], sv[9] );
// s += String.format("sym_vect: 0: %10.7f 1:%10.7f 2:%10.7f 3:%10.7f 4:%10.7f 5:%10.7f 6:%10.7f 7:%10.7f 8:%10.7f 9:%10.7f\n" ,
// sym_vect[0], sym_vect[1], sym_vect[2], sym_vect[3], sym_vect[4], sym_vect[5], sym_vect[6], sym_vect[7], sym_vect[8], sym_vect[9] );
// s += String.format("vector: 0: %10.7f 1:%10.7f 2:%10.7f 3:%10.7f 4:%10.7f 5:%10.7f 6:%10.7f 7:%10.7f 8:%10.7f 9:%10.7f\n" ,
// vector[0], vector[1], vector[2], vector[3], vector[4], vector[5], vector[6], vector[7], vector[8], vector[9] );
return s;
}
......@@ -244,18 +258,22 @@ public class GeometryCorrection {
{
//Previous does not consider movement of the 4-th sensor, so t3 = -t0+t1+t2), a3 = -(a0+a1+a2)
double [][] tar_to_sym = {
{-2.0, -2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // t0
{-2.0, 0.0, 0.0, -2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0}, // t1
{ 0.0, -2.0, 2.0, 0.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0}, // t2
{-2.0, -2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // t0
{-2.0, 0.0, 0.0, -2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0}, // t1
{ 0.0, -2.0, 2.0, 0.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0}, // t2
{ 2.0, 2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // a0
{ 0.0, 2.0, 2.0, 0.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0}, // a1
{ 2.0, 0.0, 0.0, -2.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0}, // a2
{ 2.0, 2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // a0
{ 0.0, 2.0, 2.0, 0.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0}, // a1
{ 2.0, 0.0, 0.0, -2.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0}, // a2
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}, // roll 0
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // roll 1
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // roll 2
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}};// roll 3
// { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}, // roll 0
// { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // roll 1
// { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // roll 2
// { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}};// roll 3
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.5, 0.0, 0.25}, // roll 0
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.0, 0.5, -0.25}, // roll 1
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.0, -0.5, -0.25}, // roll 2
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, -0.5, 0.0, 0.25}};// roll 3
return tar_to_sym;
}
......@@ -289,6 +307,29 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, 0. , -0. , -0.
[ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 1. , 0. , 0. ],
[ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 1. , 0. ],
[ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 1. ]])
a=[[-2.0, -2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[-2.0, 0.0, 0.0, -2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0],
[ 0.0, -2.0, 2.0, 0.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0],
[ 2.0, 2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[ 0.0, 2.0, 2.0, 0.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0],
[ 2.0, 0.0, 0.0, -2.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0],
[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.5, 0.0, 0.25],
[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.0, 0.5, -0.25],
[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.0, -0.5, -0.25],
[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, -0.5, 0.0, 0.25]]
matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. , -0. ],
[-0.125, 0.125, -0.125, 0.125, 0.125, -0.125, 0. , 0. , 0. , 0. ],
[ 0.125, -0.125, 0.125, 0.125, 0.125, -0.125, 0. , 0. , 0. , 0. ],
[-0.125, -0.125, 0.125, -0.125, 0.125, -0.125, 0. , 0. , 0. , 0. ],
[-0.125, 0.125, 0.125, -0.125, 0.125, 0.125, 0. , 0. , 0. , 0. ],
[ 0.125, -0.125, -0.125, -0.125, 0.125, 0.125, 0. , 0. , 0. , 0. ],
[ 0. , 0. , 0. , 0. , 0. , 0. , 1. , 1. , 1. , 1. ],
[-0. , -0. , -0. , -0. , -0. , -0. , 1. , -0. , -0. , -1. ],
[-0. , -0. , -0. , -0. , -0. , -0. , -0. , 1. , -1. , -0. ],
[-0. , -0. , -0. , -0. , -0. , -0. , 1. , -1. , -1. , 1. ]])
*/
double [][] sym_to_tar= {
// t0 t1 t2 a0 a1 a2 r0 r1 r2 r3
......@@ -298,12 +339,38 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, 0. , -0. , -0.
{-0.125, -0.125, 0.125, -0.125, 0.125, -0.125, 0.0 , 0.0 , 0.0 , 0.0 }, // sym3
{-0.125, 0.125, 0.125, -0.125, 0.125, 0.125, 0.0 , 0.0 , 0.0 , 0.0 }, // sym4
{ 0.125, -0.125, -0.125, -0.125, 0.125, 0.125, 0.0 , 0.0 , 0.0 , 0.0 }, // sym5
{ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 }, // sym6 = r0
{ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 }, // sym7 = r1
{ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 }, // sym8 = r2
{ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 }}; // sym9 = r3
// { 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 }, // sym6 = r0
// { 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 }, // sym7 = r1
// { 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 }, // sym8 = r2
// { 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 }}; // sym9 = r3
{ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 1.0 , 1.0 , 1.0 }, // sym6 = (r0+r1+r2+r3)/4
{ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , -1.0 }, // sym7 = (r0-r3)/2
{ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , -1.0 , 0.0 }, // sym8 = (r1-r2)/2
{ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , -1.0 , -1.0 , 1.0 }}; // sym9 = (r0+r3-r1-r2)/4
return sym_to_tar;
}
public boolean [] getParMask(
boolean use_disparity,
boolean common_roll)
{
boolean [] par_mask = { // TODO: move to GeometryCorrection
use_disparity, //sym0
true, //sym1
true, //sym2
true, //sym3
true, //sym4
true, //sym5
common_roll, //sym6 // common roll
true, //sym7
true, //sym8
true //sym9
};
return par_mask;
}
/**
* Get partial transposed Jacobian as 2d array (for one measurement set) from partial Jacobian for each sample
* with derivatives of port coordinates (all 4) by 3 tilts (ports 0..2), 3 azimuths (ports 0..2) and all 4 rolls
......@@ -385,11 +452,11 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, 0. , -0. , -0.
}
return tar_array;
}
}
public void setDistortion(
double focalLength,
double distortionC,
......
......@@ -50,6 +50,7 @@ public class ImageDtt {
// public static int FORCE_DISPARITY_BIT = 8; // move to parameters?
static int QUAD = 4; // number of cameras in camera
static int GREEN_CHN = 2; // index of green channel
static int DISPARITY_INDEX_INT = 0; // 0 - disparity from correlation integer pixels, 1 - ortho
static int DISPARITY_INDEX_CM = 2; // 2 - disparity from correlation "center mass", 3 - ortho (only used for fine correction)
static int DISPARITY_INDEX_HOR = 4; // disparity from correlation of the horizontal pairs with center suppressed
......@@ -60,9 +61,10 @@ public class ImageDtt {
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 String [] DISPARITY_TITLES = {
"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"};
"poly_disp", "poly_y_disp", "strength_disp", "vary_disp","diff0","diff1","diff2","diff3","overexp"};
static int TCORR_COMBO_RSLT = 0; // normal combined correlation from all selected pairs (mult/sum)
static int TCORR_COMBO_SUM = 1; // sum of channle correlations from all selected pairs
......@@ -773,7 +775,11 @@ public class ImageDtt {
centerY, //
((globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY) && (chn == 2)) ? 1 : 0, // external tile compare
no_deconvolution,
transpose);
transpose,
// no saturation processing
null, // boolean [] saturation_imp, // (near) saturated pixels or null
null); // int [] overexp_all ) // {number of overexposed, number of all tiles} or null
if ((globalDebugLevel > 0) && (debug_tileX == tileX) && (debug_tileY == tileY) && (chn == 2)) {
showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
String [] titles = {"CC","SC","CS","SS"};
......@@ -898,7 +904,10 @@ public class ImageDtt {
centersXY[i][1], // centerY, //
((globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY) && (chn == 2)) ? 1 : 0, // external tile compare
no_deconvolution,
transpose);
transpose,
// no saturation processing
null, // boolean [] saturation_imp, // (near) saturated pixels or null
null); // int [] overexp_all ) // {number of overexposed, number of all tiles} or null
}
if ((globalDebugLevel > 0) && (debug_tileX == tileX) && (debug_tileY == tileY) && (chn == 2)) {
showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
......@@ -956,6 +965,7 @@ public class ImageDtt {
final int [][] tile_op, // [tilesY][tilesX] - what to do - 0 - nothing for this tile
final double [][] disparity_array, // [tilesY][tilesX] - individual per-tile expected disparity
final double [][][] image_data, // first index - number of image in a quad
final boolean [][] saturation_imp, // (near) saturated pixels or null
// correlation results - final and partial
final double [][][][] clt_corr_combo, // [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
// [type][tilesY][tilesX] should be set by caller
......@@ -1127,7 +1137,9 @@ public class ImageDtt {
}
if (disparity_map != null){
for (int i = 0; i<disparity_map.length;i++){
disparity_map[i] = new double [tilesY*tilesX];
if ((i != OVEREXPOSED) || (saturation_imp!= null)){
disparity_map[i] = new double [tilesY*tilesX];
}
}
}
if (clt_mismatch != null){
......@@ -1151,7 +1163,8 @@ public class ImageDtt {
sdfa_instance.showArrays(lt_window, 2*transform_size, 2*transform_size, "lt_window");
}
// final double [] overexposed = disparity_map[OVEREXPOSED];
// final int [][] overexp_all = (saturation_imp != null) ? ( new int [tilesX*tilesY][2]): null;
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
......@@ -1182,6 +1195,9 @@ public class ImageDtt {
}
}
boolean debugTile =(tileX == debug_tileX) && (tileY == debug_tileY);
final int [] overexp_all = (saturation_imp != null) ? ( new int [2]): null;
for (int chn = 0; chn <numcol; chn++) {
centerX = tileX * transform_size + transform_size/2 - shiftX;
centerY = tileY * transform_size + transform_size/2 - shiftY;
......@@ -1261,7 +1277,6 @@ public class ImageDtt {
centersXY[2][0]+"\t"+centersXY[2][1]+"\t"+
centersXY[3][0]+"\t"+centersXY[3][1]+"\t");
}
for (int i = 0; i < quad; i++) {
clt_data[i][chn][tileY][tileX] = new double [4][];
......@@ -1281,7 +1296,10 @@ public class ImageDtt {
// (globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY) && (chn == 2), // external tile compare
no_deconvolution,
false); // transpose);
false, // ); // transpose);
((saturation_imp != null) ? saturation_imp[i] : null), //final boolean [][] saturation_imp, // (near) saturated pixels or null
((saturation_imp != null) ? overexp_all: null)); // final double [] overexposed)
}
if ((globalDebugLevel > -1) && (tileX == debug_tileX) && (tileY == debug_tileY) && (chn == 2)) {
System.out.println();
......@@ -1323,6 +1341,11 @@ public class ImageDtt {
}
}
}
// calculate overexposed fraction
if (saturation_imp != null) {
disparity_map[OVEREXPOSED][nTile] = (1.0 * overexp_all[0]) / overexp_all[1];
}
// all color channels are done here
double extra_disparity = 0.0; // if allowed, shift images extra before trying to combine
if (clt_corr_combo != null){ // not null - calculate correlations
......@@ -3571,7 +3594,10 @@ public class ImageDtt {
int debugLevel,
// boolean bdebug0, // external tile compare
boolean dbg_no_deconvolution,
boolean dbg_transpose)
boolean dbg_transpose,
boolean [] saturation_imp, // (near) saturated pixels or null
int [] overexp_all ) // {number of overexposed, number of all tiles} or null
{
boolean use_kernels = (clt_kernels != null) && !dbg_no_deconvolution;
boolean bdebug0 = debugLevel > 0;
......@@ -3632,6 +3658,39 @@ public class ImageDtt {
}
}
}
if ((chn == GREEN_CHN) && (saturation_imp != null)) {
// double overexp_fract = 1.0/(transform_size2 * transform_size2 * QUAD);
// int num_overexp = 0;
//overexp_all
if ((ctile_left >= 0) && (ctile_left < (width - transform_size2)) &&
(ctile_top >= 0) && (ctile_top < (height - transform_size2))) {
for (int i = 0; i < transform_size2; i++){
int indx = (ctile_top + i) * width + ctile_left;
for (int j = 0; j < transform_size2; j++) {
if (saturation_imp[indx++]) {
overexp_all[0] ++;
}
}
}
overexp_all[1] += transform_size2 * transform_size2;
} else { // copy by 1
for (int i = 0; i < transform_size2; i++){
int pi = ctile_top + i;
if (pi < 0) pi &= 1;
else if (pi >= height) pi = height - 2 + (pi & 1);
for (int j = 0; j < transform_size2; j++){
int pj = ctile_left + j;
if (pj < 0) pj &= 1;
else if (pj >= width) pj = width - 2 + (pj & 1);
if (saturation_imp[pi * width + pj]) {
overexp_all[0] ++;
}
}
}
overexp_all[1] += transform_size2 * transform_size2;
}
}
// Fold and transform
double [][][] fold_coeff = null;
if (!dbg_transpose){
......
......@@ -48,6 +48,7 @@ public class MacroCorrelation {
tp.superTileSize, // int superTileSize,
tp.getMagicScale(), // double scale,
trusted_correlation, // double trustedCorrelation,
0.0, // double maxOverexposure,
tp.getThreadsMax()); // int threadsMax)
}
public TileProcessor CLTMacroScan( // perform single pass according to prepared tiles operations and disparity
......@@ -225,6 +226,7 @@ public class MacroCorrelation {
macro_scan.tile_op, // per-tile operation bit codes
macro_scan.disparity, // clt_parameters.disparity, // final double disparity,
input_data, // final double [][][] imade_data, // first index - number of image in a quad
null, // boolean [][] saturation_imp, // (near) saturated pixels or null
// correlation results - final and partial
clt_corr_combo, // [tp.tilesY][tp.tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
clt_corr_partial, // clt_corr_partial, // [tp.tilesY][tp.tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -1671,8 +1671,9 @@ public class TileSurface {
debugLevel, // final int debugLevel,
dbg_X, // final int dbg_X,
dbg_Y); // final int dbg_Y);
showSurfaceDS (tileData, "tileData");
if (debugLevel >- 1) {
showSurfaceDS (tileData, "tileData");
}
this.tileData = tileData;
return tileData;
}
......@@ -2220,7 +2221,8 @@ public class TileSurface {
}
public void compareAssignments(
final int [][][] tileAssignments)
final int [][][] tileAssignments,
final int debugLevel)
{
final int imgTiles = imageTilesX * imageTilesY;
final int num_in = tileAssignments.length;
......@@ -2259,8 +2261,10 @@ public class TileSurface {
img_data[num_in+1][nTile] = combo[nTile];
}
showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays();
sdfa_instance.showArrays(img_data, imageTilesX, imageTilesY, true, "consensus",titles);
if (debugLevel > -1) {
showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays();
sdfa_instance.showArrays(img_data, imageTilesX, imageTilesY, true, "consensus",titles);
}
}
public int [][] getConsensusAssignment(
......
......@@ -49,6 +49,8 @@ public class WavefrontExport {
public int v_index = 1; // first index is 1, not 0
public int vt_index = 1; // first index is 1, not 0
public int f_index = 1; // first index is 1, not 0
public String obj_path;
public String mtl_path;
public WavefrontExport(
String out_dir,
......@@ -61,8 +63,10 @@ public class WavefrontExport {
this.correctionsParameters = correctionsParameters;
this.geometry_correction = geometry_correction;
this.clt_3d_passes = clt_3d_passes;
mtl_writer = new FileWriter(out_dir+Prefs.getFileSeparator()+project_name+MTL_EXT);
obj_writer = new FileWriter(out_dir+Prefs.getFileSeparator()+project_name+OBJ_EXT); // .close();
mtl_path = out_dir+Prefs.getFileSeparator()+project_name+MTL_EXT;
obj_path = out_dir+Prefs.getFileSeparator()+project_name+OBJ_EXT;
mtl_writer = new FileWriter(mtl_path);
obj_writer = new FileWriter(obj_path); // .close();
mtl_writer.write("#\n# Wavefront material file\n#\n");
obj_writer.write("#\n# Wavefront object file\n#\n");
obj_writer.write("mtllib ./"+project_name+MTL_EXT+"\n\n"); // add "./" to indicate relative path? // ./1488240527_408296.obj.mtl\n");
......
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