diff --git a/src/main/java/bigwarp/BigWarpInit.java b/src/main/java/bigwarp/BigWarpInit.java index f03063f9..ed8ad65d 100644 --- a/src/main/java/bigwarp/BigWarpInit.java +++ b/src/main/java/bigwarp/BigWarpInit.java @@ -1038,15 +1038,15 @@ public static & NativeType, V extends Volatile & // update the source transform to take into account any change in bounding box final AffineTransform3D newSourceTform = origScaleTform.copy(); final Translation tlation = new Translation(targetInterval.minAsDoubleArray()); - newSourceTform.concatenate(tlation.inverse()); + newSourceTform.concatenate(tlation); sourceTransforms[i] = newSourceTform; InvertibleRealTransformSequence tformToPixelSpace = new InvertibleRealTransformSequence(); - tformToPixelSpace.add(origScaleTform); + tformToPixelSpace.add(newSourceTform); tformToPixelSpace.add(transform.copy()); - tformToPixelSpace.add(newSourceTform.inverse()); + tformToPixelSpace.add(origScaleTform.inverse()); - final RandomAccessibleInterval raiTform = transform( img, pixelInterval, tformToPixelSpace); + final RandomAccessibleInterval raiTform = transform(img, pixelInterval, tformToPixelSpace); final ReadOnlyCachedCellImgFactory cacheFactory = new ReadOnlyCachedCellImgFactory( new ReadOnlyCachedCellImgOptions() .volatileAccesses(true) @@ -1071,16 +1071,16 @@ public void load(SingleCellArrayImg cell) throws Exception { final CacheHints cacheHints = new CacheHints(LoadingStrategy.BUDGETED, priority, false); vmipmaps[i] = VolatileViews.wrapAsVolatile(cachedTransformedMipmap, sharedQueue, cacheHints); } - final RandomAccessibleIntervalMipmapSource cachedTransformedSource = new RandomAccessibleIntervalMipmapSource( mipmaps, type, sourceTransforms, src.getVoxelDimensions(), - src.getName(), + src.getName() + "cached tform", src.doBoundingBoxCulling()); + final Source vsrc = new VolatileSource(cachedTransformedSource, vtype, sharedQueue); final SourceAndConverter vsac = new SourceAndConverter(vsrc, BigDataViewer.createConverterToARGB(vtype)); return new SourceAndConverter(cachedTransformedSource, BigDataViewer.createConverterToARGB(type), vsac); diff --git a/src/test/java/bigwarp/BigWarpTransformCacheTests.java b/src/test/java/bigwarp/BigWarpTransformCacheTests.java index 7cb88108..669f3b37 100644 --- a/src/test/java/bigwarp/BigWarpTransformCacheTests.java +++ b/src/test/java/bigwarp/BigWarpTransformCacheTests.java @@ -47,6 +47,13 @@ public void cachedIdentityTransform() { Source tgtSrc = bwData.getTargetSource(0).getSpimSource(); assertEquals("moving source is not cached", CachedCellImg.class, mvgSrc.getSource(0, 0).getClass()); + assertArrayEquals("scale level 0 pixel raster wrong size", + tgtSrc.getSource(0, 0).dimensionsAsLongArray(), + mvgSrc.getSource(0, 0).dimensionsAsLongArray()); + assertArrayEquals("scale level 1 pixel raster wrong size", + tgtSrc.getSource(0, 1).dimensionsAsLongArray(), + mvgSrc.getSource(0, 1).dimensionsAsLongArray()); + assertTrue("scale level 0 not equal", equal(tgtSrc.getSource(0, 0), mvgSrc.getSource(0, 0))); assertTrue("scale level 1 not equal", equal(tgtSrc.getSource(0, 1), mvgSrc.getSource(0, 1))); } @@ -111,7 +118,7 @@ public void cachedTranslationTransformOffset() { final AffineTransform3D tgtTform0 = new AffineTransform3D(); tgtSrc.getSourceTransform(0, 0, tgtTform0); - tgtTform0.preConcatenate(translation); + tgtTform0.preConcatenate(translation.inverse()); assertArrayEquals("mvg transform is not the translated tgt transform", tgtTform0.getRowPackedCopy(), mvgTform0.getRowPackedCopy(), 1e-9); }