|
From: Graeme O'K. <gj...@ne...> - 2005-08-19 05:38:40
|
Hi,
is there a way to get an image of a patch? I'd like to use patches to
display Regions Of Interest and
also use then use them as masks on the image for subsequent region
based analysis.
regards,
Graeme
===== code snippet ======
#!/usr/bin/env python
import wasabi, ugm
import pylab
#
# 22-frames * 90-slices * 128-y * 128-x
#
dy = ugm.ugm('dy22.img')
#
# grab the 20th frame
#
vol = dy.vol([20])
#
# returns a series of roi's that are defined as a set of vertices of
a polygon
# eg.
# roi['cerebellum'] = numarray.array([[x0,y0], [x1,y1], ...., [xN, yN]])
# roi['caudate'] ...
#
roi = wasabi.roi('p2873s0_HAW_emdy22.xml')
pylab.figure()
ax = pylab.gca()
n = 0
col = 'rgbcmyk'
p = []
for fld in roi.keys() :
#
# draw the polygon regions as patches with transparency
#
p.append(ax.fill(roi[fld][:,0], roi[fld][:,1], col[n],
alpha=0.5, linewidth=0))
pylab.hold(True)
n += 1
#end for
pylab.imshow(vol[45,:,:], cmap = pylab.cm.hot, origin = 'lower')
print p
#
# is there a way to 'get' an array of pixels set in the patches p[0],
p[1] so that they can be used as masks
# on the image.
#
|