Home > cellorganizer > utilities > demo2html.m

demo2html

PURPOSE ^

DEMO2HTML Returns projection images and html file

SYNOPSIS ^

function demo2html(directory,output)

DESCRIPTION ^

 DEMO2HTML Returns projection images and html file
 @param directory, the folder that contains the images
 @param output, the directory that save the projected images and html files

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function demo2html(directory,output)
0002 % DEMO2HTML Returns projection images and html file
0003 % @param directory, the folder that contains the images
0004 % @param output, the directory that save the projected images and html files
0005 
0006 % Author: Yue Yu and Ivan Cao-Berg
0007 % Created: Summer 2012
0008 %
0009 % Copyright (C) 2012 Murphy Lab
0010 % Lane Center for Computational Biology
0011 % School of Computer Science
0012 % Carnegie Mellon University
0013 %
0014 % This program is free software; you can redistribute it and/or modify
0015 % it under the terms of the GNU General Public License as published
0016 % by the Free Software Foundation; either version 2 of the License,
0017 % or (at your option) any later version.
0018 %
0019 % This program is distributed in the hope that it will be useful, but
0020 % WITHOUT ANY WARRANTY; without even the implied warranty of
0021 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0022 % General Public License for more details.
0023 %
0024 % You should have received a copy of the GNU General Public License
0025 % along with this program; if not, write to the Free Software
0026 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0027 % 02110-1301, USA.
0028 %
0029 % For additional information visit http://murphylab.web.cmu.edu or
0030 % send email to murphy@cmu.edu
0031 
0032 check_out = exist(output);
0033 if check_out ~= 7 % the output directory is not exist
0034     ifcreate = input('The output directory does not exist, do you want to create it? Y/N: ','s');
0035     if strcmp(ifcreate,'Y')
0036         mkdir(output)
0037     else
0038         disp ('No directory is created')
0039         return
0040     end
0041 end
0042 main_html = strcat('<!DOCTYPE html><html><body><h4>',strcat(directory,'</h4><ol>'));
0043 subfolders = dir(directory);
0044 subfolders = subfolders(3:end);
0045 N = length(subfolders);% the number of cells
0046 for i = 1 : N
0047     tmp_folder_name = subfolders(i).name;
0048     tmp_html = strcat('<!DOCTYPE html><html><body><h4>',strcat(tmp_folder_name,'</h4><ol>'));
0049     
0050     proj_img_folder = strcat(output,strcat('/',tmp_folder_name));
0051     mkdir(proj_img_folder)% make a dir for the project image
0052     
0053     index_img_folder = strcat(directory,strcat('/',tmp_folder_name));
0054     image_list = dir(index_img_folder);
0055     image_list = image_list(3:end);
0056     image_num = length(image_list); % the number of index images
0057     for j = 1 : image_num
0058         img = tif2img(strcat(index_img_folder,strcat('/',image_list(j).name))); 
0059         % the current image in current folder
0060         out_img = img2projection(img);
0061         tmp_img_name = regexp(image_list(j).name,'\.','split');
0062         tmp_img_name = tmp_img_name{1};
0063         tmp_img_name = strcat(tmp_img_name,'.jpg');
0064         imwrite(uint8(ml_bcimg(out_img,[],[])),strcat(proj_img_folder,strcat('/',tmp_img_name)),'jpg');
0065         %add the image to html list
0066         tmp_html = strcat(tmp_html,'<li><a');
0067         tmp_html = strcat(tmp_html,' href="');
0068         tmp_html = strcat(tmp_html,tmp_img_name);
0069         tmp_html = strcat(tmp_html,'">');
0070         tmp_html = strcat(tmp_html,tmp_img_name);
0071         tmp_html = strcat(tmp_html,'</a></li>');
0072     end
0073     tmp_html = strcat(tmp_html,'</ol></body></html>');
0074     fid = fopen(strcat(proj_img_folder,'/index.html'),'w');
0075     fprintf(fid,'%s',tmp_html);
0076     fclose(fid);
0077     
0078     %make the main html
0079     main_html = strcat(main_html,'<li><a');
0080     main_html = strcat(main_html,' href="');
0081     main_html = strcat(main_html,strcat('./',tmp_folder_name));
0082     main_html = strcat(main_html,'/index.html');
0083     main_html = strcat(main_html,'">');
0084     main_html = strcat(main_html,tmp_folder_name);
0085     main_html = strcat(main_html,'</a></li>');
0086 end
0087 main_html = strcat(main_html,'</ol></body></html>');
0088 fid = fopen(strcat(output,'/index.html'),'w');
0089 fprintf(fid,'%s',main_html);
0090 fclose(fid);

Generated on Sun 29-Sep-2013 18:44:06 by m2html © 2005