How to process a 24-bit 3 channel color image with SSE2/SSE3/SSE4?
Asked Answered
P

2

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

Parturient answered 13/3, 2013 at 3:55 Comment(0)
E
9

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

Enforcement answered 13/3, 2013 at 4:58 Comment(2)
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). ????Parturient
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.Enforcement
O
2

Here is some answers to your question:

Owlet answered 13/3, 2013 at 4:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.