OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
modulate_image.py

This script 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(img.RealFunction):
def __init__(self,f):
img.RealFunction.__init__(self)
self.f = f
def Func(self,point):
return math.sin(point[0]*self.f)*math.sin(point[1]*self.f)
im = img.CreateImage(img.Size(400,200))
im.ApplyIP(img.alg.Randomize())
im2 = im * modulator( 0.1 )
im2.SetSpatialOrigin(img.Point(0,200))
im3 = img.CreateImage(img.Size(400,400))
im3.Paste(im)
im3.Paste(im2)
v=gui.CreateDataViewer(im3,"Modulated Image")