How to detect and highlight small PCB circuit trace

Hi, I am trying to highlight all circuit trace in a gray-scale PCB image(attached). I’d like to highlight only the traces but not the ground pad.

Can someone recommend some good approach?
Thank you,

can you do computed tomography instead of a plain x-ray? that would make things easier. the trouble here is that you see two copper layers and it’s impossible (in the general case) to tell which layer a trace belongs to.

Hi @crackwitz,

Yes, I can do computed tomography. Do you have any good approaches? I’m quite new to image processing, so I’m learning.

@crackwitz , I figure my pervious question was too general. Here is a specific question that I would like to ask.

I have my CT-scanned PCB file. My first preprocessing stage is to align the 2D stack of all slices (since PCB is CT-scanned with a slight tilt in both X and Y angle and this result in missing and/or aliased information in Z-axis projection).
What is the best approach to iterate through all slices and correct the alignment?

this is the 3D version of a problem that’s 2D for flatbed scans of text. when someone scans a piece of printed text, it might not be rotated upright, so this is a typical correction step for scanned text.

this here uses a fourier transform and finds the peaks, which correspond to the angle you might wanna rotate the entire thing so it’s axis-aligned. just look at the pictures and skim the description, you’ll get the idea. I’m not saying the script is directly applicable here. Fred's ImageMagick Scripts: TEXTDESKEW

or you could calculate a PCA. the eigenvectors belonging to the two largest eigenvalues span the plane that’s probably very close (in rotation) to the copper planes.

or you could assume that the PCB lies reasonably flat in the voxel data (at least not vertical), and then take a few vertical samples through the volume in various locations, which gives you the 3d locations of a few voxels of copper, through which you can fit a plane very cheaply. if you’re lucky, many of those samples cut through the board in locations where both copper planes actually have copper (not blank).

feel free to dump some data. npy files are convenient or anything raw or of a trivial format. I have no real experience with voxel data, or visualizing it, so I personally would approach it very ad-hoc (I know of hounsfield units at least). if you’re more familiar with voxel data, you’ll surely know better tools.

I can say that OpenCV is very much geared towards images/video, not voxel data. all the processing I can imagine, I’d do with numpy/scipy/scikit-image and such, because those are made for n-dimensional arrays.

1 Like

@crackwitz ,

Thank you very much for the suggestion! It is very helpful on my end. I have a good vision now.

Hi @crackwitz,

If I would like to highlight the trace connection from point A to point B when double-click at either point, Is there an existing algorithm to mask a ROI of the trace connection with the gray-value intensity difference. Something similar to loop from mouse-clicked pixel to all direction, check the intensity change, then mask the ROI that covers only the trace area?

I’d suggest one of:

  • thresholding to separate copper from no-copper, then connected components labeling
  • floodfill

related: