0
$\begingroup$

enter image description here (enlarge the image to see it in full detail)

Can't seem to find the answer to this online, but is there a way to get the exact color I need from a texture that has multiple color IDs, which also includes HSV? Especially the Value/Lightness part?

The best setup I can find so far can isolate a solid color, but not the exact HSV of a color. The image above describes the issue in detail node for node.

Notice each finger, tricep, shoulder, bicep, and forearm in the original image have different values of green. The lightest is the shoulder, the darkest is the ring finger. How would I pinpoint, say, the dark ring finger separate from the shoulder? It appears that this node setup only allows me to select from the most lit downwards. I don't want to use a slider. I need the exact given color.

When I first tapped into this, I thought it was as easy as using the color picker RGB and putting it into the factor between a mixture node of black and white and using it as color 1 to again do the same for color two and layer the masks until I reach the final one and put them all into a factor for additional purposes.

There are also these aliases/splits showing up.

Sadly, I've been stuck at this stage for a week. If possible can someone show screenshots of the solution, please?

Please help lol. I'm in sort of a deadline. :x

$\endgroup$
5
  • $\begingroup$ I've fixed your image link. But you should upload images directly here with the button in the toolbar. Please edit your question and fix it. $\endgroup$
    – Blunder
    Nov 9, 2023 at 15:13
  • $\begingroup$ It looks as if you want to check whether 2 colors are the same. So you have a node group that takes 2 colors as input and it outputs 1.0 for a match and 0.0 for no match. But you also use color 2 as the Epsilon value (=tolerance) for the Compare nodes that compare the H, S, and V components of the colors. That makes no sense to me. The color is converted to a grayscale value (RGBtoBW), e.g. (0, 1, 0) -> 0.7152. This value is then used as tolerance to check if green 1 is similar to green 2...? Try a small constant value for Epsilon $\endgroup$
    – Blunder
    Nov 9, 2023 at 15:35
  • $\begingroup$ I followed this tutorial to create the color mask: youtube.com/watch?v=mqaa8eUqJts&t=0s The thing is it's not able to pinpoint a color relative to my texture to use it to create multiple masks, even when I slide the HSV, or even when I use the RGB node to noodle in the exact HSV, it still isn't accurate. Outside of that, I'm unfamiliar to what you're saying, sorry. If possible, can you show screenshots please? $\endgroup$
    – Marquis
    Nov 9, 2023 at 19:17
  • 1
    $\begingroup$ Thanks for the update. You need to find small values for the 3 tolerance values (the "H/S/V Tolerance" slots). They pinpoint the given color with some tolerance. Try values that expand the mask but reduce the number of artifacts. You cannot use the color values as tolerance. I've started with the V, then adjusted S and H. -- If your ID mask is a channel-packed image, then only the green values might be relevant. If so, you can do Separate Color by RGB and check if the G value is within a certain range (=tolerance). This might be easier but depends on what your ID image really looks like. $\endgroup$
    – Blunder
    Nov 10, 2023 at 14:29
  • $\begingroup$ First glance: Why are you feeding the color into the H S and V tolerance floats? $\endgroup$ Nov 10, 2023 at 17:12

1 Answer 1

1
$\begingroup$

color masking node group

The node group shown in the tutorial video is fine for color masking or color matching. You just need to guess the values for the tolerance. There are 3 of them "H Tolerance" for the hue, "S Tolerance" for the saturation, and "V" for the value (which corresponds to the brightness of the colors).

For example, the "H tolerance" defines how similar the hue values of colors 1 and 2 must be in order to be recognized as "equal". The same applies to the saturation value and the "value" value.

Using the Color Masking Node Group

Here is a test with your image. I've picked the green shade of the hand, got 4BD322 (Hex), and then adjusted the 3 tolerance values (0.002, 0.045, 0.007) to expand the mask and reduce the number of artifacts at the same time.

using the color masking node group

As the binary RGB values (0 to 255) of an image are converted into floating point numbers (0.0 to 1.0) and then again into HSV values (where V can be greater than 1.0), a certain tolerance is required. There are floating point precision errors and small accuracy errors may occur at each step. In addition, a solid color may be dithered or have a certain amount of noise.

In general, you want to keep the tolerance as small as possible to get as close as possible to the corresponding color. I think the only way to get consistent values is to try them out. Start with a small value and increase it gradually. Or try doubling/halving to get a decent mask.

Alternative Way to Compare Colors And Creating a Color Mask

According to an answer to the question "How to compare colour values in Blender using Python?" you can treat the colors as vectors, subtract the vectors, and check whether the length of the resulting vector is less than a tolerance value. If so, then the colors "match".

Here is the equivalent with nodes:

color match using vector math

I did my best to find a good tolerance value, but in this example, the mask has more artifacts than with the HSV method.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .