Quantcast
Channel: Intel® Software - Intel® Integrated Performance Primitives
Viewing all articles
Browse latest Browse all 1489

ipprResize (3D resizing)

$
0
0

 

Please explain the difference between the coordinate systems used by ipprWarpAffine and ipprResize.

In the ipprResize documentation, it says “The right coordinate system (RCS) is used here.”. What is meant by that?

 

Consider a 2x2x2 volume.

 

Plane 0 has (x,y,z) coordinates:

000 100

010 110

 

Plane 1 has (x,y,z) coordinates:

001 101

011 111

 

If I use ipprWarpAffine with (x,y,z) scale factors of 5 (and no translation), I get a 6x6x6 volume since the coordinates above trivially get mapped to {000 500 050 550} in output plane 0 and  {005 505 055 555} in output plane 5 (the rest are interpolated).

 

If I use ipprResize with (x,y,z) scale factors of 5 (and no translation), it wants me to have an output volume size of (10,10,10).

 

bool IntelFuncs::TestResizeImage()
{
	int i, x, y, z;
	const int dim = 2;
	const int dimNew = 10;

	std::vector<unsigned short> src ={100, 100, 100, 100, 200, 200, 200, 200};
	std::vector<unsigned short> dst(dimNew*dimNew*dimNew);

	ASSERT(static_cast<int>(src.size()) == dim*dim*dim);

	i = 0;
	for (z=0; z<dim; z++) {
		TRACE(_T("#################### Original Slice %d\n"), z);

		for (y=0; y<dim; y++) {
			for (x=0; x<dim; x++, i++) {
				TRACE(_T("%d "), src[i]);
			}
			TRACE(_T("\n"));
		}
	}

	IppStatus status;

	IpprVolume srcVol ={dim, dim, dim};
	IpprCuboid srcVOI ={0, 0, 0, dim, dim, dim};

	int srcStep = dim*sizeof(unsigned short);
	int srcPlaneStep = dim*dim*sizeof(unsigned short);

	int dstStep = dimNew*sizeof(unsigned short);
	int dstPlaneStep = dimNew*dimNew*sizeof(unsigned short);

	double xFactor=5.0, yFactor=5.0, zFactor=5.0, xShift=0.0, yShift=0.0, zShift=0.0;
	int nInterp = IPPI_INTER_LINEAR;

	IpprCuboid dstVOI ={0, 0, 0, 0, 0, 0};
	status = ipprGetResizeCuboid(srcVOI, &dstVOI, xFactor, yFactor, zFactor, xShift, yShift, zShift, nInterp);
	ASSERT(dstVOI.width == dimNew && dstVOI.height == dimNew && dstVOI.depth == dimNew); //It wants me to have a dstVOI of size (10,10,10)

	int bufSize = 0;
	status = ipprResizeGetBufSize(srcVOI, dstVOI, 1, nInterp, &bufSize);

	Ipp8u* pBuffer = ippsMalloc_8u(bufSize);

	status = ipprResize_16u_C1V(src.data(), srcVol, srcStep, srcPlaneStep, srcVOI, dst.data(), dstStep, dstPlaneStep, dstVOI, xFactor, yFactor, zFactor, xShift, yShift, zShift, nInterp, pBuffer);

	i = 0;
	for (z=0; z<dimNew; z++) {
		TRACE(_T("#################### New Slice %d\n"), z);

		for (y=0; y<dimNew; y++) {
			for (x=0; x<dimNew; x++, i++) {
				TRACE(_T("%d "), dst[i]);
			}
			TRACE(_T("\n"));
		}
	}

	ippsFree(pBuffer);

	return false;
}

This gives output:

#################### Original Slice 0
100 100 
100 100 
#################### Original Slice 1
200 200 
200 200 
#################### New Slice 0
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
#################### New Slice 1
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
#################### New Slice 2
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
100 100 100 100 100 100 100 100 100 100 
#################### New Slice 3
120 120 120 120 120 120 120 120 120 120 
120 120 120 120 120 120 120 120 120 120 
120 120 120 120 120 120 120 120 120 120 
120 120 120 120 120 120 120 120 120 120 
120 120 120 120 120 120 120 120 120 120 
120 120 120 120 120 120 120 120 120 120 
120 120 120 120 120 120 120 120 120 120 
120 120 120 120 120 120 120 120 120 120 
120 120 120 120 120 120 120 120 120 120 
120 120 120 120 120 120 120 120 120 120 
#################### New Slice 4
140 140 140 140 140 140 140 140 140 140 
140 140 140 140 140 140 140 140 140 140 
140 140 140 140 140 140 140 140 140 140 
140 140 140 140 140 140 140 140 140 140 
140 140 140 140 140 140 140 140 140 140 
140 140 140 140 140 140 140 140 140 140 
140 140 140 140 140 140 140 140 140 140 
140 140 140 140 140 140 140 140 140 140 
140 140 140 140 140 140 140 140 140 140 
140 140 140 140 140 140 140 140 140 140 
#################### New Slice 5
160 160 160 160 160 160 160 160 160 160 
160 160 160 160 160 160 160 160 160 160 
160 160 160 160 160 160 160 160 160 160 
160 160 160 160 160 160 160 160 160 160 
160 160 160 160 160 160 160 160 160 160 
160 160 160 160 160 160 160 160 160 160 
160 160 160 160 160 160 160 160 160 160 
160 160 160 160 160 160 160 160 160 160 
160 160 160 160 160 160 160 160 160 160 
160 160 160 160 160 160 160 160 160 160 
#################### New Slice 6
180 180 180 180 180 180 180 180 180 180 
180 180 180 180 180 180 180 180 180 180 
180 180 180 180 180 180 180 180 180 180 
180 180 180 180 180 180 180 180 180 180 
180 180 180 180 180 180 180 180 180 180 
180 180 180 180 180 180 180 180 180 180 
180 180 180 180 180 180 180 180 180 180 
180 180 180 180 180 180 180 180 180 180 
180 180 180 180 180 180 180 180 180 180 
180 180 180 180 180 180 180 180 180 180 
#################### New Slice 7
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
#################### New Slice 8
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
#################### New Slice 9
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 
200 200 200 200 200 200 200 200 200 200 

 


Viewing all articles
Browse latest Browse all 1489

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>