Adding threshold filter on contour matrix