Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

ipprCopyConstBorder_16u_C1V returns ippStsOK when it should return ippStsSizeErr

Ken_Thornton
Beginner
1,185 Views

My environment:

  • IPP 2020
  • Windows 10
  • VS 2019

I'm testing ipprCopyConstBorder_16u_C1V.

It looks like it is designed to place a small image VOI into a large image.

The following code should return a ippStsSizeErr ( since dstRoiVolume.width = 7  < srcRoiVolume.width = 5  + leftBorderWidth 3 ), but it returns ippStsOk.

Please confirm:

void TestCopy()
{
	using namespace std;

	const IpprVolume srcSize = { 5,5,5 };
	const IpprVolume dstSize = { 7,7,7 };

	const int numSrc = srcSize.width * srcSize.height * srcSize.depth;
	const int numDst = dstSize.width * dstSize.height * dstSize.depth;

	const int srcStep = srcSize.width * sizeof(unsigned short);
	const int srcPlaneStep = srcSize.width * srcSize.height * sizeof(unsigned short);

	const int dstStep = dstSize.width * sizeof(unsigned short);
	const int dstPlaneStep = dstSize.width * dstSize.height * sizeof(unsigned short);

	vector<unsigned short> srcVol(numSrc), dstVol(numDst);

	memset(dstVol.data(), 0, numDst * sizeof(unsigned short));

	//Set src image.
	int i = 0;
	for (int z = 0; z < srcSize.depth; z++) {
		for (int y = 0; y < srcSize.height; y++) {
			for (int x = 0; x < srcSize.width; x++) {
				cout << " " << i;
				srcVol[i++] = i;
			}
			cout << endl;
		}
		cout << endl << endl;
	}

	cout << "End outputting src volume" << endl << endl;
	cout << "Begin outputting dst volume" << endl << endl;

	//Using xBorder = 3 should result in a ippStsSizeErr per the documentation!
	int xBorder = 3, yBorder = 2, zBorder = 2;

	unsigned short val = numeric_limits<unsigned short>::max();

	IppStatus sts = ipprCopyConstBorder_16u_C1V(srcVol.data(), srcPlaneStep, srcStep, srcSize, dstVol.data(), dstPlaneStep, dstStep, dstSize, xBorder, yBorder, zBorder, &val);
	assert(sts == ippStsSizeErr);

	i = 0;
	for (int z = 0; z < dstSize.depth; z++) {
		for (int y = 0; y < dstSize.height; y++) {
			for (int x = 0; x < dstSize.width; x++) {
				unsigned val = dstVol[i++];
				cout << " " << val;
			}
			cout << endl;
		}
		cout << endl << endl;
	}

}

 

0 Kudos
6 Replies
Gennady_F_Intel
Moderator
1,185 Views

thanks Ken, we will  check the problem on our side

0 Kudos
Gennady_F_Intel
Moderator
1,185 Views

Yes, we confirmed the issue with IPP v.2020 and will try to fix it into one of the next updates. We will keep this thread updated with our progress.

0 Kudos
Ken_Thornton
Beginner
1,185 Views

Thanks!

0 Kudos
Ken_Thornton
Beginner
1,162 Views

Was testing this routine again today. What it seems to do is copy an entire source volume into a destination volume. The destination volume is required to be large enough to accommodate the source volume. 

The border width arguments make sense to me as the starting voxel in the destination volume, i.e. {int leftBorder, int topBorder, int forwardBorder} should be replaced by a single argument "IpprPoint startVoxel".

My experiments show that all voxels in the destination volume not covered by the copied source volume will be set to the last argument "val".

using namespace std;
void OutputVolume(const vector<unsigned short>& vol, IpprVolume size)
{
	int num = static_cast<int>(vol.size());
	if (size.depth * size.height * size.width != num) {
		assert(false);
		return;
	}

	int i = 0;
	for (int z = 0; z < size.depth; z++) {
		cout << "Begin Slice " << z << endl;
		for (int y = 0; y < size.height; y++) {
			for (int x = 0; x < size.width; x++) {
				cout << " " << vol[i++];
			}
			cout << endl;
		}
		cout << endl << endl;
	}
}

void TestCopy()
{
	const IpprVolume srcSize = { 3,3,3 };
	const IpprVolume dstSize = { 7,7,7 };

	const int numsrc=srcSize.width * srcSize.height * srcSize.depth;
	const int numDst = dstSize.width * dstSize.height * dstSize.depth;

	const int srcStep = srcSize.width * sizeof(unsigned short);
	const int srcPlaneStep = srcSize.width * srcSize.height * sizeof(unsigned short);

	const int dstStep = dstSize.width * sizeof(unsigned short);
	const int dstPlaneStep = dstSize.width * dstSize.height * sizeof(unsigned short);

	vector<unsigned short> srcVol(numSrc), dstVol(numDst);

	for (int i = 0; i < numSrc; i++) srcVol[i] = i + 1;

	cout << "Begin outputting src volume" << endl << endl;
	OutputVolume(srcVol, srcSize);

	//ipprCopyConstBorder copies an entire source volume to a destination volume.
	//The destination volume should be large enough to accommodate the entire source volume.
	//
	//Below I interpret {leftBorder, topBorder, forwardBorder} as the starting voxel in the detination volume.
	//
	//All voxels in the destination volume not covered by the copied source volume will get the background value (last argument to the call).

	unsigned short val = 30; 

	for (int zStart = 0; zStart <= dstSize.depth - srcSize.depth; zStart++) {
		for (int yStart = 0; yStart <= dstSize.height - srcSize.height; yStart++) {
			for (int xStart = 0; xStart <= dstSize.width - srcSize.width; xStart++) {
				memset(dstVol.data(), 0, numDst * sizeof(unsigned short));

				IppStatus sts = ipprCopyConstBorder_16u_C1V(srcVol.data(), srcPlaneStep, srcStep, srcSize, dstVol.data(), dstPlaneStep, dstStep, dstSize, yStart, xStart, zStart, &val);
				assert(sts == ippStsOk);

				OutputVolume(dstVol, dstSize);

				int numBackground = 0;
				for (int i = 0; i < numDst; i++) if (dstVol[i] == val) numBackground++;
				assert(numBackground == numDst - numSrc);
			}
		}
	}

	cout << "Done" << endl;

}

 

0 Kudos
Gennady_F_Intel
Moderator
1,131 Views

Ken,

Please check the version of IPP v.2020 update 2 which claims the behavior of ipprCopyConstBorder is changed.

0 Kudos
Gennady_F_Intel
Moderator
1,129 Views

Here is the output I see with your original case which linked with version 2020 update 2.

....

End outputting src volume

Begin outputting dst volume

Status ipprCopyConstBorder_16u_C1V == -6, ippStsSizeErr: Incorrect value for data size

...

========================================================================
version of IPP is: ippSP AVX2 (l9) 2020.0.2 (r0xbb6c2c1d) 2020.0.2.-1150538723
========================================================================

0 Kudos
Reply