def extract_patch(textid, os, downsample):
 temp = ('${PYLEARN2_DATA_PATH}/textures/brodatz/D%i.gif' % textid)
 fname = string_utils.preprocess(temp)
 img_i = Image.open(fname)
 img_i = img_i.resize(((img_i.size[0] / downsample), (img_i.size[1] / downsample)), Image.BILINEAR)
 x = numpy.random.randint(0, (img_i.size[0] - os))
 y = numpy.random.randint(0, (img_i.size[1] - os))
 patch = img_i.crop((x, y, (x + os), (y + os)))
 return (patch, (x, y))

def extract_patch ( textid , os , downsample ) : temp = ( '${PYLEARN2_DATA_PATH}/textures/brodatz/D%i.gif' % textid ) fname = string_utils . preprocess ( temp ) img_i = Image . open ( fname ) img_i = img_i . resize ( ( ( img_i . size [ 0 ] / downsample ) , ( img_i . size [ 1 ] / downsample ) ) , Image . BILINEAR ) x = numpy . random . randint ( 0 , ( img_i . size [ 0 ] - os ) ) y = numpy . random . randint ( 0 , ( img_i . size [ 1 ] - os ) ) patch = img_i . crop ( ( x , y , ( x + os ) , ( y + os ) ) ) return ( patch , ( x , y ) )
extract a patch of texture #textid of brodatz dataset .