📄 wpt_util.c
字号:
fprintf(outputfile, "select -c tsvq/%s.tsvq%s " "-s nest/%s.nest%s " "-n %ld " "-o tempcdbk%s >> select_out\n", codebookname, extension, codebookname, extension, node->data->subtree_number, extension); } else { /* use the node's children */ for (i = 0; i < treedim; i++) { map_tree(node->child[i], outputfile, codebookname); } }}/****************************************************************************** * DOCUMENTATION ******************************************************** ****************************************************************************** NAME encode_tree DESCRIPTION encode_tree outputs a script to encode the multiresolution subbands using the previously selected PTSVQ's. The script uses tsvqe from the tsvq code. tsvqe should be compiled be the user to take doubles as input, assuming that the wavelet data are doubles. Note that when those programs are compiled for doubles, the rounding stuff has to be commented out. This is documented in the tsvqe.c code. The script is an {\em example}, the user should change this routine to make it work for their own data. ARGUMENTS IARG node the root of the tree IARG outputfile pointer to the open script file IARG codebookname the prefix name of the files for each node RETURN ALGORITHM AUTHOR Jill R. Goldschneider******************************************************************************/void encode_tree(TreeNode *node, FILE *outputfile, char *codebookname){ int i; char extension[NAME_MAX]; char temp_str[NAME_MAX]; char temp_str2[NAME_MAX]; TreeNode *tempnode; /* if this node is best, use it and return */ if (node->split == FALSE) { /* find the extension number */ tempnode = node; strcpy(temp_str, ""); if (tempnode->depth == 0) { strcpy(extension, temp_str); } else { sprintf(temp_str, ".%d", node->child_id); while (tempnode->depth > 1) { tempnode = tempnode->parent; sprintf(temp_str2, ".%d%s", tempnode->child_id, temp_str); strcpy(temp_str, temp_str2); } strcpy(extension, temp_str); } fprintf(outputfile, "tsvqe -c tempcdbk%s " "-i test/%s.image%s " "-o tempimage%s >> tsvqe_out\n", extension, codebookname, extension, extension); fprintf(outputfile, "rm tempcdbk%s\n", extension); } else { /* use the node's children */ for (i = 0; i < treedim; i++) { encode_tree(node->child[i], outputfile, codebookname); } }}/****************************************************************************** * DOCUMENTATION ******************************************************** ****************************************************************************** NAME unblock_tree DESCRIPTION unblock_tree outputs a script to unblock the encoded multiresolution subbands. The script uses unblock from the tsvq code. The tsvq program should be compiled be the user to take doubles as input, assuming that the wavelet data are doubles. The script is an {\em example}, the user should change this routine to make it work for their own data. ARGUMENTS IARG node the root of the tree IARG outputfile pointer to the open script file RETURN ALGORITHM AUTHOR Jill R. Goldschneider******************************************************************************/void unblock_tree(TreeNode *node, FILE *outputfile){ int i, size; char extension[NAME_MAX]; char temp_str[NAME_MAX]; char temp_str2[NAME_MAX]; TreeNode *tempnode; /* if this node is best, use it and return */ if (node->split == FALSE) { size = (int) 512 / pow(2.0, (double) node->depth); /* find the extension number */ tempnode = node; strcpy(temp_str, ""); if (tempnode->depth == 0) { strcpy(extension, temp_str); } else { sprintf(temp_str, ".%d", node->child_id); while (tempnode->depth > 1) { tempnode = tempnode->parent; sprintf(temp_str2, ".%d%s", tempnode->child_id, temp_str); strcpy(temp_str, temp_str2); } strcpy(extension, temp_str); } fprintf(outputfile, "unblock -i tempimage%s " "-o timage%s " "-r %d -l %d -h $1 -w $2 >> unblock_out \n", extension, extension, size, size); fprintf(outputfile, "rm tempimage%s\n", extension); } else { /* use the node's children */ for (i = 0; i < treedim; i++) { unblock_tree(node->child[i], outputfile); } }}/****************************************************************************** * DOCUMENTATION ******************************************************** ****************************************************************************** NAME rebuild_tree DESCRIPTION rebuild_tree outputs a script to rebuild the encoded and unblocked multiresolution subbands. The script is an {\em example}. The user should change this routine to make it work for their own wavelet package or library, such as S+Wavelets or Matlab wavelets. ARGUMENTS IARG node the root of the tree IARG outputfile pointer to the open script file RETURN ALGORITHM AUTHOR Jill R. Goldschneider******************************************************************************/void rebuild_tree(TreeNode *node, FILE *outputfile){ int i, size; char extension1[NAME_MAX]; char extension2[NAME_MAX]; char temp_str[NAME_MAX]; char temp_str2[NAME_MAX]; TreeNode *tempnode; /* root node is best, reconstruct it */ if (node->depth == 0 && node->split == FALSE) { size = (int) 512 / pow(2.0, (double) node->depth); strcpy(extension1, ""); strcpy(extension2, ""); /* read in the subbands */ /* assume readsubbands function will read timage%s.n, n = 1,2,3,4 */ fprintf(outputfile, "%% readsubband function should read timage%s.n, n=1,2,3,4\n" "tempband%s = readsubbands('timage%s', %d, 1, 'double');\n", extension1, extension2, extension1, size); /* compute the inverse 2-d DWT */ fprintf(outputfile, "x = idwt_2d(tempband%s, 1, s8);\n", extension2); /* output inverse 2-d DWT */ fprintf(outputfile, "writeimage(x, 'timage%s', 'double');\n", extension1); return; } /* reconstruct the WPT */ if (node->split == TRUE) { size = (int) 512 / pow(2.0, (double) node->depth); /* use the node's children */ for (i = 0; i < treedim; i++) { rebuild_tree(node->child[i], outputfile); } } else if (node->split == FALSE) { return; } /* find extension1 used for file name */ tempnode = node; strcpy(temp_str, ""); if (tempnode->depth == 0) { strcpy(extension1, temp_str); } else { sprintf(temp_str, ".%d", node->child_id); while (tempnode->depth > 1) { tempnode = tempnode->parent; sprintf(temp_str2, ".%d%s", tempnode->child_id, temp_str); strcpy(temp_str, temp_str2); } strcpy(extension1, temp_str); } /* find extension2 used for example matlab script */ tempnode = node; strcpy(temp_str, ""); if (tempnode->depth == 0) { strcpy(extension2, temp_str); } else { sprintf(temp_str, "_%d", node->child_id); while (tempnode->depth > 1) { tempnode = tempnode->parent; sprintf(temp_str2, "_%d%s", tempnode->child_id, temp_str); strcpy(temp_str, temp_str2); } strcpy(extension2, temp_str); } /* read in the subbands */ fprintf(outputfile, "%% readsubband function should read timage%s.n, n=1,2,3,4\n" "tempband%s = readsubbands('timage%s', %d, 1, 'double');\n", extension1, extension2, extension1, size); /* compute the inverse 2-d DWT */ fprintf(outputfile, "x = idwt_2d(tempband%s, 1, s8);\n", extension2); /* output inverse 2-d DWT */ fprintf(outputfile, "writeimage(x, 'timage%s', 'double');\n", extension1); return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -