Repository navigation
Conversation
e8344f4 to
9788ae5
Compare
|
Thanks for the PR(s) @CuiweiG, I am busy with some other projects now, but will check after BioC release if can. |
`.trans_f()` spliced the matrix into `ST_Affine()` column by column, so `rbind(c(a, b, xoff), c(d, e, yoff))` arrived as `(a, d, b, e, xoff, yoff)` where DuckDB expects `(a, b, d, e, xoff, yoff)`: the linear part was transposed and rotations ran the wrong way. Translations and diagonal scalings, the cases tested so far, are the same either way.
With `rev=TRUE`, `.trans_f()` negated the affine matrix, which is not its inverse, not even for a pure translation. `crop()` on images and labels gets here through `.box2rev()`, which maps the query box back with `transform(z, 1, rev=TRUE)`. The linear part is now inverted and the offsets follow from it; a singular matrix gives an error.
The rows of a stored affine matrix follow the transformation's output axes, its columns the input axes. `transform()` applied the matrix as stored, and `.box2rev()` relabelled the axes of an array's transformation as (x, y) without reordering it. For `blobs_labels`, whose affine maps (y, x) to (x, y), `crop()` through that coordinate system sent the query box to the wrong place. `.ct_affine()` now picks rows and columns by these axes, leaves out axes not needed (e.g., the channel of an image) and fails when data and axes don't agree. `addCT()` takes the number of axes from `axes(x)`; `dim(x)` has length 2 for any point or shape element, so a 3D one got (x, y) axes.
The identity shortcut in `.trans_f()` compared an affine matrix against 1 throughout, so a matrix of ones was returned untransformed, while the actual identity was not recognised.
9788ae5 to
e3eef64
Compare
|
I've rebased this PR and #292 onto devel without changing any code. The only conflict here was in Before the rebase, both PRs failed the same two checks, for reasons unrelated to these changes. The Windows job of |
Fixes #289.
The first three commits are the ordering from the issue and the two points from my comment there. The tests include the three I listed in that comment, and
crop()onblobs_imagethrough an affine over (c, y, x)..trans_f()now passes the matrix toST_Affine()row by row, then the offsets.rev = TRUEinverts the matrix instead of negating it. A singular matrix gives an error..ct_affine()picks the rows and columns of a stored matrix by the transformation's output and input axes, and stops when axes and data don't agree.transform()uses it, and.box2rev()uses it to get the (x, y) part, without an image's channel axis.addCT()now counts the element's axes. It useddim(x), which has length 2 for any point or shape element, so a transformation added to a 3D one got (x, y) axes, and.ct_affine()would have rejected it.The fourth commit is extra: the identity shortcut in
.trans_f()compared an affine matrix with 1 throughout, so a matrix of ones was treated as the identity, and the identity itself was not. It is separate so it can be left out.Not changed: a sequence with an affine step still fails as on devel, an image or label still has no
affine()method fortransform()to dispatch to, and circle radii are only rescaled byscale().devtools::check()on the Bioconductor devel Docker image (R 4.6.1) gives 0 errors, 0 warnings and the same 4 notes as devel, andlintris clean on the changed files.On #289 I only offered the tests, so if you'd rather fix this your own way I can cut the PR down to them.