Abstract : To compute the morphological self-dual representation of images, namely the tree of shapes, the state-of-the-art algorithms do not have a satisfactory time complexity. Furthermore the proposed algorithms are only effective for 2D images and they are far from being simple to implement. That is really penalizing since a self-dual representation of images is a structure that gives rise to many powerful operators and applications, and that could be very useful for 3D images. In this paper we propose a simple-to-write algorithm to compute the tree of shapes; it works for \nD images and has a quasi-linear complexity when data quantization is low, typically 12~bits or less. To get that result, this paper introduces a novel representation of images that has some amazing properties of continuity, while remaining discrete.