Method for calculating irregularly spaced accumulation points

I'm trying to do the opposite of this : Given a two-dimensional image of (continuous) intensities, create a set of irregularly spaced accumulation points, i.e. points that irregularly cover the 2D map, being closer to each other in areas of high intensity ( but without overlapping! ).

My first attempt was "weighted" by k-means. Since I did not find a working implementation of weighted k-means, the way to input weights is to repeat the points with high intensity. Here is my code:

import numpy as np from sklearn.cluster import KMeans def accumulation_points_finder(x, y, data, n_points, method, cut_value): #computing the rms rms = estimate_rms(data) #structuring the data X,Y = np.meshgrid(x, y, sparse=False) if cut_value > 0.: mask = data > cut_value #applying the mask X = X[mask]; Y = Y[mask]; data = data[mask] _data = np.array([X, Y, data]) else: X = X.ravel(); Y = Y.ravel(); data = data.ravel() _data = np.array([X, Y, data]) if method=='weighted_kmeans': res = [] for i in range(len(data)): w = int(ceil(data[i]/rms)) res.extend([[X[i],Y[i]]]*w) res = np.asarray(res) #kmeans object instantiation kmeans = KMeans(init='k-means++', n_clusters=n_points, n_init=25, n_jobs=2) #performing kmeans clustering kmeans.fit(res) #returning just (x,y) positions return kmeans.cluster_centers_ 

Here are two different results: 1) Using all data pixels. 2) Using only pixels above a certain threshold (RMS).

No threshold

With a threshold

As you can see, the dots appear more regular than those concentrated in areas of high intensity.

So my question is that there is a (deterministic, if possible) best method for calculating such accumulation points.

+5
source share
1 answer

Separate the data using quadrants ( https://en.wikipedia.org/wiki/Quadtree ) into units of equal variance (or is it also possible to use the concentration value?) Using a specific level, then save one point per unit (centroid) . In areas with rapidly changing values, there will be more units, less in background areas.

+1
source

All Articles