Print

Print


Hi Ged,

Regarding your last reply about padding (resize_img.m)

I noticed that when I pad the image using this code or if I change the 
resolution, the image origin will be changed. In changing resolution 
case, the actual image size in mm changes as well.

For instance, if the input image size is 179x233x163 and the origin is 
at 92.0,95.0,61.0 (spacing 1x1x1), by applying the padding of [-77/2 
-23/2 0;77/2 23/2 0]+world_bb(), the size is changed to 256x256x164 and 
the center is changed to 131.0,107.0,61.0.

Is there anyway to keep the origin and size the same as its original 
version? Thanks a lot.

Regards,
Amir
 

Ged Ridgway wrote:
> 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!
>

-- 
________________________________
Amir M. Tahmasebi
Ph.D. Student,
Medical Image Analysis Lab.
School of Computing,
Queen's University,
Kingston, Ontario
CANADA
K7L 3N6
________________________________
Tel: (613) 533-2797
Web: www.cs.queensu.ca/~tahmaseb