See the picture. I'm trying to process this map drawing to be in a workable state where the drawing is black and everything else is white for further processing, but I drew the map on grid paper before deciding to do all that.
The lines are lightly blue, so I expected I could exploit that to remove it. So far I tried the following:
- Picking a blue pixel belonging to the grid and remove (turn white) all pixels whose color is within some distance (euclidean, from LAB color space) of that pixel. -> This doesn't work because the colors on the grid change too much throughout the drawing: depending on which grid pixel I pick and the tolerance I use, some of the drawing gets picked up, or part of the grid remains.
- Doing the same thing, but making it dynamic and making comparisons based on neighbouring pixels that have been "recognized" as part of the grid. This was attempting to counter subtle gradual changes in lighting. This doesn't work either, and somehow it ends up picking the entire white part of the drawing (not an issue because that should also go white, but still evidence that the idea as I implemented it doesn't follow my intuition). Depending on tolerance, here again some grid remain or part of the drawing goes away. It also fails to capture parts of the grid that are disconnected from the rest by the pencil drawing forming closed loops that don't get pierced through.
- A few other unsuccessful variations like instead of picking a single "initial" pixel, picking all pixels within some delta of that one pixel and then using them as starting points for doing the dynamic approach.
I can keep throwing random ideas at the wall but I'm kinda stumped and every attempt now somehow seems to get me further away. I'm interested in managing to do it algorithmically such that I could easily apply the same algorithms to process another drawing the same way. Otherwise I could just take the loss and manually process it and remove the grid from a black and white mask after some thresholding.
Note that I'm an outsider to this, so I'm not familiar with advanced techniques; if you suggest something, I'll look it up to the best of my abilities, but I might be stumbling around a bit. I'm working on Python so far, with OpenCV.


