Enhance pattern in image


I would like to alter/filter this image so that the lines from the pattern would be a lot more visible.

Ideally the result would look like a black background with (thick) white lines.

I’ve tried canny, sobel, denoising, opening, closing, erosion, dilation, blurring, … and various combinations. But no luck. Can someone please give me some advice on this.

The Hough transform makes the assumption that there are straight lines, which is fin in this picture. However, I want a more general solution. For instance squiggly lines.

Thanks in advance.

Kind regards,


Interesting problem. Might you be able to generate an image that is more uniform in focus and more evenly lit? With that, some combo of what you have tried might work. I would add contrast enhancement to your list of things to try and then see if you can quant down to something like 2 or 3 color values. With a more uniform image erode/dilate ought to get you what you want. In particular, the upper left corner is relatively out of focus and the lower left corner is considerably darker. This causes you to have first try rectifying those issues before you even get to your primary question. Good luck.

none of those will work, especially not Canny or Hough. those are newbie traps anyway. “denoising” is a goal, not an operation. blurring is one way to “denoise”. a blur alone won’t solve this though.

you need a bandpass filter. that would be a difference of gaussians (one gaussian may be the untouched source too), or any of the “adaptive” thresholding provided by OpenCV.

lowpass (sigma 20):

difference of gaussians (0.5 added):

stretched contrast:

now, what’s the goal of your goal? why are you “digging a hole”?

Thank you for your reply.

What I want, is to find that anomaly: the missing vertical line in the middle.

But this should work too for patterns that are not composed of straight lines.

Ideally, it would look like this synthetic image:

Then I can fit some sort of periodic regression on it and look at the difference for the location of the anomaly. Which works for this synthetic image.

Thank you.

I did try “autolevel” histogram correction. But no luck. Your advice makes me want to try this one more time though.

you are talking of automated optical inspection. a snapshot taken any which way won’t cut it.

I suspect a solution is worth money or a thesis so I’ll leave it at that. just a few days ago I saw someone get a bachelor’s from half a semester’s worth of one course’s homework assignments.