当前位置: 首页>>代码示例>>C++>>正文


C++ Neighborhood::add8方法代码示例

本文整理汇总了C++中Neighborhood::add8方法的典型用法代码示例。如果您正苦于以下问题:C++ Neighborhood::add8方法的具体用法?C++ Neighborhood::add8怎么用?C++ Neighborhood::add8使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Neighborhood的用法示例。


在下文中一共展示了Neighborhood::add8方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........
			}
			else if (isprint(optopt)) {
				fprintf(stderr, "Unknown option `-%c'.\n", optopt);
			}
			else {
				fprintf(stderr, "Unknown option character `\\x%x'.\n",
						optopt);
			}
			return 1;
		default:
			exit(1);
		}
	}

	/*
	 * Non-option arguments are now in argv from index optind
	 * to index argc-1
	 */
	Mat image;
	image = imread(argv[optind], CV_LOAD_IMAGE_GRAYSCALE);

	if (!image.data) {
		cout << "Loading image failed" << endl;
		return -1;
	}

	cout << "Using gamma = " << gamma << endl;
	cout << "Using rho = " << rho << endl;
	cout << "Using sigma = " << sigma << endl;

	Mat_<Tensor> tensors = Mat_<Tensor>::zeros(image.rows, image.cols);
	Mat blur, edge, structure, color;
	createAnisotropyTensor(tensors, image, sigma, rho, gamma,
			blur, edge, structure, color);
	imwrite(argv[optind + 1], blur);
	imwrite(argv[optind + 2], edge);
	imwrite(argv[optind + 3], structure);
	imwrite(argv[optind + 4], color);

	/*
	 * Network only handles integer edges, so we increase the scale a bit.
	 */
	int a;
	int b;
	a = 100;
	b = beta;

	/*
	 * Specify the neighbors of a pixel.
	 */
	cout << "Creating size " << neighbors << " neighborhood." << endl;
	Neighborhood neigh;
	if (neighbors >= 4) {
		neigh.add( 1, 0, b * 1.0);
		neigh.add( 0, 1, b * 1.0);
		neigh.add(-1, 0, b * 1.0);
		neigh.add( 0,-1, b * 1.0);
	}

	if (neighbors >= 8) {
		neigh.add( 1, 1, b * 1.0/sqrt(2.0));
		neigh.add(-1, 1, b * 1.0/sqrt(2.0));
		neigh.add( 1,-1, b * 1.0/sqrt(2.0));
		neigh.add(-1,-1, b * 1.0/sqrt(2.0));
	}

	if (neighbors >= 16) {
		neigh.add8(1, 2, 1.0);
	}

	if (neighbors >= 32) {
		neigh.add8(3, 1, 1.0);
		neigh.add8(3, 2, 1.0);
	}

	if (neighbors >= 48) {
		neigh.add8(1, 4, 1.0);
		neigh.add8(3, 4, 1.0);
	}

	if (neighbors >= 72) {
		neigh.add8(1, 5, 1.0);
		neigh.add8(2, 5, 1.0);
		neigh.add8(3, 5, 1.0);
	}

	cout << "Neighborhood: " << endl;
	neigh.setupAngles();
	for (Neighborhood::iterator it = neigh.begin(); it != neigh.end(); ++it) {
		cout << it->x << ", " << it->y << ": " << it->dt * 180 / M_PI << endl;
	}

	Mat out = image.clone();
	restoreAnisotropicTV(image, out, tensors, neigh, a, b, p);

	cout << "Writing output to " << argv[optind + 5] << endl;
	imwrite(argv[optind + 5], out);

	return 0;
}
开发者ID:burk,项目名称:image-restoration,代码行数:101,代码来源:main.cpp


注:本文中的Neighborhood::add8方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。