⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 canny.cc

📁 torch tracking code, it is a good code
💻 CC
字号:
const char *help = "\progname: canny.cc\n\code2html: This program reads a ppm image and performs Canny edge detection.\n\version: Torch3 vision2.0, 2004-2005\n\(c) Sebastien Marcel (marcel@idiap.ch)\n";#include "ImageGray.h"#include "xtprobeImageDiskXFile.h"#include "ipCanny.h"#include "CmdLine.h"using namespace Torch;int main(int argc, char **argv){	char *image_filename;	real threshold;	bool verbose;    		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.addRCmdOption("-threshold", &threshold, 10, "threshold");  	cmd.addBCmdOption("-verbose", &verbose, false, "verbose");	cmd.read(argc, argv);		Image *image_in = NULL;	Image *image_out = NULL;	ImageDiskXFile *image_file = NULL;	image_in = new ImageGray();	image_file = new xtprobeImageDiskXFile(image_filename, "r");	if(!image_in->loadImageXFile(image_file))		error("Impossible to load the image");	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 *canny = NULL;	canny = new ipCanny(image_in->width, image_in->height, "gray", threshold);	canny->setBOption("verbose", verbose);	canny->process(image_in);		image_out = new ImageGray();	image_out->setBOption("verbose", verbose);	image_out->copyFrom(image_in->width, image_in->height, canny->seq_out->frames[0], "gray");	image_out->save("gradientxy.pgm");	image_out->copyFrom(image_in->width, image_in->height, canny->seq_out->frames[1], "gray");	image_out->save("gradient.pgm");	image_out->copyFrom(image_in->width, image_in->height, canny->seq_out->frames[2], "gray");	image_out->save("canny.pgm");	delete canny;	delete image_out;	delete image_in;	return(0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -