# \#kmeans

**URL:** https://forum.opencv.org/tag/kmeans/36.md

[Latest](https://forum.opencv.org/latest.md) · [Categories](https://forum.opencv.org/categories.md) · [Tags](https://forum.opencv.org/tags.md)

---

## [Use kmeans to determine the prevailing colors in an image (android/java)](https://forum.opencv.org/t/use-kmeans-to-determine-the-prevailing-colors-in-an-image-android-java/19521)

<div class="topic-metadata">

**Author:** [@fuxkinghatred](https://forum.opencv.org/u/fuxkinghatred)\
**Replies:** 0\
**Last updated:** [December 14, 2024, 5:22pm UTC](https://forum.opencv.org/t/use-kmeans-to-determine-the-prevailing-colors-in-an-image-android-java/19521 "2024-12-14T17:22:26Z")

</div>

Hi! I’m trying to use kmeans to determine the prevailing colors in an image. The main idea: there is a list of URLs in the format “content://media/external/images/media/65”. I read the data from the local storage, tran…

---

## [Using custom color palette with kmeans color clustering algorithm](https://forum.opencv.org/t/using-custom-color-palette-with-kmeans-color-clustering-algorithm/16904)

<div class="topic-metadata">

**Author:** [@tndstn](https://forum.opencv.org/u/tndstn)\
**Replies:** 4\
**Last updated:** [March 22, 2024, 12:14pm UTC](https://forum.opencv.org/t/using-custom-color-palette-with-kmeans-color-clustering-algorithm/16904 "2024-03-22T12:14:18Z")

</div>

bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), data.getData()); ny = new Mat(); Utils.bitmapToMat(bitmap, ny); Mat bgrImage = new Mat(); …

---

## [Resize image/video to 2 different resolutions and reduce from RGB24 to the SAME 64 colors for both resolutions](https://forum.opencv.org/t/resize-image-video-to-2-different-resolutions-and-reduce-from-rgb24-to-the-same-64-colors-for-both-resolutions/16113)

<div class="topic-metadata">

**Author:** [@zedrummer](https://forum.opencv.org/u/zedrummer)\
**Replies:** 0\
**Last updated:** [January 10, 2024, 10:49am UTC](https://forum.opencv.org/t/resize-image-video-to-2-different-resolutions-and-reduce-from-rgb24-to-the-same-64-colors-for-both-resolutions/16113 "2024-01-10T10:49:29Z")

</div>

Hello At the moment, I use cv::resize(...,cv::INTER\_LANCZOS4) then kmeans() to display RGB24 image or videos on my 128x32 dot matrix display for pinball machines with 64 colors. The result is amazing, thanks! Now, I wo…

---

## [C++: Counting Labels in K-Means Clustering](https://forum.opencv.org/t/c-counting-labels-in-k-means-clustering/8336)

<div class="topic-metadata">

**Author:** [@MaestroFries](https://forum.opencv.org/u/MaestroFries)\
**Replies:** 1\
**Last updated:** [April 9, 2022, 8:27am UTC](https://forum.opencv.org/t/c-counting-labels-in-k-means-clustering/8336 "2022-04-09T08:27:27Z")

</div>

I want to create a program which takes an image, analyzes it, and creates a percentage of RGB colours present. I am using K-Means clustering for that: double compactness = kmeans(data, k, labels, TermCriteria(TermCriter…

---

## [Grabbing the amount of pixels in K-Means Clusters in C++](https://forum.opencv.org/t/grabbing-the-amount-of-pixels-in-k-means-clusters-in-c/8292)

<div class="topic-metadata">

**Author:** [@MaestroFries](https://forum.opencv.org/u/MaestroFries)\
**Replies:** 2\
**Last updated:** [April 7, 2022, 6:28pm UTC](https://forum.opencv.org/t/grabbing-the-amount-of-pixels-in-k-means-clusters-in-c/8292 "2022-04-07T18:28:55Z")

</div>

I have the following code which takes an image and displays a color palette using K-means clustering. #include "opencv2/core/core.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" #inclu…

---

## [1-dimensional k-means clustering c++](https://forum.opencv.org/t/1-dimensional-k-means-clustering-c/2560)

<div class="topic-metadata">

**Author:** [@Meanmachine](https://forum.opencv.org/u/Meanmachine)\
**Replies:** 5\
**Last updated:** [April 8, 2021, 9:00am UTC](https://forum.opencv.org/t/1-dimensional-k-means-clustering-c/2560 "2021-04-08T09:00:28Z")

</div>

I have a 56x1 vector of doubles avg\_intensities\_double (range: 0-255) and I want to do k-means clustering to group the values. I use the kmean function from opencv . Here is my code: Mat labels, new\_centers; vector\<dou…
