MCPcopy Create free account
hub / github.com/ImageEngine/cortex / test

Method test

test/IECoreImage/MedianCutSamplerTest.py:43–73  ·  view source on GitHub ↗
( self )

Source from the content-addressed store, hash-verified

41class MedianCutSamplerTest( unittest.TestCase ) :
42
43 def test( self ) :
44
45 image = IECore.Reader.create( os.path.join( "test", "IECoreImage", "data", "exr", "carPark.exr" ) ).read()
46 for n in ["R", "G", "B"] :
47 p = image[n]
48 p.data = IECore.DataCastOp()( object=image[n], targetType=IECore.FloatVectorData.staticTypeId() )
49 image[n] = p
50
51 luminanceImage = IECoreImage.LuminanceOp()( input=image )
52
53 s = IECoreImage.MedianCutSampler()( image=luminanceImage, subdivisionDepth=4, projection=IECoreImage.MedianCutSampler.Projection.LatLong )
54 centroids = s["centroids"]
55 areas = s["areas"]
56
57 self.assertEqual( len( s ), 2 )
58 self.assertEqual( len( centroids ), len( areas ) )
59 self.assertEqual( len( centroids ), 16 )
60 self.assertTrue( centroids.isInstanceOf( IECore.V2fVectorData.staticTypeId() ) )
61 self.assertTrue( areas.isInstanceOf( IECore.Box2iVectorData.staticTypeId() ) )
62
63 dataWindow = luminanceImage.dataWindow
64 areaSum = 0
65 for i in range( 0, len( centroids ) ) :
66 c = centroids[i]
67 c = imath.V2i( int(c.x), int(c.y) )
68 self.assertTrue( dataWindow.intersects( c ) )
69 self.assertTrue( areas[i].intersects( c ) )
70 s = areas[i].size() + imath.V2i( 1 )
71 areaSum += s.x * s.y
72
73 self.assertEqual( areaSum, luminanceImage.channelSize() )
74
75if __name__ == "__main__":
76 unittest.main()

Callers

nothing calls this directly

Calls 11

joinMethod · 0.80
DataCastOpMethod · 0.80
staticTypeIdMethod · 0.80
LuminanceOpMethod · 0.80
MedianCutSamplerMethod · 0.80
isInstanceOfMethod · 0.80
channelSizeMethod · 0.80
lenFunction · 0.50
readMethod · 0.45
createMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected