Skip to content

Commit

Permalink
updated image formats
Browse files Browse the repository at this point in the history
  • Loading branch information
dusty-nv committed Jun 18, 2020
1 parent bc84890 commit 8b2e5e8
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 6 deletions.
28 changes: 26 additions & 2 deletions image/imageFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ enum imageFormat
// YUV
IMAGE_YUYV,
IMAGE_YUY2=IMAGE_YUYV,
IMAGE_YVYU,
IMAGE_UYVY,
IMAGE_I420,
IMAGE_YV12,
Expand Down Expand Up @@ -107,15 +108,38 @@ inline size_t imageFormatDepth( imageFormat format );
inline size_t imageFormatSize( imageFormat format, size_t width, size_t height );

/**
* @returns true if the imageFormat is RGB/RGBA
* @returns true if the imageFormat is a RGB/RGBA format
* (IMAGE_RGB8, IMAGE_RGBA8, IMAGE_RGB32F, IMAGE_RGBA32F)
* otherwise, returns false.
* @ingroup image
*/
inline bool imageFormatIsRGB( imageFormat format );

/**
* @returns true if the imageFormat is Bayer
* @returns true if the imageFormat is a BGR/BGRA format
* (IMAGE_BGR8, IMAGE_BGRA8, IMAGE_BGR32F, IMAGE_BGRA32F)
* otherwise, returns false.
* @ingroup image
*/
inline bool imageFormatIsRGB( imageFormat format );

/**
* @returns true if the imageFormat is a YUV format
* (IMAGE_YUYV, IMAGE_YVYU, IMAGE_UYVY, IMAGE_I420, IMAGE_YV12, IMAGE_NV12)
* otherwise, returns false.
* @ingroup image
*/
inline bool imageFormatIsYUV( imageFormat format );

/**
* @returns true if the imageFormat is grayscale (IMAGE_GRAY8, IMAGE_GRAY32)
* otherwise, returns false.
* @ingroup image
*/
inline bool imageFormatIsGray( imageFormat format );

/**
* @returns true if the imageFormat is a Bayer format
* (IMAGE_BAYER_BGGR, IMAGE_BAYER_GBRG, IMAGE_BAYER_GRBG, IMAGE_BAYER_RGGB)
* otherwise, returns false.
* @ingroup image
Expand Down
42 changes: 38 additions & 4 deletions image/imageFormat.inl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ inline const char* imageFormatToStr( imageFormat format )
case IMAGE_NV12: return "nv12";
case IMAGE_UYVY: return "uyvy";
case IMAGE_YUYV: return "yuyv";
case IMAGE_YVYU: return "yvyu";
case IMAGE_BAYER_BGGR: return "bayer_bggr";
case IMAGE_BAYER_GBRG: return "bayer_gbrg";
case IMAGE_BAYER_GRBG: return "bayer_grbg";
Expand All @@ -60,16 +61,47 @@ inline const char* imageFormatToStr( imageFormat format )
// imageFormatIsRGB
inline bool imageFormatIsRGB( imageFormat format )
{
if( format == IMAGE_RGB8 || format == IMAGE_RGBA8 || format == IMAGE_RGB32F || format == IMAGE_RGBA32F )
//if( format == IMAGE_RGB8 || format == IMAGE_RGBA8 || format == IMAGE_RGB32F || format == IMAGE_RGBA32F )
// return true;
if( format >= IMAGE_RGB8 && format <= IMAGE_RGBA32F )
return true;

return false;
}

// imageFormatIsBGR
inline bool imageFormatIsBGR( imageFormat format )
{
if( format >= IMAGE_BGR8 && format <= IMAGE_BGRA32F )
return true;

return false;
}

// imageFormatIsYUV
inline bool imageFormatIsYUV( imageFormat format )
{
if( format >= IMAGE_YUYV && format <= IMAGE_NV12 )
return true;

return false;
}

// imageFormatIsGray
inline bool imageFormatIsGray( imageFormat format )
{
if( format == IMAGE_GRAY8 || format == IMAGE_GRAY32F )
return true;

return false;
}

// imageFormatIsBayer
inline bool imageFormatIsBayer( imageFormat format )
{
if( format == IMAGE_BAYER_BGGR || format == IMAGE_BAYER_GBRG || format == IMAGE_BAYER_GRBG || format == IMAGE_BAYER_RGGB )
//if( format == IMAGE_BAYER_BGGR || format == IMAGE_BAYER_GBRG || format == IMAGE_BAYER_GRBG || format == IMAGE_BAYER_RGGB )
// return true;
if( format >= IMAGE_BAYER_BGGR && format <= IMAGE_BAYER_RGGB )
return true;

return false;
Expand Down Expand Up @@ -139,7 +171,8 @@ inline size_t imageFormatChannels( imageFormat format )
case IMAGE_YV12:
case IMAGE_NV12:
case IMAGE_UYVY:
case IMAGE_YUYV: return 3;
case IMAGE_YUYV:
case IMAGE_YVYU: return 3;
case IMAGE_BAYER_BGGR:
case IMAGE_BAYER_GBRG:
case IMAGE_BAYER_GRBG:
Expand Down Expand Up @@ -169,7 +202,8 @@ inline size_t imageFormatDepth( imageFormat format )
case IMAGE_YV12:
case IMAGE_NV12: return 12;
case IMAGE_UYVY:
case IMAGE_YUYV: return 16;
case IMAGE_YUYV:
case IMAGE_YVYU: return 16;
case IMAGE_BAYER_BGGR:
case IMAGE_BAYER_GBRG:
case IMAGE_BAYER_GRBG:
Expand Down

0 comments on commit 8b2e5e8

Please sign in to comment.