-1

Here is the link (https://imgplay.zendesk.com/hc/en-us/articles/360029411991-What-is-GIF-Dithering-Option-) where it says When you save the file as GIF with dithering, it can make your GIF more natural.

How to implement Dithering for creating more natural GIF from UIImages or video frames using Objective-C or Swift?

sagarthecoder
  • 137
  • 1
  • 9

1 Answers1

0

Assuming your source image is 8-bit per channel RGB, you could use vImage. vImage doesn't have a vImageConvert_RGB88toIndexed8, but you can split your interleaved image into three 8-bit planar buffers for RGB. I don't know exactly how well this would work, but you could convert two of the three channels to Indexed2 with vImageConvert_Planar8toIndexed2 and the other channel to Indexed4 with vImageConvert_Planar8toIndexed4. That would give you the required 8-bit lookup table.

Apple have loads of Accelerate sample code projects here. Optimising Image-Processing Performance discusses converting interleaved images to planar format. If you have a known palette, Applying Color Transforms to Images with a Multidimensional Lookup Table may be a solution to quantising your image to 256 colors.

Flex Monkey
  • 3,583
  • 17
  • 19
  • I'm new to viImage. Even I didn't do anything with vImage. can you show an example? How to split image into 3 bit planner buffers and how to play with other functions that you provided? Thanks for your time and valuable references. @simon-gladman – sagarthecoder Jul 30 '21 at 17:58
  • 1
    Hi @sagarthecoder, I've added links to Apple docs to my answer. – Flex Monkey Aug 01 '21 at 07:59
  • ```vImageConvert_Planar8toIndexed2(argbSourcePlanarBuffers[1], argbDestinationPlanarBuffers[1], kvImageGetTempBufferSize, lookUpTable, kvImageConvert_DitherFloydSteinberg, kvImageNoFlags)``` it always shows ```Type of expression is ambiguous without more context``` – sagarthecoder Aug 02 '21 at 09:33
  • You'll need to add some more information - what types are your parameters? Have you looked at the docs (https://developer.apple.com/documentation/accelerate/1533017-vimageconvert_planar8toindexed2)? – Flex Monkey Aug 02 '21 at 16:33
  • ...you might want to raise a new post tagged [vimage]. – Flex Monkey Aug 02 '21 at 16:50