On 11/24/2012 06:37 AM, Dave Angel wrote: Oops, I sent before I was done editing. Corrections below. > On 11/24/2012 06:14 AM, Alasdair McAndrew wrote: >> I can resize a 2d image "im" with a command something like: >> >> r,c = shape(im) >> im2 = resize(im,(r//2,c//2)) > You're missing at least one import there. > > So how about you start by telling us what non-standard libraries you're > using, what version of python you're using, and what OS ? Then supply > us a working set of code, in the sense that people can see the problem > you're complaining about. > >> However, resize doesn't seem to work with an RGB image: >> >> r,c,n = shape(im) # returns, say 500 600 3 > Doesn't work is pretty vague. It could mean anything from "it makes the > image too small by 1%" to "it crashes my system after reformatting my > hard disk." If you get an error, include the entire traceback here. If > it doesn't work in some other sense,
then tell us what you expected, and what it did wrong. In this case, you might have to supply us with a link to sample data that demonstrates the problem. > >> I then need to take each band separately, resize it, and put them all back >> together with dstack: >> >> imr = im[:,:,0] >> img = im[:,:,1] >> imb = im[:,:,2] >> imr2 = resize(imr,(r//2,c//2)) >> img2 = resize(img,(r//2,c//2)) >> imb2 = resize(imb,(r//2,c//2)) >> im2 = dstack((imr2,img2,imb2)) >> >> This works fine, but seems a little clumsy. Of course this could be done in >> one command: >> >> im2 = dstack([resize(im[:,:,i],(r//2,c//2)) for i in range(3)]) >> >> What I want to know is: is there a version of resize which can be applied >> directly to multi-band images, without having to apply to each band >> separately? >> >> Thanks, >> Alasdair > -- DaveA -- http://mail.python.org/mailman/listinfo/python-list