2

I have about 500 pages of PNGs representing a schematic for an early 1980s era DIGITAL DECsystem-20 KL10PV mainframe (publicly available). The scanning process was flawed in that randomly interspersed in the PNGs are white lines that represent systematic "salt" in the drawing. This is interfering with the process I'm using to recover the schematic - both the OCR and the recovery of the netlist of the components and interconnections.

A zoomed in part of a schematic page

A full schematic page with red marks around an example area showing the problem I'm talking about is here.

What magical OpenCV mechanism can I use to detect these white strips and "heal" them by copying the average of the row above and the row below, or similar? I expect to try several "healing" techniques to find the best one once I find a mechanism to identify these flaws systematically.

1 Answer 1

1

You mean like this?

enter image description here

This particular method uses bluring and morphology to process the image. I borrowed the code from here

    int morph_elem = 1;
    int morph_size = 1;
    int morph_operator = 0;

    Mat origImage = mat;
    medianBlur(origImage, origImage,1);
    cvtColor(origImage, origImage, COLOR_RGB2GRAY);
    threshold(origImage, origImage, 0, 255, THRESH_OTSU);

    Mat element = getStructuringElement(morph_elem, Size(2 * morph_size + 1, 2 * morph_size + 1), cv::Point(morph_size, morph_size));

    morphologyEx(origImage, origImage, MORPH_OPEN, element);
    //thin(origImage, true, true, true);
    imshow("@", origImage);

I'm afraid I don't really have the enthusiasm to write up many different ways, this isn't really what Stack Overflow is for. This suggested way may get you on the correct path though.

4
  • Yes, that's just the sort of result I'm looking for. Thanks for the pointers.
    – Alan Mimms
    Oct 28, 2017 at 22:59
  • One more point, though. If this isn't really what Stack Overflow is for, what is it for? I asked an algorithmic question and got a pointer to an answer. Isn't that what people do here every day?
    – Alan Mimms
    Oct 28, 2017 at 23:00
  • 1
    The issue is your question is very broad, it could be solved by many different solutions, even my answer only partially solves the problem. SO is really aimed at "I have this specific problem, heres what i tried and the errors I am getting, please help me solve it." For instance if you had asked for some specific help on morpholy code that would be a better fit. I would suggest reading the help guide, or if still unsure ask on Meta.stackexchange.com
    – GPPK
    Oct 29, 2017 at 10:57
  • Thanks for the guidance. I'll try to make my questions more specific in future.
    – Alan Mimms
    Oct 29, 2017 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.