How to multiply 3d-arrays without image processing toolbox

3 visualizzazioni (ultimi 30 giorni)
Dear experts, I need to calculate an overlap between a binary 3D image (mri segment in .nii format) and a mask in MNI space (.nii) with the following dimensions (51, 75, 55). For this, I need to multiply both arrays with each other. Because the dimensions of my original 3D image were larger (153, 225, 165) than that of the mask, I needed to resize the 3D image first to get the same dimensions (51, 75, 55). I don't have an image processing toolbox within MATLAB, so I resized my original image with a for loop, as follows:
seg = spm_read_vols(spm_vol('/somedir/xxx/wseg.nii')); %the original 3D segmentation
for j=1:55 seg2(:,:,j)=imresize(seg(:,:,j),[51 75]); end
When I do this, I seem to loose information, as the total sum of my new array (seg2) becomes zero, while that of seg is not. I am searching for a solution for this problem. Thank you in advance.

Risposte (1)

Ahmet Cecen
Ahmet Cecen il 24 Apr 2018
Don't resize the Image, resize the Mask. I am assuming the Mask is 0/1 binary, so use nearest neighbor interpolation method.
  1 Commento
Gülizar Kaya
Gülizar Kaya il 25 Apr 2018
The image with the highest resolution is binary and in 3D. The mask is not binary, but also in 3D. I need to get the dimensions of both equal, because I am trying to obtain an exact location of the object within my binary image. The mask is made out of numbers indicating certain locations. If I am able to multiply the images, the new array will indicate the location of the object within the mask.
I have no idea how I have to use the nearest interpolation method. Can you please explain it more specifically. I am pretty new into coding.

Accedi per commentare.

Categorie

Scopri di più su MRI in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by