When processing an image with text in OpenCV, my opening operation does not result in proper output data. The issue is quite similar to the one described in this article: ht
This answer arrives late, but here is the basic algorithm for under-reconstruction:
It's not the most optimal algorithm, but it uses only basic operations.