Genus and dimension of digital images and their time and space-efficient computation