Find only specific colors in a given range

Hi,

I’m trying to make a program that only finds and selects pixels from a specific palette.

I came up with the idea that the program should only take into account pixels with an H value of 20 ° - 55 ° (I mean yellow) and it would replace all the other pixels to black.

I don’t have much experience and so can’t handle it myself and I haven’t found anything anywhere that would allow me to determine the color range.

Please help.

You need to start by setting the colorMode to HSB (Check here). Then identify the hue range after you do your own experimentation.

Then you load your image, traverse all the pixels and identify those that should be kept and blacken those that need to change. You can start by exploring pixel manipulation by checking the examples. I find this one will give you an idea to start.

You can extract the hue of each px using hue or by using bitwise operations ( for example here) if you are comfortable doing so. Finally, you need to become familair with loadPixels, updatePixels and the pixels[] array which are easy to access in the reference.

Kf

3 Likes