Bonjour,

J'utilise un code qui doit me permettre de réaliser de l'interpolation 3D de données correspondantes à des déformations dans un volume. Le problème est que l'exécution rame à fond et que le programme bug avec l'erreur suivante apparaissant :

??? Out of memory. Type HELP MEMORY for your options.

Error in ==> repmat at 62
B = A(:, ones(siz(2), 1));

Error in ==> splncore at 97
offset = repmat(reshape(sub2ind(sizeg,ind{:}),4^d,1),1,n);

Error in ==> interp3>spline3 at 670
F = splncore(varargin([2 1 3]),varargin{4},varargin([6 5 7]));

Error in ==> interp3 at 226
vi = spline3(x,y,z,v,xi,yi,zi,ExtrapVal);

Error in ==> Correction_TRS_SAG at 73
dxn=interp3(xgrid,ygrid,zgrid,dxg,xinterp,yinterp,zinterp,'spline',0);


J'ai bien regardé les commandes save et clear et essayé de les appliquer mais rien à faire... Je vous laisse ci-dessous le code de mon programme, le fichier Correction_TRS_SAG.m :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
 clear all;
close all;
 
% Reconstruction 3D du volume de coupes axiales 
 
name1='MR.1.2.392.200036.9123.100.12.11.14250.20070612134013.90.'; 
name3='.dcm';
name=strcat(name1,int2str(16),name3);
Imainfo=dicominfo(name);
x0=Imainfo.ImagePositionPatient(1);
y0=Imainfo.ImagePositionPatient(2);
z0=Imainfo.ImagePositionPatient(3);
op=Imainfo.ImageOrientationPatient;
dimpix=Imainfo.PixelSpacing;
 
volume = zeros(256,256,31);
 
for cpt=16:46
 
    name=strcat(name1,int2str(cpt),name3);
    Imainfo=dicominfo(name);
    Ima = dicomread(Imainfo);
    volume(:,:,cpt-15)=Ima;
 
end
 
% Interpolation de la déformation
 
for i=1:256
    xn(i)=x0+(i-1)*dimpix(1)*op(1)+(i-1)*dimpix(2)*op(4);        % Récupération coord3D coupe coronale pour chaque pixel   
    yn(i)=y0+(i-1)*dimpix(1)*op(2)+(i-1)*dimpix(2)*op(5);
end
 
for i=1:31
    zn(i)=z0+5*(i-1);
end
[xng,yng,zng] = meshgrid(xn,yn,zn);
xnr=reshape(xng,length(xng(: )),1);
ynr=reshape(yng,length(yng(: )),1);
znr=reshape(zng,length(zng(: )),1);
Pinterpr=[xnr ynr znr];
 
 
load Correction3D;  % Chargement des données R2,q2,xgrille,ygrille,zgrille,dxg,dyg,dzg
 
Pinterpb=Pinterpr';
Q=zeros(size(Pinterpb));
    for i=1:size(Pinterpb,2)          %Calcul des points recalés                
        Q(:,i)=R2*Pinterpb(:,i)+q2(5:7);
    end
Q=Q';
 
xinterp=reshape(Q(:,1),256,256,31);
yinterp=reshape(Q(:,2),256,256,31);
zinterp=reshape(Q(:,3),256,256,31);
 
dxn=interp3(xgrid,ygrid,zgrid,dxg,xinterp,yinterp,zinterp,'spline',0);
dyn=interp3(xgrid,ygrid,zgrid,dyg,xinterp,yinterp,zinterp,'spline',0);
dzn=interp3(xgrid,ygrid,zgrid,dzg,xinterp,yinterp,zinterp,'spline',0);
 
xnd=xinterp+dxn;                                % Obtention des coord3D correspondantes dans image déformée
ynd=yinterp+dyn;
znd=zinterp+dzn;
 
volume2=double(volume);
Imac=interp3(xinterp,yinterp,zinterp,volume2,xnd(:,:,1),ynd(:,:,1),znd(:,:,1),'cubic');           % Obtention de l'intensité aux coord3D de la nouvelle image par interpolation sur image déformée
 
figure (1)
imshow(Imac,[],'notruesize');

Merci de votre aide !