- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am calculation the center of mass of an image using the ippiMoments64f_16u_C1R and the ippiGetSpatialMoment_64f functions. This only works if my roi starts at 0/0.
To give a copy'n'paste example:
IppiSize roiSize;
roiSize.height = 100;
roiSize.width = 100;
IppiPoint roiOffset;
roiOffset.x = 500;
roiOffset.y = 500;
int pOffset = roiSize.width * roiOffset.y + roiOffset.x;
Ipp16u* pSrc = (Ipp16u*)i_vpSrcData + pOffset; // i_vpSrcData is a pointer to a mem block containing an image of 1344*1024 unsigned short image
int bytesPerScanLine = 2688;
IppiMomentState_64f* m_pMoments;
ippiMomentInitAlloc_64f(&m_pMoments, ippAlgHintNone);
ippiMoments64f_16u_C1R(pSrc,bytesPerScanLine, roiSize, m_pMoments);
Ipp64f m00;
ippiGetSpatialMoment_64f(m_pMoments, 0, 0, 0, roiOffset, &m00);
Ipp64f m10;
ippiGetSpatialMoment_64f(m_pMoments, 1, 0, 0, roiOffset, &m10);
Ipp64f m01;
ippiGetSpatialMoment_64f(m_pMoments, 0, 1, 0, roiOffset, &m01);
Ipp64f xCenter = (m10 / m00);
Ipp64f yCenter = (m01 / m00);
ippiMomentFree_64f(m_pMoments);
The results for xCenter and yCenter are definitely wrong even if a simple object is in the roi. Only if my roi starts at 0/0 I get correct results. Do you have any idea about what I am doing wrong?
Best regards,
Fabian
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am calculation the center of mass of an image using the ippiMoments64f_16u_C1R and the ippiGetSpatialMoment_64f functions. This only works if my roi starts at 0/0.
To give a copy'n'paste example:
IppiSize roiSize;
roiSize.height = 100;
roiSize.width = 100;
IppiPoint roiOffset;
roiOffset.x = 500;
roiOffset.y = 500;
int pOffset = roiSize.width * roiOffset.y + roiOffset.x;
Ipp16u* pSrc = (Ipp16u*)i_vpSrcData + pOffset; // i_vpSrcData is a pointer to a mem block containing an image of 1344*1024 unsigned short image
int bytesPerScanLine = 2688;
IppiMomentState_64f* m_pMoments;
ippiMomentInitAlloc_64f(&m_pMoments, ippAlgHintNone);
ippiMoments64f_16u_C1R(pSrc,bytesPerScanLine, roiSize, m_pMoments);
Ipp64f m00;
ippiGetSpatialMoment_64f(m_pMoments, 0, 0, 0, roiOffset, &m00);
Ipp64f m10;
ippiGetSpatialMoment_64f(m_pMoments, 1, 0, 0, roiOffset, &m10);
Ipp64f m01;
ippiGetSpatialMoment_64f(m_pMoments, 0, 1, 0, roiOffset, &m01);
Ipp64f xCenter = (m10 / m00);
Ipp64f yCenter = (m01 / m00);
ippiMomentFree_64f(m_pMoments);
The results for xCenter and yCenter are definitely wrong even if a simple object is in the roi. Only if my roi starts at 0/0 I get correct results. Do you have any idea about what I am doing wrong?
Best regards,
Fabian
Hi Fabian,
From what I can read, I think that the pOffset line is incorrect, you're using roiSize.width as step for your source image. It should be something like that : int pOffset = bytesPerScanLine * roiOffset.y + roiOffset.x;
That being said, another error would appear at this line : Ipp16u* pSrc = (Ipp16u*)i_vpSrcData + pOffset;
It should now be : Ipp16u* pSrc = (Ipp16u*)((Ipp8u*)i_vpSrcData + pOffset);
Regards,
Matthieu

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page