Relation among images: Modelling, optimization and applications