Pairwise object analysis

Sometimes it is useful to be able to create all pairs from given objects and take only some of them. In this example, distances of the nearest holes (with the same diameter) are measured, put into histogram and color coded in the image based on their length.

Join creates a Cartesian product of equal rows. Leaving the relation empty makes NxN rows from original N. We have to duplicate the β€œCenterPxX”, β€œCenterPxY” and β€œObjectId” to have them coming from both A and B. It is more convenient to measure the β€œCenter” twice and duplicate the β€œObjectId”.

Then the records have to be filtered to have only (NxN-1)/2 not to have the same pair twice (1-2, 2-1, 1-1). We want only the records where the first β€œObjectId” is smaller than the second one. As the Filter node accepts only a constant we must use JavaScript. We create a new column which has 1 where first β€œObjectId” < second β€œObjectId” and 0 in all other cases.

Then we calculate the distance between [CenterPxX, CenterPxX] and [CenterPx2X, CenterPx2X] and filter out objects farther than a given distance.

Now we insert lines: one per row so that [CenterPxX, CenterPxX] is the start point and [CenterPx2X, CenterPx2X] is the endpoint. We subtract the original spots and measure the length of these lines.

A barchart of a frequency table of lengths is created.

Note

First empty β€œFrom” cell is infinity. Last empty β€œTo” cell means infinity.

And finally all objects are color coded.