3

I just started to use SS2 optimization of image processing, but for the 3 channel 24 bit color images have no idea. My pix data arranged by BGR BGR BGR ... ,unsigned char 8-bi, so if I want to implement the Color2Gray with SSE2/SSE3/SSE4's instruction C/C++ fun ,how would I do? Does need to align(4/8/16) for my pix data? I have read article:http://supercomputingblog.com/windows/image-processing-with-sse/ But it is ARGB 4 channel 32-bit color,exactly process 4 color pix data every time. Thanks!

//Assume the original pixel:
      unsigned char* pDataColor=(unsigned char*)malloc(src.width*src.height*3);//3

  //init pDataColor every pix val
  // The dst pixel:
  unsigned char* pDataGray=(unsigned char*)malloc(src.width*src.height*1);//1 

//RGB->Gray: Y=0.212671*R + 0.715160*G + 0.072169*B

tocky
  • 107
  • 1
  • 7

2 Answers2

8

I have slides on de-interleaving of 24-bit RGB pixels, which explain how to do it with SSE2 and SSSE3.

Marat Dukhan
  • 11,993
  • 4
  • 27
  • 41
  • Yes,thank you.i have commplete the color RGB...RGB to RR...BB...GG,but when i try to makes: RGB->Gray: Y=0.212671*R + 0.715160*G + 0.072169*B . There have problems. since SSE use 128-bit,there is no SSE C/C++ instruction fun can do work like: _mm_mul_xxx(a0,b0);r0=a0*b0,r1=a1*b0,...,r15=a15*b0; (a0 is 16 uchar types,b0 is 2 double types). ???? – tocky Mar 17 '13 at 04:11
  • For color conversion typically fixed-point arithmetic is used instead of floating-point. Unpack 8-bit values into 16-bit values (using _mm_unpacklo_epi8/_mm_unpackhi_epi8), and then use integer multiplication of 16-bit values. – Marat Dukhan Mar 18 '13 at 00:03
2

Here is some answers to your question:

Community
  • 1
  • 1
Kun Ling
  • 2,211
  • 14
  • 22