Thursday, July 4, 2024
HomeLanguagesPythonWand function() function in Python

Wand function() function in Python

function() function is similar to evaluate function. In function() function pixel channels can be manipulated by applies a multi-argument function to pixel channels. 
Following are the list of FUNCTION_TYPES in Wand: 
 

  • ‘undefined’
  • ‘arcsin’
  • ‘arctan’
  • ‘polynomial’
  • ‘sinusoid’

 

Syntax : 
 

wand.image.function(function, arguments, channel)

Parameters : 
 

Parameter Input Type Description
function collections.abc.Sequence a sequence of doubles to apply against function
arguments numbers.Real Number to calculate with operator 
 
channel basestring Optional channel to apply operation on. 
 

Example 1:
Source Image: 
 

 

Python3




# Import Image from wand.image module
from wand.image import Image
 
frequency = 3
phase_shift = -90
amplitude = 0.2
bias = 0.7
 
# Read image using Image function
with Image(filename ="koala.jpeg") as img:
    # applying sinusoid FUNCTION_TYPE
    img.function('sinusoid', [frequency, phase_shift, amplitude, bias])
    img.save(filename ="kl-functioned.jpeg")


Output : 
 

Example 2:
Source Image: 
 

 

Python3




# Import Image from wand.image module
from wand.image import Image
 
frequency = 3
phase_shift = -90
amplitude = 0.2
bias = 0.7
 
# Read image using Image function
with Image(filename ="road.jpeg") as img:
    # applying sinusoid FUNCTION_TYPE
    img.function('polynomial', [frequency, phase_shift, amplitude, bias])
    img.save(filename ="rd-functioned.jpeg")


Output : 
 

 

Shaida Kate Naidoo
am passionate about learning the latest technologies available to developers in either a Front End or Back End capacity. I enjoy creating applications that are well designed and responsive, in addition to being user friendly. I thrive in fast paced environments. With a diverse educational and work experience background, I excel at collaborating with teams both local and international. A versatile developer with interests in Software Development and Software Engineering. I consider myself to be adaptable and a self motivated learner. I am interested in new programming technologies, and continuous self improvement.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments