Create a new OIDN device
Args:
device_type(int) : OIDN_DEVICE_TYPE_XXX
Batch up multiple changes on the device.
Args:
device_handle : Get from NewDevice
Args:
device_handle : Get from NewDevice
Returns:
tuple of (error_code : int, error_message : str)
Args:
device_handle : Get from NewDevice
Args:
device_handle : Get from NewDevice
These parameters can be set by SetDeviceBool:
setAffinity (default=True): enables thread affinitization (pinning software threads to hardware threads) if it is necessary for achieving optimal performance
Args:
device_handle : Get from NewDevice
name : parameter name
value : parameter value(bool type)
Alias for SetDeviceBool
These parameters can be set by SetDevice1b:
verbose : 0 verbosity level of the console output between 0-4; when set to 0, no output is printed, when set to a higher level more output is printed
numThreads (default = 0) : maximum number of threads which the library should use; 0 will set it automatically to get the best performance
Args:
device_handle : Get from NewDevice
name : parameter name
value : parameter value(bool type)
Alias for SetDeviceInt
These parameters can be get by GetDeviceInt:
version : combined version number (major.minor.patch) with two decimal digits per component
versionMajor : major version number
versionMinor : minor version number
versionPatch : patch version number
verbose : 0 verbosity level of the console output between 0-4; when set to 0, no output is printed, when set to a higher level more output is printed
Args:
device_handle : Get from NewDevice
name : parameter name
Alias for GetDeviceInt
These parameters can be get by GetDeviceBool:
setAffinity (default = True): enables thread affinitization (pinning software threads to hardware threads) if it is necessary for achieving optimal performance
Args:
device_handle : Get from NewDevice
name : parameter name
Alias for GetDeviceBool
Creates a new filter of the specified type (e.g. "RT")
Args:
device_handle(int) : Created by NewDevice
type(str) : e.g. "RT“ or "RTLightmap"
SetSharedFilterImage(filter_handle: int, name: str, data: numpy.ndarray, format: int, width: int, height: int, byteOffset: int = 0, bytePixelStride: int = 0, byteRowStride: int = 0):
Set filter image, the parameter name cound be:
color : input beauty image (3 channels, LDR values in [0, 1] or HDR values in [0, +∞), values being interpreted such that, after scaling with the inputScale parameter, a value of 1 corresponds to a luminance level of 100 cd/m²)
albedo(only support RT filter) : input auxiliary image containing the albedo per pixel (3 channels, values in [0, 1])
normal(only support RT filter) : input auxiliary image containing the shading normal per pixel (3 channels, world-space or view-space vectors with arbitrary length, values in [-1, 1])
output : output image (3 channels); can be one of the input images
Args:
filter_handle(int): Created by NewFilter
name(str): color/albedo/normal/output, See document of OIDN.
data(np.array): data buffer, should be correct in size and dtype; should be c_contiguous when name == 'output'
format: Should be oidn.FORMAT_FLOAT3 for image
width: width in pixel.
height: height in pixel.
byteOffset: default to 0
bytePixel: default to 0
byteRawStride: default to 0
Remove filter image, name could be color | albedo | normal | output
Args:
filter_handle : handle of fitler, get from NewFitler
name : image name
Alias for UnsetFilterImage
Set filter data, the name could be:
weights : trained model weights blob
Args:
filter_handle : Get from NewFilter
name : name of the parameter
data : numpy array with dtype != object
Just notify the filter that the contents of its data has been changed, name can be weight.
Args:
fitler_handle : Get from NewFilter
name : parameter name
Remove the filter data, name can be weight.
Args:
fitler_handle : Get from NewFilter
name : name of the data
Alias for UnsetFilterData
Get filter parameter (type int), the name could be:
maxMemoryMB (default=3000) : approximate maximum scratch memory to use in megabytes (actual memory usage may be higher); limiting memory usage may cause slower denoising due to internally splitting the image into overlapping tiles
alignment : when manually denoising in tiles, the tile size and offsets should be multiples of this amount of pixels to avoid artifacts; when denoising HDR images inputScale must be set by the user to avoid seam artifacts
overlap : when manually denoising in tiles, the tiles should overlap by this amount of pixels
Args:
filter_handle : Get from NewFilter
name : name of the parameter
Alias for GetFilterInt
Get filter parameter (type bool), the name could be:
hdr (default = False, only support RT) : whether the main input image is HDR
srgb (default = False, only support RT) : whether the main input image is encoded with the sRGB (or 2.2 gamma) curve (LDR only) or is linear; the output will be encoded with the same curve
cleanAux (default = False, only support RT) : whether the auxiliary feature (albedo, normal) images are noise-free; recommended for highest quality but should not be enabled for noisy auxiliary images to avoid residual noise
directional (default = False, only support RTLightmap) : whether the input contains normalized coefficients (in [-1, 1]) of a directional lightmap (e.g. normalized L1 or higher spherical harmonics band with the L0 band divided out); if the range of the coefficients is different from [-1, 1], the inputScale parameter can be used to adjust the range without changing the stored values
Args:
filter_handle : Get from NewFilter
name : name of the parameter
Alias for GEtFilterBool
Get filter parameter (type float), the name could be:
inputScale (default=nan) : scales values in the main input image before filtering, without scaling the output too, which can be used to map color or auxiliary feature values to the expected range, e.g. for mapping HDR values to physical units (which affects the quality of the output but not the range of the output values); if set to NaN, the scale is computed implicitly for HDR images or set to 1 otherwise
Args:
filter_handle : Get from NewFilter
name : name of the parameter
Alias for GetFilterFloat
Get filter parameter (type bool), the name could be:
hdr (default = False, only support RT) : whether the main input image is HDR
srgb (default = False, only support RT) : whether the main input image is encoded with the sRGB (or 2.2 gamma) curve (LDR only) or is linear; the output will be encoded with the same curve
cleanAux (default = False, only support RT) : whether the auxiliary feature (albedo, normal) images are noise-free; recommended for highest quality but should not be enabled for noisy auxiliary images to avoid residual noise
directional (default = False, only support RTLightmap) : whether the input contains normalized coefficients (in [-1, 1]) of a directional lightmap (e.g. normalized L1 or higher spherical harmonics band with the L0 band divided out); if the range of the coefficients is different from [-1, 1], the inputScale parameter can be used to adjust the range without changing the stored values
Args:
filter_handle : Get from NewFilter
name : name of the parameter
value : value of the parameter
Alias for SetFilterBool
Get filter parameter (type int), the name could be:
maxMemoryMB (default=3000) : approximate maximum scratch memory to use in megabytes (actual memory usage may be higher); limiting memory usage may cause slower denoising due to internally splitting the image into overlapping tiles
alignment : when manually denoising in tiles, the tile size and offsets should be multiples of this amount of pixels to avoid artifacts; when denoising HDR images inputScale must be set by the user to avoid seam artifacts
overlap : when manually denoising in tiles, the tiles should overlap by this amount of pixels
Args:
filter_handle : Get from NewFilter
name : name of the parameter
value : value of the parameter
Alias for SetFilterInt
Get filter parameter (type float), the name could be:
inputScale (default=nan) : scales values in the main input image before filtering, without scaling the output too, which can be used to map color or auxiliary feature values to the expected range, e.g. for mapping HDR values to physical units (which affects the quality of the output but not the range of the output values); if set to NaN, the scale is computed implicitly for HDR images or set to 1 otherwise
Args:
filter_handle : Get from NewFilter
name : name of the parameter
value : value of the parameter
Alias for SetFilterFloat
Batch up multiple changes for the filter
Args:
filter_handle : Get from NewFilter
Execute the filter. Remember CommitFilter to ensure all your parameters notified.
Args:
filter_handle : Get from NewFilter
Release the filter
Args:
filter_handle : Get from NewFilter
Release the filter
Args:
filter_handle : Get from NewFilter
These functions are FFI objects for corresponding native functions in the OIDN dynamic linked library.
Create an OIDN device.
Args:
device_type: 'cpu' or 'cuda'
Returns the device handle
Returns a tuple[error_code, error_message], the same as oidn.GetDeviceError.
Indicate whether it is a CPU device.
Indicate wheter it is a CUDA device.
Raise a RuntimeError if an error occured.
Call ReleaseDevice with self.device_handle
Args:
device : oidn.Device
type : 'RT' or 'RTLightmap'
Run the filter, wait until finished.
Returns the handle of filter.
Call ReleaseFilter with self.fitler_handle
Set image buffer for the filter.
Args:
name : color/albedo/normal/output
-------
color : input beauty image (3 channels, LDR values in [0, 1] or HDR values in [0, +∞), values being interpreted such that, after scaling with the inputScale parameter, a value of 1 corresponds to a luminance level of 100 cd/m²)
albedo (only support RT filter) : input auxiliary image containing the albedo per pixel (3 channels, values in [0, 1])
normal (only support RT filter) : input auxiliary image containing the shading normal per pixel (3 channels, world-space or view-space vectors with arbitrary length, values in [-1, 1])
output : output image (3 channels); can be one of the input images
-------
buffer : Buffer object
Do not call this.
create(width: int, height: int, channels=3, channel_first=False, device: oidn.Device = None, use_cupy=False, dtype=<class 'numpy.float32'>): method
Create a buffer.
Args:
width : width in pixel
height : height in pixel
channels : channels of the image, it could be 0 or None.
channel_first : If it is true and channels is not zero(None), self.buffer_delegate will be shaped to (channles, height, width), otherwise (height, width, channels).
If the chennels parameter is zero(None), the shape will be (height, width) regardless channel_first.
device : Device. If is_cpu, self.buffer_delegate will be a numpy.ndarray, otherwise, if use_cupy is specified, the buffer_delegate will be a cupy.ndarray, otherwise it will be a torch.Tensor with device='cuda'.
use_cupy : Use cupy, it is not implemented in OIDN-python 0.4.
dtype : could be np.float32, torch.float16(if supported)
Get height
Create a Buffer object from a data source.
Args:
device : Device of the new Buffer object
soruce : Data source, could be PIL.Image, numpy.ndarray, torch.Tensor. If it is PIL.Image, copy_data will always be True.
copy_data : Copy the source's data into a new container.
div255 : Div values by 255, useful for Image objects, if it is True, copy_data should also be True.
Release corresponding resources.
Returns:
numpy.ndarray
Returns:
torch.Tensor
Get width