use of ini.trakem2.display.Patch in project TrakEM2 by trakem2.
the class Loader method preload.
/**
* Returns null when on low memory condition.
*/
@SuppressWarnings("unchecked")
public static final FutureTask<MipMapImage> preload(final Patch p, final double mag, final boolean repaint) {
if (low_memory_conditions || num_preloader_threads < 1)
return null;
final FutureTask<MipMapImage>[] fu = (FutureTask<MipMapImage>[]) new FutureTask[1];
fu[0] = new FutureTask<MipMapImage>(new Callable<MipMapImage>() {
@Override
public MipMapImage call() {
// Utils.log2("preloading " + mag + " :: " + repaint + " :: " + p);
try {
if (p.getProject().getLoader().hs_unloadable.contains(p))
return null;
if (repaint) {
if (Display.willPaint(p)) {
final MipMapImage mipMap = p.getProject().getLoader().fetchImage(p, mag);
// To prevent it:
if (null != mipMap) {
if (!Loader.isSignalImage(mipMap.image) && p.getProject().getLoader().isCached(p, mag)) {
// not the navigator
Display.repaint(p.getLayer(), p, p.getBoundingBox(null), 1, true, false);
}
}
return mipMap;
}
} else {
// just load it into the cache if possible
return p.getProject().getLoader().fetchImage(p, mag);
}
} catch (final Throwable t) {
IJError.print(t);
} finally {
preloads.remove(fu[0]);
}
return null;
}
});
try {
preloads.add(fu[0]);
preloader.submit(fu[0]);
} catch (final Throwable t) {
Utils.log2("Ignoring error with preloading a Patch");
}
return fu[0];
}
use of ini.trakem2.display.Patch in project TrakEM2 by trakem2.
the class Loader method importImages.
/**
* <p>Import images from the given text file, which is expected to contain 4 columns or optionally 9 columns:</p>
* <ul>
* <li>column 1: image file path (if base_dir is not null, it will be prepended)</li>
* <li>column 2: x coord [px]</li>
* <li>column 3: y coord [px]</li>
* <li>column 4: z coord [px] (layer_thickness will be multiplied to it if not zero)</li>
* </ul>
* <p>optional columns, if a property is not known, it can be set to "-" which makes TrakEM2 open the file and find out by itself</p>
* <ul>
* <li>column 5: width [px]</li>
* <li>column 6: height [px]</li>
* <li>column 7: min intensity [double] (for screen display)</li>
* <li>column 8: max intensity [double] (for screen display)</li>
* <li>column 9: type [integer] (pixel types according to ImagepPlus types: 0=8bit int gray, 1=16bit int gray, 2=32bit float gray, 3=8bit indexed color, 4=32-bit RGB color</li>
* </ul>
*
* <p>This function implements the "Import from text file" command.</p>
*
* <p>Layers will be automatically created as needed inside the LayerSet to which the given ref_layer belongs.</p>
* <p>
* The text file can contain comments that start with the # sign.
* </p>
* <p>
* Images will be imported in parallel, using as many cores as your machine has.
* </p>
* @param calibration_ transforms the read coordinates into pixel coordinates, including x,y,z, and layer thickness.
* @param scale_ Between 0 and 1. When lower than 1, a preprocessor script is created for the imported images, to scale them down.
*/
public Bureaucrat importImages(Layer ref_layer, String abs_text_file_path_, String column_separator_, double layer_thickness_, double calibration_, boolean homogenize_contrast_, float scale_, int border_width_) {
// check parameters: ask for good ones if necessary
if (null == abs_text_file_path_) {
final String[] file = Utils.selectFile("Select text file");
// user canceled dialog
if (null == file)
return null;
abs_text_file_path_ = file[0] + file[1];
}
if (null == column_separator_ || 0 == column_separator_.length() || Double.isNaN(layer_thickness_) || layer_thickness_ <= 0 || Double.isNaN(calibration_) || calibration_ <= 0) {
final Calibration cal = ref_layer.getParent().getCalibrationCopy();
final GenericDialog gdd = new GenericDialog("Options");
final String[] separators = new String[] { "tab", "space", "comma (,)" };
gdd.addMessage("Choose a layer to act as the zero for the Z coordinates:");
Utils.addLayerChoice("Base layer", ref_layer, gdd);
gdd.addChoice("Column separator: ", separators, separators[0]);
// default: 60 nm
gdd.addNumericField("Layer thickness: ", cal.pixelDepth, 2);
gdd.addNumericField("Calibration (data to pixels): ", 1, 2);
gdd.addCheckbox("Homogenize contrast layer-wise", homogenize_contrast_);
gdd.addSlider("Scale:", 0, 100, 100);
gdd.addNumericField("Hide border with alpha mask", 0, 0, 6, "pixels");
gdd.showDialog();
if (gdd.wasCanceled())
return null;
layer_thickness_ = gdd.getNextNumber();
if (layer_thickness_ < 0 || Double.isNaN(layer_thickness_)) {
Utils.log("Improper layer thickness value.");
return null;
}
calibration_ = gdd.getNextNumber();
if (0 == calibration_ || Double.isNaN(calibration_)) {
Utils.log("Improper calibration value.");
return null;
}
// not pixelDepth!
layer_thickness_ /= cal.pixelWidth;
ref_layer = ref_layer.getParent().getLayer(gdd.getNextChoiceIndex());
column_separator_ = "\t";
switch(gdd.getNextChoiceIndex()) {
case 1:
column_separator_ = " ";
break;
case 2:
column_separator_ = ",";
break;
default:
break;
}
homogenize_contrast_ = gdd.getNextBoolean();
final double sc = gdd.getNextNumber();
if (Double.isNaN(sc))
scale_ = 1.0f;
else
scale_ = ((float) sc) / 100.0f;
final int border = (int) gdd.getNextNumber();
if (border < 0) {
Utils.log("Nonsensical border value: " + border);
return null;
}
border_width_ = border;
}
if (Float.isNaN(scale_) || scale_ < 0 || scale_ > 1) {
Utils.log("Non-sensical scale: " + scale_ + "\nUsing scale of 1 instead.");
scale_ = 1;
}
// make vars accessible from inner threads:
final Layer base_layer = ref_layer;
final String abs_text_file_path = abs_text_file_path_;
final String column_separator = column_separator_;
final double layer_thickness = layer_thickness_;
final double calibration = calibration_;
final boolean homogenize_contrast = homogenize_contrast_;
final float scale = (float) scale_;
final int border_width = border_width_;
return Bureaucrat.createAndStart(new Worker.Task("Importing images", true) {
@Override
public void exec() {
try {
// 1 - read text file
final String[] lines = Utils.openTextFileLines(abs_text_file_path);
if (null == lines || 0 == lines.length) {
Utils.log2("No images to import from " + abs_text_file_path);
return;
}
ContrastEnhancerWrapper cew = null;
if (homogenize_contrast) {
cew = new ContrastEnhancerWrapper();
cew.showDialog();
}
final String sep2 = column_separator + column_separator;
// 2 - set a base dir path if necessary
String base_dir = null;
// to wait on mipmap regeneration
final Vector<Future<?>> fus = new Vector<Future<?>>();
final LayerSet layer_set = base_layer.getParent();
final double z_zero = base_layer.getZ();
final AtomicInteger n_imported = new AtomicInteger(0);
final Set<Layer> touched_layers = new HashSet<Layer>();
final int NP = Runtime.getRuntime().availableProcessors();
int np = NP;
switch(np) {
case 1:
case 2:
break;
default:
np = np / 2;
break;
}
final ExecutorService ex = Utils.newFixedThreadPool(np, "import-images");
final List<Future<?>> imported = new ArrayList<Future<?>>();
final Worker wo = this;
final String script_path;
// If scale is at least 1/100 lower than 1, then:
if (Math.abs(scale - (int) scale) > 0.01) {
// Assume source and target sigma of 0.5
final double sigma = Math.sqrt(Math.pow(1 / scale, 2) - 0.25);
final String script = new StringBuilder().append("import ij.ImagePlus;\n").append("import ij.process.ImageProcessor;\n").append("import ij.plugin.filter.GaussianBlur;\n").append("GaussianBlur blur = new GaussianBlur();\n").append(// as in ij.plugin.filter.GaussianBlur
"double accuracy = (imp.getType() == ImagePlus.GRAY8 || imp.getType() == ImagePlus.COLOR_RGB) ? 0.002 : 0.0002;\n").append("imp.getProcessor().setInterpolationMethod(ImageProcessor.NONE);\n").append("blur.blurGaussian(imp.getProcessor(),").append(sigma).append(',').append(sigma).append(",accuracy);\n").append("imp.setProcessor(imp.getTitle(), imp.getProcessor().resize((int)(imp.getWidth() * ").append(scale).append("), (int)(imp.getHeight() * ").append(scale).append(")));").toString();
File f = new File(getStorageFolder() + "resize-" + scale + ".bsh");
int v = 1;
while (f.exists()) {
f = new File(getStorageFolder() + "resize-" + scale + "." + v + ".bsh");
v++;
}
script_path = Utils.saveToFile(f, script) ? f.getAbsolutePath() : null;
if (null == script_path) {
Utils.log("Could NOT save a preprocessor script for image scaling\nat path " + f.getAbsolutePath());
}
} else {
script_path = null;
}
Utils.log("Scaling script path is " + script_path);
final AtomicReference<Triple<Integer, Integer, ByteProcessor>> last_mask = new AtomicReference<Triple<Integer, Integer, ByteProcessor>>();
// 3 - parse each line
for (int i = 0; i < lines.length; i++) {
if (Thread.currentThread().isInterrupted() || hasQuitted()) {
this.quit();
return;
}
// process line
// first thing is the backslash removal, before they get processed at all
String line = lines[i].replace('\\', '/').trim();
final int ic = line.indexOf('#');
// remove comment at end of line if any
if (-1 != ic)
line = line.substring(0, ic);
if (0 == line.length() || '#' == line.charAt(0))
continue;
// reduce line, so that separators are really unique
while (-1 != line.indexOf(sep2)) {
line = line.replaceAll(sep2, column_separator);
}
final String[] column = line.split(column_separator);
if (column.length < 4) {
Utils.log("Less than 4 columns: can't import from line " + i + " : " + line);
continue;
}
// obtain coordinates
double x = 0, y = 0, z = 0;
try {
x = Double.parseDouble(column[1].trim());
y = Double.parseDouble(column[2].trim());
z = Double.parseDouble(column[3].trim());
} catch (final NumberFormatException nfe) {
Utils.log("Non-numeric value in a numeric column at line " + i + " : " + line);
continue;
}
x *= calibration;
y *= calibration;
z = z * calibration + z_zero;
// obtain path
String path = column[0].trim();
if (0 == path.length())
continue;
// check if path is relative
if ((!IJ.isWindows() && '/' != path.charAt(0)) || (IJ.isWindows() && 1 != path.indexOf(":/"))) {
// path is relative.
if (null == base_dir) {
// may not be null if another thread that got the lock first set it to non-null
// Ask for source directory
final DirectoryChooser dc = new DirectoryChooser("Choose source directory");
final String dir = dc.getDirectory();
if (null == dir) {
// quit all threads
return;
}
base_dir = Utils.fixDir(dir);
}
}
if (null != base_dir)
path = base_dir + path;
final File f = new File(path);
if (!f.exists()) {
Utils.log("No file found for path " + path);
continue;
}
// will create a new Layer if necessary
final Layer layer = layer_set.getLayer(z, layer_thickness, true);
touched_layers.add(layer);
final String imagefilepath = path;
final double xx = x * scale;
final double yy = y * scale;
final Callable<Patch> creator;
if (column.length >= 9) {
creator = new Callable<Patch>() {
private final int parseInt(final String t) {
if (t.equals("-"))
return -1;
return Integer.parseInt(t);
}
private final double parseDouble(final String t) {
if (t.equals("-"))
return Double.NaN;
return Double.parseDouble(t);
}
@Override
public Patch call() throws Exception {
int o_width = parseInt(column[4].trim());
int o_height = parseInt(column[5].trim());
double min = parseDouble(column[6].trim());
double max = parseDouble(column[7].trim());
int type = parseInt(column[8].trim());
if (-1 == type || -1 == o_width || -1 == o_height) {
// Read them from the file header
final ImageFileHeader ifh = new ImageFileHeader(imagefilepath);
o_width = ifh.width;
o_height = ifh.height;
type = ifh.type;
if (!ifh.isSupportedType()) {
Utils.log("Incompatible image type: " + imagefilepath);
return null;
}
}
ImagePlus imp = null;
if (Double.isNaN(min) || Double.isNaN(max)) {
imp = openImagePlus(imagefilepath);
min = imp.getProcessor().getMin();
max = imp.getProcessor().getMax();
}
final Patch patch = new Patch(layer.getProject(), new File(imagefilepath).getName(), o_width, o_height, o_width, o_height, type, 1.0f, Color.yellow, false, min, max, new AffineTransform(1, 0, 0, 1, xx, yy), imagefilepath);
if (null != script_path && null != imp) {
// For use in setting the preprocessor script
cacheImagePlus(patch.getId(), imp);
}
return patch;
}
};
} else {
creator = new Callable<Patch>() {
@Override
public Patch call() throws Exception {
IJ.redirectErrorMessages();
final ImageFileHeader ifh = new ImageFileHeader(imagefilepath);
final int o_width = ifh.width;
final int o_height = ifh.height;
final int type = ifh.type;
if (!ifh.isSupportedType()) {
Utils.log("Incompatible image type: " + imagefilepath);
return null;
}
double min = 0;
double max = 255;
switch(type) {
case ImagePlus.GRAY16:
case ImagePlus.GRAY32:
// Determine suitable min and max
// TODO Stream through the image, do not load it!
final ImagePlus imp = openImagePlus(imagefilepath);
if (null == imp) {
Utils.log("Ignoring unopenable image from " + imagefilepath);
return null;
}
min = imp.getProcessor().getMin();
max = imp.getProcessor().getMax();
break;
}
// add Patch
final Patch patch = new Patch(layer.getProject(), new File(imagefilepath).getName(), o_width, o_height, o_width, o_height, type, 1.0f, Color.yellow, false, min, max, new AffineTransform(1, 0, 0, 1, xx, yy), imagefilepath);
return patch;
}
};
}
// Otherwise, images would end up loaded twice for no reason
if (0 == (i % (NP + NP))) {
final ArrayList<Future<?>> a = new ArrayList<Future<?>>(NP + NP);
synchronized (fus) {
// .add is also synchronized, fus is a Vector
int k = 0;
while (!fus.isEmpty() && k < NP) {
a.add(fus.remove(0));
k++;
}
}
for (final Future<?> fu : a) {
try {
if (wo.hasQuitted())
return;
fu.get();
} catch (final Throwable t) {
t.printStackTrace();
}
}
}
imported.add(ex.submit(new Runnable() {
@Override
public void run() {
if (wo.hasQuitted())
return;
/* */
IJ.redirectErrorMessages();
Patch patch;
try {
patch = creator.call();
} catch (final Exception e) {
e.printStackTrace();
Utils.log("Could not load patch from " + imagefilepath);
return;
}
// Set the script if any
if (null != script_path) {
try {
patch.setPreprocessorScriptPath(script_path);
} catch (final Throwable t) {
Utils.log("FAILED to set a scaling preprocessor script to patch " + patch);
IJError.print(t);
}
}
// Set an alpha mask to crop away the borders
if (border_width > 0) {
final Triple<Integer, Integer, ByteProcessor> m = last_mask.get();
if (null != m && m.a == patch.getOWidth() && m.b == patch.getOHeight()) {
// Reuse
patch.setAlphaMask(m.c);
} else {
// Create new mask
final ByteProcessor mask = new ByteProcessor(patch.getOWidth(), patch.getOHeight());
mask.setValue(255);
mask.setRoi(new Roi(border_width, border_width, mask.getWidth() - 2 * border_width, mask.getHeight() - 2 * border_width));
mask.fill();
patch.setAlphaMask(mask);
// Store as last
last_mask.set(new Triple<Integer, Integer, ByteProcessor>(mask.getWidth(), mask.getHeight(), mask));
}
}
if (!homogenize_contrast) {
fus.add(regenerateMipMaps(patch));
}
synchronized (layer) {
layer.add(patch, true);
}
wo.setTaskName("Imported " + (n_imported.incrementAndGet() + 1) + "/" + lines.length);
}
}));
}
Utils.wait(imported);
ex.shutdown();
if (0 == n_imported.get()) {
Utils.log("No images imported.");
return;
}
base_layer.getParent().setMinimumDimensions();
Display.repaint(base_layer.getParent());
recreateBuckets(touched_layers);
if (homogenize_contrast) {
setTaskName("Enhance contrast");
// layer-wise (layer order is irrelevant):
cew.applyLayerWise(touched_layers);
cew.shutdown();
}
Utils.wait(fus);
} catch (final Exception e) {
IJError.print(e);
}
}
}, base_layer.getProject());
}
use of ini.trakem2.display.Patch in project TrakEM2 by trakem2.
the class TMLHandler method endElement.
public void endElement(String namespace_URI, String local_name, String qualified_name) {
if (null == loader)
return;
if (skip) {
// reset
skip = false;
return;
}
String orig_qualified_name = qualified_name;
// Utils.log2("endElement: " + qualified_name);
// iterate over all open things and find the one that matches the qualified_name, and set it closed (pop it out of the list):
qualified_name = qualified_name.toLowerCase().trim();
if (0 == qualified_name.indexOf("t2_")) {
qualified_name = qualified_name.substring(3);
}
for (int i = al_open.size() - 1; i > -1; i--) {
Thing thing = al_open.get(i);
if (thing.getType().toLowerCase().equals(qualified_name)) {
al_open.remove(i);
break;
}
}
if (null != last_annotation && null != last_displayable) {
last_displayable.setAnnotation(last_annotation.toString().trim().replaceAll("<", "<"));
last_annotation = null;
}
// terminate non-single clause objects
if (orig_qualified_name.equals("t2_node")) {
// Remove one node from the stack
nodes.removeLast();
taggables.removeLast();
} else if (orig_qualified_name.equals("t2_connector")) {
if (null != last_connector) {
tree_root_nodes.put(last_connector, last_root_node);
last_root_node = null;
last_connector = null;
last_tree = null;
nodes.clear();
}
last_displayable = null;
} else if (orig_qualified_name.equals("t2_area_list")) {
last_area_list = null;
last_displayable = null;
} else if (orig_qualified_name.equals("t2_area")) {
if (null != reca) {
if (null != last_area_list) {
// it's local
last_area_list.addArea(last_area_list_layer_id, reca.getArea());
} else {
((AreaTree.AreaNode) nodes.getLast()).setData(reca.getArea());
}
reca = null;
}
} else if (orig_qualified_name.equals("ict_transform_list")) {
ct_list_stack.remove(ct_list_stack.size() - 1);
} else if (orig_qualified_name.equals("t2_patch")) {
if (last_patch_filters.size() > 0) {
last_patch.setFilters(last_patch_filters.toArray(new IFilter[last_patch_filters.size()]));
}
if (null != last_ct) {
last_patch.setCoordinateTransformSilently(last_ct);
last_ct = null;
} else if (!last_patch.checkCoordinateTransformFile()) {
Utils.log("ERROR: could not find a file for the coordinate transform #" + last_patch.getCoordinateTransformId() + " of Patch #" + last_patch.getId());
}
if (!last_patch.checkAlphaMaskFile()) {
Utils.log("ERROR: could not find a file for the alpha mask #" + last_patch.getAlphaMaskId() + " of Patch #" + last_patch.getId());
}
last_patch = null;
last_patch_filters.clear();
last_displayable = null;
} else if (orig_qualified_name.equals("t2_ball")) {
last_ball = null;
last_displayable = null;
} else if (orig_qualified_name.equals("t2_dissector")) {
last_dissector = null;
last_displayable = null;
} else if (orig_qualified_name.equals("t2_treeline")) {
if (null != last_treeline) {
// old format:
if (null == last_root_node && null != last_treeline_data && last_treeline_data.length() > 0) {
last_root_node = parseBranch(Utils.trim(last_treeline_data));
last_treeline_data = null;
}
// new
tree_root_nodes.put(last_treeline, last_root_node);
last_root_node = null;
// always:
last_treeline = null;
last_tree = null;
nodes.clear();
}
last_displayable = null;
} else if (orig_qualified_name.equals("t2_areatree")) {
if (null != last_areatree) {
tree_root_nodes.put(last_areatree, last_root_node);
last_root_node = null;
last_areatree = null;
last_tree = null;
// the absence of this line would have made the nodes list grow with all nodes of all areatrees, which is ok but consumes memory
nodes.clear();
}
last_displayable = null;
} else if (orig_qualified_name.equals("t2_stack")) {
if (null != last_ict) {
last_stack.setInvertibleCoordinateTransformSilently(last_ict);
last_ict = null;
}
last_stack = null;
last_displayable = null;
} else if (in(orig_qualified_name, all_displayables)) {
last_displayable = null;
}
}
use of ini.trakem2.display.Patch in project TrakEM2 by trakem2.
the class FSLoader method importStackAsPatches.
/**
* Returns the last Patch.
*/
protected Patch importStackAsPatches(final Project project, final Layer first_layer, final double x, final double y, final ImagePlus imp_stack, final boolean as_copy, final String filepath) {
Utils.log2("FSLoader.importStackAsPatches filepath=" + filepath);
String target_dir = null;
if (as_copy) {
DirectoryChooser dc = new DirectoryChooser("Folder to save images");
target_dir = dc.getDirectory();
// user canceled dialog
if (null == target_dir)
return null;
if (IJ.isWindows())
target_dir = target_dir.replace('\\', '/');
if (target_dir.length() - 1 != target_dir.lastIndexOf('/')) {
target_dir += "/";
}
}
// Double.MAX_VALUE is a flag to indicate "add centered"
double pos_x = Double.MAX_VALUE != x ? x : first_layer.getLayerWidth() / 2 - imp_stack.getWidth() / 2;
double pos_y = Double.MAX_VALUE != y ? y : first_layer.getLayerHeight() / 2 - imp_stack.getHeight() / 2;
final double thickness = first_layer.getThickness();
final String title = Utils.removeExtension(imp_stack.getTitle()).replace(' ', '_');
Utils.showProgress(0);
Patch previous_patch = null;
final int n = imp_stack.getStackSize();
final ImageStack stack = imp_stack.getStack();
final boolean virtual = stack.isVirtual();
final VirtualStack vs = virtual ? (VirtualStack) stack : null;
for (int i = 1; i <= n; i++) {
Layer layer = first_layer;
double z = first_layer.getZ() + (i - 1) * thickness;
// will create new layer if not found
if (i > 1)
layer = first_layer.getParent().getLayer(z, thickness, true);
if (null == layer) {
Utils.log("Display.importStack: could not create new layers.");
return null;
}
String patch_path = null;
ImagePlus imp_patch_i = null;
if (virtual) {
// because we love inefficiency, every time all this is done again
// VirtualStack vs = (VirtualStack)imp_stack.getStack();
String vs_dir = vs.getDirectory().replace('\\', '/');
if (!vs_dir.endsWith("/"))
vs_dir += "/";
String iname = vs.getFileName(i);
patch_path = vs_dir + iname;
Utils.log2("virtual stack: patch path is " + patch_path);
releaseToFit(new File(patch_path).length() * 3);
Utils.log2(i + " : " + patch_path);
imp_patch_i = openImage(patch_path);
} else {
ImageProcessor ip = stack.getProcessor(i);
if (as_copy)
ip = ip.duplicate();
imp_patch_i = new ImagePlus(title + "__slice=" + i, ip);
}
String label = stack.getSliceLabel(i);
if (null == label)
label = "";
Patch patch = null;
if (as_copy) {
patch_path = target_dir + cleanSlashes(imp_patch_i.getTitle()) + ".zip";
ini.trakem2.io.ImageSaver.saveAsZip(imp_patch_i, patch_path);
patch = new Patch(project, label + " " + title + " " + i, pos_x, pos_y, imp_patch_i);
} else if (virtual) {
patch = new Patch(project, label, pos_x, pos_y, imp_patch_i);
} else {
patch_path = filepath + "-----#slice=" + i;
// Utils.log2("path is "+ patch_path);
final AffineTransform atp = new AffineTransform();
atp.translate(pos_x, pos_y);
patch = new Patch(project, getNextId(), label + " " + title + " " + i, imp_stack.getWidth(), imp_stack.getHeight(), imp_stack.getWidth(), imp_stack.getHeight(), imp_stack.getType(), false, imp_stack.getProcessor().getMin(), imp_stack.getProcessor().getMax(), atp);
patch.addToDatabase();
// Utils.log2("type is " + imp_stack.getType());
}
Utils.log2("B: " + i + " : " + patch_path);
addedPatchFrom(patch_path, patch);
if (!as_copy && !virtual) {
if (// each slice separately
virtual)
// each slice separately
cache(patch, imp_patch_i);
else
// uses the entire stack, shared among all Patch instances
cache(patch, imp_stack);
}
// submit for regeneration
if (isMipMapsRegenerationEnabled())
regenerateMipMaps(patch);
if (null != previous_patch)
patch.link(previous_patch);
layer.add(patch);
previous_patch = patch;
Utils.showProgress(i * (1.0 / n));
}
Utils.showProgress(1.0);
// return the last patch
return previous_patch;
}
use of ini.trakem2.display.Patch in project TrakEM2 by trakem2.
the class FSLoader method deleteStaleFiles.
/**
* Delete stale files under the {@link FSLoader#unuid} folder.
* These include "*.ct" files (for {@link CoordinateTransform})
* and "*.zip" files (for alpha mask images) that are not referenced from any {@link Patch}.
*/
@Override
public boolean deleteStaleFiles(boolean coordinate_transforms, boolean alpha_masks) {
boolean b = true;
final Project project = Project.findProject(this);
if (coordinate_transforms)
b = b && StaleFiles.deleteCoordinateTransforms(project);
if (alpha_masks)
b = b && StaleFiles.deleteAlphaMasks(project);
return b;
}
Aggregations