illuminationΒΆ

This module defines the illumination functions that are used to convert ray traced geometry into intensity values when rendering.

In GIANT, an illumination model is typically a callable that converts an array of ray traced geometry with dtype ILLUM_DTYPE (typically generated by Scene.get_illumination_inputs()) into an array of floats giving the intensity that would be expected to be returned along that ray. You can then add these values to a 2D image to create a rendered image. Note that this does not take into account camera electronics or actual photon counts or anything like that, since this is typically not important in OpNav. You could conceivably roll your own solution using the provided components to do something like that if you so desired.

The typical workflow goes as follows:

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from giant.ray_tracer.illumination import McEwenIllumination
>>> from giant.ray_tracer.scene import Scene, SceneObject
>>> from giant.ray_tracer.shapes import Ellipsoid, Point
>>> from giant.ray_tracer.rays import compute_rays
>>> from giant.camera_models import PinholeModel
>>> # define the camera model
>>> model = PinholeModel(focal_length=7.2, kx=1/2.2e-3, ky=1/2.2e-3, n_rows=1024, n_cols=1024, px=511.5, py=511.5)
>>> # set up the target that we want to render
>>> target = SceneObject(Ellipsoid(principal_axes=[0.25, 0.2, 0.25]))
>>> # move the target along the camera frame z axis
>>> target.translate([0, 0, 2.5])
>>> # create the sun
>>> sun = SceneObject(Point([0, 0, 0]))
>>> # put the sun behind and to the right of the camera
>>> sun.translate([800, 0, -400])
>>> # create the scene
>>> scene = Scene(target_objs=[target], light_obj=sun)
>>> # get the rays to trace through the scene  (for the entire image)
>>> rays, pix = compute_rays(model, (0, model.n_rows-1), (0, model.n_cols-1))
>>> # get the illumination inputs using the scene and the rays
>>> illum_inputs = scene.get_illumination_inputs(rays)
>>> # use the illumination function to convert the illumination inputs into intensity values
>>> intensity = McEwenIllumination()(illum_inputs)
>>> # create the image array
>>> image = np.zeros((model.n_rows, model.n_cols), dtype=np.float64)
>>> # set up the subscripts where we need to add the intensity values to the image
>>> subs = np.round(pix).astype(int)
>>> # add the intensity values to the image
>>> np.add.at(image, (subs[1], subs[0]), intensity.ravel())
>>> # show it
>>> plt.imshow(image, cmap='gray')
>>> plt.show()

The most commonly used illumination function for OpNav purposes is the McEwenIllumination, which is a linear weighting of the Lommel-Seeliger and Lambertian functions. All of the illumination models in this module are classes, which when initialized create callables that are then used for the conversion. A couple also provide other methods, as discussed, which may be useful in some specific circumstances.

Classes

AshikhminShirleyDiffuseIllumination

This illumination model computes the intensity values according to the Ashikhmin Shirley diffuse law

GaskellIllumination

This illumination model computes the intensity values as the weighted sum between the Lommel-Seeliger and Lambertian models, weighted using the phase angle.

IlluminationModel

This abstract base class specifies the minimum interface expected of an illumination model in GIANT.

LambertianIllumination

This basic illumination model computes the intensity values as simply the cosine of the incidence angle times the albedo.

LommelSeeligerIllumination

This basic illumination model computes the intensity values as simply the cosine of the incidence angle divided by the cosine of the incidence angle plus the exidence angle times the albedo.

McEwenIllumination

This illumination model computes the intensity values as the weighted sum between the Lommel-Seeliger and Lambertian models, weighted using the phase angle.

Constants

ILLUM_DTYPE

The numpy datatype expected by the illumination functions in this module as input for conversion to intensity values.