from typing import Iterable
from pathlib import Path


def list_images(img_dir) -> Iterable[str]:
    """List all image files in img_dir.

    Returns an iterator that lists the files to process. Subclasses may want to override this to return specific
    image types or filter the results. By default, will list all images in self.img_dir if the file extension is in
    the extensions list.

    Returns
    -------
    Iterable[str]
        The list of files to be used for generating the masks.
    """
    extensions = (".png", ".jpg", ".jpeg", ".tif", ".tiff")

    paths = Path(img_dir).glob("**/*")
    paths = filter(lambda p: p.is_file() and p.suffix.lower() in extensions, paths)
    return (str(p) for p in paths)