improving pre-processing (noise removal) orange seven segment display for OCR reading
The shapes you are interested in are very regular while the noise you are trying to deal with will be less regular. Ideally, you will only have two shapes at the end of your processing: wide rectangles for the horizontal parts of the display and tall rectangles for the vertical parts. You can leverage this fact in how you shape your structuring element when you use opening to remove noise.

This code is for Matlab (or Octave, its free cousin), but should easy to implement in Python. Note that I screen grabbed the image from your GitLab file and resized it - so these dimensions likely won't match yours exactly. I also inverted the image so the foreground is white. Also, the images below were resized to 400% before posting.

pkg load image
img = imread("download.png");
img = img * 255;
imshow(img)




First, use a wide structuring element for opening so only wide rectangles are kept.

SE_h = strel('rectangle',[1,8]);
h_lines = imerode(img, SE_h);
h_lines_reconstructed = imdilate(h_lines, SE_h);
imshow(h_lines_reconstructed)




The repeat for tall rectangles:

SE_v = strel('rectangle',[8,1]);
v_lines = imerode(img, SE_v);
v_lines_reconstructed = imdilate(v_lines, SE_v);
imshow(v_lines_reconstructed)




Recombine and display:

combined = or(v_lines_reconstructed, h_lines_reconstructed);
imshow(combined);