The Wayback Machine - https://web.archive.org/web/20240204104550/https://www.geeksforgeeks.org/wand-function-function-in-python/
Open In App
Related Articles

Wand function() function in Python

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

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: 
 

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 : 
 

Image

Example 2:
Source Image: 
 

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 : 
 

Image

 


Don't miss your chance to ride the wave of the data revolution! Every industry is scaling new heights by tapping into the power of data. Sharpen your skills and become a part of the hottest trend in the 21st century.

Dive into the future of technology - explore the Complete Machine Learning and Data Science Program by GeeksforGeeks and stay ahead of the curve.


Last Updated : 27 Feb, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials