PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
List of all members | Public Types | Static Public Member Functions
PixelCodec Class Reference

A utility class that contains static functions for converting between various pixel encodings. More...

#include <src/PlusCommon/PixelCodec.h>

Public Types

enum  ComponentOrdering { ComponentOrder_RGB, ComponentOrder_RGBA, ComponentOrder_BGR }
 
enum  PixelEncoding {
  PixelEncoding_ERROR, PixelEncoding_YUY2, PixelEncoding_RGB24, PixelEncoding_BGR24,
  PixelEncoding_RGBA32, PixelEncoding_MJPG
}
 

Static Public Member Functions

static void BGRA32ToRGB24 (int width, int height, unsigned char *s, unsigned char *d)
 
static PlusStatus ConvertToBGR24 (ComponentOrdering outputOrdering, PixelEncoding inputCompression, int width, int height, unsigned char *s, unsigned char *d)
 
static PlusStatus ConvertToGray (int inputCompression, int width, int height, unsigned char *s, unsigned char *d)
 
static PlusStatus ConvertToGray (PixelEncoding inputCompression, int width, int height, unsigned char *s, unsigned char *d)
 
static std::string GetCompressionModeAsString (int inputCompression)
 
static std::string GetCompressionModeAsString (PixelEncoding inputCompression)
 
static bool IsConvertToGraySupported (int inputCompression)
 
static bool IsConvertToGraySupported (PixelEncoding inputCompression)
 
static PlusStatus MJPGToRGB24 (ComponentOrdering outputOrdering, int width, int height, unsigned char *s, unsigned char *d)
 
static void RGB24ToGray (int width, int height, unsigned char *s, unsigned char *d)
 
static void RGBA32ToBGR24 (int width, int height, unsigned char *s, unsigned char *d)
 
static void RGBA32ToGray (int width, int height, unsigned char *s, unsigned char *d)
 
static void RGBA32ToRGB24 (int width, int height, unsigned char *s, unsigned char *d)
 
static void RGBToBGR (int width, int height, unsigned char *s, unsigned char *d)
 
static void YUV422pToGray (int width, int height, unsigned char *s, unsigned char *d)
 
static PlusStatus YUV422pToRGB24 (ComponentOrdering outputOrdering, int width, int height, unsigned char *s, unsigned char *d)
 
static void YUVToRGB_Fast (ComponentOrdering outputOrdering, unsigned char *yuv, unsigned char *rgb)
 

Detailed Description

A utility class that contains static functions for converting between various pixel encodings.

Definition at line 46 of file PixelCodec.h.

Member Enumeration Documentation

◆ ComponentOrdering

Enumerator
ComponentOrder_RGB 
ComponentOrder_RGBA 
ComponentOrder_BGR 

Definition at line 49 of file PixelCodec.h.

◆ PixelEncoding

Enumerator
PixelEncoding_ERROR 
PixelEncoding_YUY2 
PixelEncoding_RGB24 
PixelEncoding_BGR24 
PixelEncoding_RGBA32 
PixelEncoding_MJPG 

Definition at line 56 of file PixelCodec.h.

Member Function Documentation

◆ BGRA32ToRGB24()

static void PixelCodec::BGRA32ToRGB24 ( int  width,
int  height,
unsigned char *  s,
unsigned char *  d 
)
inlinestatic

Definition at line 260 of file PixelCodec.h.

◆ ConvertToBGR24()

static PlusStatus PixelCodec::ConvertToBGR24 ( ComponentOrdering  outputOrdering,
PixelEncoding  inputCompression,
int  width,
int  height,
unsigned char *  s,
unsigned char *  d 
)
inlinestatic

Definition at line 197 of file PixelCodec.h.

◆ ConvertToGray() [1/2]

static PlusStatus PixelCodec::ConvertToGray ( int  inputCompression,
int  width,
int  height,
unsigned char *  s,
unsigned char *  d 
)
inlinestatic

Definition at line 146 of file PixelCodec.h.

◆ ConvertToGray() [2/2]

static PlusStatus PixelCodec::ConvertToGray ( PixelEncoding  inputCompression,
int  width,
int  height,
unsigned char *  s,
unsigned char *  d 
)
inlinestatic

Definition at line 169 of file PixelCodec.h.

◆ GetCompressionModeAsString() [1/2]

static std::string PixelCodec::GetCompressionModeAsString ( int  inputCompression)
inlinestatic

Definition at line 103 of file PixelCodec.h.

◆ GetCompressionModeAsString() [2/2]

static std::string PixelCodec::GetCompressionModeAsString ( PixelEncoding  inputCompression)
inlinestatic

Definition at line 120 of file PixelCodec.h.

◆ IsConvertToGraySupported() [1/2]

static bool PixelCodec::IsConvertToGraySupported ( int  inputCompression)
inlinestatic

Definition at line 67 of file PixelCodec.h.

◆ IsConvertToGraySupported() [2/2]

static bool PixelCodec::IsConvertToGraySupported ( PixelEncoding  inputCompression)
inlinestatic

Definition at line 83 of file PixelCodec.h.

◆ MJPGToRGB24()

static PlusStatus PixelCodec::MJPGToRGB24 ( ComponentOrdering  outputOrdering,
int  width,
int  height,
unsigned char *  s,
unsigned char *  d 
)
inlinestatic

Definition at line 375 of file PixelCodec.h.

◆ RGB24ToGray()

static void PixelCodec::RGB24ToGray ( int  width,
int  height,
unsigned char *  s,
unsigned char *  d 
)
inlinestatic

Convert from RGB24 to grayscale Note that this method computes the intensity (simple averaging of the RGB components). This is not equivalent with the perceived luminance of color images (e.g., 0.21R + 0.72G + 0.07B or 0.30R + 0.59G + 0.11B)

Definition at line 301 of file PixelCodec.h.

◆ RGBA32ToBGR24()

static void PixelCodec::RGBA32ToBGR24 ( int  width,
int  height,
unsigned char *  s,
unsigned char *  d 
)
inlinestatic

Definition at line 272 of file PixelCodec.h.

◆ RGBA32ToGray()

static void PixelCodec::RGBA32ToGray ( int  width,
int  height,
unsigned char *  s,
unsigned char *  d 
)
inlinestatic

Convert from RGBA32 to grayscale Note that this method computes the intensity (simple averaging of the RGB components). This is not equivalent with the perceived luminance of color images (e.g., 0.21R + 0.72G + 0.07B or 0.30R + 0.59G + 0.11B)

Definition at line 317 of file PixelCodec.h.

◆ RGBA32ToRGB24()

static void PixelCodec::RGBA32ToRGB24 ( int  width,
int  height,
unsigned char *  s,
unsigned char *  d 
)
inlinestatic

Definition at line 284 of file PixelCodec.h.

◆ RGBToBGR()

static void PixelCodec::RGBToBGR ( int  width,
int  height,
unsigned char *  s,
unsigned char *  d 
)
inlinestatic

Definition at line 248 of file PixelCodec.h.

◆ YUV422pToGray()

static void PixelCodec::YUV422pToGray ( int  width,
int  height,
unsigned char *  s,
unsigned char *  d 
)
inlinestatic

YUY2 conversion to grayscale. YUY2 coding is typically used for webcams source: http://sundararajana.blogspot.ca/2007/12/yuy2-to-rgb24-conversion.html

Definition at line 443 of file PixelCodec.h.

◆ YUV422pToRGB24()

static PlusStatus PixelCodec::YUV422pToRGB24 ( ComponentOrdering  outputOrdering,
int  width,
int  height,
unsigned char *  s,
unsigned char *  d 
)
inlinestatic

YUY2 conversion to RGB24. YUY2 coding is typically used for webcams source: http://sundararajana.blogspot.ca/2007/12/yuy2-to-rgb24-conversion.html

Definition at line 387 of file PixelCodec.h.

◆ YUVToRGB_Fast()

static void PixelCodec::YUVToRGB_Fast ( ComponentOrdering  outputOrdering,
unsigned char *  yuv,
unsigned char *  rgb 
)
inlinestatic

Conversion from YUV to RGB space Uses integer math, which is faster but more complex to read Equivalent with the following floating point math (simpler but slower) int Y = yuv[0] - 16; int U = yuv[1] - 128; int V = yuv[2] - 128;

int R = 1.164*Y + 1.596*V + 0.5; int G = 1.164*Y - 0.813*V - 0.391*U + 0.5; int B = 1.164*Y + 2.018*U + 0.5;

Definition at line 339 of file PixelCodec.h.


The documentation for this class was generated from the following file: