Python – evaluate() function in Wand

In evaluate() function pixel channels can be manipulated by applying an arithmetic, relational, or logical expression.

Syntax :

wand.image.evaluate(operator, value, channel)

Parameters :

Parameter Input Type Description
operator basestring Type of operation to calculate.
value numbers.Real Number to calculate with operator
channel basestring Optional channel to apply operation on.

Following are the list of EVALUATE_OPS in Wand:

EVALUATE_OPS Description
‘undefined’ it is the defaul EVALUATE_OPS.
‘abs’ create an abstract evaluation.
‘add’ add evaluation.
‘addmodulus’ add modulus evaluation.
‘and’ and evaluation.
‘cosine’ evaluate from cosine function.
‘gaussiannoise’ Add gaussian noise evaluation
‘impulsenoise’ Add impulse noise evaluation
‘laplaciannoise’ Add laplace noise evaluation
‘leftshift’ bitwise leftshift
‘max’ max evaluation
‘mean’ mean evaluation added.
‘median’ median evaluation added.
‘multiplicativenoise’ Add multiplicative noise evaluation
‘multiply’ multiply image evaluation
‘or’ or evaluation
‘poissonnoise’ Add poisson noise evaluation
‘pow’ Add powe evaluation
‘rightshift’ bitwise right shift
‘set’ Add set evaluation
‘sine’ Add sine function evaluation
‘threshold’ Add threshold evaluation with particular threshold point.
‘thresholdblack’ Add evaluation while threshold is black.
‘thresholdwhite’ Add evaluation while threshold is white.
‘uniformnoise’ Add uniform noise evaluation

Source Image:



Code Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# Import Image from wand.image module
from wand.image import Image
  
# Read image using Image function
with Image(filename ="koala.jpeg") as img:
    img.evaluate(operator ='rightshift', value = 1, channel ='blue')
    img.save(filename ="kl-enhanced.jpeg")

chevron_right


Output Image:

Code Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# Import Image from wand.image module
from wand.image import Image
  
# Read image using Image function
with Image(filename ="koala.jpeg") as img:
    img.evaluate(operator ='leftshift', value = 1, channel ='red')
    img.save(filename ="kl-enhanced2.jpeg")

chevron_right


Output Image:




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.