polish

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2020 License: BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAlbedoMap

func CreateAlbedoMap(c *render3d.Camera, obj render3d.Object,
	width, height, bsdfSamples int) *image.RGBA

CreateAlbedoMap creates a feature image where each pixel indicates the albedo of the surface intersected by the camera ray.

The bsdfSamples argument specifies how many times each BSDF is sampled to approximate the albedo. A higher value gives more accurate results for complex materials.

func CreateAuxTensor

func CreateAuxTensor(c *render3d.Camera, obj render3d.Object, img image.Image) *nn.Tensor

CreateAuxTensor creates a Tensor for a rendering with auxiliary feature channels.

This Tensor can then be passed to PolishAux.

The channels are ordered as follows:

  1. Red
  2. Green
  3. Blue
  4. Albedo red
  5. Albedo green
  6. Albedo blue
  7. Ray-surface cosine map

func CreateAuxTensorImages

func CreateAuxTensorImages(img, albedo, incidence image.Image) *nn.Tensor

CreateAuxTensorImages creates an auxiliary Tensor using pre-constructed auxiliary images.

See CreateAuxTensor for details on the channel order.

func CreateIncidenceMap

func CreateIncidenceMap(c *render3d.Camera, obj render3d.Object,
	width, height int) *image.Gray

CreateIncidenceMap creates a feature image where each pixel indicates the dot product of the camera ray with the normal of the first ray collision.

func PolishAux

func PolishAux(t ModelType, auxImage *nn.Tensor) image.Image

PolishAux applies a denoising network to an image with auxiliary feature channels.

The Tensor may be created via CreateAuxTensor().

This should be used with a model that expects auxiliary features.

func PolishAuxPatches

func PolishAuxPatches(t ModelType, auxImage *nn.Tensor, patchSize, border int) image.Image

PolishAuxPatches is like PolishAux, but it applies the operation to patches of the image at a time to save memory.

See PolishImagePatches for more information.

func PolishImage

func PolishImage(t ModelType, img image.Image) image.Image

PolishImage applies a denoising network to an image.

A model should be used which does not expect any extra feature channels besides RGB colors.

func PolishImagePatches

func PolishImagePatches(t ModelType, img image.Image, patchSize, border int) image.Image

PolishImagePatches is like PolishImage, but it applies the operation to patches of the image at a time to save memory.

It is useful for very large images, where a neural network forward pass is too costly.

The patchSize argument specifies how large the output patches should be (they are always square).

The border argument specifies how many extra pixels are included on the side of each patch before it is fed into the network. A value of -1 will use a reasonable default border. Larger border values ensure more accuracy at the cost of redundant computation, while lower values may cause checkerboarding artifacts.

func SaveFeatureMap

func SaveFeatureMap(path string, img image.Image) error

SaveFeatureMap encodes a feature map image to a PNG file.

Types

type ModelType

type ModelType int
const (
	// ModelTypeBilateral uses a tuned bilateral filter to
	// denoise the image without a neural network.
	ModelTypeBilateral ModelType = iota

	// ModelTypeShallow is a small convolutional network
	// that operates only on the pixels of an RGB image.
	//
	// It is fast, but the smoothing is very primitive.
	ModelTypeShallow

	// ModelTypeDeep is a large convolutional network that
	// operates only on the pixels of an RGB image.
	//
	// It is slow and performs a great deal of smoothing.
	ModelTypeDeep

	// ModelTypeShallowAux is like ModelTypeShallow, but
	// the model expects albedo and ray incidence angles
	// as extra input channels.
	ModelTypeShallowAux

	// ModelTypeDeepAux is like ModelTypeDeep, but the
	// model expects albedo and ray incidence angles as
	// extra input channels.
	ModelTypeDeepAux
)

func (ModelType) Aux

func (m ModelType) Aux() bool

Aux checks if the model requires auxiliary features.

func (ModelType) LCD

func (m ModelType) LCD() int

LCD gets a factor which must divide the dimensions of images fed to this type of model.

func (ModelType) Layer

func (m ModelType) Layer() nn.Layer

Layer creates a pre-trained layer implementing this model.

func (ModelType) RF added in v0.1.1

func (m ModelType) RF() int

RF gets the radius of the receptive field of the model.

The radius is the maximum number of pixels to the left, right, top, or bottom that the model can "see".

Directories

Path Synopsis
Package nn implements a small collection of neural network layers for denoising auto-encoders.
Package nn implements a small collection of neural network layers for denoising auto-encoders.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL