ML Scenario Speedup: Make UnpackIntoRgbPlanes and PackFromRgbPlanes public APIs #2350
Unanswered
georg-jung
asked this question in
Ideas
Replies: 1 comment 1 reply
-
|
I'm not against exposing this functionality but we need to get the API right. The main reason why this is internal is the asymmetry between the pack and unpack methods: pack consumes byte buffers while unpack will produce float buffers. In this form it feels like an implementation detail of our Jpeg codec rather than a well-designed generic solution that can be made public. Doesn't this asymmetry limit you or force you to do pre/post conversions? Can you present some specific use-cases (best with sample code/pseudocode)? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
rel: #1955
rel: #1462
I think it would be great to make
PackFromRgbPlanesandUnpackIntoRgbPlanespublicly available.src/ImageSharp/PixelFormats/PixelOperations%7BTPixel%7D.cs/// <summary> /// Bulk operation that unpacks pixels from <paramref name="source"/> /// into 3 seperate RGB channels. The destination must have a padding of 3. /// </summary> /// <param name="redChannel">A <see cref="ReadOnlySpan{T}"/> to the red values.</param> /// <param name="greenChannel">A <see cref="ReadOnlySpan{T}"/> to the green values.</param> /// <param name="blueChannel">A <see cref="ReadOnlySpan{T}"/> to the blue values.</param> /// <param name="source">A <see cref="Span{T}"/> to the destination pixels.</param> - internal virtual void UnpackIntoRgbPlanes( + public virtual void UnpackIntoRgbPlanes( Span<float> redChannel, Span<float> greenChannel, Span<float> blueChannel, ReadOnlySpan<TPixel> source) {This way it would be easy to create efficient, vectorized code that transforms image data loaded using ImageSharp to arbitrary tensor formats for machine learning scenarios. The code to support this use case seems to already exist as far is I can tell, it simply is no
publicAPI but aninternalone.If I'm overlooking any well-suited public APIs please point me in the right direction :)
Beta Was this translation helpful? Give feedback.
All reactions