Using 3D spatial relationships for image retrieval by contents