output result as IPixelSource #175
-
Right now, all variations of ProcessImage support multiple input types, including I want to use PhotoSauce to resize loaded images, but then use the result, the resized pixels, to fill an ONNX Tensor so it can be used for AI inference. Right now the only way around the current API I see is to encode a PNG to a MemoryStream, and then decode it back to pixels, which is a huge waste of CPU and memory, specially if thousands of images are to be processed. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The result of an open pipeline is already available as ProcessingPipeline.PixelSource Sounds like you want something like this: var settings = new ProcessImageSettings {
Width = 1024,
// The default profile mode may convert to other well-known color spaces,
// but there is currently no way to retrieve the profile. Normalizing to
// sRGB ensures the color space is known.
ColorProfileMode = ColorProfileMode.ConvertToSrgb
};
// create an open pipeline
using var pipeline = MagicImageProcessor.BuildPipeline("/path/to/input", settings);
// normalize the pixel format to match destination
pipeline.AddTransform(new FormatConversionTransform(PixelFormats.Bgr24bpp));
// copy the output anywhere you like
pipeline.PixelSource.CopyPixels(regionOfInterest, bufferStride, bufferSpan); |
Beta Was this translation helpful? Give feedback.
The result of an open pipeline is already available as ProcessingPipeline.PixelSource
Sounds like you want something like this: