'snap to' colour

Hi all.

How would I go about makiing a colour ‘snap to’ the closest match from a predefined selection?

I’m looking for a way to integrate colour schemes into my work and it would be great to for example take a video stream pixel’s colour and turn it from it’s existing colour into one of a number of colours in a palette, based on how ‘close’ their hues are.

Any related tips on how people work with colour schemes in their work would also be gobbled up with glee!

Cheers

For the same Hue it is not that hard, But I never got my head around on how to compare AND hue AND saturation AND value.

I use - (Value Cyclic) because hue 0.99 and hue 0.01 are both red.

In my 2 color related video tuts, I explained a bit more on colour, perhaps you pick up a thing or two.

ClosestHue.v4p (9.6 kB)

Thanks muchly. I’ll take a look in the morning. I’m pretty sure that hue is all I need to match.

the trick is to see a color simply as 4 values, if we leave the alpha, its 3 values. say we have RGB color ‘space’. then a color is a position in that space, which is 3 dimensional. so its finding the closest position to a given position.

maybe HSL or HSV space give other results, havn’t tested that…

ClosestColor.v4p (15.3 kB)

Wow, brilliant, never looked at colors like points in a 3D space, but sure makes sense now, thanks for the lesson.

Both great patches, thanks!

West’s is pretty much what I need, as I just want to match and replace the hue and leave the Saturation and Luminance as original.

A problem though, it’s not spreadable…

I’ve attached an example showing the jist of what I’m trying to do, hooked up to West’s solution. Just load a video in to the filestream.

You’ll see that the output pixels change colour, but only to one hue value at a time. What I need is for every pixel to match the closest one of the palette hues.

Any ideas?
Cheers

ClosestHueOfPixel (Not Spreadable).v4p (15.5 kB)

You never mentioned you wanted it spreadable ;) When you use a basic CAR (or CDR for that mather) you alwyas get 1 slice, the first (or the last) so that can never be spreadable.

How many colors in your palette do you have? To make it spreadable I think you have to resample your palette with palette * pipet spread, that can give a high spreadcount, so be careful.

Than you need a binsized sort, wich we don’t have (!!), so a binsized bounds from the the plugin pack (thnx Woei!!) should work. The binsized nodes are the ones with (Spreads Advanced) in it.

Want to figure out how to do is with the 3D colorspace from tonfilm, but it should work the same.

edit: note one Resample is set to repeat, and the other is set to Point!!

ClosestHueSpreadableMess.v4p (13.6 kB)

Thanks West it’s working perfectly!

So are bins a way of combining multiple spreads in a single spread?

Happy to read it works.

Hope you create a userpage and show us some results :)

Bins are to group spreads inside spreads (so to speak), so yes multiple spreads in a single spread. It is soo very difficult to explain I still not sure how to explain it in my video tuts.

…but you still can find a BinSize Tutorial in the “old fashioned” User Tutorials…: