Okay I can now create a incremental list of maximally distribution of points.

From the acceptable points mask, I selected a first point which is simply the closest point to any corner.

For this I set up a distance gradient for each of the corners, mask it, then select the smalled pixel value that

was not zero.

The result in my setup was the lower right corner, but using the above example it is the top-left.

Code: Select all

```
convert acceptable.miff \
\( +clone -threshold -1 \
-fill black -draw 'rectangle 0,0 1,1' -roll -1-1 \
-virtual-pixel white -morphology Distance Euclidean:2 \
\) -compose multiply -composite -compose over \
-depth 16 txt:- |
tr -sc '0-9\012' ' ' |
awk 'NR==1 { min=1e8; next; }
$3 > 0 && $3 < min { x=$1; y=$2; min=$3; }
END { print x,y,min; }'
```

Using the X,Y of the point found I set up a 'distribution map'. this is simply an all white image with a single black point at that location.

Code: Select all

```
convert acceptable.miff -threshold -1 \
-fill black -draw "point $x,$y" \
distribute.miff
```

To find the next point to try I take the 'distribution map', run it through the distance function and mask it with the 'acceptable points map'. The pixel with the largest distance was the next point.

Code: Select all

```
convert distribute.miff -morphology Distance Euclidean:2 \
acceptable.miff -compose multiply -composite \
-depth 16 txt:- |
tr -sc '0-9\012' ' ' |
awk 'NR==1 { next; }
$3 > max { x=$1; y=$2; max=$3; }
END { print x,y,max; }'
```

This new point is added as the second black pixel in the 'distribution map', ready to find the thrid point.

Code: Select all

```
convert distribute.miff \
-fill black -draw "point $x,$y" \
distribute.miff
```

After four iterations all four corners were found, which is what I would have expected.

This is what the 'distance gradient' of the 'distribution map' looks like (normalized).

Remember this is then masked with the acceptable points, and the maximum masked distance is used to select the fifth point.

The fifth point was near the center, afetr this edges are selected, and so on... here is the distance map after 6 points have been selected.

And after 10 points have been selected.

Sort of looks like reproducing skin cells

The apparent randomness is due to the 'acceptable points' masking constraint, so the positions that are really most distant may not be selected, only the most distance 'acceptable point' is returned each time.

Note that as more points are found the distance to the next point slowly gets less. In the above (10 point map) the largest distance to found was 33.1 pixels (a 16 bit color value of 3310, in a non-normalized distance gradient)

It actually drops down in stages,

And here is the first 100 maximally distributed acceptable points (largest distance is now only 6.2 pixels)

Note only points which are 'acceptable' according to the mask that was generated from the entropy map will be selected.

I doubt I need to go beyond a list of 100 points in a sub-image serach before finding an appropriate match (probably only the first 10 will be needed).

As a matter of interest Here I let it run for some time (401 points, seperation distance now 2 pixels)

The "overlap" script is currently generating these images as the points are found.

Now I just need to convert these selected points into sub-image crops to search on the second image, and see if we can find a overlap. I would not be suprised if we don't find a good match within 4, (all corners), or 9 (corners, center, edges) points. If not found in 20 points I doubt a acceptable overlap would ever be found for final verification.