Filtration after Canny Edge Detection

Hi everyone,

In the image above, I want to detect some portion of the image after I apply Canny Edge Detection. Anyone can advise on how to detect that portion.

Thank you in advance. :slight_smile:

first, discard Canny. forget it even exists.

what do we see? show us the original unfiltered uncropped untouched image

what is the goal?

I want to detect some cosmetic NG with image processing.

Picture above are the uncropped image and I already did some detection, but the tuning parameter is quite hard.

Can you advise the technique that is more robust?


I don’t hate Canny as much as Crackwitz does, but I do think you should do some pre-processing before you do any edge detection. You are trying to detect features/defects that are medium scale, but your image has a lot of high frequency information due to (I presume) the interaction of the lighting and the textured plastic. Edge detectors are going to go nuts with all the speckle, so you probably want to reduce that early in the pipeline. I’d try a (small radius) gaussian blur or median filter. There is also a lot of structure in the image - if it’s consistent, you could exploit that. I’d consider detecting the lines and processing them to determine where the textured areas are so you can exclude them to avoid false positives. If you do that you might be able to come up with a pretty reliable detection scheme for this image - if all of your images look like this, that might be good enough, but you risk overfitting your algorithm and ending up with something that’s pretty brittle.

Maybe provide a little more information about what you are trying to achieve, along with other sample images.

Can you control the lighting? Are all input images similar, or are there different types of things being inspected? etc.

1 Like

once you make a picture, “the dice are cast” and no amount of “fix it in post” will fix it.

those faint cosmetic defects should be approached with specific lighting that enhances them, so they’re more visible than they are in that picture.

experiment with the differing reflection caused by those detects.

you might need a “point” light or a line/bar/strip/tube light.

if you must work with that picture: if you can assume that those defects only appear on the ridges, you could mask out (digitally) the flat textured surface… that requires some model of the pattern, and locating it in the picture.

Hi All,

Thanks for the explanation and input.

The problem here is, our operator keep escapee on this NG. I would like to introduce simple computer vision to my team to detect this NG.

In future, we will make fixing jig and light for this issue, so less variation result will get.

Any additional point to add?

Thanks you.

again, avoid canny, it’s producing ‘double’ lines & a lot of noise, also blur a bit before thresholding.

if you can make the ridges more horizontal / parallel & straight (no perspective),
you can use reduce()to get a spatial histogram (projection on the x-axis) to detect, if there are defects on the black ridges

Thanks sir for the enlightenment, will update here if have any concern.


1 Like