<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic ROI problem with ippiMoments64f in Intel® Integrated Performance Primitives</title>
    <link>https://community.intel.com/t5/Intel-Integrated-Performance/ROI-problem-with-ippiMoments64f/m-p/877865#M9797</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;To give a copy'n'paste example:&lt;/P&gt;
&lt;P&gt;IppiSize roiSize;&lt;BR /&gt; roiSize.height = 100;&lt;BR /&gt; roiSize.width = 100;&lt;BR /&gt; IppiPoint roiOffset;&lt;BR /&gt; roiOffset.x = 500;&lt;BR /&gt; roiOffset.y = 500;&lt;BR /&gt; int pOffset = roiSize.width * roiOffset.y + roiOffset.x;&lt;BR /&gt; Ipp16u* pSrc = (Ipp16u*)i_vpSrcData + pOffset; // i_vpSrcData is a pointer to a mem block containing an image of 1344*1024 unsigned short image&lt;BR /&gt; int bytesPerScanLine = 2688;&lt;BR /&gt; IppiMomentState_64f* m_pMoments;&lt;BR /&gt; ippiMomentInitAlloc_64f(&amp;amp;m_pMoments, ippAlgHintNone);&lt;BR /&gt; ippiMoments64f_16u_C1R(pSrc,bytesPerScanLine, roiSize, m_pMoments);&lt;BR /&gt;&lt;BR /&gt; Ipp64f m00;&lt;BR /&gt; ippiGetSpatialMoment_64f(m_pMoments, 0, 0, 0, roiOffset, &amp;amp;m00);&lt;BR /&gt; Ipp64f m10;&lt;BR /&gt; ippiGetSpatialMoment_64f(m_pMoments, 1, 0, 0, roiOffset, &amp;amp;m10);&lt;BR /&gt; Ipp64f m01; &lt;BR /&gt; ippiGetSpatialMoment_64f(m_pMoments, 0, 1, 0, roiOffset, &amp;amp;m01);&lt;BR /&gt;&lt;BR /&gt; Ipp64f xCenter = (m10 / m00); &lt;BR /&gt; Ipp64f yCenter = (m01 / m00); &lt;BR /&gt; &lt;BR /&gt; ippiMomentFree_64f(m_pMoments);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;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?&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Fabian&lt;/P&gt;</description>
    <pubDate>Mon, 22 Dec 2008 08:44:50 GMT</pubDate>
    <dc:creator>haerle1</dc:creator>
    <dc:date>2008-12-22T08:44:50Z</dc:date>
    <item>
      <title>ROI problem with ippiMoments64f</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/ROI-problem-with-ippiMoments64f/m-p/877865#M9797</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;To give a copy'n'paste example:&lt;/P&gt;
&lt;P&gt;IppiSize roiSize;&lt;BR /&gt; roiSize.height = 100;&lt;BR /&gt; roiSize.width = 100;&lt;BR /&gt; IppiPoint roiOffset;&lt;BR /&gt; roiOffset.x = 500;&lt;BR /&gt; roiOffset.y = 500;&lt;BR /&gt; int pOffset = roiSize.width * roiOffset.y + roiOffset.x;&lt;BR /&gt; Ipp16u* pSrc = (Ipp16u*)i_vpSrcData + pOffset; // i_vpSrcData is a pointer to a mem block containing an image of 1344*1024 unsigned short image&lt;BR /&gt; int bytesPerScanLine = 2688;&lt;BR /&gt; IppiMomentState_64f* m_pMoments;&lt;BR /&gt; ippiMomentInitAlloc_64f(&amp;amp;m_pMoments, ippAlgHintNone);&lt;BR /&gt; ippiMoments64f_16u_C1R(pSrc,bytesPerScanLine, roiSize, m_pMoments);&lt;BR /&gt;&lt;BR /&gt; Ipp64f m00;&lt;BR /&gt; ippiGetSpatialMoment_64f(m_pMoments, 0, 0, 0, roiOffset, &amp;amp;m00);&lt;BR /&gt; Ipp64f m10;&lt;BR /&gt; ippiGetSpatialMoment_64f(m_pMoments, 1, 0, 0, roiOffset, &amp;amp;m10);&lt;BR /&gt; Ipp64f m01; &lt;BR /&gt; ippiGetSpatialMoment_64f(m_pMoments, 0, 1, 0, roiOffset, &amp;amp;m01);&lt;BR /&gt;&lt;BR /&gt; Ipp64f xCenter = (m10 / m00); &lt;BR /&gt; Ipp64f yCenter = (m01 / m00); &lt;BR /&gt; &lt;BR /&gt; ippiMomentFree_64f(m_pMoments);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;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?&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Fabian&lt;/P&gt;</description>
      <pubDate>Mon, 22 Dec 2008 08:44:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/ROI-problem-with-ippiMoments64f/m-p/877865#M9797</guid>
      <dc:creator>haerle1</dc:creator>
      <dc:date>2008-12-22T08:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: ROI problem with ippiMoments64f</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/ROI-problem-with-ippiMoments64f/m-p/877866#M9798</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/301943"&gt;haerle@embl.de&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;To give a copy'n'paste example:&lt;/P&gt;
&lt;P&gt;IppiSize roiSize;&lt;BR /&gt; roiSize.height = 100;&lt;BR /&gt; roiSize.width = 100;&lt;BR /&gt; IppiPoint roiOffset;&lt;BR /&gt; roiOffset.x = 500;&lt;BR /&gt; roiOffset.y = 500;&lt;BR /&gt; int pOffset = roiSize.width * roiOffset.y + roiOffset.x;&lt;BR /&gt; Ipp16u* pSrc = (Ipp16u*)i_vpSrcData + pOffset; // i_vpSrcData is a pointer to a mem block containing an image of 1344*1024 unsigned short image&lt;BR /&gt; int bytesPerScanLine = 2688;&lt;BR /&gt; IppiMomentState_64f* m_pMoments;&lt;BR /&gt; ippiMomentInitAlloc_64f(&amp;amp;m_pMoments, ippAlgHintNone);&lt;BR /&gt; ippiMoments64f_16u_C1R(pSrc,bytesPerScanLine, roiSize, m_pMoments);&lt;BR /&gt;&lt;BR /&gt; Ipp64f m00;&lt;BR /&gt; ippiGetSpatialMoment_64f(m_pMoments, 0, 0, 0, roiOffset, &amp;amp;m00);&lt;BR /&gt; Ipp64f m10;&lt;BR /&gt; ippiGetSpatialMoment_64f(m_pMoments, 1, 0, 0, roiOffset, &amp;amp;m10);&lt;BR /&gt; Ipp64f m01; &lt;BR /&gt; ippiGetSpatialMoment_64f(m_pMoments, 0, 1, 0, roiOffset, &amp;amp;m01);&lt;BR /&gt;&lt;BR /&gt; Ipp64f xCenter = (m10 / m00); &lt;BR /&gt; Ipp64f yCenter = (m01 / m00); &lt;BR /&gt; &lt;BR /&gt; ippiMomentFree_64f(m_pMoments);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;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?&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Fabian&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hi Fabian,&lt;/P&gt;
&lt;P&gt;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 = &lt;EM&gt;&lt;EM&gt;bytesPerScanLine&lt;/EM&gt;&lt;/EM&gt; * roiOffset.y + roiOffset.x;&lt;/P&gt;
&lt;P&gt;That being said, another error would appear at this line : &lt;EM&gt;&lt;EM&gt;Ipp16u* pSrc = (Ipp16u*)i_vpSrcData + pOffset;&lt;/EM&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;It should now be &lt;EM&gt;&lt;EM&gt;: &lt;/EM&gt;&lt;/EM&gt;&lt;EM&gt;&lt;EM&gt;Ipp16u* pSrc = (&lt;/EM&gt;&lt;/EM&gt;&lt;EM&gt;&lt;EM&gt;Ipp16u*)&lt;/EM&gt;&lt;/EM&gt;&lt;EM&gt;&lt;EM&gt;((Ipp8u*)i_vpSrcData + pOffset);&lt;/EM&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Matthieu&lt;EM&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Dec 2008 09:03:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/ROI-problem-with-ippiMoments64f/m-p/877866#M9798</guid>
      <dc:creator>matthieu_darbois</dc:creator>
      <dc:date>2008-12-22T09:03:01Z</dc:date>
    </item>
  </channel>
</rss>

