Last active
August 29, 2015 14:16
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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