CodingTrain / Suggestion-Box

A repo to track ideas for topics
568 stars 86 forks source link

Kuwahara Filtering #1797

Open Rodak123 opened 1 year ago

Rodak123 commented 1 year ago

This algorithm was invented with fixing images with missing pixels. It however doesn't work that well for that, but what it works well for is art.

Wikipedia

Kuwahara Filtering works like a blur algorithm.

Here are the needed steps:

  1. Imagine a rectangle around each pixel
  2. Divide the rectangle into 4 equally sized sectors
  3. For each sector get the average color and the color deviation
  4. Lastly pick the sector with the smallest deviation and use its color

I've somehow implemented the algorithm, but it is far from acceptable. Here is the result:

Image before: stephanie-harvey-yr45Zv1MM94-unsplash

And after: cat

With a bigger texel size (I didn't implement the texel size computation): cat-2