StandardSensor¶
- class dnois.sensor.StandardSensor(pixel_num: int | tuple[int, int], pixel_size: float | tuple[float, float], rgb: bool = True, srf: Tensor | tuple[Tensor, Tensor, Tensor] = None, bayer_pattern: Literal['RGGB', 'GRBG', 'BGGR', 'GBRG'] = None, noise_std: float | tuple[float, float] = 0.0, max_value: float = 1.0, _quantize: int = 256, linear2srgb: bool = True, differentiable_quant: bool = True)¶
A simple RGB or grayscale sensor model, which processes the radiance field reaching the sensor plane as follows:
Divide pixels into channels according to Bayer CFA.
Spectral integral by
srf
.Apply additional Gaussian white noise.
Restrict signal values to a given range.
Quantize signal to a given level.
- Parameters:
pixel_num (int or tuple[int, int]) – Numbers of pixels in vertical and horizontal directions.
pixel_size (float or tuple[float, float]) – Height and width of a pixel in meters.
rgb (bool) – RGB sensor if
True
, grayscale sensor otherwise. Default:True
.srf (Tensor or tuple[Tensor, Tensor, Tensor]) – SRF tensor of shape
(N_C, N_wl)
whereN_C
is 1 or 3, or a 3-tuple of tensors of lengthN_wl
, corresponding to the SRF of R, G, B channels. Default: do not perform spectral integral.bayer_pattern (BayerPattern) – See
rgb2raw()
. Default: no CFA.noise_std (float or tuple[float, float]) – Standard deviation of the Gaussian white noise. See
gaussian()
. Default: 0.max_value (float) – Maximum possible value of output signal. Default: 1.
_quantize (int) – Quantization level. The output signal will not be quantized if a negative or zero value is given. Default: 256.
linear2srgb (bool) – Whether to convert linear RGB to sRGB. Default:
True
.differentiable_quant (bool) – See
quantize()
. Default:True
.
- extra_repr() str ¶
Return the extra representation of the module.
To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.
- forward(radiance: Tensor) Tensor ¶
Simulate the process of conversion from optical signal
radiance
to electric signal, an 2D image.- Parameters:
radiance (Tensor) – A tensor representing the received radiance field, of shape
(..., N_wl, H, W)
.- Returns:
Output image signal, a tensor of shape
(..., N_C', H, W)
. Ifself.srf
is notNone
,radiance
is monochromatic (N_wl=1
) orself.bayer_pattern
is notNone
,N_C'
is 1. Otherwise,N_C'
is 3 (RGB regardless of SRF and Bayer CFA).- Return type:
Tensor
- differentiable_quantization: bool¶
Whether to perform differentiable quantization.
- property h¶
Physical height of the sensor in meters.
- Type:
float
- linear2srgb: bool¶
Whether to convert linear RGB to sRGB.
- max_value: float¶
Maximum possible value of signal.
- noise_std: float | tuple[float, float]¶
Standard deviation of Gaussian noise.
- property pixel_h: float¶
Height of a pixel.
- Type:
float
- pixel_num: tuple[int, int]¶
Numbers of pixels in vertical and horizontal directions.
- pixel_size: tuple[float, float]¶
Height and width of a pixel in meters.
- property pixel_w: float¶
Width of a pixel.
- Type:
float
- quantize: int¶
Quantization level.
- property res_h: int¶
Number of pixels in vertical direction.
- Type:
int
- property res_w: int¶
Number of pixels in horizontal direction.
- Type:
int
- rgb: bool¶
RGB sensor or not.
- property size: tuple[float, float]¶
Returns the physical size i.e. height and width of the sensor.
- Type:
tuple[float, float]
- srf: Tensor¶
Spectral response functions. Either
None
or a tensor of shape(1, N_wl)
or(4, N_wl)
(two identical green SRF in Bayer CFA)
- property w¶
Physical width of the sensor in meters.
- Type:
float