对比度计算

e_feeling 2003-10-09 02:59:21
图像亮度、对比度的计算方法?
...全文
544 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
potlee 2003-10-22
  • 打赏
  • 举报
回复
有两个C++Builder的函数,希望有用

调整对比度的函数
void TForm1::DoContrast(int s)
{
int XX;
BYTE *ptr;
Graphics::TBitmap *tmpBitmap=new Graphics::TBitmap();
tmpBitmap->Assign((TPersistent*)Image1->Picture->Graphic);
tmpBitmap->PixelFormat=pf24bit;
for (int y = 0; y < tmpBitmap->Height; y++)
{
ptr =(BYTE *) tmpBitmap->ScanLine[y];
for (int x = 0; x < tmpBitmap->Width*3; x+=3){
XX=((ptr[x+2]-128)*s+12800)/100;
XX=MAX(XX,0);XX=MIN(XX,255);ptr[x+2]=XX;
XX=((ptr[x+1]-128)*s+12800)/100;
XX=MAX(XX,0);XX=MIN(XX,255);ptr[x+1]=XX;
XX=((ptr[x]-128)*s+12800)/100;
XX=MAX(XX,0);XX=MIN(XX,255);ptr[x+0]=XX;
}
}
Image1->Picture->Graphic=tmpBitmap;
delete tmpBitmap;

}
调整亮度的函数
void TForm1::DoBright(int b)
{
int XX;
BYTE *ptr;
Graphics::TBitmap *tmpBitmap=new Graphics::TBitmap();
tmpBitmap->Assign((TPersistent*)Image1->Picture->Graphic);
tmpBitmap->PixelFormat=pf24bit;
for (int y = 0; y < tmpBitmap->Height; y++)
{
ptr =(BYTE *) tmpBitmap->ScanLine[y];
for (int x = 0; x < tmpBitmap->Width*3; x+=3){
XX=ptr[x+2]+b;
XX=MAX(XX,0);XX=MIN(XX,255);ptr[x+2]=XX;
XX=ptr[x+1]+b;
XX=MAX(XX,0);XX=MIN(XX,255);ptr[x+1]=XX;
XX=ptr[x]+b;
XX=MAX(XX,0);XX=MIN(XX,255);ptr[x+0]=XX;
}
}
Image1->Picture->Graphic=tmpBitmap;
delete tmpBitmap;
}
e_feeling 2003-10-21
  • 打赏
  • 举报
回复
SFTW
e_feeling 2003-10-16
  • 打赏
  • 举报
回复
haiyouma
z
ljranby 2003-10-15
  • 打赏
  • 举报
回复
ttmmdd(老孩子) 你说的是灰度
根据CIE的标准
HSI系统中亮度为I=(R+G+B)/3
对比度S=1-(min(R,G,B)/I)
e_feeling 2003-10-14
  • 打赏
  • 举报
回复
@@
e_feeling 2003-10-14
  • 打赏
  • 举报
回复
寻找
e_feeling 2003-10-13
  • 打赏
  • 举报
回复
还有没有?
zzwu 2003-10-12
  • 打赏
  • 举报
回复
不知道看看下面的贴能不能解决问题:
http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=179307
e_feeling 2003-10-11
  • 打赏
  • 举报
回复
?
e_feeling 2003-10-11
  • 打赏
  • 举报
回复
增加减少亮度, 增加减少对比度怎么计算?
zzwu 2003-10-10
  • 打赏
  • 举报
回复

Imax = 图像亮度最大值
Imin = 图像亮度最小值


对比度 = (Imax-Imin)/256

图像各点亮度上面已给了计算公式.



ttmmdd 2003-10-10
  • 打赏
  • 举报
回复
亮度应是0.3f*R + 0.59f*G + 0.11f*B
topology18 2003-10-10
  • 打赏
  • 举报
回复
亮度:light = 1/3(r+g+b)

4,445

社区成员

发帖
与我相关
我的任务
社区描述
图形图像/机器视觉
社区管理员
  • 机器视觉
  • 迪菲赫尔曼
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧