modified show_shape to discard the white border
optimization parameter tweaks