So I recently read this excellent post about generating random points over arbitrary regions. I hope Wolfram eventually builds that functionality into Mathematica's Random
functions. I want to do this for binary images.
Given a binary image like this:
... I can generate random lattice points over the black parts by doing:
ListPlot[RandomSample[PixelValuePositions[Binarize[img], Black],1500],
AspectRatio -> ImageAspectRatio[img]]
which gives this plot:
However, the problem is that all generated random points will lie on integer coordinates. For example, the point {150, 100}
can be generated by my approach, yet the point {150.278, 100.123}
will never be generated. I want to generate random points uniformly anywhere within the coastlines/black regions.