Converts a Planar16U image to a Planar8 image with dithering.


func vImageConvert_Planar16UtoPlanar8_dithered(_ src: UnsafePointer<vImage_Buffer>, _ dest: UnsafePointer<vImage_Buffer>, _ dither: Int32, _ flags: vImage_Flags) -> vImage_Error



A pointer to a vImage buffer structure that contains the source image whose data you want to convert.


A pointer to a vImage buffer data structure. You're responsible for filling out the height, width, and rowBytes fields of this structure, and for allocating a data buffer of the appropriate size. On return, the data buffer this structure points to contains the destination image data. When you no longer need the data buffer, you must deallocate the memory..


Type of dithering, if any, to apply to the image.


The options to use when performing the operation. If you plan to perform your own tiling or use multithreading, pass kvImageDoNotTile.

Return Value

kvImageNoError; otherwise, one of the error codes described in Data Types and Constants.


This function supports the following dithering options:


This option applies no dithering. Input values are rounded to the nearest value representable in the destination format.


Precomputed blue noise is added to the image before the values are rounded to the destination format. The offset into the blue noise is randomized per call to avoid visible artifacts if you do your own tiling or call the function on sequential frames of video.


Precomputed blue noise is added to the image before the values are rounded to the destination format. The offset into the blue noise is the same for every call to allow users to get reproducible results.


Floyd-Steinberg dithering is applied to the image.


Atkinson dithering is applied to the image.

You can further influence the ordered dither methods by shaping the noise distribution using the Gaussian and uniform options below. These options are OR-ed with kvImageConvert_DitherOrdered or kvImageConvert_DitherOrderedReproducible:


When using an ordered dither pattern, distribute the noise according to a Gaussian distribution. This generally gives more pleasing images—less noisy and perhaps a little more saturated—but color fidelity can suffer. Its effect is between kvImageConvert_DitherNone and kvImageConvert_DitherOrdered | kvImageConvert_DitherUniform. This option is the default for kvImageConvert_DitherOrdered and kvImageConvert_DitherOrderedReproducible.


When using an ordered dither pattern, distribute the noise uniformly. This generally gives the best color fidelity, but the resulting image is noisier and more obviously dithered. This is usually the best choice when low bit depth content is drawn next to high bit depth content and in other circumstances where subtle changes to color arising from the conversion could be easily noticed. It may be a poor choice when the image is likely to be enlarged—which would cause the noise to become more evident—and for very flat or synthetic content with little inherent noise. You can avoid the enlargement problem by enlarging first at high bit depth, then converting to lower bit depth.

See Also

Converting Between Planar Formats

func vImageConvert_PlanarFtoPlanar8(UnsafePointer<vImage_Buffer>, UnsafePointer<vImage_Buffer>, Pixel_F, Pixel_F, vImage_Flags) -> vImage_Error

Converts a PlanarF image to a Planar8 image, clipping values to the provided minimum and maximum values.