eXtended Image (ximage)

The eXtended image (ximage) is Aliquis’ format to store and handle metadata informations inside image files like JPEGs or PNGs.

It is based on XMP ISO standard, an evolution of Exif, that allows to inject XML structures inside image files.

Aliquis use its own namespace (http://bioretics.com/aliquis) to define the schema of metadata handled.

Metadata inside a ximage are composed of:

  • acquisition: a set of properties related to the acquision process. E.g: date, progressive shot id, dataset name, …
  • setup: a set of properties related to the acquisition setup. E.g: camera parameters, lights configuration, …
  • classes: an array of name-color pairs, describing what kind objects are described in the annotations
  • items: a set of objects present on the scene, identified by an UUID and represented by a hierarchy of blobs, that are contours of parts of the item with an associated array of values

ximage is available in Aliquis with its own implemantation and with the command-line tool aliquispl_ximage useful to manage single ximages and databases of ximages. The tools is composed of several commands, available running aliquispl_ximage <command>:

extract and inject

extract reads XML of a ximage and save it to a file. injects performs the opposite operation, reading an .xml file and writing its content inside an image to convert it to a ximage. This operation is usually useful to prepare a large set of images with the same base metadata, e.g. to inject acquisition, setup and classes properties to a set of images acquired in the same aquisition.

export and import

These commands manage the conversion of ximage’s items to an from an indexmask. In fact, with export it’s possible to generate a indexmask (grayscale image where each gray level corresponds to a index or class) from a ximage, whereas import searches for contours in an indexmask and save them as items and blobs in a ximage. These tools are useful when there is the need to convert an old dataset of image/indexmask pairs to ximage format or, conversely, to create sibling indexmasks for tools that don’t support ximage format.

update, uuid and view

update command inject new metadata in an image that is already a ximage. By default, it will not overwrite or delete other informations, so that the user can update only specific metadata.

uuid permits to set or get all items’ UUID of a ximage.

view display items and blobs in a graphical interface, by drawing contours of blobs whose color is defined by the respective class.

index and query

With these tools it’s possibile to manage a large database of annotate ximage.

index command reads all images inside a folder and for each ximage it saves metadata to a sqlite database, effectively indexing the whole folder.

query allows to search in the metadata indexed in the database, and print out path of ximages that reflects required features.

Example of database creation and querying

Suppose we have a folder ~/imgs of annotated ximages of cats and dogs.

We can index the folder and create a database with:

cd ~/imgs
aliquispl_ximage index .

When the command finish, we can search for images that contains a cat with:

aliquispl_ximage query 'count(item.cat)>0'

This will result in a list of all images paths that contains at least a cat in their annotation. Let’s say we want images were there are both cats and dogs:

aliquispl_ximage query 'count(item.cat)>0 and count(item.dog)>0'

If instead we want images were there are at least 2 dogs:

aliquispl_ximage query 'count(item.dog)>=2'

The list of paths can than be used as an input for another program, for example to a SOURCE_IMAGE stage as a text file.