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

📄 subsampleppm.cc

📁 torch tracking code, it is a good code
💻 CC
字号:
const char *help = "\progname: subsampleppm.cc\n\code2html: This program reads a color ppm image and subsample it.\n\version: Torch3 vision2.1, 2004-2005\n\(c) Sebastien Marcel (marcel@idiap.ch)\n";#include "ImageRgb.h"#include "ipSubsample.h"#include "ipScale_yx.h"#include "xtprobeImageDiskXFile.h"#include "ppmDiskXFile.h"#include "DiskXFile.h"#include "CmdLine.h"using namespace Torch;int main(int argc, char **argv){	char *image_filename;	int width_out;	int height_out;	bool verbose;	bool yx;	char *output_image_filename;  		CmdLine cmd;	cmd.setBOption("write log", false);  	cmd.info(help);  	cmd.addText("\nArguments:");  	cmd.addSCmdArg("image filename", &image_filename, "image filename");  	cmd.addICmdArg("new width", &width_out, "new width");  	cmd.addICmdArg("new height", &height_out, "new height");  	cmd.addText("\nOptions:");  	cmd.addBCmdOption("-verbose", &verbose, false, "verbose");  	cmd.addBCmdOption("-yx", &yx, false, "use yx subsampling");  	cmd.addSCmdOption("-o", &output_image_filename, "subsample.ppm", "ouput image filename");	cmd.read(argc, argv);  	ImageDiskXFile *image_file = NULL;	Image *image_in = NULL;	Image *image_out = NULL;	image_in = new ImageRgb();	image_in->setBOption("verbose", verbose);        image_file = new xtprobeImageDiskXFile(image_filename, "r");        image_in->loadImageXFile(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 *submachine = NULL;	if(yx) submachine = new ipScale_yx(image_in->width, image_in->height, "rgb", width_out, height_out);	else submachine = new ipSubsample(image_in->width, image_in->height, "rgb", width_out, height_out);	submachine->setBOption("verbose", verbose);	submachine->process(image_in);		image_out = new ImageRgb();	image_out->setBOption("verbose", verbose);	image_out->copyFrom(width_out, height_out, submachine->seq_out->frames[0], "rgb");	image_out->save(output_image_filename);		delete submachine;	delete image_out;	delete image_in;	return(0);}

⌨️ 快捷键说明

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