130 likes | 308 Views
Color Models. Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University. Outline. Color models Color Images C***Document & C***View Tools library. Color Models.
E N D
Color Models Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University Color Models
Outline • Color models • Color Images • C***Document & C***View • Tools library Color Models
Color Models • To facilitate the specification of colors in some standard • Hardware-oriented • RGB: color monitors • CYM: printers • YIQ: TV broadcast • Application-oriented • HSI: color image manipulation • HSV: color image manipulation Color Models
RGB Color Model B (0,0,1) Blue Cyan Magenta White GrayScale (0,1,0) Black G Green (1,0,0) Red Yellow R Color Models
YIQ • Used for commercial color TV broadcasting • Compatibility with monochrome TV standards • Take advantage of human visual system’s greater sensitivity to changes in luminance • Y (luminance) • The amount of light perceived by the eye • IQ (color information) Color Models
RGB to YIQ • Y = 0.299 R + 0.587 G + 0.114 B • I = 0.596 R - 0.275 G – 0.321 B • Q = 0.212 R – 0.523 G + 0.311 B Color Models
Add data short * m_p2BImage; unsigned char * m_p1BImage; unsigned char * m_pRedImage; unsigned char * m_pGreenImage; unsigned char * m_pBlueImage; int m_nWidth; int m_nHeight; C***Document Color Models
Add core functions short * Get2BImageBuffer(); unsigned char * Get1BImageBuffer(); unsigned char * GetRedImageBuffer(); unsigned char * GetGreenImageBuffer(); unsigned char * GetBlueImageBuffer(); int GetImageWidth(); int GetImageHeight(); C***Document Color Models
C***View • #include “tools.h” • C***View::OnDraw(CDC * pDC){ int nWidth = pDoc->GetImageWidth(); int nHeight = pDoc->GetImageHeight(); ShowImage_1B(pDC, pDoc->Get1BImageBuffer(), nWidth, nHeight ); ShowImage_2B(pDC, pDoc->Get2BImageBuffer(), nWidth, nHeight, nWidth, 0 ); ShowImage_3B(pDC, pDoc->GetRedImageBuffer(), pDoc->GetGreenImageBuffer(), pDoc->GetBlueImageBuffer(), nWidth, nHeight, 0, nHeight);} Color Models
Tools Library • Providing functions of displaying images • 1-byte • void ShowImage_1B(CDC * pDC, unsigned char * pImage, int nWidth, int nHeight); • 2-byte • void ShowImage_2B(CDC * pDC, short * pImage, int nWidth, int nHeight); • 3-byte • void ShowImage_3B(CDC * pDC, unsigned char * pRedImage, unsigned char * pGreenImage, unsigned char * pBlueImage, int nWidth, int nHeight); Color Models
Results Color Models