51 internal const string ConversionPolicyKey =
"ConversionPolicy";
52 internal const string ChannelLayoutKey =
"ChannelLayout";
53 private readonly ImageConverterCInterface.Handle _handle;
60 var handle =
new ImageConverterCInterface.Handle();
61 DllHelper.ExecuteAndMapReturnCodes(() =>
62 ImageConverterCInterface.CInterface.peak_icv_Preprocessing_ImageConverter_Create(out handle));
67 public override string TypeId =>
"Debayer";
121 GC.SuppressFinalize(
this);
146 return base.Process(input);
177 PixelFormat outputFormat = GetOutputFormat(inputFormat);
179 if (inputFormat == outputFormat)
184 var outputImageHandle =
new Image.Handle();
186 DllHelper.ExecuteAndMapReturnCodes(() =>
187 ImageConverterCInterface.CInterface.peak_icv_Preprocessing_ImageConverter_Convert(_handle,
189 outputFormat, out outputImageHandle));
191 return new Image(outputImageHandle);
207 base.Serialize(archive);
239 base.Deserialize(archive);
290 DllHelper.ExecuteAndMapReturnCodes(() =>
291 ImageConverterCInterface.CInterface.peak_icv_Preprocessing_ImageConverter_ReleaseBuffers(_handle));
294 private long GetOutputBitDepth(
long inputBitDepth)
299 ProcessingPolicy.Enhanced => Math.Max(inputBitDepth,
TargetBitDepth),
313 if (!info.IsSingleChannel)
318 var isBayer = info.HasChannel(
Channel.Bayer);
319 var isMono = info.HasIntensityChannel;
326 var inputBitDepth = info.StorageBitsPerChannel;
327 var outputBitDepth = GetOutputBitDepth(inputBitDepth);
332 $
"The given input pixel format 0x{(long) inputFormat:X} is unknown!");
335 if (outputBitDepth <= 8)
343 _ => ThrowNotSupported()
347 if (outputBitDepth <= 10)
355 _ => ThrowNotSupported()
359 if (outputBitDepth <= 12)
367 _ => ThrowNotSupported()
371 return ThrowNotSupported();
Occurs when reading from a file or stream that is incomplete, damaged, or in an unexpected format.
Occurs when a requested operation is not implemented or supported (e.g., exporting to an unsupported ...
Debayer is an image pipeline module that converts Bayer RAW images into standard color formats.
override void Deserialize(IArchive archive)
Restores the object's state from the provided archive.
override Image Process(Image inputImage)
Converts a Bayer or mono image to a color image, or returns the input image unchanged.
const ProcessingPolicy DefaultPolicy
The default processing policy.
void ReleaseBuffers()
Frees unused internal buffers.
override void ResetToDefault()
Resets all module settings to its default settings.
const DebayerChannelLayout DefaultChannelLayout
The default channel layout.
DebayerModule()
Creates an instance of class DebayerModule.
override object Process(object input)
Converts a Bayer or mono image to a color image, or returns the input image unchanged.
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 uint DefaultTargetBitDepth
The default target bit depth.
DebayerChannelLayout ChannelLayout
The output channel layout used for debayered images.
uint TargetBitDepth
The target bit depth for processed images.
const DebayerConversionPolicy DefaultConversionPolicy
The default conversion policy.
DebayerConversionPolicy ConversionPolicy
The debayer conversion policy.
override void Serialize(IArchive archive)
Serializes the object's internal state into the provided archive.
Base class for all pipeline modules.
virtual bool IsEnabled
Get whether this module is enabled.
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...
DebayerConversionPolicy
Specifies the conditions under which the debayer module applies color conversion.
DebayerChannelLayout
Specifies the channel layout used by the debayer module in image processing pipelines.
ProcessingPolicy
Specifies the processing policy.
Represents a hierarchical, strongly-typed key-value archive.
string GetString(string key)
Retrieves a string value by key.
void SetString(string key, string value)
Stores a string value under the specified key.