- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I need to use morphology operations from IPP. From the manual I got (page 8-13 of image and viedo library) it seems like I need to call ippiMorphologyInitAlloc.
Could someone help me pointing out where's wrong? The manual is short of any example on this function.
I also did a search in this forum.In Jan 2004 someone asked hot to use dilate&erode functions. There he/she didn't use ippiMorphologyInitAlloc at all.
So my second question is: is it necessary to call ippiMorphologyInitAlloc for all morphological operations?
Thanks a lot
//
// C code fragment that initialzes the morphology operation.
//
//----------------------------------------------------------------------------
IppiSize seSize = { 3, 3 };
IppiPoint seAnchor = { 1, 1 }; // se's anchor point is the center. (0-based)
IppiMorphState** ppMorphState = NULL; // internal state structure.
IppStatus status;
IppiPoint seAnchor = { 1, 1 }; // se's anchor point is the center. (0-based)
IppiMorphState** ppMorphState = NULL; // internal state structure.
IppStatus status;
//
// initialize morphology operation
//
status = ippiMorphologyInitAlloc(
imageDim, // int roiWidth.ROI width in pixels.
8u, // IppDataType dataType
1, // int channels. num of channels in image.
seSize, // size of structuring element.
seAnchor, // anchor point of the se.
ippiShapeCross, // structuring element shape.
NULL, // int* pElData not considered.
ppMorphState );
if( status != ippStsNoErr )
{
printf(" ippiMorphologyInitAlloc() failed with error %d: %s!", status, ippCoreGetStatusString( status ) );
}
//----------------------------------------------------------------------------
//
// The error message is:
//
// ippiMorphologyInitAlloc() failed with error -8: Null pointer error!
// The error message is:
//
// ippiMorphologyInitAlloc() failed with error -8: Null pointer error!
Link Copied
10 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
could you please specify what version of IPP do you use and for which platform?
Regards,
Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Vladimir,
Thanks for asking. I have solved the issue. I'm using Ipp ver. 4.1. It turned out to be that I don't need to call ippiMorphologyInitAlloc and I used dilate & erode directly.
Even though my code works now, I still noticed a difference between in-line and not-in-line dilate. Specifically, not in-line dilate gives larger spike artifacts along the border. ( I shunk the roi 6 pixels less than the image size already)
Anyway, glad to get IPP dilate&erode work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, it is great that you solved this issue, after consulting with engineers I can confirm that you choose correct way - no InitAlloc is required.
For example
Code:
/// Dilate a dot IppStatus dilate( void ) { Ipp8u x[7*5]; IppiSize roi = {7,5}; ippiSet_8u_C1R( 0, x, 7, roi ); x[2*7+3] = 1; roi.width = roi.width - 2; roi.height = roi.height - 2; return ippiDilate3x3_8u_C1IR( x+7+1, 7, roi ); } /* 00 00 00 00 00 00 00 00 00 01 01 01 00 00 00 00 01 01 01 00 00 00 00 01 01 01 00 00 00 00 00 00 00 00 00 */
Reagrding difference in inline and not-inline implementation I will pass this info to developers.
Regards,
Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi!
You only need MorphologyInitAlloc for
ippiDilateStrip_Rect and ippiErodeStrip_Rect
ippiDilateStrip_Cross and ippiErodeStrip_Cross
ippiDilateStrip_Ellipse and ippiErodeStrip_Ellipse
ippiDilateStrip and ippiErodeStrip.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
RIght, that's correct
Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
IPP contains several morphology functions:
- erode/dilate with arbitraryvs rectangularSE. First are Erode/Dilate, Erode DilateErodeBorderReplicate, second areErode/Dilate3x3, FilterMin/Max, FilterMin/MaxBorderReplicate.
- functions for images with the border pixelsin memory (src and dst of different size) vs for images of the same size (with suffix BorderReplicate)
Alexander
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Recently, I am using the IPP morphology functions. I got 3 questions:
1. In ver 4.1, IPP is still using the elShape (ippiShapeRect, ippiShapeCross, ippiShapeEllipse and ippiShapeCustom) to define the shape of structuring element. But why in the ver 5.0 thereafter, IPP removed those shapes?
2. After removing the elShape, how can I use the MorphologyInitAlloc and MorphologyInit to initialize a structuring element?
3. How to use the function: MorphologyGetSize to obtain the size of morphollgy state structure? Can you provide some sample code (C++)?
Thanks
Recently, I am using the IPP morphology functions. I got 3 questions:
1. In ver 4.1, IPP is still using the elShape (ippiShapeRect, ippiShapeCross, ippiShapeEllipse and ippiShapeCustom) to define the shape of structuring element. But why in the ver 5.0 thereafter, IPP removed those shapes?
2. After removing the elShape, how can I use the MorphologyInitAlloc and MorphologyInit to initialize a structuring element?
3. How to use the function: MorphologyGetSize to obtain the size of morphollgy state structure? Can you provide some sample code (C++)?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
In IPP 5.0 the interface of morphology function is changed. The reason was that modes (START, MIDDLE, END, WHOLE) had not really supported. Functions for Elliple and Cross worked completely the same as for arbitrary SE.
In IPP 5.0 there exist the functions for arbitrary SE and for special kernels:
ippiErode/Dilate - arbitrary SE, border pixels in the memory,
ippiErode/Dilate3x3 - 3x3 rectangular SE, border pixels in the memory,
ippiFilterMin/Max - rectangular SE, border pixels in the memory,
ippiMorphologyInitAlloc or
ippiMorphologyGetSize + malloc + ippiMorphologyInit - initialization of a structure for erode/dilate with arbitrary SE. Rectangular and symmetric SE are detected and are processed faster while eroding or dilating. Once initialized the structure can be used for many erode/dilate operations with the same SE
ippiErode/DilateBorder - morphology using preallocated structute, no border pixels in the memory,
Advanced morphology operationd (Open,Close,Tophat, Blackhat, Gradient), no border pixels in the memory,
Alexander
ippiFilterMin/MaxBorder - morphology with rectangular SE, no border pixels in the memory,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I've got a little problem with ippiMorphologyInitAlloc and ippiMorphologyFree.
I allocate and initialize the IppiMorphState structure with ippiMorphologyInitAlloc. Then I proceed an erosion with ippiErodeBorderReplicate and a dilatation with ippiDilateBorderReplicate. Finally I try to free the memory used by the structure with ippiMorphologyFree. The problem is that my program crashes on the line where it tries to free the memory with ippiMorphologyFree.
Here is the code I use :
----------------------------------------------------------------
#define LARGEUR 384
#define HAUTEUR 288
typedef unsigned char BYTE;
[...]
I allocate and initialize the IppiMorphState structure with ippiMorphologyInitAlloc. Then I proceed an erosion with ippiErodeBorderReplicate and a dilatation with ippiDilateBorderReplicate. Finally I try to free the memory used by the structure with ippiMorphologyFree. The problem is that my program crashes on the line where it tries to free the memory with ippiMorphologyFree.
Here is the code I use :
----------------------------------------------------------------
#define LARGEUR 384
#define HAUTEUR 288
typedef unsigned char BYTE;
[...]
void X::Y(BYTE ** Image)
{
IppiSize roiSize = {LARGEUR, HAUTEUR};
IppiMorphState* pState;
IppiPoint elAnchor;
Ipp8u*pMask;
IppiSize elSize;
elSize.height = 3;
elSize.width = 3;
elAnchor.x = 1;
elAnchor.y = 1;
pMask = (Ipp8u*)malloc(9*sizeof(Ipp8u));
pMask[0] = 1;
pMask[1] = 1;
pMask[2] = 1;
pMask[3] = 1;
pMask[4] = 1;
pMask[5] = 1;
pMask[6] = 1;
pMask[7] = 1;
pMask[8] = 1;
BYTE * Temp = (BYTE*)malloc(LARGEUR*HAUTEUR*sizeof(BYTE));
ippiMorphologyInitAlloc_8u_C1R(LARGEUR,pMask,elSize,elAnchor,&pState);
ippiErodeBorderReplicate_8u_C1R(*Image,LARGEUR,Temp,LARGEUR,roiSize,ippBorderRepl,pState);
ippiDilateBorderReplicate_8u_C1R(Temp,LARGEUR,*Image,LARGEUR,roiSize,ippBorderRepl,pState);
ippiMorphologyFree(pState);
free(Temp);
free(pMask);
}
-------------------------------------------------------
Image is ok.
I use the IPP 5.1.
Can someone help me ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
ppMorph is the pointer to the variable for the pointer to the morphology structure. You should provide the memory where InitAlloc function could return it.
Change to
IppiMorphState* pMorphState; // internal state structure
status = ippiMorphologyInitAlloc(
imageDim, // int roiWidth.ROI width in pixels.
8u, // IppDataType dataType
1, // int channels. num of channels in image.
seSize, // size of structuring element.
seAnchor, // anchor point of the se.
ippiShapeCross, // structuring element shape.
NULL, // int* pElData not considered.
&pMorphState );
Morphology with the rectangular kernel can be done by ippiFilterMin/Max(BorderReplicate) functions
Thanks,
Alexander

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