bandSpectra {colorSpec}R Documentation

Compute Band-based Material Spectra, and Bands for Existing Material Spectra

Description

A band-based material spectrum is a superimposition of bandpass filters, and (optionally) a bandstop filter. The 2 functions in this topic convert a vector of numbers between 0 and 1 to a band representation, and back again.

Usage

bandMaterial( lambda, wavelength=380:780 )

## S3 method for class 'colorSpec'
bandRepresentation( x )

Arguments

lambda

a numeric Mx2 matrix with wavelength pairs in the rows, or a vector that can be converted to such a matrix, by row. The two wavelengths in a row (the transition wavelengths) define either a bandpass or bandstop filter, and all the rows are superimposed to define the transmittance spectrum of the final material. If the 2 wavelengths are denoted by \lambda_1 and \lambda_2, and \lambda_1 < \lambda_2 then the filter is a bandpass filter. If the 2 wavelengths are swapped, then the spectrum is "flipped" and is a bandstop filter, and the band "wraps around" from long wavelengths to short. There can be at most 1 bandstop filter in the matrix, otherwise it is an error. The bands must be pairwise disjoint, otherwise it is an error. To get a material with transmittance identically 0, set lambda to a 0x2 matrix. To get a material with transmittance identically 1, set lambda to a 1x2 matrix with \lambda_1=\beta_0 and \lambda_2=\beta_N, where N is the number of wavelengths. See vignette Convexity and Transitions for the definition of \beta_0 and \beta_N and other mathematical details.
lambda can also be a list of such matrices, which are processed separately, see Value.

wavelength

a vector of wavelengths for the returned object

x

a colorSpec object with type equal to 'material'

Details

bandRepresentation() is a right-inverse of bandMaterial(), see Examples and the test script test-bands.R. For more mathematical details, see the vignette Convexity and Transitions.

Value

bandMaterial() returns a colorSpec object with quantity equal to 'transmitance'. If lambda is a matrix, then the object has 1 spectrum. If lambda is a list of matrices with length N, then the object has N spectra.

bandRepresentation() returns a list of matrices with 2 columns. There is a matrix in the list for each spectrum in x.

See Also

rectangularMaterial(), vignette Convexity and Transitions

Examples

#  make a vector superimposing a bandpass and a bandstop filter, and of the proper length 401
vec = c( rep(1,100), 0.5, rep(0,40), .25, rep(1,50), 0.9, rep(0,100), 0.4, rep(1,107) )

#	 convert that vector to a colorSpec object, with a single spectrum
spec = colorSpec( vec, wavelength=380:780, quantity='transmittance', specnames='sample' )

#	 extract and print the 2 bands
lambda = bandRepresentation( spec ) ;  print(lambda)

##  $sample
##      lambda1 lambda2
##  BS   673.10   480.0
##  BP1  521.25   572.4

#  convert the 2 bands  (the transition wavelengths) back to a vector of length 401
#  and compare with the original vector
delta = vec - coredata( bandMaterial(lambda) )

range(delta)
##  [1] -9.092727e-14  2.275957e-14

[Package colorSpec version 1.5-0 Index]