#HSV to RGB help

63 messages · Page 1 of 1 (latest)

dusky trellis
#

So far this works, but mixes the order of the values up. (Example: HSV 111.8919, 0.8671875, 0.5019608 = 17, 128, 32 when original RGB was 32, 128, 17) Sounds like a simple fix, its clearly a bug where i ordered it wrong, but this has to be the like, the 7th time i tried rewiring everything to the if values. So either i misunderstood a step, or i need a different equation. Reference Equation: https://www.rapidtables.com/convert/color/hsv-to-rgb.html

dusky trellis
#

Commenting bc this got swept away bc of a buncha other posts 😂

digital geode
silver tapir
#

here @dusky trellis ill just publish my RGB to HSV invention and you can look at it

#

its still use only lol

#

no reason to be

dusky trellis
silver tapir
#

also colors aren't 4D

digital geode
digital geode
silver tapir
dusky trellis
digital geode
#

Oh LOL

digital geode
dusky trellis
dusky trellis
# digital geode Aren't these chips coming?

most likely, but i planned on making this like 4 months ago, gave up, and then Cryptic gave me hope that if i look hard enough, theres a formula, so now i got RGB to HSV, now i just need HSV to RGB

#

Me and him discussed this in another thread but it got huge, so he suggested i make my own thread when i need the help

digital geode
# dusky trellis most likely, but i planned on making this like 4 months ago, gave up, and then C...

Given the values of H, S, and V, you can first compute m and M with the equations

M = 255V
m = M(1-S).

Now compute another number, z, defined by the equation

z = (M-m)[1 - |(H/60)mod_2 - 1|],

where mod_2 means division modulo 2. For example, if H = 135, then (H/60)mod_2 = (2.25)mod_2 = 0.25. In modulo 2 division, the output is the remainder of the quantity when you divide it by 2.

Now you can compute R, G, and B according to the angle measure of H. There are six cases. When 0 ≤ H < 60,

R = M
G = z + m
B = m.

If 60 ≤ H < 120,

R = z + m
G = M
B = m.

If 120 ≤ H < 180,

R = m
G = M
B = z + m.

When 180 ≤ H < 240,

R = m
G = z + m
B = M.

When 240 ≤ H < 300,

R = z + m
G = m
B = M.

And if 300 ≤ H < 360,

R = M
G = m
B = z + m.

#

totally wrote this myself

silver tapir
#

would make sense

dusky trellis
#

idkkkk

silver tapir
#

easy to make with switches

Modulo degrees by 360, Divide degrees by 60 and round to int

Now you have a Value String Switch match :D

dusky trellis
#

the conversion works, just sumn with the if value chunk outputs things in the wrong order sometimes, so sumn up with the logic. Math checks out tho

silver tapir
#

i keep calling it Value String Switch by accident

#

Its better than an If Expression chain

dusky trellis
#

ah mk. But still, it has to be exact, otherwise values in between would call the default

silver tapir
#

it would be

#

actually not round to int

#

Floor To Int

dusky trellis
silver tapir
#

Floor(60/60) = 1
Floor(59.999999.../60) = 0

dusky trellis
#

yee, rounding would work then

inner ginkgo
#

Why would you want HSV to RGB anyways, like when would you use it?

digital geode
#

(january)

dusky trellis
#

also never know when theyll release markers v2 they somehow havent made yet. Printers would be insane

digital geode
#

pretty dumb

digital geode
dusky trellis
#

magic markers is like, user convinent anyway, marker with control board would be cv2 compatible and million times more useful unless someone wants to chamge hex codes every pixel which would only get slower bc its so laggy the more u open magic markers

#

they really need to fix that, how dose that happen? someone forget to reset a variable so everytime u open it, the floating point precision gets more and more off? 😂

dusky trellis
digital geode
#

@dusky trellis bad news

dusky trellis
dusky trellis
dusky trellis
digital geode
#

did you forget about the |x|?

#

(absolute value)

#

z = (M-m)[1 - |(H/60)mod_2 - 1|],

dusky trellis
#

waiiit, i forgot i copied the RGB vector create so it was RGB in instead HSV xD lmao

dusky trellis
# digital geode bruv

yee, this ones good too because it already converts it to a range of 0-255 without needing to multiply by 255 at the end :3 CheerGeneral