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

📄 imagediff.cc

📁 torch tracking code, it is a good code
💻 CC
字号:
const char *help = "\progname: imagediff.cc\n\code2html: This program computes the difference of 2 images.\n\version: Torch3 vision2.0, 2004-2005\n\(c) Sebastien Marcel (marcel@idiap.ch)\n";#include "ImageGray.h"#include "xtprobeImageDiskXFile.h"#include "CmdLine.h"using namespace Torch;int main(int argc, char **argv){	char *image_filename1;	char *image_filename2;	bool verbose;	// Construct the command line  	CmdLine cmd;	cmd.setBOption("write log", false);	  	// Put the help line at the beginning  	cmd.info(help);  	cmd.addText("\nArguments:");  	cmd.addSCmdArg("image filename 1", &image_filename1, "image filename 1");  	cmd.addSCmdArg("image filename 2", &image_filename2, "image filename 2");  	cmd.addText("\nOptions:");  	cmd.addBCmdOption("-verbose", &verbose, false, "verbose");	cmd.read(argc, argv);  	ImageDiskXFile *image_file = NULL;	Image *grayimage1 = NULL;	Image *grayimage2 = NULL;	grayimage1 = new ImageGray();	grayimage1->setBOption("verbose", verbose);	grayimage2 = new ImageGray();	grayimage2->setBOption("verbose", verbose);	image_file = new xtprobeImageDiskXFile(image_filename1, "r");	grayimage1->loadImageXFile(image_file);	delete image_file;	image_file = new xtprobeImageDiskXFile(image_filename2, "r");	grayimage2->loadImageXFile(image_file);	delete image_file;	if(verbose)	{		print("Image 1 info:\n");		print("   width = %d\n", grayimage1->width);		print("   height = %d\n", grayimage1->height);		print("   format = %s (%d)\n", grayimage1->coding, grayimage1->n_planes);		print("Image 2 info:\n");		print("   width = %d\n", grayimage2->width);		print("   height = %d\n", grayimage2->height);		print("   format = %s (%d)\n", grayimage2->coding, grayimage2->n_planes);	}	if(grayimage1->width != grayimage2->width)		error("Images of different width");		if(grayimage1->height != grayimage2->height)		error("Images of different height");	int n = grayimage1->width * grayimage1->height;		real mse = 0.0;		for(int i = 0 ; i < n ; i++)	{		real z = (real) (grayimage1->data[i] - grayimage2->data[i]) / 255.0;		mse += z*z;		}	mse /= (real) n;	printf("MSE = %g\n", mse);		mse = 0.0;	for(int i = 0 ; i < grayimage1->width ; i++)		for(int j = 0 ; j < grayimage1->height ; j++)		{			grayimage1->get(j,i)[0] = grayimage2->get(j,i)[0];			real z = (real) (grayimage1->get(j,i)[0] - grayimage2->get(j,i)[0]) / 255.0;			mse += z*z;			}	mse /= (real) n;	printf("MSE = %g\n", mse);		delete grayimage1;	delete grayimage2;	return(0);}

⌨️ 快捷键说明

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