Parcly-Taxel on DeviantArthttp://creativecommons.org/licenses/by-sa/3.0/https://www.deviantart.com/parcly-taxel/art/Very-Angry-Numerical-Linear-Algebraists-702475765Parcly-Taxel

Deviation Actions

Parcly-Taxel's avatar

Very Angry Numerical Linear Algebraists

By
Published:
4.3K Views

Description

def alphatint(backs, comps):
    if len(backs) != len(comps): raise TypeError("colour sets differ in length")
    if len(backs) < 2: raise TypeError("computing the tint requires at least two pairs of colours")
    A = np.block([[np.eye(3), (backs[i] - comps[i]).reshape(3, 1)] for i in range(len(backs))])
    b = np.concatenate(backs)
    x = np.linalg.lstsq(A, b)[0]
    if abs(x[3]) < 1e-8: return np.zeros(3), 0
return x[:3], 1 / x[3]


When I committed the above function into Kinross, I was very excited. The existing MLP Vector Club blending calculator only handled two pairs of colours, yet I had found the generalisation to any number of pairs by transforming the compositing equations into a linear-least-squares problem – right in NumPy's linear algebra capabilities. (The similar problem of ellipse fitting had fell the day before to the same approach.) This linear algebra is what the title of this picture references; condition numbers are quite an important topic in the field.

SVG | CMR: Starlight, Twilight | MVC listing | Reference image | Tumblr | Derpibooru | Fur Affinity | Inkbunny
Image size
10349x6400px 2.43 MB
Comments1
Join the community to add your comment. Already a deviant? Log In
Zacharygoblin55's avatar