img2vid
It contains the source-code to generate the videos in the publication:
If you find img2vid useful, please cite our paper.
v0.1
imreadRGBTiff
imreadTiff
curtain
radar
colorm
scalebar
edging
frame
imlarge
appendt
appendxy
Merge
tifresize
Attention! The most important thing to create a video with
img2vid
is the concept of canvas. Specifically, before process the images, you should plan the canvas size of your video e.g.zeros(2000,4000,3)
. Once the canvas is settled, all left is to draw (fill in) your canvas with your designed content.
imwriteRGBstack
imwritestack
draw_gif
draw_avi
/example1
rate=5;
data1=before;
data2{1}=after1;
data2{2}=after3;
img=curtain(data1,data2,rate)
/example2
data1=before;
data2=after;
img=curtain(data1,data2,rate)
/example3
for i=1:3
data1=before(:,:,i);
data2=after(:,:,i);
img(:,:,i,:)=curtain(data1,data2,rate)
end
/example1
rate=5;
isRGB=1;
linewidth=1;
out = radar(data1,data2,rate,isRGB,linewidth);
/example2
rate=5;
isRGB=0;
linewidth=1;
outRGB = radar(data1,data2,rate,isRGB,linewidth);
out=squeeze(outRGB(:,:,1,:));
large=zeros(975+130,1042*2+200,3);
jet=double(imread('16_colors.tif'));
Mito=3*SHMito;
Mito=edging(Mito,3);
Mito=scalebar(Mito,950,953,750,855);
Tubulin=scalebar(Tubulin,950,953,750,855);
Mito2=2*SIMMito;
Mito2=edging(Mito2,3);
Mito=colorm(Mito,jet);
Mito2=colorm(Mito2,jet);
flage=0;
for i=141:-1:1
large=zeros(975+130,1042*2+200,3);
flage=flage+1;
mid=sum(Mito(:,:,:,i:140),4);
mid=mid./max(mid(:));
mid=edging(mid,3);
mid=scalebar(mid,900,903,850,955);
large(81:80+975,71:70+1042,:)=mid;
mid=sum(Mito2(:,:,:,i:140),4);
mid=10*mid./max(mid(:));
mid=edging(mid,3);
mid=scalebar(mid,900,903,850,955);
large(81:80+975,141+1042:140+1042*2,:)=mid;
large(651:650+size(ceil(i*256/120):256,2),131:162,1)=jet(:,256:-1:ceil(i*256/120),1)'/255;
large(651:650+size(ceil(i*256/120):256,2),131:162,2)=jet(:,256:-1:ceil(i*256/120),2)'/255;
large(651:650+size(ceil(i*256/120):256,2),131:162,3)=jet(:,256:-1:ceil(i*256/120),3)'/255;
imwrite(large,['stage1\',int2str(flage),'.tif']);
end
large=imlarge(imgsmall,20);
function draw_avi(display,filename,mag,Quality)
if nargin < 3 || isempty(mag)
mag=1;
end
if nargin < 4 || isempty(Quality)
Quality=100;
end
vid = VideoWriter(filename,'MPEG-4');
% vid = VideoWriter(filename,'Uncompressed AVI');
vid.Quality = Quality;
vid.FrameRate=30;
open(vid)
for i = 1 : 141
for loop2=1:2
imshow(display(:,:,:,i),'border','tight','initialmagnification','fit')
set (gcf,'Position',[0,0,mag*size(display(:,:,i),2),mag*size(display(:,:,i),1)])
axis normal
drawnow;
c = getframe;
writeVideo(vid, c);
end
end
for i = 141 : 141
for loop2=1:60
imshow(display(:,:,:,i),'border','tight','initialmagnification','fit')
set (gcf,'Position',[0,0,mag*size(display(:,:,i),2),mag*size(display(:,:,i),1)])
axis normal
drawnow;
c = getframe;
writeVideo(vid, c);
end
end
close(vid)
for i=142:349
figure(1)
flage=flage+1;
large=imread(['stage1\',int2str(i),'.tif']);
imshow(large,'border','tight','initialmagnification','fit')
set (gcf,'Position',[0,0,1*size(large,2),1*size(large,1)])
text1=text(920,40,['\it{Z axial position 0 ~ }',num2str(roundn((140)*(0.05),-2)),' (\mu\it{m})']);
set(text1,'Color',[1,1, 0],'Fontsize',20,'Fontname','Arial')
text1=text(500,45,['label1']);
set(text1,'Color',[1,1,0.99],'Fontsize',20,'Fontname','Arial')
text1=text(1580,45,['label 2']);
set(text1,'Color',[1,1,0.99],'Fontsize',20,'Fontname','Arial')
text1=text(1284,1005-(i-142)*4,['\it{y}']);
set(text1,'Color',[1,1,0.99],'Fontsize',18,'Fontname','Arial')
text1=text(1224,951-(i-142)*4,['\it{z}']);
set(text1,'Color',[1,1,0.99],'Fontsize',18,'Fontname','Arial')
annotation(gcf,'arrow',[0.53 0.53],...
[0.097+(0.0034)*(i-142) 0.17+(0.0034)*(i-142)],'Color',[1 1 1],'LineWidth',2);
annotation(gcf,'arrow',[0.53 0.58],...
[0.096+(0.0034)*(i-142), 0.096+(0.0034)*(i-142)],'Color',[1 1 1],'LineWidth',2);
export_fig(gcf,['stage2\',int2str(flage),'total.png'])
end
for i=517:543
figure(1)
flage=flage+1;
large=imread(['stage1\',int2str(i),'.tif']);
imshow(large,'border','tight','initialmagnification','fit')
set (gcf,'Position',[0,0,1*size(large,2),1*size(large,1)])
text1=text(230,505,['label1']);
set(text1,'Color',[1,0,0],'Fontsize',25,'Fontname','Arial')
text1=text(280,545,['+']);
set(text1,'Color',[1,1,1],'Fontsize',25,'Fontname','Arial')
text1=text(170,585,['label2']);
set(text1,'Color',[0,1,0],'Fontsize',25,'Fontname','Arial')
export_fig(gcf,['stage2\',int2str(flage),'total.png'])
end
frame
aims to draw a rectangle ROI in the large field of view.appendt
and appendxy
aim to append frames along different axes.Merge
and tifresize
aim to append frames with different xy size along t axial.saclebar
aims to draw a scale bar.edging
aims to draw white boxes on the edge of images.Adobe Premiere
type UI software. You may spend a little time on your first video, but with the accumulated code snippets, this will speed up much on your second video.Adobe Premiere
.Adobe Premiere
. But you may want to avoid twice video label production, which will leave to different label resolution.img2vid
.matlab fig UI
to locate the specific position and angle of them. Additionally, in my usage, the images/videos/gif labeled and produced with python are usually with low resolution.You can find documents through the links! Also img2vid is accompanied with some imagej macro from @HenriquesLab and @cleterrier.
BTW, if you want to merge a multi-channel 2D or 3D (to MIP view) images, you can have a try on Palette. Palette enables users to ‘fine tune’ each merged color (exact weights of RGB components assembling, gamma, and gain setting for each channel).
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.