Using the +level ImageMagick operator (https://imagemagick.org/script/command-line-options.php#level) in command line will produce an output image with the channel values of the
Sorry, I do not know Wand syntax that well. Perhaps someone who does can add to this answer or post another that provides the proper syntax.
But you can achieve the equivalent to +level using the wand function
command with argument polynomial
, where the polynomial arguments are the equivalent of the equation a*x+b
. See http://docs.wand-py.org/en/0.5.1/wand/image.html.
You have to compute a and b from your values and the following equation to achieve the equivalent of +level.
a*X+b = Y
When X=0, then Y=0.45.
When X=1, then y=0.70.
So we have two linear equations that need to be solved.
0*a+b=0.45
1*a+b=0.70
From the top equation, you have
b=0.45
Substitute b into the bottom equation and get
a+0.45=0.70 --> a=0.25
In ImageMagick, you would then use
convert image.suffix -function polynomial "0.45, 0.25" result.suffix
See https://imagemagick.org/Usage/transform/#function_polynomial
In Wand function, you will need to select polynomial and then provide the a and b values above.
A guess at the Wand function
syntax would be something like:
from wand.image import Image
with Image(filename='yourimage.suffix') as img:
a = 0.25
b = 0.45
img.function('polynomial', [a, b])
...