45 private readonly ImageConverterCInterface.Handle _handle;
52 var handle =
new ImageConverterCInterface.Handle();
53 DllHelper.ExecuteAndMapReturnCodes(() =>
54 ImageConverterCInterface.CInterface.peak_icv_Preprocessing_ImageConverter_Create(out handle));
59 public override string TypeId =>
"Unpack";
119 GC.SuppressFinalize(
this);
144 var outputBitDepth = GetOutputBitDepth(inputBitDepth);
152 var outputImageHandle =
new Image.Handle();
154 DllHelper.ExecuteAndMapReturnCodes(() =>
155 ImageConverterCInterface.CInterface.peak_icv_Preprocessing_ImageConverter_Convert(_handle,
157 outputPixelFormat, out outputImageHandle));
159 return new Image(outputImageHandle);
206 DllHelper.ExecuteAndMapReturnCodes(() =>
207 ImageConverterCInterface.CInterface.peak_icv_Preprocessing_ImageConverter_ReleaseBuffers(_handle));
229 private uint GetOutputBitDepth(uint inputBitDepth)
234 ProcessingPolicy.Enhanced => Math.Max(inputBitDepth,
TargetBitDepth),
242 var isBayer = inputPixelFormatInfo.HasChannel(
Channel.Bayer);
243 var isYuv = inputPixelFormatInfo.HasChannel(
Channel.ChromaV);
244 var isMono = !isYuv && inputPixelFormatInfo.HasChannel(
Channel.Intensity);
253 return outputBitDepth
switch
257 _ => PixelFormat.Mono8
265 var isBayerRg = unpackedFormat is
266 PixelFormat.BayerRG8 or
267 PixelFormat.BayerRG10 or
271 return outputBitDepth
switch
275 _ => PixelFormat.BayerRG8
279 var isBayerGr = unpackedFormat is
280 PixelFormat.BayerGR8 or
281 PixelFormat.BayerGR10 or
285 return outputBitDepth
switch
289 _ => PixelFormat.BayerGR8
293 var isBayerBg = unpackedFormat is
294 PixelFormat.BayerBG8 or
295 PixelFormat.BayerBG10 or
299 return outputBitDepth
switch
303 _ => PixelFormat.BayerBG8
307 var isBayerGb = unpackedFormat is
308 PixelFormat.BayerGB8 or
309 PixelFormat.BayerGB10 or
313 return outputBitDepth
switch
317 _ => PixelFormat.BayerGB8
322 return inputPixelFormat;
Base class for all pipeline modules.
Unpack is an image pipeline module that converts packed pixel formats into corresponding unpacked Bay...
override void Deserialize(IArchive archive)
This function has no effect on the Unpack module.
UnpackModule()
Creates an instance of class UnpackModule.
override Image Process(Image inputImage)
Converts a packed pixel format image into an unpacked Bayer or monochrome format.
void ReleaseBuffers()
Frees unused internal buffers.
override void ResetToDefault()
Resets all settings to their defaults.
void Dispose()
Releases all resources used by this class.
override string TypeId
The unique type identifier for this module implementation.This should be a unique string identifying ...
const ProcessingPolicy DefaultProcessingPolicy
The default processing policy.
const uint DefaultTargetBitDepth
The default target bit depth.
uint TargetBitDepth
The target bit depth used during image processing.
override bool IsEnabled
Gets a value indicating whether the unpack module is enabled. This property always returns true.
override void Serialize(IArchive archive)
This function has no effect on the Unpack module.
Constructs an Image from an IImageView Instance.
PixelFormat PixelFormat
Gets the pixel format from the image.
Channel
Represents the various data channels in image or spatial data formats. /// This enumeration defines s...
PixelFormat
Each enumerator represents a specific pixel layout and bit-depth, used for interpreting raw image dat...
ProcessingPolicy
Specifies the processing policy.
Represents a hierarchical, strongly-typed key-value archive.