📄 dilate.cc
字号:
const char *help = "\progname: dilate.cc\n\code2html: This program reads an image and apply dilate image morphology operator.\n\version: Torch3 vision2.0, 2003-2005\n\(c) Sebastien Marcel (marcel@idiap.ch)\n";#include "ImageGray.h"#include "ipDilate.h"#include "ipDilateXY.h"#include "DiskXFile.h"#include "CmdLine.h"using namespace Torch;int main(int argc, char **argv){ char *image_filename; int iteration; int radius; int threshold; bool xy; bool verbose; CmdLine cmd; cmd.setBOption("write log", false); cmd.info(help); cmd.addSCmdArg("image filename", &image_filename, "image filename"); cmd.addText("\nOptions:"); cmd.addBCmdOption("-verbose", &verbose, false, "verbose"); cmd.addBCmdOption("-xy", &xy, false, "dilate only in XY direction"); cmd.addICmdOption("-iteration", &iteration, 1, "iteration"); cmd.addICmdOption("-radius", &radius, 1, "radius"); cmd.addICmdOption("-threshold", &threshold, 100, "threshold"); 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); } ipCore *morph = NULL; if(xy) morph = new ipDilateXY(image_in->width, image_in->height, "gray", iteration, radius, radius, threshold); else morph = new ipDilate(image_in->width, image_in->height, "gray", iteration, radius, threshold); morph->setBOption("verbose", verbose); morph->process(image_in); image_out = new ImageGray(); image_out->setBOption("verbose", verbose); image_out->copyFrom(image_in->width, image_in->height, morph->seq_out->frames[0], "gray"); if(xy) image_file = new DiskXFile("dilateXY.pgm", "w"); else image_file = new DiskXFile("dilate.pgm", "w"); image_out->saveXFile(image_file); delete image_file; delete morph; delete image_out; delete image_in; return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -