<?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 UIC Jpeg encoding color distortion in Intel® Integrated Performance Primitives</title>
    <link>https://community.intel.com/t5/Intel-Integrated-Performance/UIC-Jpeg-encoding-color-distortion/m-p/950295#M18567</link>
    <description>&lt;P&gt;I am trying to encode raw bitmap pixel data to a jpeg encoded equivalent. I am able to compile the uic example given (uic_transcoder_con) and everything is working fine. When I try to implement the sample into my code however I am getting a color distorted version of my original image. I have the same encoding parameters as the example and have tried using other combinations but to no success. I have attached a sample image I am trying to encode and the resulting jpeg I get after the encoding. Here is a snippet of the code I am trying out.&lt;/P&gt;

&lt;P&gt;.....&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;
		//BEGIN ENCODING PROCESS
		ExcStatus excStatus = ExcStatusOk;
		JPEGEncoder encoder;
		Image imageCn;
		ImageDataPtr dataPtr;
		ImageDataOrder dataOrder;
		Rect refgrid;
		RectSize size;
		Point origin;
		ImageSamplingGeometry geometry;
		CMemBuffOutput* out = new CMemBuffOutput(); 
		BaseStream::TSize mosize;
		Ipp8u* buf;

		int nOfComponents = numSamples;

		//int du = ((8&amp;amp;255)+7)/8 ;
		int step = dstWidth * nOfComponents; 

		mosize = step*dstHeight*2; 

		buf = (Ipp8u*)ippMalloc((int)mosize);
		if(0 == buf)
			return 1;

		//open the output stream
		out-&amp;gt;Open(buf, (int)mosize);
	
		excStatus = encoder.SetNOfThreads(1);
		if(UIC::ExcStatusOk != status)
			return 1;

		//initialize encoder
		excStatus = encoder.Init();
		if(UIC::ExcStatusOk != status)
			return 1;

		//attach output stream to encoder
		excStatus = encoder.AttachStream(*out);
		if(ExcStatusOk != excStatus)
			return 1;

		dataOrder.SetDataType(T8u);

		origin.SetX(0);
		origin.SetY(0);

		size.SetWidth(dstWidth);
		size.SetHeight(dstHeight);
		
		refgrid.SetOrigin(origin);
		refgrid.SetSize(size);
		
		geometry.SetRefGridRect(refgrid);
		geometry.ReAlloc(nOfComponents);
		geometry.SetEnumSampling(S444);

		dataOrder.ReAlloc(Interleaved, nOfComponents);
		dataOrder.PixelStep()[0] = nOfComponents;
		dataOrder.LineStep() [0] = step;

		imageCn.ColorSpec().ReAlloc(nOfComponents);
		imageCn.ColorSpec().SetColorSpecMethod(Enumerated);
		imageCn.ColorSpec().SetComponentToColorMap(Direct);

		for(int i = 0; i &amp;lt; nOfComponents; i++)
		{
			imageCn.ColorSpec().DataRange()&lt;I&gt;.SetAsRange8u(255);
		}

		imageCn.ColorSpec().SetEnumColorSpace(ImageEnumColorSpace::RGBA);
		
		//set pointer equal to resized pixel data (NOTE: imgResizeBuf is an unsigned char* )
		dataPtr.p8u = imgResizeBuf;

		//set the buffer of the image
		imageCn.Buffer().Attach(&amp;amp;dataPtr,dataOrder,geometry);
	
		if(ExcStatusOk != encoder.AttachImage(imageCn))
		return 1;
		
		//initialize encoding params
		JPEGEncoderParamsBAS je_params;
		
		je_params.SetColor((JCOLOR)ImageEnumColorSpace::YCbCr);
		je_params.SetSampling(JSS::JS_444);
		je_params.SetRestartInterval(1);
		je_params.SetHuffmanOption(0);
		je_params.SetQuality(100);
		je_params.SetThreading((JTMODE)1);
		
		if(ExcStatusOk != encoder.SetParams(je_params))
			return 1;


		excStatus = encoder.WriteHeader();
		if(ExcStatusOk != excStatus)
			return 1;

		//encode the data
		excStatus = encoder.WriteData();
		if(ExcStatusOk != excStatus)
			return 1;
		&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 17 Mar 2014 12:48:41 GMT</pubDate>
    <dc:creator>Matthew_C_1</dc:creator>
    <dc:date>2014-03-17T12:48:41Z</dc:date>
    <item>
      <title>UIC Jpeg encoding color distortion</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/UIC-Jpeg-encoding-color-distortion/m-p/950295#M18567</link>
      <description>&lt;P&gt;I am trying to encode raw bitmap pixel data to a jpeg encoded equivalent. I am able to compile the uic example given (uic_transcoder_con) and everything is working fine. When I try to implement the sample into my code however I am getting a color distorted version of my original image. I have the same encoding parameters as the example and have tried using other combinations but to no success. I have attached a sample image I am trying to encode and the resulting jpeg I get after the encoding. Here is a snippet of the code I am trying out.&lt;/P&gt;

&lt;P&gt;.....&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;
		//BEGIN ENCODING PROCESS
		ExcStatus excStatus = ExcStatusOk;
		JPEGEncoder encoder;
		Image imageCn;
		ImageDataPtr dataPtr;
		ImageDataOrder dataOrder;
		Rect refgrid;
		RectSize size;
		Point origin;
		ImageSamplingGeometry geometry;
		CMemBuffOutput* out = new CMemBuffOutput(); 
		BaseStream::TSize mosize;
		Ipp8u* buf;

		int nOfComponents = numSamples;

		//int du = ((8&amp;amp;255)+7)/8 ;
		int step = dstWidth * nOfComponents; 

		mosize = step*dstHeight*2; 

		buf = (Ipp8u*)ippMalloc((int)mosize);
		if(0 == buf)
			return 1;

		//open the output stream
		out-&amp;gt;Open(buf, (int)mosize);
	
		excStatus = encoder.SetNOfThreads(1);
		if(UIC::ExcStatusOk != status)
			return 1;

		//initialize encoder
		excStatus = encoder.Init();
		if(UIC::ExcStatusOk != status)
			return 1;

		//attach output stream to encoder
		excStatus = encoder.AttachStream(*out);
		if(ExcStatusOk != excStatus)
			return 1;

		dataOrder.SetDataType(T8u);

		origin.SetX(0);
		origin.SetY(0);

		size.SetWidth(dstWidth);
		size.SetHeight(dstHeight);
		
		refgrid.SetOrigin(origin);
		refgrid.SetSize(size);
		
		geometry.SetRefGridRect(refgrid);
		geometry.ReAlloc(nOfComponents);
		geometry.SetEnumSampling(S444);

		dataOrder.ReAlloc(Interleaved, nOfComponents);
		dataOrder.PixelStep()[0] = nOfComponents;
		dataOrder.LineStep() [0] = step;

		imageCn.ColorSpec().ReAlloc(nOfComponents);
		imageCn.ColorSpec().SetColorSpecMethod(Enumerated);
		imageCn.ColorSpec().SetComponentToColorMap(Direct);

		for(int i = 0; i &amp;lt; nOfComponents; i++)
		{
			imageCn.ColorSpec().DataRange()&lt;I&gt;.SetAsRange8u(255);
		}

		imageCn.ColorSpec().SetEnumColorSpace(ImageEnumColorSpace::RGBA);
		
		//set pointer equal to resized pixel data (NOTE: imgResizeBuf is an unsigned char* )
		dataPtr.p8u = imgResizeBuf;

		//set the buffer of the image
		imageCn.Buffer().Attach(&amp;amp;dataPtr,dataOrder,geometry);
	
		if(ExcStatusOk != encoder.AttachImage(imageCn))
		return 1;
		
		//initialize encoding params
		JPEGEncoderParamsBAS je_params;
		
		je_params.SetColor((JCOLOR)ImageEnumColorSpace::YCbCr);
		je_params.SetSampling(JSS::JS_444);
		je_params.SetRestartInterval(1);
		je_params.SetHuffmanOption(0);
		je_params.SetQuality(100);
		je_params.SetThreading((JTMODE)1);
		
		if(ExcStatusOk != encoder.SetParams(je_params))
			return 1;


		excStatus = encoder.WriteHeader();
		if(ExcStatusOk != excStatus)
			return 1;

		//encode the data
		excStatus = encoder.WriteData();
		if(ExcStatusOk != excStatus)
			return 1;
		&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Mar 2014 12:48:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/UIC-Jpeg-encoding-color-distortion/m-p/950295#M18567</guid>
      <dc:creator>Matthew_C_1</dc:creator>
      <dc:date>2014-03-17T12:48:41Z</dc:date>
    </item>
    <item>
      <title>Hi Matthew,</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/UIC-Jpeg-encoding-color-distortion/m-p/950296#M18568</link>
      <description>&lt;P&gt;Hi Matthew,&lt;/P&gt;

&lt;P&gt;As far as uci_transcoder_con works OK with this image, could your check the difference in JPEG encoder initialization between your source code and uic_transcoder. Just in debugger, line by line. Especially, when it concerns pixel type, channel number and color space. May be you need to specify BGRA instead of RGBA ?&lt;/P&gt;

&lt;P&gt;Regards,&lt;BR /&gt;
	Sergey&lt;/P&gt;</description>
      <pubDate>Mon, 17 Mar 2014 13:05:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/UIC-Jpeg-encoding-color-distortion/m-p/950296#M18568</guid>
      <dc:creator>Sergey_K_Intel</dc:creator>
      <dc:date>2014-03-17T13:05:17Z</dc:date>
    </item>
    <item>
      <title>Hi Sergey,</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/UIC-Jpeg-encoding-color-distortion/m-p/950297#M18569</link>
      <description>&lt;P&gt;Hi Sergey,&lt;/P&gt;

&lt;P&gt;I have ran both uic_transcoder_con and my source code at the same time and compared the jpeg encoder properties. They are identical to one another, (noChannels = 4, RGBA color space, etc.). The one line in my source code I am a bit concerned about is how I am allocating the dataPtr.p8u to an unsigned char* (imgResizeBuf). Could this be a possible problem? The reason I mention this is that I saw my memory output stream length after writing was not the same size as the one in the uic_transcoder_con.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Thanks&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Mar 2014 13:21:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/UIC-Jpeg-encoding-color-distortion/m-p/950297#M18569</guid>
      <dc:creator>Matthew_C_1</dc:creator>
      <dc:date>2014-03-17T13:21:13Z</dc:date>
    </item>
    <item>
      <title>How did you read BMP file? In</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/UIC-Jpeg-encoding-color-distortion/m-p/950298#M18570</link>
      <description>&lt;P&gt;How did you read BMP file? In uic_transcoder I see the channel swapping for 32-bit BMPs:&lt;/P&gt;

&lt;P&gt;&amp;nbsp; &amp;nbsp; case 4:&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; status = ippiSwapChannels_8u_C4IR((Ipp8u*)m_imageData,m_step, m_roi, order);&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;/P&gt;

&lt;P&gt;with order=&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int order_c4[4] = { 2, 1, 0, 3};&lt;/P&gt;

&lt;P&gt;Did you do that?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Mar 2014 14:09:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/UIC-Jpeg-encoding-color-distortion/m-p/950298#M18570</guid>
      <dc:creator>Sergey_K_Intel</dc:creator>
      <dc:date>2014-03-17T14:09:54Z</dc:date>
    </item>
    <item>
      <title>Hi Sergey,</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/UIC-Jpeg-encoding-color-distortion/m-p/950299#M18571</link>
      <description>&lt;P&gt;Hi Sergey,&lt;/P&gt;

&lt;P&gt;That was exactly my problem! Thank you so much for the quick reply.&lt;/P&gt;

&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Mon, 17 Mar 2014 14:49:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/UIC-Jpeg-encoding-color-distortion/m-p/950299#M18571</guid>
      <dc:creator>Matthew_C_1</dc:creator>
      <dc:date>2014-03-17T14:49:07Z</dc:date>
    </item>
  </channel>
</rss>

