Change the voxel size from a 3D matrix
5 views (last 30 days)
Show older comments
Katharina Hecker
on 18 Jun 2018
Commented: Katharina Hecker
on 18 Jun 2018
Hi everyone,
I wanted to change the voxel size of an image stack in 50x50x50 Right now I loaded the image stack into a matrix inside a .mat file It has the dimensions: 1186x1834x121 Initially I just wanted to change the dimensions of the z axis in mm to 6.05 mm so that I have a the right relation (one image was 0.05mm thick; all dimensions: x = 13 mm y = 10 mm z = 6.05 mm), but I wasn´t able to find the right code, since I´m new to Matlab I need more time to look into every code. I would be really happy about any suggestions!!! Thanks in advance.
Accepted Answer
KSSV
on 18 Jun 2018
Read about interpn
A = rand(1186,1834,121) ;
[m1,n1,p1]= size(A) ;
x0 = 13 ; y0 = 10 ; z0 = 6.05 ;
x1 = x0+(m1-1)*x0 ;
y1 = y0+(n1-1)*y0 ;
z1 = z0+(p1-1)*z0 ;
x = linspace(x0,x1,m1) ;
y = linspace(y0,y1,n1) ;
z = linspace(z0,z1,p1) ;
[X1,Y1,Z1] = ndgrid(x,y,z) ;
xi = linspace(x0,x1,50) ;
yi = linspace(y0,y1,50) ;
zi = linspace(z0,z1,50) ;
[Xi,Yi,Zi] = ndgrid(xi,yi,zi) ;
Ai = interpn(X1,Y1,Z1,A,Xi,Yi,Zi) ;
More Answers (0)
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!