首页 > 代码库 > 数字图像处理(1)-图片信息获取和RGB-HSI

数字图像处理(1)-图片信息获取和RGB-HSI


数字图像处理 信息获取

struct Rgb

{
    unsigned char    b;
    unsigned char    g;
    unsigned char    r;
};
lpSrc=http://www.mamicode.com/(unsigned char*)pDoc->m_pDib->m_lpImage +
          lLineBytes*(lHeight - 1 -point.y) + point.x*3;
Rgb rgb;

rgb.b=*lpSrc;

rgb.g=*(lpSrc+1);

rgb.r=*(lpSrc+2);


亮度

int gray=(int)(0.114*rgb.r+0.587*rgb.g+0.299*rgb.b)



RGB到HSI图片信息采集


技术分享


编码如下

R = ((double) pRgb->r) / 255.0;
G = ((double) pRgb->g) / 255.0;
B = ((double) pRgb->b) / 255.0;

Sum = R + G + B;
pHsi->Intensity = Sum / 3.0;

MinValue = http://www.mamicode.com/(R < G) ? R : G;
MinValue = http://www.mamicode.com/(B < MinValue) ? B : MinValue;
MaxValue = http://www.mamicode.com/(R > G) ? R : G;
MaxValue = http://www.mamicode.com/(B > MaxValue) ? B : MaxValue;
if(pHsi->Intensity < 0.00001)
    pHsi->Saturation = ZERO_SATURATION;
else
    pHsi->Saturation = 1.0 - (3.0 * MinValue) / Sum;

if(MinValue =http://www.mamicode.com/= MaxValue){
    pHsi->Hue = UNDEFINED_HUE;
    pHsi->Saturation = ZERO_SATURATION;
    return;
    }

TempDouble1 = (((R - G) + (R - B)) / 2.0);
    TempDouble2 = (R - G) * (R - G) + (R - B) * (G - B);
    Quotient = (TempDouble1 / sqrt(TempDouble2));
    Radians = acos(Quotient);
    Angle = Radians * DEGREES_PER_RADIAN;
    pHsi->Hue =(B>G)? 360.0 – Angle : Angle;






    







数字图像处理(1)-图片信息获取和RGB-HSI