0001 function demo2html(directory,output)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 check_out = exist(output);
0033 if check_out ~= 7
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);
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)
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);
0057 for j = 1 : image_num
0058 img = tif2img(strcat(index_img_folder,strcat('/',image_list(j).name)));
0059
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
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
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);