Giter Club home page Giter Club logo

Comments (3)

johnnychen94 avatar johnnychen94 commented on August 19, 2024 1

Ah, sorry that I didn't know this works. _round is used to stabilize transformation coefficients for Transformation(see issue #104), for general functions, there's no need to assume such a need, hence an identity map is a reasonable choice.

I believe this is a sufficient patch, would you mind putting a PR for it?

_round(tform::ComposedFunction; kwargs...) = _round(tform.outer; kwargs...)  _round(tform.inner; kwargs...)
_round(tform; kwargs...) = tform

from imagetransformations.jl.

yakir12 avatar yakir12 commented on August 19, 2024

I also found out that the example in this useful SO https://stackoverflow.com/a/45782741 (solved by Tim) doesn't work any longer:

using StaticArrays, ImageTransformations, CoordinateTransformations, Colors
M = @SMatrix [1 0 0; 0 1 0; -1/1000 0 1] 
push1(x) = push(x, 1.0)
tform2 = PerspectiveMap()  inv(LinearMap(M))  push1
img = rand(RGB{Float64}, 100, 100)
imgw = warp(img, tform2, axes(img));

The relevance to this issue is that testing passes before that commit and fails after:

ERROR: MethodError: no method matching _round(::ComposedFunction{CoordinateTransformations.ComposedTransformation{PerspectiveMap, LinearMap{SMatrix{3, 3, Float64, 9}}}, typeof(push1)})
Closest candidates are:
  _round(::T; kwargs...) where T<:Transformation at /home/yakir/.julia/packages/ImageTransformations/cCs2K/src/autorange.jl:88
Stacktrace:
 [1] warp!(out::Matrix{RGB{Float64}}, img::Interpolations.FilledExtrapolation{RGB{Float64}, 2, Interpolations.BSplineInterpolation{RGB{Float64}, 2, Matrix{RGB{Float64}}, Interpolations.BSpline{Interpolations.Linear}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, Interpolations.BSpline{Interpolations.Linear}, RGB{Float64}}, tform::ComposedFunction{CoordinateTransformations.ComposedTransformation{PerspectiveMap, LinearMap{SMatrix{3, 3, Float64, 9}}}, typeof(push1)})
   @ ImageTransformations ~/.julia/packages/ImageTransformations/cCs2K/src/warp.jl:88
 [2] warp(img::Interpolations.FilledExtrapolation{RGB{Float64}, 2, Interpolations.BSplineInterpolation{RGB{Float64}, 2, Matrix{RGB{Float64}}, Interpolations.BSpline{Interpolations.Linear}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, Interpolations.BSpline{Interpolations.Linear}, RGB{Float64}}, tform::Function, inds::Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}})
   @ ImageTransformations ~/.julia/packages/ImageTransformations/cCs2K/src/warp.jl:84
 [3] warp(::Matrix{RGB{Float64}}, ::Function, ::Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}})
   @ ImageTransformations ~/.julia/packages/ImageTransformations/cCs2K/src/warp.jl:97
 [4] top-level scope
   @ REPL[18]:1

from imagetransformations.jl.

yakir12 avatar yakir12 commented on August 19, 2024

Thanks for the great suggestion!

Before posting this issue, I naively tried only

_round(tform; kwargs...) = tform

which didn't work for my example, but your additional ComposedFunction method fixed it. So this works for me!

At some point though, it would be good to take care of these more complicated transformations at the source, CoordinateTransformations.

from imagetransformations.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.