Here comes a CLIJ2 version delivering an indexlist mapping points from two point lists according to nearest neighbors:

```
run("CLIJ2 Macro Extensions", "cl_device=");
Ext.CLIJ2_clear();
// define to images with labelled individual pixels
Ext.CLIJ2_pushArray(input1,
newArray(0, 1, 0, 0,
2, 0, 0, 0,
0, 0, 3, 0), 4, 3, 1);
Ext.CLIJ2_pushArray(input2,
newArray(0, 0, 1, 0,
2, 0, 0, 4,
0, 3, 0, 0), 4, 3, 1);
// determine point coordinates
Ext.CLIJ2_labelledSpotsToPointList(input1, pointlist1);
Ext.CLIJ2_labelledSpotsToPointList(input2, pointlist2);
// determine a distance matrix showing distances of all points to all points
Ext.CLIJ2_generateDistanceMatrix(pointlist1, pointlist2, distance_matrix);
// crop out a distance matrix which ignore the background
Ext.CLIJ2_getDimensions(distance_matrix, width, height, depth);
Ext.CLIJ2_crop2D(distance_matrix, distance_matrix_without_background, 1, 1, width, height);
// determine closest points; similar to a minimum-y projection
n_closest_points_to_find = 1;
Ext.CLIJ2_nClosestDistances(distance_matrix_without_background, distances, indexlist, n_closest_points_to_find);
print("Indices for closes points:");
Ext.CLIJ2_print(indexlist);
```

With this output:

Let me known if I can help integrating it in your workflow!

Cheers,

Robert