Rendering an RGB image

Explain Kubelka-Munk theory

from inktime import data, rgbkm 

import numpy as np 
import matplotlib.pyplot as plt 
Rg = data.fetch_blackwhite()[:,:,0:3]
# todo: quick fix multiplier 
D = 5 * data.fetch_star()[:,:,0]
K_hansa = np.array([0.06, 0.21, 1.78]) 
S_hansa = np.array([0.50, 0.88, 0.009])
refl = rgbkm.reflectance(K_hansa, S_hansa, D, Rg)
plt.imshow(refl);

Functions

reflectance[source]

reflectance(K, S, D, Rg)

Calculates reflectance for single colorant Kubelka-Munk model.

Based on Nobbs (1997) formulation with modified Saunderson expression for infinite reflectance.
Function works for single channel, 3 RGB channels, and spectral data/images with muliple wavelength channels.


Parameters:
-----------
    K: tuple-like (n channels)
        Colorant absorption coefficients for wavelength or RGB channels
    S: tuple-like (n channels)
        Colorant scattering coefficients for wavelength or RGB channels
    D: array ( height x width)
        Colorant thickness image
    Rg: array (height x width x n) or rgb tuple with shape (3,)
        Background reflectance image or background color

Returns:
--------
    refl: array (height x width x n)
        n-channel reflectance image