📄 mymono_file.c~
字号:
/**@(#)**//* mono_file.c * * Modification: 16-Sep-99 by IH, DICOM added * * file handling for mono_tool.c */#include <stdio.h>#include <sys/param.h>#include <string.h>#include <tina/sys.h>#include <tina/sysfuncs.h>#include <tina/math.h>#include <tina/mathfuncs.h>#include <tina/vision.h>#include <tina/visionfuncs.h>#include <tina/file.h>#include <tina/filefuncs.h>#include <tina/file_gen.h>#include <tina/tv.h>#include <tina/tvfuncs.h>#include <tina/toolsfuncs.h>#include <tina/toolsfuncs.h>#define AIFF_FILE 0#define PGM_FILE 1#define RAD_FILE 2#define EDGE_FILE 3#define POLY_FILE 4#define CAMERA 5#define WISP 6//#define RAS 7#define GIF 8#define DICOM_FILE 9 #define BMP 7 extern Imrect *pgm_read_image(char *pathname);extern int pgm_write_image(Imrect *im, char *pathname); extern Imrect *ReadGIF(char *pn, int imageNumber);extern void gif_write_file(Imrect *opm, char *pn);/*extern Imrect *dicom_read_image(char *pathname);*/void mono_input(char *directory_name, char *base_name, int file_type){ Imrect *im; char pathname[MAXPATHLEN]; if (directory_name != NULL) { (void) strip_spaces(base_name); (void) strip_spaces(directory_name); (void) string_append(pathname, directory_name, "/", base_name, NULL); } else { (void) strip_spaces(base_name); (void) string_append(pathname, base_name, NULL); } switch (file_type) { case AIFF_FILE: (void) strcat(pathname, ".aiff"); if ((im = (Imrect *) aiff_read_image(pathname))) mono_image_set(im); else error("mono_input: null mono aiff image", warning); break; case PGM_FILE: (void) strcat(pathname, ".pgm"); mono_image_set(pgm_read_image(pathname)); break; case RAD_FILE: (void) strcat(pathname, ".rad"); if ((im = (Imrect *) rad_read_image(pathname))) mono_image_set(im); else error("mono_input: null mono raw image", warning); break; case EDGE_FILE: { Imregion *region = NULL; int height = 256, width = 256; (void) strcat(pathname, ".edges"); if ((im = mono_image())) { height = im->height; width = im->width; region = im->region; } if (im = edges_read_file(pathname, height, width, region)) mono_edges_set(im); else error("mono_input: null mono edges", warning); er_find_edge_strings(im); break; } case POLY_FILE: (void) strcat(pathname, ".poly"); mono_geom_set(geom2_read(pathname)); break; case CAMERA: mono_camera_set(input_camera_file(pathname, "")); break;/* case RAS: if ((im = (Imrect *) ras_read_image(pathname, uchar_v))) mono_image_set(im); else error("mono_input: null mono ras image", warning); break;*/ case BMP: (void) strcat(pathname, ".bmp"); mono_image_set(BmpToImrect(pathname)); break; case GIF: (void) strcat(pathname, ".gif"); mono_image_set(ReadGIF(pathname, 1)); break; case DICOM_FILE: if ((im = (Imrect *) dicom_read_image(pathname))) mono_image_set(im); else error("mono_input: null mono dicom image", warning); break; default: error("file type not available", non_fatal); return; } /* Input camera */ switch (file_type) { case AIFF_FILE: if (im) mono_camera_set(input_camera_file(pathname, "")); break; }}void mono_output(char *directory_name, char *base_name, int file_type){ char pathname[MAXPATHLEN]; Imrect *temp_image; (void) strip_spaces(base_name); (void) strip_spaces(directory_name); (void) string_append(pathname, directory_name, "/", base_name, NULL); switch (file_type) { case AIFF_FILE: (void) strcat(pathname, ".aiff"); aiff_write_image(mono_image(), pathname); break; case PGM_FILE: (void) strcat(pathname, ".pgm"); pgm_write_image(mono_image(), pathname); break; case RAD_FILE: (void) strcat(pathname, ".rad"); rad_write_image(mono_image(), pathname); break; case EDGE_FILE: (void) strcat(pathname, ".edges"); edges_write_file(pathname, mono_edges()); break; case POLY_FILE: /* to be updated */ (void) strcat(pathname, ".poly"); geom2_write(pathname, mono_geom_get()); break; case CAMERA: (void) strcat(pathname, ".cam"); cam_write(pathname, mono_camera(), rdist_write_fp); break; case WISP: (void) strcat(pathname, ".wisp"); wisp_write_edges(pathname, mono_edges(), mono_camera()); break; case BMP: (void) strcat(pathname, ".bmp"); ImrectToBMP8(mono_image(), pathname); break;/* case GIF: (void) strcat(pathname, ".gif"); temp_image = im_copy(mono_image()); im_shift(temp_image, -temp_image->region->ly, -temp_image->region->lx); gif_write_file(temp_image, pathname); im_free(temp_image);*/ break; default: error("file type not available for output", non_fatal); return; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -