july-2016
- Warning
- This document is very much work in progress and not of any current use other than for its author. It started as a database specific for lit spheres textures, but evolved to a more general database that UnityMol can interact with.
Goals and objectives
Implement a database to handle the large number of customizable settings in UnityMol such as color palettes and collected sphere textures for lit sphere artistic lighting of scenes.
The settings we want to be able to retrieve from within UnityMol are:
- color palettes
- hballs lit spheres textures
- hballs lit spheres texture sets
- surface textures
- skyboxes
This is a generalization of an initial database version only for lit sphere textures. These settings are to be stored and managed within the database, for instance to rank them, sort according to criteria (e.g. hue for textures),..
Among the functionalities we want to be able to..
- rank the textures and select by several filters (eg ranking + image size + ??)
- generate the relevant data (scripts, raw asset resources etc) for UnityMol automatically
Roadmap
- Todo:
umol: auto-generate snapshots for database
add table for color palettes
umol: retrieve color palettes from database
add table for surface textures
umol: retrieve surface textures from database
add table for skybox textures
umol: retrieve skybox textures from database
add table for hballs screenshot
add table for surface screenshot
add table for texture sets
umol: retrieve texture set from database
add table for comparisons and image similarity
add relationship between tables
generate custom database views with xataface
add thumbnails to database
cut out actual sphere for hue and gray determination so background doesn't factor in
move database to a publicly accessible server at the lab (eg ProxMox VM)
Emulate VMD, pymol, chimera, yasara looks and feel e.g, through color palettes and texture sets
Resources used
Key resources
Sphere repositories
Skybox repositories
Good search keywords (e.g. for Google image search) are: cylindrical projection / equirectangular panorama / skybox / cubemap
Other resources
Texture sets
To experiment
This is a collection of sphere texture ideas:
- plankton
- shaded sphere
- charcoal !
- pastel
- aquarelle
- soap bubbles
- goutte / drop
- cross-hatch
- hatching
- 101 dalmatiens
- ink
- ballon gonflable
- gems
- comic
- Schakal 97 sphere
(Automatic) generation of lit sphere textures with povray
Generated a Makefile from examples on the net to render a color set, currently based on the pastel colors in UnityMol, with povray. Example usage:
When textures/pigments/materials have many reflections, the scene ground, background and lights become very important.
- Todo:
- define relevant colors for palette, eg based on Pastel, Watercolor, etc. ; also relevant for Pixelmator method2
- Todo:
- find good sphere textures/pigments
- Todo:
- further tune Povray scene, in particular background, ground planes and lights
Manual generation of a texture set from an initial texture
Using Pixelmator method1
Image
> Remplacer la couleur
Couleur
> select dominant color from image with color picker
Etendue
> extend the color selection to a maximum (200
)
- turn colored wheel until appropriate color is obtained
- evtl. adjust
Saturation
and Luminosite
Using Pixelmator method2
- Open texture
- Evtl. treat the original image, such as desaturation of remaining color
- Create new layer:
Calque
> Nouveau Calque
- Fill layer with the desired color
- Choose mixing option, e.g.
Obscurcir
, Lummiere tamisee
, Couleur
, ..
- Save snapshot
Data preparation
- added textures currently within UnityMol
(OK)
- find duplicate filenames (
find_dupnmes.sh
) (OK)
- check we have only image files left (
find_non_image.sh
) (OK)
- generate uniform filenames
- remove spaces within filenames (
replace_spaces.sh
) (OK)
- remove quotes within filenames
(OK)
- remove special characters (parenthesis) within filenames (
replace_special.sh
) (OK)
- detect non-square textures and manually adjust them to be of equal dimensions
- run UnityMol in batch mode and generate a snapshot for a hyperballs molecule textured with the given sphere and for a surface textured with it
- sort/store according to filenames/directory names
- tool(s) to modify/update existing entries through scripts (eg update ranking based on directory)
Running a test PHP/MySQL environment
PHP/MySQL implementation
Check it out in the local environment from http://localhost:8888/lit-spheres-db/
I added a DB
feature to UnityMol so that textures can be fetched by their ID number from this database through the apercu.php
PHP page, from within the UnityMol application.
Gitlab git repository
Fields to include in the tables
- is_gray field!
- unique identifier/number
- user ranking (1 to 5 stars)
- image size
- lit sphere snapshot
- keywords (material, technique, ..)
- dominant color as in google image search
- Read support for EXIF (digital camera info) annotations
- Read support for IPTC annotations
- Read ICC color profiles?
- Color Histogram Viewable?
- Ability to set Highlight /Shadow Thresholds?
- toggles: hballs-proof, grayscale-proof, surface-proof, texture-series, in-unitymol
Make a separate table for small molecule snapshots
Make a separate table for surface snapshots
Make a separate scheme for inventorizing sphere series
Implementation details
Images table
Current fields:
Field | Type | Description |
img_id | int | unique identifier, primary key |
img_nom | varchar 50 | (file)name of the image |
img_dir | varchar 100 | directory where image resides |
img_taille | int | file size |
img_type | varchar 25 | what type of image? Eg JPG, PNG, .. |
img_desc | varchar 100 | short description of the image |
img_blob | medium blob | the actual image data |
img_pixels_x | int | image width in pixels |
img_pixels_y | int | image height in pixels |
img_rating | enum 1-5 | One to five star rating of the image |
img_avg_hue | int | Average hue of the image for sorting according to color |
img_avg_gray | float | Average gray value (saturation) to filter grayscale images, which should have a value very close or equal to zero |
Fields to add:
Field | Type | Description |
umol_legacy | bool | present in UnityMol? |
img_n_votes | int | number of votes received for this image |
img_avg_vote | float | continuously updated average vote for this image |
thumb_64 | blob | small thumbnail picture for this image |
thumb_256 | blob | bigger thumbnail |
Generate SQL tables
CREATE TABLE `images` (
`img_id` INT NOT NULL AUTO_INCREMENT ,
`img_nom` VARCHAR( 50 ) NOT NULL ,
`img_dir` VARCHAR( 100 ) NOT NULL ,
`img_taille` VARCHAR( 25 ) NOT NULL ,
`img_type` VARCHAR( 25 ) NOT NULL ,
`img_desc` VARCHAR( 100 ) NOT NULL ,
`img_blob` MEDIUMBLOB NOT NULL ,
PRIMARY KEY ( `img_id` )
)
CREATE TABLE `hball_snaps` (
`img_id` INT NOT NULL AUTO_INCREMENT ,
`litsph_ref` INT NOT NULL ,
`img_nom` VARCHAR( 50 ) NOT NULL ,
`img_dir` VARCHAR( 100 ) NOT NULL ,
`img_desc` VARCHAR( 100 ) NOT NULL ,
`img_blob` BLOB NOT NULL ,
PRIMARY KEY ( `img_id` )
)
CREATE TABLE `surf_snaps` (
`img_id` INT NOT NULL AUTO_INCREMENT ,
`litsph_ref` INT NOT NULL ,
`img_nom` VARCHAR( 50 ) NOT NULL ,
`img_dir` VARCHAR( 100 ) NOT NULL ,
`img_desc` VARCHAR( 100 ) NOT NULL ,
`img_blob` BLOB NOT NULL ,
PRIMARY KEY ( `img_id` )
)
Useful SQL snippets
$db = mysqli_connect("localhost","root","","DbName");
$sql = "SELECT * FROM products WHERE id = $id";
Show DDL statement:
1 show create table litspheres.images;
Database features
- import textures through a command-line php script ()
- generate input files (eg txt) for UnityMol
- be able to identify duplicates (not only exact but also approximate ones)
- detect toon-style textures
Views
- generata an html page with a 4 column and infinte row view of
- gen image on the texture
- texture image
- hballs with texture screenshot
- surface with texture screenshot
- be able to filter the above webpage, eg on image pixel size, ranking, hue etc.
Troubleshooting
- issues with ImageMagick.. install recent version (6.9+)
- get hue -> shell/php script cascade
- get grayscale `convert '$image_path' -colorspace HSL -channel g -separate +channel -format '%[fx:mean]' info:`
Inspiration
$imagick = new Imagick($image_path);
$imagick->transformImageColorspace(imagick::COLORSPACE_HSL);
$saturation_channel = $imagick->getImageChannelMean(imagick::CHANNEL_GREEN);
$saturation_level = $saturation_channel['mean']/65535;