📄 x2pgm.cc
字号:
const char *help = "\progname: x2pgm.cc\n\code2html: This program reads an image and saves it as a pgm.\n\version: Torch3 vision2.0, 2004-2005\n\(c) Sebastien Marcel (marcel@idiap.ch)\n";#include "ImageGray.h"#include "xtprobeImageDiskXFile.h"#include "CmdLine.h"using namespace Torch;int main(int argc, char **argv){ char *image_filename; bool verbose; // Construct the command line CmdLine cmd; cmd.setBOption("write log", false); // Put the help line at the beginning cmd.info(help); cmd.addText("\nArguments:"); cmd.addSCmdArg("image filename", &image_filename, "image filename"); cmd.addText("\nOptions:"); cmd.addBCmdOption("-verbose", &verbose, false, "verbose"); cmd.read(argc, argv); ImageDiskXFile *image_file = NULL; Image *grayimage = NULL; grayimage = new ImageGray(); grayimage->setBOption("verbose", verbose); image_file = new xtprobeImageDiskXFile(image_filename, "r"); grayimage->loadImageXFile(image_file); delete image_file; if(verbose) { print("Image info:\n"); print(" width = %d\n", grayimage->width); print(" height = %d\n", grayimage->height); print(" format = %s (%d)\n", grayimage->coding, grayimage->n_planes); } grayimage->save("gray.pgm"); delete grayimage; return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -