Hi,
an easy trick to remove closed borders it to fill the outside area with the border color and then with the opposite one. See the attached example.
For image 2 it is more complex. You can crop a little the image to remove the external borders and paint a rectangle over the middle line if the location is approximately fixed.
Otherwise use morphological transformations to merge the number into blobs:
dilate to join the letters and later erode to delete the lines (or the opposite depending if the background if black or white).
Now do component analysis to find the remaining blobs and crop those regions from the original image with some margin.
Now you have the numbers but I do not know a simple reliable way to fill them. Maybe tesseract is able to read them. Otherwise I would try to do a little dilate, to make them thicker, it might help.
Bye
Lorenzo