Commit f6006466 authored by Andrey Filippov's avatar Andrey Filippov

Adding channels to overlapped textures

parent 7780b796
......@@ -135,10 +135,11 @@ public class CLTParameters {
public double diff_threshold = 1.5; // RMS difference from average to discard channel (~ 1.0 - 1/255 full scale image)
public boolean diff_gauss = true; // when averaging images, use Gaussian around average as weight (false - sharp all/nothing)
public double min_agree = 3.0; // minimal number of channels to agree on a point (real number to work with fuzzy averages)
public boolean dust_remove = true; // Do not reduce average weight when only one image differes much from the average
public boolean dust_remove = true; // Do not reduce average weight when only one image differs much from the average
public boolean black_back = true; // use Black for backdrop outside of the FOV
public boolean keep_weights = true; // add port weights to RGBA stack (debug feature)
public boolean replace_weights = false; //replace port weights with ports textures (16x16)
public boolean sharp_alpha = false; // combining mode for alpha channel: false - treat as RGB, true - apply center 8x8 only
public double alpha0 = 0.6; // > .525 Alpha channel 0.0 threshold (lower - transparent) (watch for far objects)
public double alpha1 = 0.8; // Alpha channel 1.0 threshold (higher - opaque) (watch for window dust)
......@@ -1195,6 +1196,7 @@ public class CLTParameters {
properties.setProperty(prefix+"dust_remove", this.dust_remove+"");
properties.setProperty(prefix+"black_back", this.black_back+"");
properties.setProperty(prefix+"keep_weights", this.keep_weights+"");
properties.setProperty(prefix+"replace_weights", this.replace_weights+"");
properties.setProperty(prefix+"sharp_alpha", this.sharp_alpha+"");
properties.setProperty(prefix+"alpha0", this.alpha0 +"");
......@@ -2095,6 +2097,7 @@ public class CLTParameters {
if (properties.getProperty(prefix+"dust_remove")!=null) this.dust_remove=Boolean.parseBoolean(properties.getProperty(prefix+"dust_remove"));
if (properties.getProperty(prefix+"black_back")!=null) this.black_back=Boolean.parseBoolean(properties.getProperty(prefix+"black_back"));
if (properties.getProperty(prefix+"keep_weights")!=null) this.keep_weights=Boolean.parseBoolean(properties.getProperty(prefix+"keep_weights"));
if (properties.getProperty(prefix+"replace_weights")!=null) this.replace_weights=Boolean.parseBoolean(properties.getProperty(prefix+"replace_weights"));
if (properties.getProperty(prefix+"sharp_alpha")!=null) this.sharp_alpha=Boolean.parseBoolean(properties.getProperty(prefix+"sharp_alpha"));
if (properties.getProperty(prefix+"alpha0")!=null) this.alpha0=Double.parseDouble(properties.getProperty(prefix+"alpha0"));
if (properties.getProperty(prefix+"alpha1")!=null) this.alpha1=Double.parseDouble(properties.getProperty(prefix+"alpha1"));
......@@ -3033,6 +3036,7 @@ public class CLTParameters {
gd.addCheckbox ("Do not reduce average weight when only one image differes much from the average", this.dust_remove);
gd.addCheckbox ("Use black for backdrop outside of the FOV", this.black_back);
gd.addCheckbox ("Add port weights to RGBA stack (debug feature)", this.keep_weights);
gd.addCheckbox ("Replace port weights with per-channel MIDCT (16x16) - were relevant", this.replace_weights);
gd.addCheckbox ("Alpha channel: use center 8x8 (unchecked - treat same as RGB)", this.sharp_alpha);
gd.addNumericField("Alpha channel 0.0 thereshold (lower - transparent)", this.alpha0, 3);
gd.addNumericField("Alpha channel 1.0 threshold (higher - opaque)", this.alpha1, 3);
......@@ -4238,6 +4242,7 @@ public class CLTParameters {
this.dust_remove= gd.getNextBoolean();
this.black_back= gd.getNextBoolean();
this.keep_weights= gd.getNextBoolean();
this.replace_weights= gd.getNextBoolean();
this.sharp_alpha= gd.getNextBoolean();
this.alpha0= gd.getNextNumber();
this.alpha1= gd.getNextNumber();
......
......@@ -349,14 +349,15 @@ public class ImageDtt extends ImageDttCPU {
if (texture_img != null) {
Rectangle woi = new Rectangle(); // will be filled out to match actual available image
gpuQuad.execRBGA(
col_weights, // double [] color_weights,
isLwir(), // boolean is_lwir,
col_weights, // double [] color_weights,
isLwir(), // boolean is_lwir,
min_shot, // double min_shot, // 10.0
scale_shot, // double scale_shot, // 3.0
diff_sigma, // double diff_sigma, // pixel value/pixel change
diff_threshold, // double diff_threshold, // pixel value/pixel change
min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
dust_remove); // boolean dust_remove,
dust_remove, // boolean dust_remove,
0); // int keep_weights)
float [][] rbga = gpuQuad.getRBGA(
(isMonochrome() ? 1 : 3), // int num_colors,
(texture_woi_pix != null)? texture_woi_pix : woi);
......@@ -376,6 +377,7 @@ public class ImageDtt extends ImageDttCPU {
diff_threshold, // double diff_threshold, // pixel value/pixel change - never used in GPU ?
min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
dust_remove, // boolean dust_remove, // Do not reduce average weight when only one image differs much from the average
0, // int keep_weights, // 2 bits now, move to parameters
false, // boolean calc_textures,
true, // boolean calc_extra
false); // boolean linescan_order) // TODO: use true to avoid reordering of the low-res output
......@@ -427,6 +429,7 @@ public class ImageDtt extends ImageDttCPU {
diff_threshold, // double diff_threshold, // pixel value/pixel change - never used in GPU ?
min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
dust_remove, // boolean dust_remove, // Do not reduce average weight when only one image differs much from the average
0, // int keep_weights, // 2 bits now, move to parameters
true, // boolean calc_textures,
false, // boolean calc_extra
false); // boolean linescan_order)
......@@ -438,7 +441,7 @@ public class ImageDtt extends ImageDttCPU {
numcol, // int num_colors,
false); // clt_parameters.keep_weights); // boolean keep_weights);
gpuQuad.doubleTextures(
GpuQuad.doubleTextures(
new Rectangle(0, 0, tilesX, tilesY), // Rectangle woi,
texture_tiles, // double [][][][] texture_tiles, // null or [tilesY][tilesX]
texture_indices, // int [] indices,
......@@ -663,7 +666,8 @@ public class ImageDtt extends ImageDttCPU {
double diff_sigma, // pixel value/pixel change Used much larger sigma = 10.0 instead of 1.5
double diff_threshold, // pixel value/pixel change
double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
boolean dust_remove
boolean dust_remove,
int keep_weights // 2 bits now, move to parameters
){
int numcol = isMonochrome()? 1 : 3;
double [] col_weights = new double[numcol];
......@@ -684,6 +688,7 @@ public class ImageDtt extends ImageDttCPU {
diff_threshold, // double diff_threshold, // pixel value/pixel change
min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
dust_remove, // boolean dust_remove,
keep_weights, // int keep_weights, // 2 bits now, move to parameters
true, // boolean calc_textures,
false, // boolean calc_extra
false); // boolean linescan_order)
......@@ -696,7 +701,7 @@ public class ImageDtt extends ImageDttCPU {
int tilesX = gpuQuad.img_width / GPUTileProcessor.DTT_SIZE;
int tilesY = gpuQuad.img_height / GPUTileProcessor.DTT_SIZE;
double [][][][] texture_tiles = new double [tilesY][tilesX][][];
gpuQuad.doubleTextures(
GpuQuad.doubleTextures(
new Rectangle(0, 0, tilesX, tilesY), // Rectangle woi,
texture_tiles, // double [][][][] texture_tiles, // null or [tilesY][tilesX]
texture_indices, // int [] indices,
......@@ -744,6 +749,7 @@ public class ImageDtt extends ImageDttCPU {
diff_threshold, // double diff_threshold, // pixel value/pixel change
min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
dust_remove, // boolean dust_remove,
0, // int keep_weights, // 2 bits now, move to parameters
false, // boolean calc_textures,
true, // boolean calc_extra
false); // boolean linescan_order)
......
......@@ -1655,7 +1655,9 @@ public class QuadCLT extends QuadCLTCPU {
clt_parameters.diff_sigma, // double diff_sigma, // pixel value/pixel change Used much larger sigma = 10.0 instead of 1.5
clt_parameters.diff_threshold, // double diff_threshold, // pixel value/pixel change
clt_parameters.min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
clt_parameters.dust_remove); // boolean dust_remove
clt_parameters.dust_remove, // boolean dust_remove
0); // int keep_weights // 2 bits now, move to parameters
if (max_distortion > 0) {// remove distorted tiles
double max_distortion2 = max_distortion * max_distortion;
......@@ -2225,6 +2227,10 @@ public class QuadCLT extends QuadCLTCPU {
col_weights[1] = clt_parameters.corr_blue * col_weights[2];
}
Rectangle woi = new Rectangle(); // will be filled out to match actual available image
// int keep_weights = (clt_parameters.keep_weights? 1 : 0) + (clt_parameters.replace_weights? 2 : 0);
int keep_weights = (clt_parameters.replace_weights? 2 : 0); // just 0/2
int text_colors = (isMonochrome() ? 1 : 3);
int texture_layers = (text_colors + 1)+((keep_weights != 0)?(text_colors * getNumSensors()):0);
gpuQuad.execRBGA(
col_weights, // double [] color_weights,
isLwir(), // boolean is_lwir,
......@@ -2233,9 +2239,10 @@ public class QuadCLT extends QuadCLTCPU {
clt_parameters.diff_sigma, // double diff_sigma, // pixel value/pixel change Used much larger sigma = 10.0 instead of 1.5
clt_parameters.diff_threshold, // double diff_threshold, // pixel value/pixel change
clt_parameters.min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
clt_parameters.dust_remove); // boolean dust_remove,
clt_parameters.dust_remove, // boolean dust_remove,
keep_weights); // int keep_weights)
float [][] rbga = gpuQuad.getRBGA(
(isMonochrome() ? 1 : 3), // int num_colors,
texture_layers - 1, // (isMonochrome() ? 1 : 3), // int num_colors,
woi);
for (int ncol = 0; ncol < texture_img.length; ncol++) if (ncol < rbga.length) {
texture_img[ncol] = rbga[ncol];
......@@ -2301,6 +2308,7 @@ public class QuadCLT extends QuadCLTCPU {
clt_parameters.diff_threshold, // double diff_threshold, // pixel value/pixel change
clt_parameters.min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
clt_parameters.dust_remove, // boolean dust_remove,
0, // int keep_weights, // 2 bits now, move to parameters
false, // boolean calc_textures,
true, // boolean calc_extra
false); // boolean linescan_order) // TODO: use true to avoid reordering of the low-res output
......@@ -2320,6 +2328,7 @@ public class QuadCLT extends QuadCLTCPU {
}
if (try_textures) {
int keep_weights = (clt_parameters.keep_weights? 1 : 0) + (clt_parameters.replace_weights? 2 : 0);
//Generate non-overlapping (16x16) texture tiles, prepare
gpuQuad.execTextures(
col_weights, // double [] color_weights,
......@@ -2330,27 +2339,33 @@ public class QuadCLT extends QuadCLTCPU {
clt_parameters.diff_threshold, // double diff_threshold, // pixel value/pixel change
clt_parameters.min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
clt_parameters.dust_remove, // boolean dust_remove,
keep_weights, // int keep_weights, // 2 bits now, move to parameters
true, // boolean calc_textures,
false, // boolean calc_extra
false); // boolean linescan_order)
int [] texture_indices = gpuQuad.getTextureIndices();
int numcol = isMonochrome()? 1 : 3;
int num_src_slices = numcol + 1; // + (clt_parameters.keep_weights?(ports + numcol + 1):0); // 12 ; // calculate
// int num_src_slices = numcol + 1; // + (clt_parameters.keep_weights?(ports + numcol + 1):0); // 12 ; // calculate
int num_src_slices = numcol + 1 + (clt_parameters.keep_weights?(getNumSensors() + numcol + 1):0); // 12 ; // calculate
float [] flat_textures = gpuQuad.getFlatTextures( // fatal error has been detected by the Java Runtime Environment:
texture_indices.length,
numcol, // int num_colors,
false); // clt_parameters.keep_weights); // boolean keep_weights);
(keep_weights != 0)); // false); // clt_parameters.keep_weights); // boolean keep_weights);
if (keep_weights != 0) {
}
// numcol + 1 + (clt_parameters.keep_weights?(getNumSensors() + numcol + 1):0); // 12 ; // calculate
int tilesX = gpuQuad.img_width / GPUTileProcessor.DTT_SIZE;
int tilesY = gpuQuad.img_height / GPUTileProcessor.DTT_SIZE;
double [][][][] texture_tiles = new double [tilesY][tilesX][][];
gpuQuad.doubleTextures(
GpuQuad.doubleTextures(
new Rectangle(0, 0, tilesX, tilesY), // Rectangle woi,
texture_tiles, // double [][][][] texture_tiles, // null or [tilesY][tilesX]
texture_indices, // int [] indices,
flat_textures, // float [][][] ftextures,
tilesX, // int full_width,
isMonochrome()? 2: 4, // rbga only /int num_slices
num_src_slices, // isMonochrome()? 2: 4, // rbga only /int num_slices
num_src_slices // int num_src_slices
);
int num_out_slices = 0;
......@@ -2361,6 +2376,29 @@ public class QuadCLT extends QuadCLTCPU {
}
}
if (num_out_slices > 0) {
String [] dbg_titles = new String[num_out_slices];
fill_titles:
{
int indx = 0;
for (int i = 0; i < numcol; i++) {
if (indx >= num_out_slices) break fill_titles;
else dbg_titles[indx++] = "c"+i;
}
if (indx >= num_out_slices) break fill_titles;
else dbg_titles[indx++] = "alpha";
for (int i = 0; i < getNumSensors(); i++) {
if (indx >= num_out_slices) break fill_titles;
else dbg_titles[indx++] = (((keep_weights & 2) != 0)?"t":"w")+i;
}
for (int i = 0; i < numcol; i++) {
if (indx >= num_out_slices) break fill_titles;
else dbg_titles[indx++] = "crms"+i;
}
if (indx >= num_out_slices) break fill_titles;
else dbg_titles[indx++] = "crms";
}
//crms
int ssize = 2*GPUTileProcessor.DTT_SIZE;
int width = tilesX * ssize;
int height = tilesY * ssize;
......@@ -2390,8 +2428,8 @@ public class QuadCLT extends QuadCLTCPU {
width,
height,
true,
getImageName()+"-textures"
);
getImageName()+"-textures-"+keep_weights,
dbg_titles);
}
System.out.println("try_textures DONE");
}
......@@ -2661,6 +2699,7 @@ public class QuadCLT extends QuadCLTCPU {
clt_parameters.diff_threshold, // double diff_threshold, // pixel value/pixel change - never used in GPU ?
clt_parameters.min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
clt_parameters.dust_remove, // boolean dust_remove, // Do not reduce average weight when only one image differs much from the average
0, // int keep_weights, // 2 bits now, move to parameters
calc_textures, // boolean calc_textures,
calc_extra, // boolean calc_extra)
false); // boolean linescan_order) // TODO: use true to avoid reordering of the low-res output
......@@ -2680,7 +2719,9 @@ public class QuadCLT extends QuadCLTCPU {
clt_parameters.diff_sigma, // double diff_sigma, // pixel value/pixel change
clt_parameters.diff_threshold, // double diff_threshold, // pixel value/pixel change
clt_parameters.min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
clt_parameters.dust_remove); // boolean dust_remove,
clt_parameters.dust_remove, // boolean dust_remove,
0); // int keep_weights)
long endTexturesRBGA = System.nanoTime();
long endGPUTime = System.nanoTime();
......@@ -2973,7 +3014,7 @@ public class QuadCLT extends QuadCLTCPU {
String results_path= quadCLT_main.correctionsParameters.selectResultsDirectory( // selectX3dDirectory(
true, // smart,
true); //newAllowed, // save
quadCLT_main.eyesisCorrections.saveAndShow( // save and show color RGBA texture
EyesisCorrections.saveAndShow( // save and show color RGBA texture
imp_texture_stack,
results_path,
true, // quadCLT_main.correctionsParameters.png && !clt_parameters.black_back,
......@@ -3021,7 +3062,8 @@ public class QuadCLT extends QuadCLTCPU {
}
}
double [][][][] texture_tiles = new double [tilesY][tilesX][][];
quadCLT_main.getGPU().doubleTextures(
quadCLT_main.getGPU();
GpuQuad.doubleTextures(
new Rectangle(0, 0, tilesX, tilesY), // Rectangle woi,
texture_tiles, // double [][][][] texture_tiles, // null or [tilesY][tilesX]
texture_indices, // int [] indices,
......
......@@ -13730,7 +13730,8 @@ public class QuadCLTCPU {
clt_parameters.diff_sigma, // double diff_sigma, // pixel value/pixel change Used much larger sigma = 10.0 instead of 1.5
clt_parameters.diff_threshold, // double diff_threshold, // pixel value/pixel change
clt_parameters.min_agree, // double min_agree, // minimal number of channels to agree on a point (real number to work with fuzzy averages)
clt_parameters.dust_remove); // boolean dust_remove
clt_parameters.dust_remove, // boolean dust_remove
0); // int keep_weights // 2 bits now, move to parameters
}
if (save_diff || save_lowres) {
image_dtt.get_diffs_lowres( // CUDA_ERROR_INVALID_VALUE (because no tiles)
......
......@@ -144,6 +144,7 @@ extern "C" __global__ void textures_nonoverlap(
float params[5],
float weights[3], // scale for R,B,G
int dust_remove, // Do not reduce average weight when only one image differs much from the average
int keep_weights, // Was not here before 10/12/2022. return channel weights after A in RGBA (was removed) (should be 0 if gpu_texture_rbg)?
// combining both non-overlap and overlap (each calculated if pointer is not null )
size_t texture_stride, // in floats (now 256*4 = 1024) // may be 0 if not needed
float * gpu_texture_tiles, // (number of colors +1 + ?)*16*16 rgba texture tiles // may be 0 if not needed
......
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