- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Need to use,
ippiFilterPrewittHorizBorder_32f_C1R,
tried it one of sample program, but it always gives One or more input pointers are NULL error.
Validated src & dst images & roi as well.
int main() {
// Define image dimensions
const int width = 512;
const int height = 512;
// Allocate memory for source and destination images
Ipp32f* psrc=new (std::nothrow) Ipp32f[width * height]; // Source image (grayscale)
Ipp32f* pDst = new (std::nothrow) Ipp32f[width * height]; // Destination image (filtered)
// Check for memory allocation success
if (psrc== nullptr) {
std::cerr << "Memory allocation for source image failed!" << std::endl;
return -1;
}
if (pDst == nullptr) {
std::cerr << "Memory allocation for destination image failed!" << std::endl;
delete[] pSrc; // Clean up previously allocated memory
return -1;
}
// Initialize source image with some data (example: simple gradient)
for (int i = 0; i < height; ++i) {
for (int j = 0; j < width; ++j) {
pSrc[i * width + j] = static_cast<Ipp32f>((j + i) % 256); // Simple data initialization
}
}
// Define region of interest
IppiSize roiSize = {width, height}; // Full image
int srcStep = width * sizeof(Ipp32f); // Step size in bytes for source image
int dstStep = width * sizeof(Ipp32f); // Step size in bytes for destination image
// Check ROI dimensions and step sizes
std::cout << "ROI Size: " << roiSize.width << "x" << roiSize.height << std::endl;
std::cout << "Source Step: " << srcStep << ", Destination Step: " << dstStep << std::endl;
// Apply the Prewitt horizontal filter
IppStatus status = ippiFilterPrewittHorizBorder_32f_C1R(
pSrc, // Source pointer
srcStep, // Source step
pDst, // Destination pointer
dstStep, // Destination step
roiSize, // ROI size
ippMskSize3x3,
ippBorderConst, // Border type
0.0f, // Constant border value
nullptr
);
// Check for errors
if (status != ippStsNoErr) {
std::cerr << "Error applying Prewitt horizontal filter: " << status << std::endl;
// Output additional debugging information
switch (status) {
case ippStsNullPtrErr:
std::cerr << "One or more input pointers are NULL." << std::endl;
break;
case ippStsSizeErr:
std::cerr << "ROI size is incorrect." << std::endl;
break;
case ippStsStepErr:
std::cerr << "Step size is incorrect." << std::endl;
break;
default:
std::cerr << "An unexpected error occurred." << std::endl;
}
} else {
std::cout << "Prewitt horizontal filter applied successfully!" << std::endl;
}
// Clean up
delete[] pSrc;
delete[] pDst;
return 0;
}
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
have you got chance to check our sample at here?
Before using this function, y, it need to allocate a buffer, it needs to use FilterPrewittHorizBorderGetBufferSize to get the buffer size, and then use provide the buffer for this function. In the code before, only a NULL pointer is provided.
thanks,
Chao
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page