<?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 Thanks for the explanation! in Intel® Integrated Performance Primitives</title>
    <link>https://community.intel.com/t5/Intel-Integrated-Performance/Affine-transform-produces-invalid-outputs/m-p/1053780#M24083</link>
    <description>&lt;P&gt;Thanks for the explanation!&lt;/P&gt;</description>
    <pubDate>Thu, 03 Jul 2014 16:31:40 GMT</pubDate>
    <dc:creator>Goran_N</dc:creator>
    <dc:date>2014-07-03T16:31:40Z</dc:date>
    <item>
      <title>Affine transform produces invalid outputs</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Affine-transform-produces-invalid-outputs/m-p/1053776#M24079</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am trying to implement this simple test program in IPP. It enlarges a sample 2d matrix by 200%. This is the Matlab version:&lt;/P&gt;

&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;A = uint8([1 2 3; 4 5 6]) &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#228b22" face="Courier New" size="2"&gt;% Input matrix&lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;tform = affine2d([2 0 0; 0 2 0; 0 0 1]); &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#228b22" face="Courier New" size="2"&gt;% Define transform&lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;B = imwarp(A, tform, &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#a020f0" face="Courier New" size="2"&gt;&lt;FONT color="#a020f0" face="Courier New" size="2"&gt;&lt;FONT color="#a020f0" face="Courier New" size="2"&gt;'nearest'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;) &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#228b22" face="Courier New" size="2"&gt;% Run the transform&lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;I get this output, as expected:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;A =&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	B =&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/P&gt;

&lt;P&gt;This is IPP equivalent code:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;// ipptest.cpp : Attempt to use WarpAffine to scale an image 200%.
//

#include "ipp.h"

#include &amp;lt;iostream&amp;gt;
#include &amp;lt;iomanip&amp;gt;

typedef unsigned char byte;

int main(int argc, char* argv[])
{
&amp;nbsp;ippInit();

&amp;nbsp;// Source image and ROI
&amp;nbsp;static const int kHEIGHT = 2;
&amp;nbsp;static const int kWIDTH = 3;
&amp;nbsp;byte srcImage[kHEIGHT][kWIDTH] =
&amp;nbsp;{
&amp;nbsp;&amp;nbsp;{ 1, 2, 3 },
&amp;nbsp;&amp;nbsp;{ 4, 5, 6 }
&amp;nbsp;};

&amp;nbsp;IppiRect srcRoi;
&amp;nbsp;srcRoi.x = srcRoi.y = 0;
&amp;nbsp;srcRoi.width = kWIDTH + 1;
&amp;nbsp;srcRoi.height = kHEIGHT + 1;

&amp;nbsp;IppiSize srcSize;
&amp;nbsp;srcSize.height = kHEIGHT;
&amp;nbsp;srcSize.width = kWIDTH;


&amp;nbsp;// Destinatino image buffer and ROI
&amp;nbsp;byte destImage[kHEIGHT * 2][kWIDTH * 2];

&amp;nbsp;IppiRect destRoi;
&amp;nbsp;destRoi.x = destRoi.y = 0;
&amp;nbsp;destRoi.width = kWIDTH * 2 + 1;
&amp;nbsp;destRoi.height = kHEIGHT * 2 + 1;


&amp;nbsp;// Scale source image by 200% in both x and y
&amp;nbsp;double coeffs[2][3] =
&amp;nbsp;{
&amp;nbsp;&amp;nbsp;{ 2.0, 0.0, 0.0 },
&amp;nbsp;&amp;nbsp;{ 0.0, 2.0, 0.0 }
&amp;nbsp;};

&amp;nbsp;IppStatus stat;
&amp;nbsp;double bound[2][2];

&amp;nbsp;// Following code is from AffineTransform sample to figure out destination width and height
&amp;nbsp;stat = ippiGetAffineBound(srcRoi, bound, coeffs);
&amp;nbsp;double width = bound[1][0] - bound[0][0];
&amp;nbsp;double height = bound[1][1] - bound[0][1];

&amp;nbsp;std::cout &amp;lt;&amp;lt; "IPP sample says " &amp;lt;&amp;lt; kWIDTH &amp;lt;&amp;lt; " x " &amp;lt;&amp;lt; kHEIGHT &amp;lt;&amp;lt; " image should be scaled 200% to " &amp;lt;&amp;lt; width &amp;lt;&amp;lt; " x " &amp;lt;&amp;lt; height &amp;lt;&amp;lt; std::endl;

&amp;nbsp;// Print input image
&amp;nbsp;std::cout &amp;lt;&amp;lt; std::endl &amp;lt;&amp;lt; "Source image: " &amp;lt;&amp;lt; std::endl;
&amp;nbsp;for (int row = 0; row &amp;lt; kHEIGHT; ++row)
&amp;nbsp;{
&amp;nbsp;&amp;nbsp;for (int col = 0; col &amp;lt; kWIDTH; ++col)
&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;std::cout &amp;lt;&amp;lt; " " &amp;lt;&amp;lt; (unsigned int)srcImage[row][col];
&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;std::cout &amp;lt;&amp;lt; std::endl;
&amp;nbsp;}

&amp;nbsp;// Apply transform
&amp;nbsp;stat = ippiWarpAffine_8u_C1R(
&amp;nbsp;&amp;nbsp;(const Ipp8u*)srcImage, srcSize, kWIDTH, srcRoi,
&amp;nbsp;&amp;nbsp;(Ipp8u*)destImage, kWIDTH * 2, destRoi,
&amp;nbsp;&amp;nbsp;coeffs, IPPI_INTER_NN);

&amp;nbsp;// Print output image
&amp;nbsp;std::cout &amp;lt;&amp;lt; std::endl &amp;lt;&amp;lt; "Transformed image: " &amp;lt;&amp;lt; std::endl;
&amp;nbsp;for (int row = 0; row &amp;lt; kHEIGHT * 2; ++row)
&amp;nbsp;{
&amp;nbsp;&amp;nbsp;for (int col = 0; col &amp;lt; kWIDTH * 2; ++col)
&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;std::cout &amp;lt;&amp;lt; " " &amp;lt;&amp;lt; (unsigned int)destImage[row][col];
&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;std::cout &amp;lt;&amp;lt; std::endl;
&amp;nbsp;}

&amp;nbsp;return 0;
}

&lt;/PRE&gt;

&lt;P&gt;But what I get is this:&lt;/P&gt;

&lt;P&gt;IPP sample says 3 x 2 image should be scaled 200% to 6 x 4&lt;/P&gt;

&lt;P&gt;Source image:&lt;BR /&gt;
	&amp;nbsp;1 2 3&lt;BR /&gt;
	&amp;nbsp;4 5 6&lt;/P&gt;

&lt;P&gt;Transformed image:&lt;BR /&gt;
	&amp;nbsp;1 2 2 3 3 204&lt;BR /&gt;
	&amp;nbsp;4 5 5 6 6 204&lt;BR /&gt;
	&amp;nbsp;4 5 5 6 6 204&lt;BR /&gt;
	&amp;nbsp;204 204 204 204 204 204&lt;BR /&gt;
	Press any key to continue . . .&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	Obviously the transformed image isn't correct. Can somebody point out what's wrong, please.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jul 2014 19:57:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Affine-transform-produces-invalid-outputs/m-p/1053776#M24079</guid>
      <dc:creator>Goran_N</dc:creator>
      <dc:date>2014-07-01T19:57:02Z</dc:date>
    </item>
    <item>
      <title>Hi Goran,Which version of</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Affine-transform-produces-invalid-outputs/m-p/1053777#M24080</link>
      <description>&lt;P&gt;Hi Goran,&lt;/P&gt;
&lt;P&gt;Which version of Matlab is used?&lt;/P&gt;
&lt;P&gt;To check the transformation I implemented the following small test for Matlab.&lt;/P&gt;
&lt;P&gt;A = uint8([1 2 3; 4 5 6]) % Input matrix&lt;BR /&gt;tform=maketform('affine',[2 0 0; 0 2 0; 0 0 1]); % Define transform&lt;BR /&gt;B = imtransform(A, tform, 'nearest') % Run the transform&lt;/P&gt;
&lt;P&gt;I got this result:&lt;/P&gt;
&lt;P&gt;A =&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/P&gt;
&lt;P&gt;B =&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Regards, Valentin&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jul 2014 15:19:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Affine-transform-produces-invalid-outputs/m-p/1053777#M24080</guid>
      <dc:creator>Valentin_K_Intel</dc:creator>
      <dc:date>2014-07-02T15:19:57Z</dc:date>
    </item>
    <item>
      <title>OK, I see, I get the same</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Affine-transform-produces-invalid-outputs/m-p/1053778#M24081</link>
      <description>&lt;P&gt;OK, I see, I get the same output when I run your version, so Matlab and IPP match.&lt;/P&gt;

&lt;P&gt;But could you please explain why if I have a 2x3 matrix and enlarge it by 200% I get 3x5 output&amp;nbsp;instead of&amp;nbsp;4x6.&lt;/P&gt;

&lt;P&gt;Wouldn't it&amp;nbsp;make sense that using&amp;nbsp;[2&amp;nbsp;0;&amp;nbsp;0 2] linear transform matrix would double the size of the input matrix?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jul 2014 16:57:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Affine-transform-produces-invalid-outputs/m-p/1053778#M24081</guid>
      <dc:creator>Goran_N</dc:creator>
      <dc:date>2014-07-02T16:57:58Z</dc:date>
    </item>
    <item>
      <title>Thank you for the question.</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Affine-transform-produces-invalid-outputs/m-p/1053779#M24082</link>
      <description>&lt;P&gt;Thank you for the question. The matrix represents the image, where each pixel is a point that has own color value and (x,y) coordinates. Pixel coordinates correspond to the position of the number in the matrix. So if we have MxN matrix then the left-top point has coordinates (0,0) and the right-bottom point has coordinates (N-1,M-1). When we double increase the matrix size, we obtain a new matrix with the left-top point (0,0) and the right-bottom point ( (N-1) * 2, (M-1) * 2 ). In case of 2x3 matrix the right-bottom point has coordinates (x,y) = ( (3 - 1)*2 , (2 - 1)*2 ) = (4, 2), therefore the size of the enlarged matrix is 3x5.&lt;/P&gt;

&lt;P&gt;Regards, Valentin&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jul 2014 06:49:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Affine-transform-produces-invalid-outputs/m-p/1053779#M24082</guid>
      <dc:creator>Valentin_K_Intel</dc:creator>
      <dc:date>2014-07-03T06:49:49Z</dc:date>
    </item>
    <item>
      <title>Thanks for the explanation!</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Affine-transform-produces-invalid-outputs/m-p/1053780#M24083</link>
      <description>&lt;P&gt;Thanks for the explanation!&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jul 2014 16:31:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Affine-transform-produces-invalid-outputs/m-p/1053780#M24083</guid>
      <dc:creator>Goran_N</dc:creator>
      <dc:date>2014-07-03T16:31:40Z</dc:date>
    </item>
  </channel>
</rss>

