In [CITE], Kronrod proves that the connected components of isolevelsets of a continuous function can be endowed with a treestructure. Obviously, the connected components of upper level sets are aninclusion tree, and the same is true for connected components of lower levelsets. We prove that in the case of semicontinuous functions, those trees canbe merged into a single one, which, following its use in image processing, wecall “tree of shapes”. This permits us to solve a classical representationproblem in mathematical morphology: to represent an image in such a way thatmaxima and minima can be computationally dealt with simultaneously. We provethe finiteness of the tree when the image is the result of applying anyextrema killer (a classical denoising filter in image processing). The shapetree also yields an easy mathematical definition of adaptive imagequantization.