📄 rotatepgm.cc
字号:
const char *help = "\progname: rotatepgm.cc\n\code2html: This program reads a pgm image and rotate it.\n\version: Torch3 vision2.0, 2004-2005\n\(c) Sebastien Marcel (marcel@idiap.ch)\n";#include "ImageGray.h"#include "ipRotate.h"#include "DiskXFile.h"#include "CmdLine.h"using namespace Torch;int main(int argc, char **argv){ char *image_filename; bool verbose; real angle; int xc; int yc; CmdLine cmd; cmd.setBOption("write log", false); cmd.info(help); cmd.addText("\nArguments:"); cmd.addSCmdArg("image filename", &image_filename, "image filename"); cmd.addText("\nOptions:"); cmd.addBCmdOption("-verbose", &verbose, false, "verbose"); cmd.addRCmdOption("-angle", &angle, 0.0, "ccw angle in degree"); cmd.addICmdOption("-xc", &xc, -1, "center X of rotation (if -1 center of the image)"); cmd.addICmdOption("-yc", &yc, -1, "center Y of rotation (if -1 center of the image)"); cmd.read(argc, argv); Image *image_in = NULL; Image *image_out = NULL; image_in = new ImageGray(); image_in->setBOption("verbose", verbose); image_in->load(image_filename); 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); } if(xc == -1) xc = FixI(image_in->width/2.0); if(yc == -1) yc = FixI(image_in->height/2.0); ipRotate *imachine = NULL; imachine = new ipRotate(angle, image_in->width, image_in->height, "gray"); imachine->setBOption("verbose", verbose); imachine->setCenter(xc, yc); imachine->process(image_in); image_out = new ImageGray(); image_out->setBOption("verbose", verbose); image_out->copyFrom(imachine->getWidthOut(), imachine->getHeightOut(), imachine->seq_out->frames[0], "gray"); image_out->save("rotate.pgm"); delete imachine; delete image_out; delete image_in; return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -