<s> import numpy as np <EOL> from PIL import Image <EOL> from cube import Cube <EOL> class MaskCube ( Cube ) : <EOL> def __init__ ( self , cubesize = [ <NUM_LIT:64> , <NUM_LIT:64> , <NUM_LIT:64> ] ) : <EOL> """<STR_LIT>""" <EOL> Cube . __init__ ( self , cubesize ) <EOL> self . data = np . zeros ( self . cubesize , dtype = np . uint8 ) <EOL> def _pack ( self , unpacked ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def _unpack ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def xySlice ( self , fileobj ) : <EOL> zdim , ydim , xdim = self . data . shape <EOL> outimage = Image . frombuffer ( '<STR_LIT:L>' , ( xdim , ydim ) , self . data [ <NUM_LIT:0> , : , : ] . flatten ( ) , '<STR_LIT>' , '<STR_LIT:L>' , <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> outimage . save ( fileobj , "<STR_LIT>" ) <EOL> def xzSlice ( self , zscale , fileobj ) : <EOL> zdim , ydim , xdim = self . data . shape <EOL> outimage = Image . frombuffer ( '<STR_LIT:L>' , ( xdim , zdim ) , self . data [ : , <NUM_LIT:0> , : ] . flatten ( ) , '<STR_LIT>' , '<STR_LIT:L>' , <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> newimage = outimage . resize ( [ xdim , int ( zdim * zscale ) ] ) <EOL> newimage . save ( fileobj , "<STR_LIT>" ) <EOL> def yzSlice ( self , zscale , fileobj ) : <EOL> zdim , ydim , xdim = self . data . shape <EOL> outimage = Image . frombuffer ( '<STR_LIT:L>' , ( ydim , zdim ) , self . data [ : , : , <NUM_LIT:0> ] . flatten ( ) , '<STR_LIT>' , '<STR_LIT:L>' , <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> newimage = outimage . resize ( [ ydim , int ( zdim * zscale ) ] ) <EOL> newimage . save ( fileobj , "<STR_LIT>" ) <EOL> def fromNPZ ( self , pandz ) : <EOL> """<STR_LIT>""" <EOL> super ( MaskCube , self ) . fromNPZ ( pandz ) <EOL> self . data = np . unpackbits ( self . data ) <EOL> def toNPZ ( self ) : <EOL> """<STR_LIT>""" <EOL> self . data = np . packbits ( self . data ) <EOL> super ( MaskCube , self ) . toNPZ ( ) </s>
