Function

vImageConvert_Planar16UtoPlanar8_dithered(_:_:_:_:)

Converts a Planar16U image to a Planar8 image with dithering.

Declaration

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

Parameters

src

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

dest

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..

dither

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

flags

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.

Discussion

This function supports the following dithering options:

kvImageConvert_DitherNone

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

kvImageConvert_DitherOrdered

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.

kvImageConvert_DitherOrderedReproducible

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.

kvImageConvert_DitherFloydSteinberg

Floyd-Steinberg dithering is applied to the image.

kvImageConvert_DitherAtkinson

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:

kvImageConvert_OrderedGaussianBlue

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.

kvImageConvert_OrderedUniformBlue

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.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software