Skip to content

Instantly share code, notes, and snippets.

@icaoberg
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icaoberg/15f16f832647661b2812 to your computer and use it in GitHub Desktop.
Save icaoberg/15f16f832647661b2812 to your computer and use it in GitHub Desktop.
Helper script that generates a library of png from a collection of multi tiffs
patterns = { 'nuc', 'endo', 'mit', 'lyso' };
for i=1:length(patterns)
pattern = patterns{i};
disp( pattern );
mkdir(pattern);
files = dir( '*.tif' );
for j=1:1:length(files)
file = files(j).name;
disp( [ 'Opening ' file ] );
filename = strcat(pattern, sprintf('%05d',j), '.png' );
img = tif2img( file );
img2 = cat( 3, cat( 3, img(:,:,1), img(:,:,2) ), img(:,:,2+i) );
position = [5 5];
footnote = [ pattern num2str(j) '.tif'];
try
img2 = insertText(img2,position,footnote);
catch
disp( 'Unable to insert text' );
end
img2 = uint8( img2 );
filename = [ pwd filesep pattern filesep ...
filename ];
disp( [ 'Saving ' filename ] );
imwrite( img2, filename );
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment