Texture.to_grayscale

Texture.to_grayscale#

Texture.to_grayscale() Texture[source]#

Convert this texture as a single component (grayscale) texture.

Returns:
pyvista.Texture

Texture converted to grayscale. If already grayscale, the original texture itself is returned.

Notes#

The transparency channel (if available) will be dropped.

Follows the CCIR 601 luma calculation equation of Y = 0.299*R + 0.587*G + 0.114*B.

Examples#

Download Python source code | Download Jupyter notebook

>>> from pyvista import examples
>>> texture = examples.download_masonry_texture()
>>> bw_texture = texture.to_grayscale()
>>> bw_texture
Texture (...)
  Components:   1
  Cube Map:     False
  Dimensions:   256, 256
>>> bw_texture.plot()
../../../_images/pyvista-Texture-to_grayscale-fa3404c43387a4f0_00_00.png