We propose an adaptive procedure for segmenting images by merging of homogeneous regions. The algorithm is based on sharp concentration inequalities and is tailored to avoid over- and under-merging by controlling simultaneously the type I and II errors in the associated statistical testing problem.