I have an RGB image of the following form ((3L, 5L, 5L). This means that a 5 by 5 pixel image has 3 layers (R, G and B.). I want to group it using the DBSCAN algorithm as follows. But I got the error message ValueError: Found array with dim 3. Expected <= 2 Can't I use it for my 3D image?
import numpy as np from sklearn.cluster import DBSCAN from collections import Counter data = np.random.rand(3,5,5) print np.shape(data) print data db = DBSCAN(eps=0.12, min_samples=3).fit(data) print db DBSCAN(algorithm='auto', eps=0.12, leaf_size=30, metric='euclidean', min_samples=1, p=None, random_state=None) labels = db.labels_ print Counter(labels)
source share