I am trying to segment a QFN package on the xray image of the PCB image. The general description of QNF package is that square or rectangule in the centre with the rectangular pins on the edge. The example is on this image: https://goo(dot)gl/photos/LSVcXwA2e3yPh8gj9
I can segment the rectangles on the xray image quite good but (see this image https://goo(dot)gl/photos/vSdD43ZjekF7mnxbA
I dont know how to write the condition to segment only the QFN package. The package can be square or rectangle and can have different number of pins on the edge. Do you have any idea?