From ca426ecad8121627c45ea7da9e83254aec9af529 Mon Sep 17 00:00:00 2001 From: Heiner Spiess Date: Thu, 4 Dec 2025 15:02:55 +0100 Subject: [PATCH] adding a pixel to all sides in needed to not interpolate. however, bounds are off now --- src/projective/affine.jl | 9 +++++++-- test/projective/affine.jl | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/projective/affine.jl b/src/projective/affine.jl index 51a77ae..acf23d5 100644 --- a/src/projective/affine.jl +++ b/src/projective/affine.jl @@ -76,7 +76,7 @@ function getprojection(scale::ScaleFixed, bounds::Bounds{N}; randstate = nothing # If no scaling needs to be done, return a noop transform (scale.sizes == length.(bounds.rs)) && return IdentityTransformation() - ratios = (scale.sizes .+ 1) ./ length.(bounds.rs) + ratios = (scale.sizes .+ 2) ./ length.(bounds.rs) upperleft = SVector{N, Float32}(minimum.(bounds.rs)) .- 1 P = scaleprojection(ratios) if any(upperleft .!= 0) @@ -111,7 +111,12 @@ getrandstate(tfm::Zoom) = rand(tfm.dist) function getprojection(tfm::Zoom, bounds::Bounds{N}; randstate = getrandstate(tfm)) where N ratio = randstate - return scaleprojection(ntuple(_ -> ratio, N)) + return getprojection(ScaleRatio{N}(ntuple(_ -> ratio, N)), bounds; randstate = nothing) +end + +function projectionbounds(tfm::Zoom, P, bounds::Bounds{N}; randstate = getrandstate(tfm)) where N + ratio = randstate + projectionbounds(ScaleFixed{N}(fixed_sizes(ScaleRatio{N}(ntuple(_ -> ratio, N)), bounds)), P, bounds; randstate = nothing) end """ diff --git a/test/projective/affine.jl b/test/projective/affine.jl index 519d5d2..fa5855a 100644 --- a/test/projective/affine.jl +++ b/test/projective/affine.jl @@ -82,7 +82,7 @@ include("../imports.jl") testprojective(tfm) end - + @testset ExtendedTestSet "ScaleRatio" begin tfm = ScaleRatio((1/2, 1/2)) @test_nowarn apply(tfm, image)