added threshold and histogram