# Examples from pyvista.ImageDataFilters.close
# ============================================

# Load a binary image: `download_yinyang()`.
from pyvista import examples
im = examples.download_yinyang()

# Use `close` with a relatively small kernel to fill the top black edge of the yinyang.
closed = im.close(kernel_size=5)
kwargs = dict(
    cmap='grey',
    lighting=False,
    cpos='xy',
    zoom='tight',
    show_axes=False,
    show_scalar_bar=False,
)
closed.plot(**kwargs)

# Use a much larger kernel to also fill the small black circle.
closed = im.close(kernel_size=25)
closed.plot(**kwargs)

# Since closing is the inverse of opening, we can alternatively use `open()` to
# fill the white foreground values instead of the black background.
opened = im.open(kernel_size=25)
opened.plot(**kwargs)

# ----------------------------------------------------------------------
# Generated by sphinx-examples-as-code https://github.com/pyvista/sphinx-examples-as-code
