kmeans or Jenks clustering

Discussion related to "under the hood" OpenMV topics.
User avatar
aardvark
Posts: 1
Joined: Mon Jan 27, 2020 2:05 am

kmeans or Jenks clustering

Postby aardvark » Mon Jan 27, 2020 3:12 am

Hey guys, I saw that you have kmeans clustering in your firmware, but it doesn't seem to be exposed on the python side (or used elsewhere in the github repo?).

Is there any chance you could expose this function in python, so that it could be called on an image?

I'm trying segment ~450x40 pix grayscale images into three colors, without predefining/hardcoding the thresholds, as they're subject to change

Otsu / get_threshold() works great if the number of colors is two

I tried to use this Jenks Natural Breaks clustering (https://github.com/llimllib/jenks-pytho ... s/jenks.py), but ran out of memory (what I wouldn't give for an H7 Plus :D)

Anyway, kmeans or Jenks would be super useful to have available, even if they run slow
User avatar
kwagyeman
Posts: 4271
Joined: Sun May 24, 2015 2:10 pm

Re: kmeans or Jenks clustering

Postby kwagyeman » Mon Jan 27, 2020 11:56 am

Technically the cartoon method was implemented to do this. It works poorly however as kmeans/jenks would be much better for this.

...

Um, anyway, me and Ibrahim are really maxed out on the things we have to do and our time to do it. Can you submit C for for what you want? Then it can get in the firmware quickly. I have a large backlog to do otherwise and it will take months to get to this...

Note, on the H7 Plus only the frame buffer is in SDRAM, the MicroPython heap is still small. But, you basically have unlimited C memory for algorithms.
Nyamekye,
User avatar
kwagyeman
Posts: 4271
Joined: Sun May 24, 2015 2:10 pm

Re: kmeans or Jenks clustering

Postby kwagyeman » Mon Jan 27, 2020 12:10 pm

Question, can I implement these algorithms on histograms? Or do they need to be on all pixels? I assume it needs to be on all pixels at once...
Nyamekye,

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 17 guests