Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I want to achieve 2.10 posturize with color-erase blending mode effect in python
#4
You are likely working directly on gamma-corrected values instead of "linear light". See my answers in this thread: https://www.gimp-forum.net/Thread-Layer-...cial-guide.

Not included in the referenced post but something equivalent exists for layer masks. The gamma-corrected grayscale value of a 50% opacity layer mask is #BC, and a black layer over white or a white layer over black with a mask with #BC will produce a the middle gray which is also #BC.

Some more info here:  https://en.wikipedia.org/wiki/SRGB#Transformation

The python functions that implement the sRGB transforms (and give identical result to Gimp as far as my tests go):

Code:
import math

# Linear is [0.0 .. 1.0]
# sRGB is [0 .. 255]

def srgbToLinear(v255):
   v=v255/255.
   return v/12.92 if v <= 0.04045 else math.pow((v+0.055)/1.055,2.4)

def linearToSrgb(linear):
   srgb=linear*12.92 if linear < 0.0031308 else 1.055*math.pow(linear,1/2.4)-0.055
   return 255*srgb

... but if you process whole images I hope you are using numpy or equivalent.
Reply


Messages In This Thread
RE: I want to achieve 2.10 posturize with color-erase blending mode effect in python - by Ofnuts - 07-16-2024, 08:59 AM

Forum Jump: