Relational databases are not specially good for storing information that you would say "have very variable structure".
A fully normalized structure would probably represent an image of your kind with two tables:
- one for
- and another for
non_background_pixels_of_pictures (picture_id, x, y, color).
But this would probably be terribly space consuming and inconvenient for image processing. It all depends on which kind of "queries" you would be performing, and which tools you'd be using.
Alternatives (based on PostgreSQL):
- Store a reference to a standard image file (the path of the file). If this is done for "scientific" purposes, I guess you want a lossless storage format. This will allow to use very many libraries or programs that work directly with standard image formats (TIFF, JPEG, PNG, ...).
- Store the standard image data format as binary data (a "blob", using the
bytea type in PostgreSQL, for instance; or the Large Objects Facility).
- Use some specific types or extensions for images.
For instance, with certain versions of PostgreSQL, you can use:
PostPic is an extension for the open source PostgreSQL dbms that enables image processing inside the database, like PostGIS does for spatial data. It adds the new 'image' type to the SQL, and several functions to process images and to extract their attributes.
[...] To facilitate the development of new CBIR systems, we propose an image-handling extension to the relational database management system (RDBMS) PostgreSQL. This extension, called PostgreSQL-IE, is independent of the application and provides the advantage of being open source and portable. The proposed system extends the functionalities of the structured query language SQL with new functions that are able to create new feature extraction procedures, new feature vectors as combinations of previously defined features, and new access methods, as well as to compose similarity queries. PostgreSQL-IE makes available a new image data type, which permits the association of various images with a given unique image attribute.
NOTE: this seems to have been a doctoral thesis or some other research program... from 2006. Check also their download page.
c. pg_image, A bitmap image datatype for JPEG and PNG images.
This extension provides an IMAGE datatype for the storage of bitmap images, which verifies that the image data is in a recognized format (PNG or JPEG) and provides accessor functions for the image metadata (format, width, height) as well as the image data itself.
Planned features include conversion between formats, cropping and scaling, annotating with text, and compositing of multiple images.
Depends on the GD library for image loading and manipulation.
Compatible with PostgreSQL 9.2 and 9.3beta2.
NOTE: Looks like it's not being maintained.