I’m at the moment computing histogram, waveform, and vectoroscope utilizing Speed up and Metallic shaders. This code is for 8-bit SDR pixel buffers and it really works. I need to rewrite them utilizing Core Picture in order that they will work for each 10-bit HDR & SDR buffers.
Speed up works very nicely for histogram for 8-bit photographs. Nevertheless it doesn’t assist 10bit YCbCr pixel buffers. CoreImage helps it however it’s unclear how one can seize uncooked histogram knowledge from the
CIAreaHistogramoutput in order to show it utilizing CoreGraphics or MTKView. The builtin histogram
CIHistogramDisplayFilterto show histogram has much less flexibility. I additionally need histogram of luminance as nicely aside from rgb.
atomic_fetch_add_explicitin Metallic shaders to compute statistics akin to Waveform and vectoroscope. It appears Metallic core picture kernels haven’t any assist for atomics. Is there any approach to do the identical in CoreImage?
For the histogram, I believe you may have two choices:
- You may write your individual histogram visualization kernel, much like what
CIHistogramDisplayFilterdoes. You might go it an RGB and a luminance histogram and visualize them to your liking.
- You calculate the histograms (e.g., with
CIAreaHistogram) and render the consequence right into a bitmap buffer. You may then learn the bin values from that buffer and visualize them customized UI elements, e.g., utilizing SwiftUI. In our CoreImageExtensions library on Github we even have some comfort APIs for studying values from a
CIImagethat may ease this course of.
In regards to the atomics: If you have already got a working Metallic implementation for these statistics, I might advocate you write a
CIImageProcessorKernel round it. It is made for this actual objective: together with customized picture processors right into a Core Picture pipeline. Particularly working with Metallic may be very handy, as you already get a Metallic gadget, textures, and a command buffer to work with.