figure4=figure(4);
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
M4=max((max(reshape(BBIO,503*647,146))'));
R4=reshape(BIO,503*647,146);
X=15;
for j=1:146
for i=1:503*647
if R4(i,j)<X
R4(i,j)=0;
else
R4(i,j)=1;
end
end
end
A4=reshape(R4,503,647,146);
for i=1:146
ax1 = axes('Parent',figure4);
ax2 = axes('Parent',figure4);
clims=[X M4];
i1=imagesc(BIO(:,:,i),'Parent',ax2,clims);
colormap(ax2,jet);
hold on;
set(i1,'alphadata',A4(:,:,i));
colorbar;
c3=colorbar;
w=c3.Position;
c3.Position=[0.860954412414402,0.110072689511942,0.030111111111111,0.815160955347871];
set(c3,'YTick',[])
hold on;
imagesc(BIO_US_double(:,:,i),'Parent',ax1);
colormap(ax1,gray);
daspect(ax1,[1 1 1]);
daspect(ax2,[1 1 1]);
set(ax2,'Visible','off');
ax1.XTick = [];
ax1.YTick = [];
title(ax1,['\lambda=',sprintf('%d',2*i+678),'nm']);
hold off;
drawnow;
frame = getframe(4);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
outfile = 'BIO.gif';
if i==1
imwrite(imind,cm,outfile,'gif','DelayTime',0,'loopcount',inf);
else
imwrite(imind,cm,outfile,'gif','DelayTime',0,'writemode','append');
end
if 146~=i
title(ax1,'');
end
end
clear('ax1','ax2','clims','i','j','lambda','M4','R4','A4','figure4','i1');
Best Answer