TransWikia.com

Can Mean Shift Algorithm used in color quantization?

Software Engineering Asked by user10057710 on November 6, 2021

I have a problem with deciding algorithm for color quantization. The image that I want to do color quantization is an RGB image with resolution 512 x 512. I want to reduce the color value in the pixel to reduce the image size.

I don’t want to use the popular algorithm k-means. And I found this mean shift algorithm.

Mean shift is a clustering algorithm (same as k-means) that have certain centroids and window (each centroids have 1) to look for densest part in its window then move the centroid into the densest part.
It will keep going like that until it converge with another centroid and not moving anymore.

Is it possible to use mean shift in color quantization? Because both k-means and mean shift are clustering algorithms but all I found is image segmentation for mean algorithm and k-means for color quantization?

One Answer

Sure it can.

I am pretty sure I did not understand mean shift in full. But it is quite clear it is a clustering algorithm (well, I think it is more a class of algorithms, nothing which you can just implement without making further decisions about some algorithmic details). But let us assume you got an implementation, then apply the algorithm in some appropriate color space for a given image. Afterwards calculate the center of each cluster. Then replace the color of each point by the center value of its cluster.

Opposed to k-means, one does not have to choose the number of colors for the clustering beforehand (instead, you have to choose a "kernel function" and/or "window size"). If that is really an advantage about k-means for your specific use case is something you have to decide for yourself.

Disclaimer: I have implemented an k-means color quantization algorithm some time ago by myself, took me some effort to get all the details right.

Answered by Doc Brown on November 6, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP