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
#3
(07-12-2023, 07:01 AM)Ofnuts Wrote: The Color erase mode computes the most transparent pixel under which you can stack the erased color to rebuild the initial color. For instance, yif you Color-erase a purple pixel with red, you are left with a partially transparent blue, and if you put this pixel over the erase red, you get the purple back.



In your case the result of the posterization is used as a temporary/virtual color-erase layer. If you had an infinite level of posterization, the posterized image would be identical to the source image, and all pixels would be color-erased by a copy of themselves and would turn fully transparent. With normal posterization levels, you color-erase pixels with whatever color the posterization would color them into, which is fairly random because that depends on the rest f the image and the posterization levels.... The only not-too-random part of the result is that since the pixel is replaced by the closest color in the posterization set it will be likely quite transparent. But since you throw away the alpha channel all you see is the residual color, which v very transparent pixels is not that accurate so you have a bit of randomness here too, especially in 8bpc mode.

IMHO you would get very similar results, by 1) color-indexing the image, and 2) assigning random values in the color map.

Source of color-erase mode is here (starts at line 1180 in the current master version).

First of all, thank you Ofnuts for your input. It's been a while since I attempted this project. I have nearly succeeded at my process of replicating the desired posterize + color-erase effect using python, numpy, and PIL. I am currently hung up on replicating the exact output of my gimp process.


I am only making a new post here because I am pretty stuck. Seems I may have missed some subtle nature of gimp that could be affecting gimp's output versus my limited understanding of the process.

I have theorized that it could be something to do any or none of these processes:
  • The blending of the images
  • the alpha calculation for the color-erase
  • A default palette or preset within gimp that produces the particular color combination.
There is a subtle difference between the outputs produced by gimp and my python program. I will give an example of this difference. My output appears to be producing more intense highlights and shadows. I heavily suspect this has to do with how I am calculating the alpha mask for blending the posterize layer with the original image.

Example:

Gimp posterize with 2 levels using color-erase blending option:
[Image: bug-scaled-posterized-2.png]

Python replication of gimp 2.10 posterize and color erase algorithm:
[Image: bug-posterized-scaled-python-2.png]
Original image:
[Image: bug-scaled.png]

If more information is necessary please let me know. I'm appreciative and open to any suggestions on how I can solve this issue.
Reply


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

Forum Jump: