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

📄 histopgm.cc

📁 torch tracking code, it is a good code
💻 CC
字号:
const char *help = "\progname: histopgm.cc\n\code2html: This program reads a pgm image and computes the histogram of pixels.\n\version: Torch3 vision2.0, 2003-2005\n\(c) Sebastien Marcel (marcel@idiap.ch)\n";#include "ImageGray.h"#include "ipHisto.h"#include "DiskXFile.h"#include "CmdLine.h"using namespace Torch;int main(int argc, char **argv){	char *image_filename;	bool verbose;	bool normalise;  	  	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.addBCmdOption("-normalise", &normalise, false, "normalise");	cmd.read(argc, argv);  	DiskXFile *image_file = NULL;	Image *image_in = 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 *histo = NULL;	histo = new ipHisto(image_in->width, image_in->height, "gray");	histo->setBOption("verbose", verbose);	histo->setBOption("normalise", normalise);	histo->process(image_in);	real *h = histo->seq_out->frames[0];		XFile *histo_file = new DiskXFile("histo.txt", "w");	int output_size = 256;	for(int i = 0; i < output_size; i++)	{	   	int h_ = (int) (h[i] * image_in->width * image_in->height);				if(h_ != 0) histo_file->printf("%d %g\n", i, h[i]);	}	delete histo_file;		delete histo;	delete image_in;	return(0);}

⌨️ 快捷键说明

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