.. index:: 
  !FaceAnalyser.applyMask Method
  
.. _id3_face_face_analyser_apply_mask_class_method:

===============================================================================
FaceAnalyser.applyMask Method
===============================================================================

Module: :ref:`FaceAnalyser<id3_face_face_analyser_class>`

Definition
----------

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


.. tab-set::

    .. tab-item:: Python
      :sync: Python

      .. code:: Python

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

      **Parameters**

        .. line-block::

          ``image`` :ref:`Image<id3_face_image_class>`
          :guilabel:`in` Source image to process.

          ``mask`` :ref:`Image<id3_face_image_class>`
          :guilabel:`in` Mask to be applied. Must be a 8-bit greyscale image of same size as the input image.

          ``red`` int
          :guilabel:`in` Green channel of the background color. Must be a value from 0 to 255.

          ``green`` int
          :guilabel:`in` Red channel of the background color. Must be a value from 0 to 255.

          ``blue`` int
          :guilabel:`in` Blue channel of the background color. Must be a value from 0 to 255.


      **Returns**

        .. line-block::

          :ref:`Image<id3_face_image_class>`
          The output image.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


    .. tab-item:: Dart
      :sync: Dart

      .. code:: Dart

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

      **Parameters**

        .. line-block::

          ``image`` :ref:`Image<id3_face_image_class>`
          :guilabel:`in` Source image to process.

          ``mask`` :ref:`Image<id3_face_image_class>`
          :guilabel:`in` Mask to be applied. Must be a 8-bit greyscale image of same size as the input image.

          ``red`` int
          :guilabel:`in` Green channel of the background color. Must be a value from 0 to 255.

          ``green`` int
          :guilabel:`in` Red channel of the background color. Must be a value from 0 to 255.

          ``blue`` int
          :guilabel:`in` Blue channel of the background color. Must be a value from 0 to 255.


      **Returns**

        .. line-block::

          :ref:`Image<id3_face_image_class>`
          The output image.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


    .. tab-item:: C#
      :sync: C#

      .. code:: C#

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

      **Parameters**

        .. line-block::

          ``image`` :ref:`Image<id3_face_image_class>`
          :guilabel:`in` Source image to process.

          ``mask`` :ref:`Image<id3_face_image_class>`
          :guilabel:`in` Mask to be applied. Must be a 8-bit greyscale image of same size as the input image.

          ``red`` int
          :guilabel:`in` Green channel of the background color. Must be a value from 0 to 255.

          ``green`` int
          :guilabel:`in` Red channel of the background color. Must be a value from 0 to 255.

          ``blue`` int
          :guilabel:`in` Blue channel of the background color. Must be a value from 0 to 255.


      **Returns**

        .. line-block::

          :ref:`Image<id3_face_image_class>`
          The output image.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


    .. tab-item:: Java
      :sync: Java

      .. code:: Java

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

      **Parameters**

        .. line-block::

          ``image`` :ref:`Image<id3_face_image_class>`
          :guilabel:`in` Source image to process.

          ``mask`` :ref:`Image<id3_face_image_class>`
          :guilabel:`in` Mask to be applied. Must be a 8-bit greyscale image of same size as the input image.

          ``red`` int
          :guilabel:`in` Green channel of the background color. Must be a value from 0 to 255.

          ``green`` int
          :guilabel:`in` Red channel of the background color. Must be a value from 0 to 255.

          ``blue`` int
          :guilabel:`in` Blue channel of the background color. Must be a value from 0 to 255.


      **Returns**

        .. line-block::

          :ref:`Image<id3_face_image_class>`
          The output image.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


    .. tab-item:: Swift
      :sync: Swift

      .. code:: Swift

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

      **Parameters**

        .. line-block::

          ``image`` :ref:`Image<id3_face_image_class>`
          :guilabel:`in` Source image to process.

          ``mask`` :ref:`Image<id3_face_image_class>`
          :guilabel:`in` Mask to be applied. Must be a 8-bit greyscale image of same size as the input image.

          ``red`` Int32
          :guilabel:`in` Green channel of the background color. Must be a value from 0 to 255.

          ``green`` Int32
          :guilabel:`in` Red channel of the background color. Must be a value from 0 to 255.

          ``blue`` Int32
          :guilabel:`in` Blue channel of the background color. Must be a value from 0 to 255.


      **Returns**

        .. line-block::

          :ref:`Image<id3_face_image_class>`
          The output image.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


    .. tab-item:: C
      :sync: C

      .. code:: 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**

        .. line-block::

          ``hFaceAnalyser`` :ref:`ID3_FACE_ANALYSER<id3_face_face_analyser_class>`
          :guilabel:`in` Handle to the FaceAnalyser object.

          ``hImage`` :ref:`ID3_FACE_IMAGE<id3_face_image_class>`
          :guilabel:`in` Source image to process.

          ``hMask`` :ref:`ID3_FACE_IMAGE<id3_face_image_class>`
          :guilabel:`in` Mask to be applied. Must be a 8-bit greyscale image of same size as the input image.

          ``red`` int
          :guilabel:`in` Green channel of the background color. Must be a value from 0 to 255.

          ``green`` int
          :guilabel:`in` Red channel of the background color. Must be a value from 0 to 255.

          ``blue`` int
          :guilabel:`in` Blue channel of the background color. Must be a value from 0 to 255.

          ``hSegmentedFace`` :ref:`ID3_FACE_IMAGE<id3_face_image_class>`
          :guilabel:`out` The output image.


      **Returns**

        .. line-block::

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


