私がやっていることは、量子化によって画像の色を減らすことですが、フロートを使用する代わりに、RGB に変換する必要があります (例: array(255, 255, 255))。同様の質問を見つけましたが、簡単で直接的な解決策ではありません。
戻るclustered
と、float の配列が生成されます。float を RGB に変換するにはどうすればよいですか?
# Pixel Matrix
pixel = reshape(img,(img.shape[0]*img.shape[1],3))
# Clustering
centroids,_ = kmeans(pixel,8) # six colors will be found
# Quantization
qnt,_ = vq(pixel,centroids)
# Shape Quantization Result
centers_idx = reshape(qnt,(img.shape[0],img.shape[1]))
clustered = centroids[centers_idx]