<?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 Converting float matrix to rgb in Intel® Integrated Performance Primitives</title>
    <link>https://community.intel.com/t5/Intel-Integrated-Performance/Converting-float-matrix-to-rgb/m-p/1147970#M26263</link>
    <description>&lt;P&gt;I have the following code written to have IPP resize my matrix:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include "ipp_mx.h"
#include "ipp.h"

#include "stdafx.h"
#define IPPCALL(name) name

int main()
{
    IppiSize srcSize = { 3,3 };
    float srcImage[9] =
    { 20, 40, 30,
      35, 55, 70,
      100, 30, 20 };
    float* src = new float[srcSize.width*srcSize.height];
    for (int i = 0; i &amp;lt; srcSize.width*srcSize.height; i++) {
        src&lt;I&gt; = srcImage&lt;I&gt;;
    }
    double xFactor = 10; double yFactor = 10;

    int numChannels = 1;
    int bytesPerPixel = 4;
    int srcStep = srcSize.width*bytesPerPixel*numChannels;
    IppiRect srcRoi = { 0, 0, srcSize.width, srcSize.width };

    float* dest = new float[srcSize.width*srcSize.height*xFactor*yFactor];
    IppiSize destSize = { srcSize.width*xFactor, srcSize.height*yFactor };
    int destStep = destSize.width*bytesPerPixel*numChannels;
    IppiRect destRoi = { 0, 0, destSize.width, destSize.width };

    double xShift = 0; double yShift = 0;

    int interpolation = 1; //nearest neighbour

    int bufSize;
    IPPCALL(ippiResizeGetBufSize)(srcRoi, destRoi, 1, interpolation, &amp;amp;bufSize);
    unsigned char* buffer = new unsigned char[bufSize];

    IPPCALL(ippiResizeSqrPixel_32f_C1R)(src, srcSize, srcStep, srcRoi, dest, destStep, destRoi, xFactor, yFactor, xShift, yShift, interpolation, buffer);
    return 0;
}&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;Is there an IPP function I can use that now converts this float matrix dest to an RGB24 format, given a colour map?&lt;/P&gt;

&lt;P&gt;I know I can do it by hand in a for loop, but the raw matrices I want to work with are much larger and for loops may not cut it.&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jul 2017 13:13:49 GMT</pubDate>
    <dc:creator>John_M_3</dc:creator>
    <dc:date>2017-07-14T13:13:49Z</dc:date>
    <item>
      <title>Converting float matrix to rgb</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Converting-float-matrix-to-rgb/m-p/1147970#M26263</link>
      <description>&lt;P&gt;I have the following code written to have IPP resize my matrix:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include "ipp_mx.h"
#include "ipp.h"

#include "stdafx.h"
#define IPPCALL(name) name

int main()
{
    IppiSize srcSize = { 3,3 };
    float srcImage[9] =
    { 20, 40, 30,
      35, 55, 70,
      100, 30, 20 };
    float* src = new float[srcSize.width*srcSize.height];
    for (int i = 0; i &amp;lt; srcSize.width*srcSize.height; i++) {
        src&lt;I&gt; = srcImage&lt;I&gt;;
    }
    double xFactor = 10; double yFactor = 10;

    int numChannels = 1;
    int bytesPerPixel = 4;
    int srcStep = srcSize.width*bytesPerPixel*numChannels;
    IppiRect srcRoi = { 0, 0, srcSize.width, srcSize.width };

    float* dest = new float[srcSize.width*srcSize.height*xFactor*yFactor];
    IppiSize destSize = { srcSize.width*xFactor, srcSize.height*yFactor };
    int destStep = destSize.width*bytesPerPixel*numChannels;
    IppiRect destRoi = { 0, 0, destSize.width, destSize.width };

    double xShift = 0; double yShift = 0;

    int interpolation = 1; //nearest neighbour

    int bufSize;
    IPPCALL(ippiResizeGetBufSize)(srcRoi, destRoi, 1, interpolation, &amp;amp;bufSize);
    unsigned char* buffer = new unsigned char[bufSize];

    IPPCALL(ippiResizeSqrPixel_32f_C1R)(src, srcSize, srcStep, srcRoi, dest, destStep, destRoi, xFactor, yFactor, xShift, yShift, interpolation, buffer);
    return 0;
}&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;Is there an IPP function I can use that now converts this float matrix dest to an RGB24 format, given a colour map?&lt;/P&gt;

&lt;P&gt;I know I can do it by hand in a for loop, but the raw matrices I want to work with are much larger and for loops may not cut it.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2017 13:13:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Converting-float-matrix-to-rgb/m-p/1147970#M26263</guid>
      <dc:creator>John_M_3</dc:creator>
      <dc:date>2017-07-14T13:13:49Z</dc:date>
    </item>
    <item>
      <title>Hi,</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Converting-float-matrix-to-rgb/m-p/1147971#M26264</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
	Can you suggest how do you want to perform the conversion?&amp;nbsp;&amp;nbsp; Intel IPP provides one mapping function here:&lt;BR /&gt;
	&lt;A href="https://software.intel.com/en-us/node/504062"&gt;https://software.intel.com/en-us/node/504062&lt;/A&gt;&lt;BR /&gt;
	Can this function be used there?&amp;nbsp;&lt;BR /&gt;
	If the code just want to convert some data types, it can use the&amp;nbsp; ippiConvert functions:&lt;BR /&gt;
	&lt;A href="https://software.intel.com/en-us/node/503746"&gt;https://software.intel.com/en-us/node/503746&lt;/A&gt;&lt;BR /&gt;
	&lt;BR /&gt;
	regards,&lt;BR /&gt;
	Chao&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 02:53:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Converting-float-matrix-to-rgb/m-p/1147971#M26264</guid>
      <dc:creator>Chao_Y_Intel</dc:creator>
      <dc:date>2017-07-31T02:53:33Z</dc:date>
    </item>
    <item>
      <title>Hi,</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Converting-float-matrix-to-rgb/m-p/1147972#M26265</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;How I wanted to perform the conversion was, given a float value and an array that maps value ranges to RGB colours, convert the float value to an RGB colour.&lt;/P&gt;

&lt;P&gt;What I ended up doing was:&lt;/P&gt;

&lt;OL&gt;
	&lt;LI&gt;ippiConvert_32f8u_C1R - convert the float image to char by truncating as in my case I don't need the decimal precision as the colour steps are integer.&lt;/LI&gt;
	&lt;LI&gt;ippiGrayToRGB_8u_C1C3R - convert the float to RGB.&lt;/LI&gt;
	&lt;LI&gt;ippiLUTPallete_8uC3R - given a palette, transform the gray values into colour.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Say a pixel value is 20.5.&lt;/P&gt;

&lt;OL&gt;
	&lt;LI&gt;ippiConvert_328u_C1R converts it to 20.&lt;/LI&gt;
	&lt;LI&gt;ippiGrayToRGB_8u_C1C3R converts the pixel to 3 channels of 20 red, 20 green, 20 blue.&lt;/LI&gt;
	&lt;LI&gt;Construct a palette that maps 20 red, 20 green, 20 blue to, say, 0 red, 0 green, 255 blue.&lt;/LI&gt;
	&lt;LI&gt;Pass the RGB converted pixel and the pallet to ippiLUTPallete_8uC3R which makes the proper transformation to 0, 0, 255.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 13:19:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Converting-float-matrix-to-rgb/m-p/1147972#M26265</guid>
      <dc:creator>John_M_3</dc:creator>
      <dc:date>2017-07-31T13:19:00Z</dc:date>
    </item>
  </channel>
</rss>

