This scripts loads one or more images and creates a split image where each of the images is displayed in a cone of equal angle.
1import sys
2from math import *
5
6
7def CreateSplitImage(imagelist, start_at_y=True):
8 result=imagelist[0].Copy(False)
9 result.CenterSpatialOrigin()
10 extent=imagelist[0].GetExtent()
11 if start_at_y:
12 startpoint=Vec2(0.0,-extent.GetSize()[0])
13 else:
14 startpoint=Vec2(extent.GetSize()[0],0.0)
15 angle=2*pi/len(imagelist)
16 count=0
17 for image in imagelist:
18 image.CenterSpatialOrigin()
19 start_angle=angle*count
20 end_angle=angle*(count+1)
21 pol=Polygon2()
22 pol.AddNode(Vec2(0,0))
23 pol.AddNode(Rotate(startpoint,start_angle))
24 if(start_angle<pi/4.0 and end_angle>pi/4.0):
25 pol.AddNode(Rotate(startpoint,pi/4.0))
26 if(start_angle<3.0*pi/4.0 and end_angle>3.0*pi/4.0):
27 pol.AddNode(Rotate(startpoint,3.0*pi/4.0))
28 if(start_angle<5.0*pi/4.0 and end_angle>5.0*pi/4.0):
29 pol.AddNode(Rotate(startpoint,5.0*pi/4.0))
30 if(start_angle<7.0*pi/4.0 and end_angle>7.0*pi/4.0):
31 pol.AddNode(Rotate(startpoint,7.0*pi/4.0))
32 pol.AddNode(Rotate(startpoint,end_angle))
33 m=img.Mask(pol)
34 result+=image.Apply(img.alg.MaskImage(m))
35 count+=1
36 return result
37
38if len(sys.argv)<3:
39 imagelist=io.LoadImageList(['circle.png', 'square.png'])
40else:
41 imagelist=io.LoadImageList(sys.argv[1:-1])
42
43result=CreateSplitImage(imagelist)
44v_result=gui.CreateDataViewer(result,"Split Image")