how to convert .mat file to .nrrd file with correct size
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
mohd akmal masud
le 11 Juin 2023
Réponse apportée : Anush
le 15 Juin 2023
Dear all,
I have file outVol.mat (can download thru link: https://drive.google.com/file/d/10O7ou3lcP_YWXzsYhUL6N_9xnoOQrJ_S/view?usp=sharing).
The size is 135x135x74.
I want to convert it into .nrrd format. Below is my command. The attached nrrd function attached.
But I little bit confuse. How to get the same size when convert into .nrrd format? because I get the wrong size
Anyone can help me?
clc
clear all
close all
img = load('outVol.mat');
% Set pixel data
[x,y,z] = meshgrid([-10:10],[-12:15],[-8:6]);
img.pixelData = x/3+y/4+z/2;
% Define origin, spacing, axis directions by a homogeneous transformation matrix:
img.ijkToLpsTransform = [ 1.2 0 0 10; 0 1.2 0 12; 0 0 3.0 -22; 0 0 0 1];
% Enable compression
img.metaData.encoding='gzip';
nrrdwrite('testOutput.nrrd', img);
0 commentaires
Réponse acceptée
Anush
le 15 Juin 2023
Hello,
Instead of the following line of code:
img = load('outVol.mat');
You need to access the outVol field of the img structure to retrieve the image data. Here's the modified code:
imgData = load('outVol.mat');
img = imgData.outVol;
This is because img is a structure containing multiple fields, including the outVol field that holds the actual image data
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Convert Image Type dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!