I am plotting a lot of surfaces, and the code is very slow, is there a faster/ more efficient way to plot this in a 3d graph?
I am currently plotting 150 surfaces of 550 by 550. This is very slow in rendering and loading.
axis_images= handles.figure.CurrentAxes;
for k=1:length(slices) %plots the registration slices
%the next line makes a great big box, handles, which contains all the
%plot data, but in a cell array so must be refrenced by using handles.plot{1}
%instead of handles.plot1 or handles.plot(1)
hold on
handles.registration_slices{k}= surf(X,Y,Z.*(slices(k)), …
‘CData’,image(:,:,:,k,:), ‘CDataMapping’,’direct’, …
‘EdgeColor’,’none’, ‘FaceColor’, ‘texturemap’, …
‘FaceAlpha’,’texturemap’,’AlphaData’,masks(:,:,:,k));
%FaceColor determines the color with the data in Cdata
%FaceAlpha determines the opacity of a given slice based on the
%texturemap given in AlphaData
end
freezeColors;
view(3), box on, %axis tight square
pause(1);
for i = 1:size(atlas_slices,3) %creates the atlas masks
atlas_mask=atlas_slices(:,:,i);
atlas_mask(atlas_mask<=50)=0;
atlas_mask(atlas_mask>50)=120;
atlas_masks=cat(4,atlas_masks,atlas_mask);
end
% Y_scaled=scale(Y,atlas_scale);
for k=1:length(slices) %plots the atlas slices
hold on
handles.atlas_slices{k}=surf(X+Atlas_x_correction,Y+Atlas_y_correction,Z.*(slices(k)-0.5), …
‘CData’,atlas_slices(:,:,k), ‘CDataMapping’,’direct’, …
‘EdgeColor’,’none’,’FaceColor’, ‘texturemap’, …
‘FaceAlpha’,’texturemap’,’AlphaData’,atlas_masks(:,:,:,k));
end
colormap(handles.figure.CurrentAxes, gray);
%axis equal;
%axis(axis_atlas,’off’)I am currently plotting 150 surfaces of 550 by 550. This is very slow in rendering and loading.
axis_images= handles.figure.CurrentAxes;
for k=1:length(slices) %plots the registration slices
%the next line makes a great big box, handles, which contains all the
%plot data, but in a cell array so must be refrenced by using handles.plot{1}
%instead of handles.plot1 or handles.plot(1)
hold on
handles.registration_slices{k}= surf(X,Y,Z.*(slices(k)), …
‘CData’,image(:,:,:,k,:), ‘CDataMapping’,’direct’, …
‘EdgeColor’,’none’, ‘FaceColor’, ‘texturemap’, …
‘FaceAlpha’,’texturemap’,’AlphaData’,masks(:,:,:,k));
%FaceColor determines the color with the data in Cdata
%FaceAlpha determines the opacity of a given slice based on the
%texturemap given in AlphaData
end
freezeColors;
view(3), box on, %axis tight square
pause(1);
for i = 1:size(atlas_slices,3) %creates the atlas masks
atlas_mask=atlas_slices(:,:,i);
atlas_mask(atlas_mask<=50)=0;
atlas_mask(atlas_mask>50)=120;
atlas_masks=cat(4,atlas_masks,atlas_mask);
end
% Y_scaled=scale(Y,atlas_scale);
for k=1:length(slices) %plots the atlas slices
hold on
handles.atlas_slices{k}=surf(X+Atlas_x_correction,Y+Atlas_y_correction,Z.*(slices(k)-0.5), …
‘CData’,atlas_slices(:,:,k), ‘CDataMapping’,’direct’, …
‘EdgeColor’,’none’,’FaceColor’, ‘texturemap’, …
‘FaceAlpha’,’texturemap’,’AlphaData’,atlas_masks(:,:,:,k));
end
colormap(handles.figure.CurrentAxes, gray);
%axis equal;
%axis(axis_atlas,’off’) I am currently plotting 150 surfaces of 550 by 550. This is very slow in rendering and loading.
axis_images= handles.figure.CurrentAxes;
for k=1:length(slices) %plots the registration slices
%the next line makes a great big box, handles, which contains all the
%plot data, but in a cell array so must be refrenced by using handles.plot{1}
%instead of handles.plot1 or handles.plot(1)
hold on
handles.registration_slices{k}= surf(X,Y,Z.*(slices(k)), …
‘CData’,image(:,:,:,k,:), ‘CDataMapping’,’direct’, …
‘EdgeColor’,’none’, ‘FaceColor’, ‘texturemap’, …
‘FaceAlpha’,’texturemap’,’AlphaData’,masks(:,:,:,k));
%FaceColor determines the color with the data in Cdata
%FaceAlpha determines the opacity of a given slice based on the
%texturemap given in AlphaData
end
freezeColors;
view(3), box on, %axis tight square
pause(1);
for i = 1:size(atlas_slices,3) %creates the atlas masks
atlas_mask=atlas_slices(:,:,i);
atlas_mask(atlas_mask<=50)=0;
atlas_mask(atlas_mask>50)=120;
atlas_masks=cat(4,atlas_masks,atlas_mask);
end
% Y_scaled=scale(Y,atlas_scale);
for k=1:length(slices) %plots the atlas slices
hold on
handles.atlas_slices{k}=surf(X+Atlas_x_correction,Y+Atlas_y_correction,Z.*(slices(k)-0.5), …
‘CData’,atlas_slices(:,:,k), ‘CDataMapping’,’direct’, …
‘EdgeColor’,’none’,’FaceColor’, ‘texturemap’, …
‘FaceAlpha’,’texturemap’,’AlphaData’,atlas_masks(:,:,:,k));
end
colormap(handles.figure.CurrentAxes, gray);
%axis equal;
%axis(axis_atlas,’off’) surf, optimization MATLAB Answers — New Questions