📄 croppgm.cc
字号:
const char *help = "\progname: croppgm.cc\n\code2html: This program crops a pgm image.\n\version: Torch3 vision2.0, 2003-2005\n\(c) Sebastien Marcel (marcel@idiap.ch)\n";#include "ImageGray.h"#include "DiskXFile.h"#include "CmdLine.h"using namespace Torch;int main(int argc, char **argv){ char *image_filename; bool verbose; int x, y, w, h; CmdLine cmd; cmd.setBOption("write log", false); cmd.info(help); cmd.addText("\nArguments:"); cmd.addSCmdArg("image filename", &image_filename, "image filename"); cmd.addICmdArg("x", &x, "x"); cmd.addICmdArg("y", &y, "y"); cmd.addICmdArg("w", &w, "w"); cmd.addICmdArg("h", &h, "h"); cmd.addText("\nOptions:"); cmd.addBCmdOption("-verbose", &verbose, false, "verbose"); cmd.read(argc, argv); DiskXFile *image_file = NULL; Image *image_in = NULL; Image *image_out = NULL; image_in = new ImageGray(); image_in->setBOption("verbose", verbose); image_file = new DiskXFile(image_filename, "r"); image_in->loadXFile(image_file); delete image_file; if(verbose) { print("Image info:\n"); print(" width = %d\n", image_in->width); print(" height = %d\n", image_in->height); print(" format = %s (%d)\n", image_in->coding, image_in->n_planes); } real *data = new real [w*h]; cropGray(image_in->data, image_in->width, image_in->height, x, y, w, h, data); image_out = new ImageGray(w, h); image_out->setBOption("verbose", verbose); image_out->copyFrom(w, h, data, "gray"); image_file = new DiskXFile("crop.pgm", "w"); image_out->saveXFile(image_file); delete image_file; delete [] data; delete image_out; delete image_in; return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -