Calculate position at maximum and at minimum in case of having a dynamic stack of images.