Commit 8550fc6e authored by Andrey Filippov's avatar Andrey Filippov

Update generation of TIFF sequence subtracting new averages from the CLT

parent 81ca6c68
...@@ -737,6 +737,7 @@ min_str_neib_fpn 0.35 ...@@ -737,6 +737,7 @@ min_str_neib_fpn 0.35
public boolean um_mono = true; // applies to both TIFF and AVI public boolean um_mono = true; // applies to both TIFF and AVI
public double um_sigma = 10; public double um_sigma = 10;
public double um_weight = 0.97; // public double um_weight = 0.97; //
public boolean um_mono_linear = true; // save linear (no-UM) in addition to UM
public boolean mono_fixed = true; // normalize to fixed range when converting to 8 bits public boolean mono_fixed = true; // normalize to fixed range when converting to 8 bits
public double mono_range = 500.0; // monochrome full-scale range (+/- half) public double mono_range = 500.0; // monochrome full-scale range (+/- half)
public boolean anaglyth_en = true; // applies to both TIFF and AVI public boolean anaglyth_en = true; // applies to both TIFF and AVI
...@@ -2140,6 +2141,8 @@ min_str_neib_fpn 0.35 ...@@ -2140,6 +2141,8 @@ min_str_neib_fpn 0.35
"Unsharp mask Gaussian sigma."); "Unsharp mask Gaussian sigma.");
gd.addNumericField("Unsharp mask weight", this.um_weight, 5,7,"", gd.addNumericField("Unsharp mask weight", this.um_weight, 5,7,"",
"Unsharp mask weightt (multiply blurred version before subtraction from the original)."); "Unsharp mask weightt (multiply blurred version before subtraction from the original).");
gd.addCheckbox ("Save linear", this.um_mono_linear,
"Save TIFF sequences without UM in addition to UM");
gd.addCheckbox ("Fixed monochrome range", this.mono_fixed, gd.addCheckbox ("Fixed monochrome range", this.mono_fixed,
"Normalize monochrome (after UM) to a fixed range when converting to 8 bit RGB."); "Normalize monochrome (after UM) to a fixed range when converting to 8 bit RGB.");
...@@ -2964,6 +2967,7 @@ min_str_neib_fpn 0.35 ...@@ -2964,6 +2967,7 @@ min_str_neib_fpn 0.35
this.um_mono = gd.getNextBoolean(); this.um_mono = gd.getNextBoolean();
this.um_sigma = gd.getNextNumber(); this.um_sigma = gd.getNextNumber();
this.um_weight = gd.getNextNumber(); this.um_weight = gd.getNextNumber();
this.um_mono_linear = gd.getNextBoolean();
this.mono_fixed = gd.getNextBoolean(); this.mono_fixed = gd.getNextBoolean();
this.mono_range = gd.getNextNumber(); this.mono_range = gd.getNextNumber();
...@@ -3783,6 +3787,7 @@ min_str_neib_fpn 0.35 ...@@ -3783,6 +3787,7 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"um_mono", this.um_mono+""); // boolean properties.setProperty(prefix+"um_mono", this.um_mono+""); // boolean
properties.setProperty(prefix+"um_sigma", this.um_sigma+""); // double properties.setProperty(prefix+"um_sigma", this.um_sigma+""); // double
properties.setProperty(prefix+"um_weight", this.um_weight+""); // double properties.setProperty(prefix+"um_weight", this.um_weight+""); // double
properties.setProperty(prefix+"um_mono_linear", this.um_mono_linear+""); // boolean
properties.setProperty(prefix+"mono_fixed", this.mono_fixed+""); // boolean properties.setProperty(prefix+"mono_fixed", this.mono_fixed+""); // boolean
properties.setProperty(prefix+"mono_range", this.mono_range+""); // double properties.setProperty(prefix+"mono_range", this.mono_range+""); // double
properties.setProperty(prefix+"anaglyth_en", this.anaglyth_en+""); // boolean properties.setProperty(prefix+"anaglyth_en", this.anaglyth_en+""); // boolean
...@@ -4584,6 +4589,7 @@ min_str_neib_fpn 0.35 ...@@ -4584,6 +4589,7 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"um_mono")!=null) this.um_mono=Boolean.parseBoolean(properties.getProperty(prefix+"um_mono")); if (properties.getProperty(prefix+"um_mono")!=null) this.um_mono=Boolean.parseBoolean(properties.getProperty(prefix+"um_mono"));
if (properties.getProperty(prefix+"um_sigma")!=null) this.um_sigma=Double.parseDouble(properties.getProperty(prefix+"um_sigma")); if (properties.getProperty(prefix+"um_sigma")!=null) this.um_sigma=Double.parseDouble(properties.getProperty(prefix+"um_sigma"));
if (properties.getProperty(prefix+"um_weight")!=null) this.um_weight=Double.parseDouble(properties.getProperty(prefix+"um_weight")); if (properties.getProperty(prefix+"um_weight")!=null) this.um_weight=Double.parseDouble(properties.getProperty(prefix+"um_weight"));
if (properties.getProperty(prefix+"um_mono_linear")!=null) this.um_mono_linear=Boolean.parseBoolean(properties.getProperty(prefix+"um_mono_linear"));
if (properties.getProperty(prefix+"mono_fixed")!=null) this.mono_fixed=Boolean.parseBoolean(properties.getProperty(prefix+"mono_fixed")); if (properties.getProperty(prefix+"mono_fixed")!=null) this.mono_fixed=Boolean.parseBoolean(properties.getProperty(prefix+"mono_fixed"));
if (properties.getProperty(prefix+"mono_range")!=null) this.mono_range=Double.parseDouble(properties.getProperty(prefix+"mono_range")); if (properties.getProperty(prefix+"mono_range")!=null) this.mono_range=Double.parseDouble(properties.getProperty(prefix+"mono_range"));
...@@ -5368,35 +5374,36 @@ min_str_neib_fpn 0.35 ...@@ -5368,35 +5374,36 @@ min_str_neib_fpn 0.35
imp.sensor_mask = this.sensor_mask; imp.sensor_mask = this.sensor_mask;
imp.merge_all = this.merge_all; imp.merge_all = this.merge_all;
imp.video_fps = this. video_fps; imp.video_fps = this.video_fps;
imp.sensor_fps = this. sensor_fps; imp.sensor_fps = this.sensor_fps;
imp.mode_avi = this. mode_avi; imp.mode_avi = this.mode_avi;
imp.avi_JPEG_quality = this. avi_JPEG_quality; imp.avi_JPEG_quality = this.avi_JPEG_quality;
imp.run_ffmpeg = this. run_ffmpeg; imp.run_ffmpeg = this.run_ffmpeg;
imp.video_ext = this. video_ext; imp.video_ext = this.video_ext;
imp.video_codec = this. video_codec; imp.video_codec = this.video_codec;
imp.video_crf = this. video_crf; imp.video_crf = this.video_crf;
imp.remove_avi = this. remove_avi; imp.remove_avi = this.remove_avi;
imp.video_codec_combo = this. video_codec_combo; imp.video_codec_combo = this.video_codec_combo;
imp.video_crf_combo = this. video_crf_combo; imp.video_crf_combo = this.video_crf_combo;
imp.add_average = this. add_average; imp.add_average = this.add_average;
imp.subtract_average = this. subtract_average; imp.subtract_average = this.subtract_average;
imp.running_average = this. running_average; imp.running_average = this.running_average;
imp.extract_center_orientation=this.extract_center_orientation; imp.extract_center_orientation=this.extract_center_orientation;
imp.um_mono = this. um_mono; imp.um_mono = this.um_mono;
imp.um_sigma = this. um_sigma; imp.um_sigma = this.um_sigma;
imp.um_weight = this. um_weight; imp.um_weight = this.um_weight;
imp.mono_fixed = this. mono_fixed; imp.um_mono_linear = this.um_mono_linear;
imp.mono_range = this. mono_range; imp.mono_fixed = this.mono_fixed;
imp.mono_range = this.mono_range;
imp.anaglyth_en = this. anaglyth_en;
imp.anaglyph_left = this. anaglyph_left; imp.anaglyth_en = this.anaglyth_en;
imp.anaglyph_right = this. anaglyph_right; imp.anaglyph_left = this.anaglyph_left;
imp.anaglyph_right = this.anaglyph_right;
imp.annotate_color = this. annotate_color;
imp.annotate_mono = this. annotate_mono; imp.annotate_color = this.annotate_color;
imp.annotate_color_color = this. annotate_color_color; imp.annotate_mono = this.annotate_mono;
imp.annotate_color_mono = this. annotate_color_mono; imp.annotate_color_color = this.annotate_color_color;
imp.annotate_color_mono = this.annotate_color_mono;
imp.annotate_transparent_mono = this. annotate_transparent_mono; imp.annotate_transparent_mono = this. annotate_transparent_mono;
// vegetation // vegetation
......
...@@ -4814,6 +4814,7 @@ public class OpticalFlow { ...@@ -4814,6 +4814,7 @@ public class OpticalFlow {
boolean um_mono = clt_parameters.imp.um_mono; boolean um_mono = clt_parameters.imp.um_mono;
double um_sigma = clt_parameters.imp.um_sigma; double um_sigma = clt_parameters.imp.um_sigma;
double um_weight = clt_parameters.imp.um_weight; double um_weight = clt_parameters.imp.um_weight;
boolean um_mono_linear= clt_parameters.imp.um_mono_linear;
boolean mono_fixed = clt_parameters.imp.mono_fixed; boolean mono_fixed = clt_parameters.imp.mono_fixed;
double mono_range = clt_parameters.imp.mono_range; double mono_range = clt_parameters.imp.mono_range;
...@@ -5967,13 +5968,23 @@ public class OpticalFlow { ...@@ -5967,13 +5968,23 @@ public class OpticalFlow {
} }
} }
// setCenterAverage();
ImagePlus imp_center_clt= center_CLT.showCenterClt(
null, // float [][] fclt, // may be null
clt_parameters, // CLTParameters clt_parameters,
false); // true); // boolean show);
center_CLT.setCenterAverage(imp_center_clt);
// just for verification // just for verification
boolean cuas_debug = clt_parameters.imp.cuas_debug; // save debug images (and show them if not in batch mode) boolean cuas_debug = clt_parameters.imp.cuas_debug; // save debug images (and show them if not in batch mode)
if (cuas_debug) { // show_clt && !clt_parameters.batch_run) { if (cuas_debug) { // show_clt && !clt_parameters.batch_run) {
ImagePlus imp_center_clt= center_CLT.showCenterClt( if (!clt_parameters.batch_run) {
null, // float [][] fclt, // may be null imp_center_clt.show();
clt_parameters, // CLTParameters clt_parameters, }
!clt_parameters.batch_run); // true); // boolean show); // ImagePlus imp_center_clt= center_CLT.showCenterClt(
// null, // float [][] fclt, // may be null
// clt_parameters, // CLTParameters clt_parameters,
// !clt_parameters.batch_run); // true); // boolean show);
if (imp_center_clt != null) { if (imp_center_clt != null) {
String suffix =dbg_created?"-CLT-CREATED":"CLT-UPDATED"; String suffix =dbg_created?"-CLT-CREATED":"CLT-UPDATED";
center_CLT.saveImagePlusInModelDirectory( center_CLT.saveImagePlusInModelDirectory(
...@@ -6241,11 +6252,14 @@ public class OpticalFlow { ...@@ -6241,11 +6252,14 @@ public class OpticalFlow {
final boolean toRGB = col_mode > 0; final boolean toRGB = col_mode > 0;
String scenes_suffix = quadCLTs[quadCLTs.length-1].getImageName()+ String scenes_suffix = quadCLTs[quadCLTs.length-1].getImageName()+
"-SEQ-" + IntersceneMatchParameters.MODES3D[mode3d+1] + "-"+(toRGB?"COLOR":"MONO"); "-SEQ-" + IntersceneMatchParameters.MODES3D[mode3d+1] + "-"+(toRGB?"COLOR":"MONO");
String um_suffix = "";
if (!toRGB && um_mono) { if (!toRGB && um_mono) {
if (mono_fixed) { if (mono_fixed) {
scenes_suffix+=String.format("-UM%.1f_%.3f_%.0f",um_sigma,um_weight,mono_range); um_suffix = String.format("-UM%.1f_%.3f_%.0f",um_sigma,um_weight,mono_range);
/// scenes_suffix+=String.format("-UM%.1f_%.3f_%.0f",um_sigma,um_weight,mono_range);
} else { } else {
scenes_suffix+=String.format("-UM%.1f_%.3f_A",um_sigma,um_weight); um_suffix = String.format("-UM%.1f_%.3f_A",um_sigma,um_weight);
/// scenes_suffix+=String.format("-UM%.1f_%.3f_A",um_sigma,um_weight);
} }
} }
int num_stereo = (is_stereo && (mode3d > 0))? 2:1; // only for 3D views int num_stereo = (is_stereo && (mode3d > 0))? 2:1; // only for 3D views
...@@ -6269,7 +6283,7 @@ public class OpticalFlow { ...@@ -6269,7 +6283,7 @@ public class OpticalFlow {
} }
if (generate_mapped) { if (generate_mapped) {
double [][] ds_vantage = new double[][] {selected_disparity,selected_strength}; double [][] ds_vantage = new double[][] {selected_disparity,selected_strength};
if ((views[ibase][0] != 0) || (views[ibase][1] != 0) || (views[ibase][2] != 0)) { if ((views[ibase][0] != 0) || (views[ibase][1] != 0) || (views[ibase][2] != 0) || master_CLT.hasCenterClt()) {
ds_vantage = transformCameraVew( ds_vantage = transformCameraVew(
null, // (debug_ds_fg_virt?"transformCameraVew":null), // final String title, null, // (debug_ds_fg_virt?"transformCameraVew":null), // final String title,
ds_vantage, // final double [][] dsrbg_camera_in, ds_vantage, // final double [][] dsrbg_camera_in,
...@@ -6279,28 +6293,47 @@ public class OpticalFlow { ...@@ -6279,28 +6293,47 @@ public class OpticalFlow {
master_CLT, // quadCLTs[ref_index], // final QuadCLT reference_QuadClt, master_CLT, // quadCLTs[ref_index], // final QuadCLT reference_QuadClt,
8); // iscale); // final int iscale); 8); // iscale); // final int iscale);
} }
imp_scenes_pair[nstereo]= renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters, float [] average_pixels = (master_CLT.getCenterAverage() != null) ? ((float []) master_CLT.getCenterAverage().getProcessor().getPixels()):null;
clt_parameters.imp.um_mono, // boolean um_mono, float [][] average_channels = new float [][] {average_pixels}; // for future color images
clt_parameters.imp.add_average, // boolean insert_average, imp_scenes_pair[nstereo]= renderSceneSequence(
clt_parameters.imp.subtract_average, // boolean subtract_average, clt_parameters, // CLTParameters clt_parameters,
clt_parameters.imp.running_average, // int running_average, master_CLT.hasCenterClt(), // boolean mode_cuas,
fov_tiles, // Rectangle fov_tiles, false, // clt_parameters.imp.um_mono, // boolean um_mono,
mode3d, // int mode3d, false, // clt_parameters.imp.add_average, // boolean insert_average, // then add new parameter, keep add average
toRGB, // boolean toRGB, average_channels, // average_slice,
xyz_offset, // double [] stereo_offset, // offset reference camera {x,y,z} clt_parameters.imp.subtract_average, // boolean subtract_average,
cuas_atr, // double [] stereo_atr, // offset reference orientation (cuas) clt_parameters.imp.running_average, // int running_average,
sensor_mask, // int sensor_mask, fov_tiles, // Rectangle fov_tiles,
scenes_suffix, // String suffix, mode3d, // int mode3d,
ds_vantage[0], // selected_disparity, // double [] ref_disparity, toRGB, // boolean toRGB,
quadCLTs, // QuadCLT [] quadCLTs, xyz_offset, // double [] stereo_offset, // offset reference camera {x,y,z}
master_CLT, // ref_index, // int ref_index, cuas_atr, // double [] stereo_atr, // offset reference orientation (cuas)
threadsMax, // int threadsMax, sensor_mask, // int sensor_mask,
debugLevel); // int debugLevel); scenes_suffix, // String suffix,
if (save_mapped_mono_color[col_mode]) { ds_vantage[0], // selected_disparity, // double [] ref_disparity,
quadCLTs[ref_index].saveImagePlusInModelDirectory( quadCLTs, // QuadCLT [] quadCLTs,
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix, master_CLT, // ref_index, // int ref_index,
imp_scenes_pair[nstereo]); // imp_scenes); // ImagePlus imp) threadsMax, // int threadsMax,
debugLevel); // int debugLevel);
if (toRGB || um_mono_linear || !um_mono) { // save linear w/o UM
if (save_mapped_mono_color[col_mode]) {
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_scenes_pair[nstereo]); // imp_scenes); // ImagePlus imp)
}
}
if (!toRGB && um_mono) {
imp_scenes_pair[nstereo]=applyUM ( // apply UM
scenes_suffix+ um_suffix , // final String title, // should include -UM...
imp_scenes_pair[nstereo], // final ImagePlus imp,
um_sigma, // final double um_sigma,
um_weight); // final double um_weight)
if (save_mapped_mono_color[col_mode]) { // save with UM
master_CLT.saveImagePlusInModelDirectory(
null, // "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_scenes_pair[nstereo]); // imp_scenes); // ImagePlus imp)
}
} }
} else { } else {
if (fov_tiles==null) { if (fov_tiles==null) {
...@@ -6747,8 +6780,10 @@ public class OpticalFlow { ...@@ -6747,8 +6780,10 @@ public class OpticalFlow {
String scenes_suffix = quadCLTs[quadCLTs.length-1].getImageName()+"-TERRAIN"; String scenes_suffix = quadCLTs[quadCLTs.length-1].getImageName()+"-TERRAIN";
ImagePlus imp_terrain = renderSceneSequence( ImagePlus imp_terrain = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
master_CLT.hasCenterClt(), // boolean mode_cuas,
false, // boolean um_mono, false, // boolean um_mono,
clt_parameters.imp.add_average, // boolean insert_average, clt_parameters.imp.add_average, // boolean insert_average,
null, // float [] average_slice,
clt_parameters.imp.subtract_average, // boolean subtract_average, clt_parameters.imp.subtract_average, // boolean subtract_average,
clt_parameters.imp.running_average, // int running_average, clt_parameters.imp.running_average, // int running_average,
null, // Rectangle fov_tiles, null, // Rectangle fov_tiles,
...@@ -6774,8 +6809,10 @@ public class OpticalFlow { ...@@ -6774,8 +6809,10 @@ public class OpticalFlow {
String scenes_suffix = quadCLTs[quadCLTs.length-1].getImageName()+"-ELEVATION"; String scenes_suffix = quadCLTs[quadCLTs.length-1].getImageName()+"-ELEVATION";
ImagePlus imp_elevation = renderSceneSequence( ImagePlus imp_elevation = renderSceneSequence(
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
master_CLT.hasCenterClt(), // boolean mode_cuas,
false, // boolean um_mono, false, // boolean um_mono,
clt_parameters.imp.add_average, // boolean insert_average, clt_parameters.imp.add_average, // boolean insert_average,
null, // average_slice,
clt_parameters.imp.subtract_average, // boolean subtract_average, clt_parameters.imp.subtract_average, // boolean subtract_average,
clt_parameters.imp.running_average, // int running_average, clt_parameters.imp.running_average, // int running_average,
null, // Rectangle fov_tiles, null, // Rectangle fov_tiles,
...@@ -8189,8 +8226,10 @@ public class OpticalFlow { ...@@ -8189,8 +8226,10 @@ public class OpticalFlow {
public static ImagePlus renderSceneSequence( public static ImagePlus renderSceneSequence(
CLTParameters clt_parameters, CLTParameters clt_parameters,
boolean mode_cuas,
boolean um_mono, boolean um_mono,
boolean insert_average, // now only with float pixels boolean caculate_average, // now only with float pixels
float [][] average_slice, // [channel][pixel]
boolean subtract_average, boolean subtract_average,
int running_average, int running_average,
Rectangle fov_tiles, Rectangle fov_tiles,
...@@ -8205,17 +8244,18 @@ public class OpticalFlow { ...@@ -8205,17 +8244,18 @@ public class OpticalFlow {
QuadCLT ref_scene, // int ref_index, QuadCLT ref_scene, // int ref_index,
int threadsMax, int threadsMax,
int debugLevel) { int debugLevel) {
boolean insert_average = (average_slice != null) || caculate_average; // now only with float pixels
boolean corr_raw_ers = true; boolean corr_raw_ers = true;
double [] stereo_atr = (stereo_atr_in != null)? stereo_atr_in: ZERO3; // maybe later play with rotated camera double [] stereo_atr = (stereo_atr_in != null)? stereo_atr_in: ZERO3; // maybe later play with rotated camera
boolean mode_cuas = (stereo_atr[0] != 0) || (stereo_atr[1] != 0) || (stereo_atr[2] != 0); /// boolean mode_cuas = (stereo_atr[0] != 0) || (stereo_atr[1] != 0) || (stereo_atr[2] != 0);
// boolean um_mono = clt_parameters.imp.um_mono; // boolean um_mono = clt_parameters.imp.um_mono;
double um_sigma = clt_parameters.imp.um_sigma; double um_sigma = clt_parameters.imp.um_sigma;
double um_weight = clt_parameters.imp.um_weight; double um_weight = clt_parameters.imp.um_weight;
boolean mb_en = clt_parameters.imp.mb_en && (fov_tiles==null) && (mode3d > 0); boolean mb_en = clt_parameters.imp.mb_en && (fov_tiles==null) && (mode3d > 0);
double mb_tau = clt_parameters.imp.mb_tau; // 0.008; // time constant, sec double mb_tau = clt_parameters.imp.mb_tau; // 0.008; // time constant, sec
double mb_max_gain = clt_parameters.imp.mb_max_gain; // 5.0; // motion blur maximal gain (if more - move second point more than a pixel double mb_max_gain = clt_parameters.imp.mb_max_gain; // 5.0; // motion blur maximal gain (if more - move second point more than a pixel
/// insert_average = (mode3d == 1); // merged
insert_average = (mode3d == 1); // merged insert_average &= (mode3d == 1); // merged
if (mode3d != 1) { if (mode3d != 1) {
running_average = 0; running_average = 0;
} }
...@@ -8404,20 +8444,32 @@ public class OpticalFlow { ...@@ -8404,20 +8444,32 @@ public class OpticalFlow {
} }
} }
if (insert_average) { // calculate average to average slices (one per channel) if (insert_average) { // calculate average to average slices (one per channel)
int num_scenes = (stack_scenes.getSize() / channels.length) -1; // remove average if (average_slice != null) {
// single-threaded for (int nchn = 0; nchn < channels.length; nchn++) {
for (int nchn = 0; nchn < channels.length; nchn++) { float [] avg_slice = (float[]) stack_scenes.getPixels(nchn+1);
float [] avg_slice = (float[]) stack_scenes.getPixels(nchn+1); System.arraycopy(
int num_pix = avg_slice.length; average_slice[nchn],
for (int nscene = 0; nscene < num_scenes; nscene++) { 0,
float [] fpixels = (float[]) stack_scenes.getPixels(nchn + (nscene+1)*channels.length + 1); avg_slice,
0,
average_slice[nchn].length);
}
} else {
int num_scenes = (stack_scenes.getSize() / channels.length) -1; // remove average
// single-threaded
for (int nchn = 0; nchn < channels.length; nchn++) {
float [] avg_slice = (float[]) stack_scenes.getPixels(nchn+1);
int num_pix = avg_slice.length;
for (int nscene = 0; nscene < num_scenes; nscene++) {
float [] fpixels = (float[]) stack_scenes.getPixels(nchn + (nscene+1)*channels.length + 1);
for (int npix = 0; npix < num_pix; npix++) {
avg_slice[npix] += fpixels[npix];
}
}
for (int npix = 0; npix < num_pix; npix++) { for (int npix = 0; npix < num_pix; npix++) {
avg_slice[npix] += fpixels[npix]; avg_slice[npix] /= num_scenes;
} }
} }
for (int npix = 0; npix < num_pix; npix++) {
avg_slice[npix] /= num_scenes;
}
} }
// seems that fpixels are automatically updated in the images // seems that fpixels are automatically updated in the images
} }
...@@ -8469,7 +8521,7 @@ public class OpticalFlow { ...@@ -8469,7 +8521,7 @@ public class OpticalFlow {
} }
} }
} }
/*
// Apply unsharp mask here, in parallel // Apply unsharp mask here, in parallel
if (um_mono && !toRGB) { if (um_mono && !toRGB) {
final ImageStack fstack_scenes = stack_scenes; final ImageStack fstack_scenes = stack_scenes;
...@@ -8497,9 +8549,52 @@ public class OpticalFlow { ...@@ -8497,9 +8549,52 @@ public class OpticalFlow {
} }
ImageDtt.startAndJoin(threads); ImageDtt.startAndJoin(threads);
} }
*/
ImagePlus imp_scenes = new ImagePlus(suffix, stack_scenes); ImagePlus imp_scenes = new ImagePlus(suffix, stack_scenes);
imp_scenes.getProcessor().resetMinAndMax(); imp_scenes.getProcessor().resetMinAndMax();
// Apply unsharp mask here, in parallel
if (um_mono && !toRGB) {
imp_scenes = applyUM (
suffix, // final String title, // should include -UM...
imp_scenes, // final ImagePlus imp,
um_sigma, // final double um_sigma,
um_weight); // final double um_weight)
}
return imp_scenes;
}
public static ImagePlus applyUM (
final String title, // should include -UM...
final ImagePlus imp,
final double um_sigma,
final double um_weight) {
final float fum_weight = (float) um_weight;
final ImageStack stack_scenes = imp.getStack();
final int nSlices = stack_scenes.getSize();
final Thread[] threads = ImageDtt.newThreadArray(QuadCLT.THREADS_MAX);
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nSlice = ai.getAndIncrement(); nSlice < nSlices; nSlice = ai.getAndIncrement()) {
FloatProcessor fp = (FloatProcessor) stack_scenes.getProcessor(nSlice+1);
float [] fpixels = (float[]) stack_scenes.getPixels(nSlice+1);
float [] fpixels_orig = fpixels.clone();
(new GaussianBlur()).blurFloat(
fp, // FloatProcessor ip,
um_sigma, // double sigmaX,
um_sigma, // double sigmaY,
0.01); // double accuracy)
for (int i = 0; i < fpixels.length; i++) {
fpixels[i] = fpixels_orig[i] - fum_weight * fpixels[i];
}
}
}
};
}
ImageDtt.startAndJoin(threads);
ImagePlus imp_scenes = new ImagePlus(title, stack_scenes);
imp_scenes.getProcessor().resetMinAndMax();
return imp_scenes; return imp_scenes;
} }
......
...@@ -222,6 +222,17 @@ public class QuadCLTCPU { ...@@ -222,6 +222,17 @@ public class QuadCLTCPU {
@Deprecated @Deprecated
public boolean center_is_parent = false; // when true - use image_path that discards current version public boolean center_is_parent = false; // when true - use image_path that discards current version
public String center_parent_dir = null; public String center_parent_dir = null;
public ImagePlus imp_center_average = null;
public ImagePlus getCenterAverage() {
return imp_center_average;
}
public void setCenterAverage(ImagePlus imp_center_average) {
this.imp_center_average = imp_center_average;
}
@Deprecated @Deprecated
public boolean isCenterParent() { public boolean isCenterParent() {
......
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