How can I isolate the capacitor in these images?

Question:

I’m having a lot of difficulty isolating these capacitors, yellow squares, in these images. The end goal would be to draw a minAreaRectangle around it and get the location and rotation. I can dim the brightness a bit but that’s the least desirable outcome as other inspections rely on that same level of brightness.

I’ve tried thresholding, color extraction, morphological processes, line detection, edge detection, shape detection but everything I’ve tried hasn’t been able to consistently get at the capacitors.

Capacitor 1:

1

Capacitor 2:

2

Capacitor 3:

3

Lower brightness Capacitor:

4

Asked By: Raptors

||

Answers:

I think you are too quick to exclude color thresholding and morphology to clean up in Python/OpenCV.

I get the following from color thresholding using cv2.inRange() for yellow color range.

Input:

enter image description here

lower = (100,200,200)
upper = (160,255,255)
result = cv2.inRange(input, lower, upper)

enter image description here

From that you should be able to use morphology to remove the partial ring and close up the white in the square

Answered By: fmw42
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.