Coder Social home page Coder Social logo

Comments (4)

johnnychen94 avatar johnnychen94 commented on June 16, 2024 2

Is there a reason to not want to overload inv?

From ?inv, it is required to satisfy inv(x) * x == x * inv(x) == one(x) so clearly that inv(x::Real) = one(x) - x doesn't satisfy this property. Hence we can't overload Base.inv function. We might introduce a new function, e.g., invert_color.

I was trying to mess around with some of the common filters like inverting the colors, and it seems this would be well defined.

This concept is more like a "mirror" operation and might only be well defined for "linear" color space such as RGB, XYZ. For non-linear color space such as Lab, I don't know, it might be sufficient to only invert the L channel.

from colors.jl.

kimikage avatar kimikage commented on June 16, 2024 2

FYI, you can use ColorVectorSpace.complement (formerly Images.complement) for AbstractRGB.
See also the second half of JuliaGraphics/ColorVectorSpace.jl#125 (comment).

from colors.jl.

anandijain avatar anandijain commented on June 16, 2024

Thanks, yes I was worried about the roundoff error. This is helpful, I know really little about color spaces. Is there a type specifically for the Linear spaces so that invert_color could be extended?

julia> dump(inv(inv(purp)) - purp)
RGB{Float64}
  r: Float64 0.0
  g: Float64 -2.7755575615628914e-17
  b: Float64 0.0

It's not a big deal to not have this, since it is so easy to write. I was mainly just curious

from colors.jl.

kimikage avatar kimikage commented on June 16, 2024

Anyway, since inv is no longer a topic of this discussion, I think it would be better to change the subject of this issue or open a new issue.

I have no objection to adding the functionality to get the complementary "color" (not "numbers"), but I don't think we should introduce our own definition for it. We should refer to papers or well-known tools on color science or image processing.

from colors.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.