Skip to content

Commit 85929bf

Browse files
committed
Issue #3 array out of bound error fixed.
The reason was that anchor point array for affine was defined only for singele point, not three points. At the same time, anchors for the translation was excessively defined to be three points, so these two definitions were swapped.
1 parent 9b4785f commit 85929bf

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<groupId>de.embl.cmci</groupId>
1717
<artifactId>MultiStackRegistration_</artifactId>
18-
<version>1.46.0</version>
18+
<version>1.46.1</version>
1919

2020
<name>plugins/MultiStackRegistration_.jar</name>
2121
<description>A Maven project implementing an ImageJ 1.x plugin. MultiStackRegistration plugin written by Brad Busse.</description>
@@ -37,6 +37,11 @@
3737
<groupId>net.imagej</groupId>
3838
<artifactId>ij</artifactId>
3939
</dependency>
40+
<dependency>
41+
<groupId>sc.fiji</groupId>
42+
<artifactId>TurboReg_</artifactId>
43+
<version>2.0.1-SNAPSHOT</version>
44+
</dependency>
4045
</dependencies>
4146

4247
<build>

src/main/java/de/embl/cmci/registration/MultiStackReg_.java

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ public void run ( final String arg) {
237237
loadPath="";
238238
loadFile="None";
239239

240+
//@TODO show help with a help button, rather than a radio button.
240241
if (viewManual){ //they just want to read the manual. Do so and quit.
241242
final MultiStackRegCredits dialog = new MultiStackRegCredits(IJ.getInstance());
242243
GUI.center(dialog);
@@ -433,14 +434,14 @@ public int processDirectives(ImagePlus imp, boolean loadBool){
433434
};
434435
double[][] anchorPoints = null;
435436
switch (transformation) {
436-
case AFFINE: {
437+
case TRANSLATION: { //AFFINE: { //should be three points, not one.
437438
anchorPoints = new double[1][3];
438439
anchorPoints[0][0] = (double)(width / 2);
439440
anchorPoints[0][1] = (double)(height / 2);
440441
anchorPoints[0][2] = 1.0;
441442
break;
442443
}
443-
case RIGID_BODY: {
444+
case RIGID_BODY: { //three points
444445
anchorPoints = new double[3][3];
445446
anchorPoints[0][0] = (double)(width / 2);
446447
anchorPoints[0][1] = (double)(height / 2);
@@ -453,7 +454,7 @@ public int processDirectives(ImagePlus imp, boolean loadBool){
453454
anchorPoints[2][2] = 1.0;
454455
break;
455456
}
456-
case SCALED_ROTATION: {
457+
case SCALED_ROTATION: { //two points
457458
anchorPoints = new double[2][3];
458459
anchorPoints[0][0] = (double)(width / 4);
459460
anchorPoints[0][1] = (double)(height / 2);
@@ -463,7 +464,7 @@ public int processDirectives(ImagePlus imp, boolean loadBool){
463464
anchorPoints[1][2] = 1.0;
464465
break;
465466
}
466-
case TRANSLATION: {
467+
case AFFINE: {//TRANSLATION: { //should be one point, not three.
467468
anchorPoints = new double[3][3];
468469
anchorPoints[0][0] = (double)(width / 2);
469470
anchorPoints[0][1] = (double)(height / 4);
@@ -1578,7 +1579,7 @@ private void QRdecomposition (
15781579
} /* end QRdecomposition */
15791580

15801581
/*------------------------------------------------------------------*/
1581-
@SuppressWarnings({ "rawtypes", "rawtypes" })
1582+
@SuppressWarnings({ })
15821583
private ImagePlus registerSlice (
15831584
ImagePlus source,
15841585
ImagePlus target,
@@ -2351,10 +2352,16 @@ private ImagePlus registerSlice (
23512352
sourcePoints[0][i] = 0.0;
23522353
sourcePoints[1][i] = 0.0;
23532354
sourcePoints[2][i] = 0.0;
2355+
IJ.log("sourcePoints rows:" + Integer.toString(sourcePoints.length));
2356+
IJ.log("sourcePoints cols:" + Integer.toString(sourcePoints[0].length));
2357+
IJ.log("globalTransform rows:" + Integer.toString(globalTransform.length));
2358+
IJ.log("globalTransform cols:" + Integer.toString(globalTransform[0].length));
2359+
IJ.log("anchorPoints rows:" + Integer.toString(anchorPoints.length));
2360+
IJ.log("anchorPoints cols:" + Integer.toString(anchorPoints[0].length));
23542361
for (int j = 0; (j < 3); j++) {
23552362
sourcePoints[0][i] += globalTransform[i][j]
23562363
* anchorPoints[0][j];
2357-
sourcePoints[1][i] += globalTransform[i][j]
2364+
sourcePoints[1][i] += globalTransform[i][j] //java.lang.ArrayIndexOutOfBoundsException: 1
23582365
* anchorPoints[1][j];
23592366
sourcePoints[2][i] += globalTransform[i][j]
23602367
* anchorPoints[2][j];
@@ -2533,5 +2540,18 @@ public void setSavePath(String savePath) {
25332540
this.savePath = savePath;
25342541
}
25352542

2543+
public static void main(String[] args) {
2544+
MultiStackReg_ msr = new MultiStackReg_();
2545+
ImagePlus srcimp = new ImagePlus("/Users/miura/Dropbox/sampleImages/RegistrationExample/translation/MAX_reference.tif");
2546+
ImagePlus tgtimp = new ImagePlus("/Users/miura/Dropbox/sampleImages/RegistrationExample/translation/MAX_30-pixel-translation-along-x.tif");
2547+
msr.setSrcImg(srcimp);
2548+
msr.setTgtImg(tgtimp);
2549+
msr.setSrcAction("Use as Reference");
2550+
msr.setTgtAction("Align to First Stack");
2551+
msr.setTransformation(0);
2552+
msr.setSaveTransform(true);
2553+
msr.core("", "");
2554+
}
2555+
25362556
} /* end class StackReg_ */
25372557

0 commit comments

Comments
 (0)