Contouring based on region merging adopted.
New contouring algorithm included.