Commit b063bc39 authored by Andrey Filippov's avatar Andrey Filippov

implemented disparity-> Z (not distance) conversion and output in the

final Tiff/video
parent f531219b
......@@ -87,8 +87,9 @@ public class CuasMotionLMA {
public static final int RSLT_WHEN = 42;
public static final int RSLT_FAIL = 43;
public static final int RSLT_DISPARITY=44;
public static final int RSLT_DISP_STR =45;
public static final int RSLT_RANGE = 46;
public static final int RSLT_DISP_DIFF=45;
public static final int RSLT_DISP_STR =46;
public static final int RSLT_RANGE = 47;
public static final int RSLT_LEN = RSLT_RANGE+1;
......@@ -107,7 +108,7 @@ public class CuasMotionLMA {
"*Q-AMPL","*Q-RMSE","*Q-RMSE/A","*Q-CENTER","*Q-MATCH","*Q-LENGTH","*QTRAVEL","*Q-SCORE",
"Stronger","Slow",
"WHEN", "FAILURE",
"Disparity","Strength","Range"};
"Disparity","Disparity-Diff","Strength","Range"};
public static final int FAIL_NONE = 0;
public static final int FAIL_MOTION = 1; // motion strength/fraction too low
......
......@@ -6164,10 +6164,10 @@ if (debugLevel < -100) {
}
}
return um_mono;
}
}
public static double [][][][] unsharpMaskSource(
@Deprecated
public static double [][][][] unsharpMaskSource_old(
final QuadCLT[] scenes,
final int start_scene,
final int num_scenes,
......@@ -6266,6 +6266,195 @@ if (debugLevel < -100) {
return images_um;
}
public static double [][][][] unsharpMaskSource(
final QuadCLT[] scenes,
final int start_scene,
final int num_scenes,
final boolean um_en,
final boolean unsharped,
final boolean update_source, // if update_source will not generate output, return null
final double um_sigma,
final boolean um_twice,
final double um_weight,
final int debugLevel){
final int num_sens = scenes[start_scene].getNumSensors();
int [] whc = scenes[start_scene].getWHC(false);
final int width = whc[0];
final int height = whc[1];
final int num_col = whc[2];
final double [][][][] images_um = update_source? null : new double [num_scenes][num_sens][num_col][];
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
double [] img_buf = new double [width * height];
double [] img_buf2 = um_twice ? (new double [width * height]) : null;
for (int iScene = ai.getAndIncrement(); iScene < num_scenes; iScene = ai.getAndIncrement()) {
double [][][] image_um = unsharpMaskSource(
scenes[iScene + start_scene], // final QuadCLT scene,
um_en, // final boolean um_en,
unsharped, // final boolean unsharped,
update_source, // final boolean update_source, // if update_source will not generate output, return null
um_sigma, // final double um_sigma,
img_buf, // final double [] img_buf, // = new double [width * height];
img_buf2, // final double [] img_buf2, // = um_twice ? (new double [width * height]) : null;
um_weight, // final double um_weight,
debugLevel); // final int debugLevel)
if (images_um != null) {
images_um[iScene] = image_um;
}
}
}
};
}
ImageDtt.startAndJoin(threads);
return images_um;
}
public static double [][][] unsharpMaskSourceMono(
final QuadCLT[] scenes,
final int start_scene,
final int num_scenes,
final boolean um_en,
final double [][][] img_um, // cache for unsharped images, same length as scenes. May be null
final boolean unsharped, // ==false, not used
final boolean update_source, // ==false, not used if update_source will not generate output, return null
final double um_sigma,
final boolean um_twice,
final double um_weight,
final int debugLevel){
final int num_sens = scenes[start_scene].getNumSensors();
int [] whc = scenes[start_scene].getWHC(false);
final int width = whc[0];
final int height = whc[1];
final int num_col = whc[2];
final double [][][] images_um = new double [num_scenes][num_sens][];
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
double [] img_buf = new double [width * height];
double [] img_buf2 = um_twice ? (new double [width * height]) : null;
for (int iScene = ai.getAndIncrement(); iScene < num_scenes; iScene = ai.getAndIncrement()) {
int nscene = iScene + start_scene;
if ((img_um == null) || (img_um[nscene] == null)) {
double [][][] image_um_col = unsharpMaskSource( // [sensor][color][pixel]
scenes[iScene + start_scene], // final QuadCLT scene,
um_en, // final boolean um_en,
unsharped, // unsharped, // final boolean unsharped,
update_source, // update_source, // final boolean update_source, // if update_source will not generate output, return null
um_sigma, // final double um_sigma,
img_buf, // final double [] img_buf, // = new double [width * height];
img_buf2, // final double [] img_buf2, // = um_twice ? (new double [width * height]) : null;
um_weight, // final double um_weight,
debugLevel); // final int debugLevel)
for (int nsens = 0; nsens < num_sens; nsens++) {
images_um[iScene][nsens] = image_um_col[nsens][0];
}
if (img_um != null) { // save to cache
img_um[nscene] = images_um[iScene];
}
} else if (img_um != null) { // get from cache
images_um[iScene] = img_um[nscene]; // img_um[nscene] is not null here
}
}
}
};
}
ImageDtt.startAndJoin(threads);
return images_um;
}
public static double [][][] unsharpMaskSource( // [sensor][color][pixel]
final QuadCLT scene,
final boolean um_en,
final boolean unsharped,
final boolean update_source, // if update_source will not generate output, return null
final double um_sigma,
final double [] img_buf, // = new double [width * height];
final double [] img_buf2, // = um_twice ? (new double [width * height]) : null;
final double um_weight,
final int debugLevel){
final int num_sens = scene.getNumSensors();
int [] whc = scene.getWHC(false);
final int width = whc[0];
final int height = whc[1];
final int num_col = whc[2];
final double [][][] images_um = update_source? null : new double [num_sens][num_col][];
final int num_sens_col = num_sens*num_col;
DoubleGaussianBlur gb = new DoubleGaussianBlur();
for (int nsens_col = 0; nsens_col < num_sens_col; nsens_col++) {
int nsens = nsens_col / num_col;
int ncol = nsens_col % num_col;
double [] img_src = scene.getOrigImageData()[nsens][ncol];
if (!unsharped && um_en) {
System.arraycopy(img_src, 0, img_buf, 0, img_buf.length);
gb.blurDouble(
img_buf, //
width,
height,
um_sigma, // double sigmaX,
um_sigma, // double sigmaY,
0.01); // double accuracy)
if (um_weight != 1.0) {
for (int i = 0; i < img_buf.length; i++) {
img_buf[i] *= um_weight;
}
}
if (img_buf2 != null) {
for (int i = 0; i < img_buf.length; i++) {
img_buf2[i] = img_src[i] - img_buf[i];
}
System.arraycopy(img_buf2, 0, img_buf, 0, img_buf.length);
gb.blurDouble(
img_buf2, //
width,
height,
um_sigma, // double sigmaX,
um_sigma, // double sigmaY,
0.01); // double accuracy)
if (um_weight != 1.0) {
for (int i = 0; i < img_buf.length; i++) {
img_buf2[i] *= um_weight;
}
}
for (int i = 0; i < img_buf.length; i++) {
img_buf[i] -= img_buf2[i];
}
if (update_source) {
for (int i = 0; i < img_buf.length; i++) {
img_src[i] = img_buf[i];
}
} else {
images_um[nsens][ncol] = img_buf.clone();
}
} else {
if (update_source) {
for (int i = 0; i < img_buf.length; i++) {
img_src[i] -= img_buf[i];
}
} else {
for (int i = 0; i < img_buf.length; i++) {
img_buf[i] = img_src[i] - img_buf[i];
}
images_um[nsens][ncol] = img_buf.clone();
}
}
} else { // just copy
images_um[nsens][ncol] = img_src.clone();
}
}
return images_um;
}
}
......@@ -5068,6 +5068,15 @@ __device__ void convertCorrectTile(
clt_src += DTT_SIZE1;
clt_dst += DTT_SIZE;
}
// A hack to accumulate with positive scale
} else if (tscale > 10.0f) { // > 10 - scale by (tscale-10) and add
float tscale1 = tscale - 10.0f;
for (int j = 0; j < DTT_SIZE * 4; j++){ // all 4 components, 8 rows
// shared memory tiles use DTT_SIZE1
*clt_dst += *clt_src * tscale1;
clt_src += DTT_SIZE1;
clt_dst += DTT_SIZE;
}
} else if (tscale > 0) { // positive - scale and set. For motion blur positive should be first
#pragma unroll
for (int j = 0; j < DTT_SIZE * 4; j++){ // all 4 components, 8 rows
......
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