MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / BatchProcessor

Class BatchProcessor

ij/src/main/java/ij/plugin/BatchProcessor.java:38–505  ·  view source on GitHub ↗

This plugin implements the File/Batch/Macro and File/Batch/Virtual Stack commands.

Source from the content-addressed store, hash-verified

36
37/** This plugin implements the File/Batch/Macro and File/Batch/Virtual Stack commands. */
38 public class BatchProcessor implements PlugIn, ActionListener, ItemListener, Runnable {
39 private static final String MACRO_FILE_NAME = "BatchMacro.ijm";
40 private static final String[] formats = {"TIFF", "8-bit TIFF", "JPEG", "GIF", "PNG", "PGM", "BMP", "FITS", "Text Image", "ZIP", "Raw"};
41 private static String format = Prefs.get("batch.format", formats[0]);
42
43 private static final String[] code = {
44 "[Select from list]",
45 "Add Border",
46 "Convert to RGB",
47 "Crop",
48 "Gaussian Blur",
49 "Invert",
50 "Label",
51 "Timestamp",
52 "Max Dimension",
53 "Measure",
54 "Print Index and Title",
55 "Resize",
56 "Scale",
57 "Show File Info",
58 "Unsharp Mask",
59 };
60
61 private static final String help = "<html>"
62 +"<h1>Process&gt;Batch&gt;Virtual Stack</h1>"
63 +"<font size=+1>"
64 +"This command runs macro code on each image in a virtual stack.<br>"
65 +"The processed images are saved in the <i>Output</i> folder,<br>"
66 +"in the specified <i>Format</i>, allowing them to be opened as a<br>"
67 +"virtual stack. Make sure the <i>Output</i> folder is empty<br>"
68 +"before clicking on <i>Process</i>.<br>"
69 +"<br>"
70 +"In the macro code, the 'i' (slice index) and 'n' (stack size) variables<br>"
71 +"are predefined. Call <i>setOption('SaveBatchOutput',false)</i> to<br>"
72 +"prevent the image currently being processed from being saved,<br>"
73 +"effectively removing it from the output virtual stack.<br> <br>"
74 +"</font>";
75
76 private String macro = "";
77 private int testImage;
78 private Button input, output, open, save, test;
79 private TextField inputDir, outputDir;
80 private GenericDialog gd;
81 private Thread thread;
82 private ImagePlus virtualStack;
83 private ImagePlus outputImage;
84 private boolean errorDisplayed;
85 private String filter;
86 private static boolean saveOutput = true;
87
88 public void run(String arg) {
89 if (arg.equals("stack")) {
90 virtualStack = IJ.getImage();
91 if (virtualStack.getStackSize()==1) {
92 error("This command requires a stack or virtual stack.");
93 return;
94 }
95 }

Callers

nothing calls this directly

Calls 1

getMethod · 0.95

Tested by

no test coverage detected