- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not getting the result that I think I should from ippiDilate_16u_C1IR with some larger kernel sizes. The following is some code which demonstrates the issue. It creates a circular dilation mask of a given radius and applies it to an isolated pixel in the image. I would expect this to result in a reproduction of the mask. (I think there is a 180 degree rotation, but this is unobservable with a circular mask.) This holds true for mask radii up to 7 but fails for 8 and above. The radius 7 mask is 15x15 and the radius 8 mask is 17x17 so the mask size crosses 256 elements between these two radii. The ippiErode_16u_C1IR does not appear to exhibit this problem.
#include
#include "ippdefs.h"
#include "ippi.h"
// Create a disk (circular) structuring element
std::vector
{
size_t nKernel = 2 * radius + 1;
std::vector
int rSquared = (int)(radius * radius);
for (size_t iRow = 0; iRow < nKernel; ++iRow)
{
int dR = (int)radius - (int)iRow;
for (size_t iCol = 0; iCol < nKernel; ++iCol)
{
int dC = (int)radius - (int)iCol;
if (dR * dR + dC * dC <= rSquared)
disk[iRow * nKernel + iCol] = 1;
}
}
return disk;
}
// Verify that the dilation of a single point centered in an image
// of the appropriate size matches the mask.
bool testDilate(size_t radius)
{
// Construct a circular mask of the specified size.
size_t maskSize = 2 * radius + 1;
std::vector
// Create an Ipp image to perform the dilation in.
size_t paddedImageSize = maskSize + 2 * radius;
int stepBytes = 0;
Ipp16u* data = ippiMalloc_16u_C1((int)paddedImageSize, (int)paddedImageSize, &stepBytes);
size_t stepElements = (size_t)stepBytes / sizeof(Ipp16u);
// Set the ROI to the entire image and then set the image to 0.
IppiSize roiSize = {(int)paddedImageSize, (int)paddedImageSize};
Ipp16u* roiStart = data;
ippiSet_16u_C1R(0, roiStart, stepBytes, roiSize);
// Set the roi to a centered square of the same size as the mask.
roiStart = data + radius * stepElements + radius;
roiSize.width = (int)maskSize;
roiSize.height = (int)maskSize;
// Set the center pixel of the image to 1.
roiStart[radius * stepElements + radius] = 1;
// Dilate the image using the mask.
IppiSize ippiMaskSize = {(int)maskSize, (int)maskSize};
IppiPoint anchor = {(int)radius, (int)radius};
ippiDilate_16u_C1IR(roiStart, stepBytes, roiSize, &mask[0], ippiMaskSize, anchor);
// Check that each pixel in the roi matches the mask.
bool good = true;
for (size_t iRow = 0; iRow < maskSize; ++iRow)
{
for (size_t iCol = 0; iCol < maskSize; ++iCol)
{
if (mask[iRow * maskSize + iCol] != roiStart[iRow * stepElements + iCol])
{
good = false;
}
}
}
// Cleanup
if (data != 0)
{
ippiFree(data);
data = 0;
roiStart = 0;
}
return good;
}
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Vladimir
We are using IPP version 5.3.85 on Windows XP SP2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Vladimir
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page