1
$\begingroup$

I'm trying to make clustering of image's pixels with DBSCAN, using RGB values and pixel's coordinates as features. It works well with just RGB values as features, but I want pixels with the same color, but from different regions, to be considered as pixels from different clusters (Imagine 2 red circles on image - even though their pixels share the same color, they belong to different circles, so intuitively, there are 2 different clusters). But, adding coordinates to feautres worsens result.

I've decided, that using a weighted distance metric, where RGB color have higher weights and coordinates have lower, could be useful.But I can't figure out how to pass weights for selected metric (e.g., Minkowski) to scikit-learn implementation of DBSCAN, or, how to precompute distance matrix fast enough (e.g., with scipy.spatial.distance.minkowski, it takes too long for feature's matrix with size of (14000,5)).

Any ideas how to implement it?

$\endgroup$
0
$\begingroup$

Finally, I've figured it out. It can be done almost the same, as described here. And it works much faster, than precomputation of distance matrix.

clstr = DBSCAN(eps=7,min_samples=14,metric='wminkowski',p=2,metric_params={"w":np.ones(len(X))})
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.