Skip to content
Snippets Groups Projects
Commit 582eed5c authored by ac's avatar ac
Browse files

Merge branch 'log_seg' of git-bioimage.coe.drexel.edu:bioimage/leverjs into log_seg

parents bf78d909 fe4b6c99
Branches
No related tags found
No related merge requests found
function [nPixels,microns] = scaleBar(CONSTANTS,targetPixels)
function [nPixels,microns] = scaleBar(CONSTANTS,targetPixels,szim)
if ~exist('targetPixels','var')
targetPixels = 100;
......@@ -9,7 +9,10 @@ microns = targetPixels .* microns_per_pixel;
microns = 5 * round(microns/5);
nPixels = round(microns / microns_per_pixel);
rectangle('Position',[2*size(im,2)-100,25,nPixels,10],'facecolor','w')
text(2*size(im,2)-100+nPixels/2,25,'30um','color','w','HorizontalAlignment','center', ...
'VerticalAlignment','bottom')
% rectangle('Position',[szim(2)-100,25,nPixels,10],'facecolor','w')
% text(szim(2)-100+nPixels/2,25,'30um','color','w','HorizontalAlignment','center', ...
% 'VerticalAlignment','bottom')
rectangle('Position',[szim(2)-30-nPixels,40,nPixels,15],'FaceColor','w');
% text(szim(2)-30-nPixels,15,[num2str(microns) '\mum'],'color','w','VerticalAlignment','top','fontsize',12)
text(szim(2)-30-nPixels,5,[num2str(microns) '\mum'],'color','w','VerticalAlignment','top','fontsize',12)
% this code can be functionalized
% can also add features:
% periodicity toggle? if true remove final frame
% changing number of inbetweens to speed up or slow down the animation
fileName = 'ssfClustering'; % name of movie generated
frameRate = 30; % desired frame rate
duration = 30; % desired length of movie in seconds
azimuthList = [-20,-110,-190,-290,-380]; % camera pan angle at key frames
elevationList = [10,10,10,10,10]; % camera tilt angle at key frames
v = VideoWriter(fileName,'MPEG-4');
v.FrameRate = frameRate;
open(v);
% interpolate viewing angles between key frames to match the specified duration
keyFrameList = [azimuthList;elevationList]';
numFrames = round(duration * frameRate);
intervalLength = (numFrames - 1) / (size(keyFrameList,1) - 1);
% initialize the angleList
angleList = zeros(numFrames,2);
for numKeyFrame = 1:size(keyFrameList,1) - 1
firstRow = round(intervalLength * (numKeyFrame - 1) + 1); % first row of the interval between key frames
lastRow = round(intervalLength * numKeyFrame + 1); % last row of the interval between key frames
a = keyFrameList(numKeyFrame,1); % initial key frame azimuth angle
b = keyFrameList(numKeyFrame + 1,1); % ending key frame azimuth angle
c = keyFrameList(numKeyFrame,2); % initial key frame elevation angle
d = keyFrameList(numKeyFrame + 1,2); % ending key frame elevation angle
n = round(intervalLength * numKeyFrame) - round(intervalLength * (numKeyFrame - 1)) + 1; % number of angles to add
angleList(firstRow:lastRow,:) = [linspace(a,b,n).' , linspace(c,d,n).'];
end
% capture frames and write to the movie file
for frame = 1:size(angleList,1)
view(angleList(frame,:));
drawnow;
writeVideo(v,getframe(gcf));
end
close(v);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment