Module Image by Python Function

This snippet shows how to define a python function that modulates an image by a sine. Note the explicit call of RealFunction.__init__ in the modulator class.

import math

class modulator(RealFunction):
	def __init__(self,f):
		RealFunction.__init__(self)
		self.f = f
		
	def Func(self,point):
		return math.sin(point[0]*self.f)*math.sin(point[1]*self.f)


im = CreateImage(Size(400,200))
im.ApplyIP(alg.Randomize())

im2 = im * modulator( 0.1 )

im2.SetSpatialOrigin(Point(0,200))

im3 = CreateImage(Size(400,400))
im3.Paste(im)
im3.Paste(im2)

v=Viewer(im3)