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


C++ Array2D::setValue方法代码示例

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


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

示例1: src

Array2D<math::Vec3f> ShallowWater::computeNormals(const Array2D<float> & src) const {

	math::Vec3f a, b, c, d;
	Array2D<math::Vec3f> upNorms;
	upNorms.init(src.getDimX()-1, src.getDimY()-1);
	Array2D<math::Vec3f> downNorms;
	downNorms.init(src.getDimX()-1, src.getDimY()-1);
	Array2D<math::Vec3f> temp;
	temp.init(src.getDimX(), src.getDimY());

	for(int i = 0; i < upNorms.getDimX(); i++) {
		for(int j = 0; j < upNorms.getDimY(); j++) {

			a = math::Vec3f(i*m_dx, src(i, j), j*m_dy);
			b = math::Vec3f((i+1)*m_dx, src(i+1, j), j*m_dy);
			c = math::Vec3f((i+1)*m_dx, src(i+1, j+1), (j+1)*m_dy);
			d = math::Vec3f(i*m_dx, src(i, j+1), (j+1)*m_dy);
			upNorms.setValue(i, j, d-a ^ b-a);
			downNorms.setValue(i, j, b-c ^ d-c);
		}
	}

	for(int i = 0; i < src.getDimX(); i++) {
		for(int j = 0; j < src.getDimY(); j++) {

			math::Vec3f tmp(0.0, 0.0, 0.0);
			int tmpNb = 0;
			if(i-1 >= 0 && j < src.getDimY()-1) {
				tmpNb += 2;
				tmp += upNorms(i-1, j) + downNorms(i-1, j);
			}
			if(j-1 >= 0 && i < src.getDimX()-1) {
				tmpNb += 2;
				tmp += upNorms(i, j-1) + downNorms(i, j-1);
			}
			if(j-1 >= 0 && i-1 >= 0) {
				tmpNb++;
				tmp += downNorms(i-1, j-1);
			}
			if(i < src.getDimX()-1 && j < src.getDimY()-1) {
				tmpNb++;
				tmp += upNorms(i, j);
			}

			temp.setValue(i, j, (tmp/tmpNb).normalize());
		}
	}
	return temp;
}
开发者ID:NoRomaneNoCry,项目名称:ASS3D,代码行数:49,代码来源:ShalowWater.cpp

示例2: ssfeatures

int ssfeatures(FILE* infile, FILE* outfile, const QMap<QString, QVariant>& params)
{
    int nfeatures = params["nfeatures"].toInt();
    int niterations = params["niterations"].toInt();

    //get the input file header
    MDAIO_HEADER HH_infile;
    if (!mda_read_header(&HH_infile, infile))
        return 0;
    int32_t M = HH_infile.dims[0];
    int32_t T = HH_infile.dims[1];
    int32_t N = HH_infile.dims[2];
    if (M <= 0)
        return 0;
    if (T <= 0)
        return 0;
    if (N <= 0)
        return 0;

    Array2D X;
    X.allocate(M * T, N);
    float* inbuf = (float*)malloc(sizeof(float) * M * T);
    for (int i = 0; i < N; i++) {
        mda_read_float32(inbuf, &HH_infile, M * T, infile);
        for (int j = 0; j < M * T; j++) {
            X.setValue(inbuf[j], j, i);
        }
    }
    free(inbuf);

    PCASolver SS;
    SS.setVectors(X);
    SS.setNumIterations(niterations);
    SS.setComponentCount(nfeatures);
    SS.solve();
    Array2D features = SS.coefficients();

    //write the output header
    MDAIO_HEADER HH_outfile;
    mda_copy_header(&HH_outfile, &HH_infile);
    HH_outfile.num_dims = 2;
    HH_outfile.dims[0] = nfeatures;
    HH_outfile.dims[1] = N;
    HH_outfile.dims[2] = 1;
    HH_outfile.data_type = MDAIO_TYPE_FLOAT32;
    mda_write_header(&HH_outfile, outfile);

    float* outbuf = (float*)malloc(sizeof(float) * nfeatures);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < nfeatures; j++) {
            outbuf[j] = features.value(j, i);
        }
        mda_write_float32(outbuf, &HH_outfile, nfeatures, outfile);
    }
    free(outbuf);

    return 1;
}
开发者ID:magland,项目名称:mountainlab,代码行数:58,代码来源:ssfeatures.cpp

示例3: compute_median_filter

Array2D FMSegViewPrivate::compute_median_filter(const Array2D &array,int radius) {
	Array2D ret; ret.allocate(array.N1(),array.N2());
	for (int y=0; y<array.N2(); y++)
	for (int x=0; x<array.N1(); x++) {
		QList<float> list;
		for (int dy=-radius; dy<=radius; dy++)
		for (int dx=-radius; dx<=radius; dx++) {
			list << array.getValue(x+dx,y+dy);
		}
		qSort(list);
		ret.setValue(list[list.count()/2],x,y);
	}
	return ret;
}
开发者ID:magland,项目名称:fmseg,代码行数:14,代码来源:fmsegview.cpp

示例4:

Array2D<float> ShallowWater::advect(const Array2D<float> & src) {

	Array2D<float> temp;
	temp.init(src.getDimX(), src.getDimY());

	float x, y;
	temp = src;

	for(int j = 1; j < src.getDimY()-1; j++) {
		for(int i = 1; i < src.getDimX()-1; i++) {
			x = i - m_dt * m_vX(i, j);
			y = j - m_dt * m_vY(i, j);
			temp.setValue(i, j, src.interpolate(x, y));
		}
	}
	return temp;
}
开发者ID:NoRomaneNoCry,项目名称:ASS3D,代码行数:17,代码来源:ShalowWater.cpp

示例5: compute_mask_boundary

Array2D FMSegViewPrivate::compute_mask_boundary(const Array2D &mask) {
	Array2D B;
	int N1=mask.N1();
	int N2=mask.N2();
	B.allocate(N1,N2);
	for (int y=0; y<N2; y++)
	for (int x=0; x<N1; x++) {
		if (mask.getValue(x,y)) {
			for (int dy=-1; dy<=1; dy++)
			for (int dx=-1; dx<=1; dx++) {
				if ((!mask.getValue(x+dx,y+dy))&&(!B.getValue(x,y))) {
					B.setValue(1,x,y);
				}
			}
		}
	}
	return B;
}
开发者ID:magland,项目名称:fmseg,代码行数:18,代码来源:fmsegview.cpp


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