Hi Amir,
> I was wondering if there is a function in SPM for zero padding a series of
> images. For instance, changing the size from 128x128 to 256x256 only by
> adding zeros around while keeping the image centered. Thanks.
I think you should be able to do something like this with:
resize_img('blah.img', nan(1,3), 2*world_bb('blah.img'));
which should increase the bounding box by 2 while keeping the image
fixed in world-space. To get exactly 128->256 or exactly symmetric
padding might be tricky, but should be possible if you experiment with
the BB values until you get the result you want.
SPM's bounding box is specified as a 2-by-3 matrix, in world/mm
coordinates, [Xmin Ymin Zmin; Xmax Ymax Zmax]. So e.g. instead of
2*world_bb(), if you have 2mm square pixels you might try:
[-128 -128 0; 128 128 0]+world_bb()
to pad by 64 pixels symmetrically either side of the image in the x
and y directions.
Hope that helps,
Ged.
http://www.cs.ucl.ac.uk/staff/gridgway/vbm/resize_img.m
http://www.cs.ucl.ac.uk/staff/gridgway/vbm/world_bb.m
P.S. I don't think I ever tested these functions on 2D images, please
let me know if they don't work!
|