Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
Toggle table of contents sidebar

# FaceAnalyser.applyMask Method

Module: FaceAnalyser

## Definition

Applies a mask to replace the background with the specified color and returns a 24-bit BGR image.

Python

    apply_mask(self, image: Image, mask: Image, red: int, green: int, blue: int) -> Image

Parameters

> `image` Image
> in Source image to process.
> `mask` Image
> in Mask to be applied. Must be a 8-bit greyscale image of same size as the input image.
> `red` int
> in Green channel of the background color. Must be a value from 0 to 255.
> `green` int
> in Red channel of the background color. Must be a value from 0 to 255.
> `blue` int
> in Blue channel of the background color. Must be a value from 0 to 255.

Returns

> Image
> The output image.

Exceptions

> FaceException
> An error has occurred during Face Library execution.

Dart

    Image applyMask(Image image, Image mask, int red, int green, int blue)

Parameters

> `image` Image
> in Source image to process.
> `mask` Image
> in Mask to be applied. Must be a 8-bit greyscale image of same size as the input image.
> `red` int
> in Green channel of the background color. Must be a value from 0 to 255.
> `green` int
> in Red channel of the background color. Must be a value from 0 to 255.
> `blue` int
> in Blue channel of the background color. Must be a value from 0 to 255.

Returns

> Image
> The output image.

Exceptions

> FaceException
> An error has occurred during Face Library execution.

C#

    public Image ApplyMask(Image image, Image mask, int red, int green, int blue)

Parameters

> `image` Image
> in Source image to process.
> `mask` Image
> in Mask to be applied. Must be a 8-bit greyscale image of same size as the input image.
> `red` int
> in Green channel of the background color. Must be a value from 0 to 255.
> `green` int
> in Red channel of the background color. Must be a value from 0 to 255.
> `blue` int
> in Blue channel of the background color. Must be a value from 0 to 255.

Returns

> Image
> The output image.

Exceptions

> FaceException
> An error has occurred during Face Library execution.

Java

    public Image applyMask(Image image, Image mask, int red, int green, int blue) throws FaceException

Parameters

> `image` Image
> in Source image to process.
> `mask` Image
> in Mask to be applied. Must be a 8-bit greyscale image of same size as the input image.
> `red` int
> in Green channel of the background color. Must be a value from 0 to 255.
> `green` int
> in Red channel of the background color. Must be a value from 0 to 255.
> `blue` int
> in Blue channel of the background color. Must be a value from 0 to 255.

Returns

> Image
> The output image.

Exceptions

> FaceException
> An error has occurred during Face Library execution.

Swift

    public func applyMask(image: Image, mask: Image, red: Int32, green: Int32, blue: Int32) throws -> Image

Parameters

> `image` Image
> in Source image to process.
> `mask` Image
> in Mask to be applied. Must be a 8-bit greyscale image of same size as the input image.
> `red` Int32
> in Green channel of the background color. Must be a value from 0 to 255.
> `green` Int32
> in Red channel of the background color. Must be a value from 0 to 255.
> `blue` Int32
> in Blue channel of the background color. Must be a value from 0 to 255.

Returns

> Image
> The output image.

Exceptions

> FaceException
> An error has occurred during Face Library execution.

C

    int id3FaceAnalyser_ApplyMask (
        ID3_FACE_ANALYSER hFaceAnalyser,
        ID3_FACE_IMAGE hImage,
        ID3_FACE_IMAGE hMask,
        int red,
        int green,
        int blue,
        ID3_FACE_IMAGE hSegmentedFace)

Parameters

> `hFaceAnalyser` ID3_FACE_ANALYSER
> in Handle to the FaceAnalyser object.
> `hImage` ID3_FACE_IMAGE
> in Source image to process.
> `hMask` ID3_FACE_IMAGE
> in Mask to be applied. Must be a 8-bit greyscale image of same size as the input image.
> `red` int
> in Green channel of the background color. Must be a value from 0 to 255.
> `green` int
> in Red channel of the background color. Must be a value from 0 to 255.
> `blue` int
> in Blue channel of the background color. Must be a value from 0 to 255.
> `hSegmentedFace` ID3_FACE_IMAGE
> out The output image.

Returns

> `int`
> An error code.
> See id3FaceError file for the list of possible error codes.