擅长:python、mysql、java
<p><strong>未经测试的代码</strong></p>
<p>基于进一步的澄清,发布第二个答案,以便更好地索引<code>binaryMap</code>,因为<code>points</code>包含浮点数</p>
<pre><code>imageResoluton = 256
MAX_X = # Fill in here the max x value ever possible in `points`
MIN_X = # Fill in here the min x value ever possible in `points`
MAX_Y = # Fill in here the max y value ever possible in `points`
MIN_Y = # Fill in here the min y value ever possible in `points`
SCALE_FAC = imageResolution / max(MAX_X-MIN_X, MAX_Y-MIN_Y)
X = np.around(SCALE_FAC * points[:,0]).astype(np.int64)
Y = np.around(SCALE_FAC * points[:,1]).astype(np.int64)
X [X >= imageResolution] = imageResolution-1
Y [Y >= imageResolution] = imageResolution-1
binaryMap[X, Y] = 1
</code></pre>
<p>(不需要<code>find_index()</code>)</p>