示例#1
0
void WarpInstantiate(void)
{
    CByteImage i1;
    CFloatImage uv1;
    WarpLocal(i1, i1, uv1, false, eWarpInterpLinear, 1.0f);
    CTransform3x3 M;
    WarpGlobal(i1, i1, M, eWarpInterpLinear, 1.0f);
}
示例#2
0
int SphrWarp(int argc, const char *argv[])
{
    // Warp the input image to correct for radial distortion and/or map to spherical coordinates
    if (argc < 5)
    {
        printf("usage: %s input.tga output.tga f [k1 k2]\n", argv[1]);
        return -1;
    }
    const char *infile  = argv[2];
	const char *outfile = argv[3];
	float f             = (float) atof(argv[4]);
	float k1            = (argc > 5) ? (float) atof(argv[5]) : 0.0f;
	float k2            = (argc > 6) ? (float) atof(argv[6]) : 0.0f;

	CByteImage src, dst, temp;

	/* Added by Adarsh */
	{
		bool success = LoadImageFile(infile, src);
		if (!success) {
			printf("couldn't load image 1\n");
			return -1;
		}
		else
		{
			printf("Done loading file\n");
		}
	}

	CShape sh = src.Shape();

    CTransform3x3 R;

#define THETA 0.0 // 0.1638
    R[0][0] = 1.0;  R[0][1] = 0.0;  R[0][2] = 0.0;
    R[1][0] = 0.0; R[1][1] = cos(THETA); R[1][2] = -sin(THETA);
    R[2][0] = 0.0; R[2][1] = sin(THETA);  R[2][2] = cos(THETA);

    // CFloatImage uv = WarpSphericalField(sh, sh, f, k1, k2, CTransform3x3());
    CFloatImage uv = WarpSphericalField(sh, sh, f, k1, k2, R);
    WarpLocal(src, dst, uv, false, eWarpInterpLinear);
    WriteFile(dst, outfile);
    return 0;
}
示例#3
0
int SphrWarp(int argc, const char *argv[])
{
    // Warp the input image to correct for radial distortion and/or map to spherical coordinates
    if (argc < 5)
    {
        printf("usage: %s input.tga output.tga f [k1 k2]\n", argv[1]);
        return -1;
    }
    const char *infile  = argv[2];
    const char *outfile = argv[3];
    float f             = (float) atof(argv[4]);
    float k1            = (argc > 5) ? (float) atof(argv[5]) : 0.0f;
    float k2            = (argc > 6) ? (float) atof(argv[6]) : 0.0f;

    CByteImage src, dst;
    ReadFile(src, infile);
    if (src.Shape().nBands != 4)
        src = ConvertToRGBA(src);
    CShape sh = src.Shape();

    CTransform3x3 R;

#define THETA 0.0 // 0.1638
    R[0][0] = 1.0;
    R[0][1] = 0.0;
    R[0][2] = 0.0;
    R[1][0] = 0.0;
    R[1][1] = cos(THETA);
    R[1][2] = -sin(THETA);
    R[2][0] = 0.0;
    R[2][1] = sin(THETA);
    R[2][2] = cos(THETA);

    // CFloatImage uv = WarpSphericalField(sh, sh, f, k1, k2, CTransform3x3());
    CFloatImage uv = WarpSphericalField(sh, sh, f, k1, k2, R);
    WarpLocal(src, dst, uv, false, eWarpInterpLinear);
    WriteFile(dst, outfile);
    return 0;
}