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

Class ImagesToStack

ij/src/main/java/ij/plugin/ImagesToStack.java:24–314  ·  view source on GitHub ↗

Implements the Image/Stacks/Images to Stack" command.

Source from the content-addressed store, hash-verified

22
23/** Implements the Image/Stacks/Images to Stack" command. */
24public class ImagesToStack implements PlugIn {
25 private static final int rgb = 33;
26 private static final int COPY_CENTER=0, COPY_TOP_LEFT=1, SCALE_SMALL=2, SCALE_LARGE=3;
27 private static final String[] methods = {"Copy (center)", "Copy (top-left)", "Scale (smallest)", "Scale (largest)"};
28 private static int staticMethod = COPY_CENTER;
29 private static boolean staticBicubic;
30 private static boolean staticKeep;
31 private static boolean staticTitlesAsLabels = true;
32 private int method = COPY_CENTER;
33 private boolean bicubic;
34 private boolean keep;
35 private boolean titlesAsLabels = true;
36 private String filter;
37 private int width, height;
38 private int maxWidth, maxHeight;
39 private int minWidth, minHeight;
40 private int minSize, maxSize;
41 private boolean allInvertedLuts;
42 private Calibration cal2;
43 private int stackType;
44 private ImagePlus[] images;
45 private String name = "Stack";
46 private Color fillColor;
47
48 /** Converts the images in 'images' to a stack, using the
49 default settings ("copy center" and "titles as labels"). */
50 public static ImagePlus run(ImagePlus[] images) {
51 ImagesToStack itos = new ImagesToStack();
52 int count = itos.findMinMaxSize(images, images.length);
53 return itos.convert(images, count);
54 }
55
56 public void run(String arg) {
57 convertImagesToStack();
58 }
59
60 public void convertImagesToStack() {
61 boolean scale = false;
62 int[] wList = WindowManager.getIDList();
63 if (wList==null) {
64 IJ.error("No images are open.");
65 return;
66 }
67
68 int count = 0;
69 int stackCount = 0;
70 images = new ImagePlus[wList.length];
71 for (int i=0; i<wList.length; i++) {
72 ImagePlus imp = WindowManager.getImage(wList[i]);
73 if (imp.getStackSize()==1)
74 images[count++] = imp;
75 else
76 stackCount++;
77 }
78 if (count<2) {
79 String msg = "";
80 if (stackCount>1)
81 msg = "\n \nUse the Image>Stacks>Tools>Concatenate\ncommand to combine stacks.";

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected