Skip to content

Commit

Permalink
Align_Image: fix Fiji bug #1019
Browse files Browse the repository at this point in the history
This changes the code to select the images only from the
_valid_ image IDs, not the list of _all_ image IDs.
  • Loading branch information
ctrueden committed Mar 25, 2015
1 parent 6de555f commit a24791f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/java/Align_Image.java
Expand Up @@ -43,14 +43,17 @@ public void run(final String arg) {
// Find all images that have a LineRoi in them
final int[] ids = WindowManager.getIDList();
if (null == ids) return; // no images open
final ArrayList<Integer> validIDs = new ArrayList<Integer>();
final ArrayList<ImagePlus> validImages = new ArrayList<ImagePlus>();
for (int i = 0; i < ids.length; i++) {
final ImagePlus imp = WindowManager.getImage(ids[i]);
final Roi roi = imp.getRoi();
if (roi instanceof Line && isSupported(imp.getType())) {
validIDs.add(ids[i]);
validImages.add(imp);
}
}

if (validImages.size() < 2) {
IJ.showMessage("Need 2 images with a line roi in each.\n"
+ "Images must be 8, 16 or 32-bit.");
Expand All @@ -73,12 +76,12 @@ public void run(final String arg) {
gd.showDialog();
if (gd.wasCanceled()) return;

final ImagePlus source =
WindowManager.getImage(ids[gd.getNextChoiceIndex()]);
final int sourceIndex = gd.getNextChoiceIndex();
final ImagePlus source = WindowManager.getImage(validIDs.get(sourceIndex));
final Line line1 = (Line) source.getRoi();

final ImagePlus target =
WindowManager.getImage(ids[gd.getNextChoiceIndex()]);
final int targetIndex = gd.getNextChoiceIndex();
final ImagePlus target = WindowManager.getImage(validIDs.get(targetIndex));
final Line line2 = (Line) target.getRoi();
final boolean withScaling = gd.getNextBoolean();
final boolean withRotation = gd.getNextBoolean();
Expand Down

0 comments on commit a24791f

Please sign in to comment.