import_image

menpo.io.import_image(filepath, landmark_resolver=<function same_name>, normalise=True)[source]

Single image (and associated landmarks) importer.

If an image file is found at filepath, returns an Image or subclass representing it. By default, landmark files sharing the same filename stem will be imported and attached with a group name based on the extension of the landmark file, although this behavior can be customised (see landmark_resolver). If the image defines a mask, this mask will be imported.

Parameters:
  • filepath (pathlib.Path or str) – A relative or absolute filepath to an image file.
  • landmark_resolver (function, optional) – This function will be used to find landmarks for the image. The function should take one argument (the image itself) and return a dictionary of the form {'group_name': 'landmark_filepath'} Default finds landmarks with the same name as the image file.
  • normalise (bool, optional) – If True, normalise the image pixels between 0 and 1 and convert to floating point. If false, the native datatype of the image will be maintained (commonly uint8). Note that in general Menpo assumes Image instances contain floating point data - if you disable this flag you will have to manually convert the images you import to floating point before doing most Menpo operations. This however can be useful to save on memory usage if you only wish to view or crop images.
Returns:

images (Image or list of) – An instantiated Image or subclass thereof or a list of images.