Introduced explicit template parameter for output dimension.

This is useful eg. for intensity transforms where the output dimension is not always the same as the input dimension.