直方图均衡化
来源:互联网 发布:三三地方门户系统源码 编辑:程序博客网 时间:2024/06/07 00:54
//获取图像的直方图
int[] histogram = new int[256];
for(int i=0; i<ih*iw; i++){
int grey = pixels[i]&0xff;
histogram[grey]++;
} //计算每一个灰度级的像素数
//直方图均衡化
double a = (double)255/(iw*ih);
double[] c = new double [256];
c[0] = (a*histogram[0]);
for(int i=1; i<256; i++){
c[i] = c[i-1]+(double)(a*histogram[i]);//直方图均衡化
}
for(int i=0; i<ih; i++){
for(int j=0; j<iw; j++){
int grey = pixels[i*iw+j]&0x0000ff;
int hist = (int)(c[grey]);
pixels[i*iw+j] = 255<<24|hist<<16|hist<<8|hist;
greyImage.setRGB(j, i, pixels[i*iw+j]);
}
}
tmp = greyImage;
flag_load = true;
repaint();
}else{
JOptionPane.showMessageDialog(null, "先点击“装载图像”,3Q!","提示:",
JOptionPane.WARNING_MESSAGE);
}
}
int[] histogram = new int[256];
for(int i=0; i<ih*iw; i++){
int grey = pixels[i]&0xff;
histogram[grey]++;
} //计算每一个灰度级的像素数
//直方图均衡化
double a = (double)255/(iw*ih);
double[] c = new double [256];
c[0] = (a*histogram[0]);
for(int i=1; i<256; i++){
c[i] = c[i-1]+(double)(a*histogram[i]);//直方图均衡化
}
for(int i=0; i<ih; i++){
for(int j=0; j<iw; j++){
int grey = pixels[i*iw+j]&0x0000ff;
int hist = (int)(c[grey]);
pixels[i*iw+j] = 255<<24|hist<<16|hist<<8|hist;
greyImage.setRGB(j, i, pixels[i*iw+j]);
}
}
tmp = greyImage;
flag_load = true;
repaint();
}else{
JOptionPane.showMessageDialog(null, "先点击“装载图像”,3Q!","提示:",
JOptionPane.WARNING_MESSAGE);
}
}
阅读全文
0 0
- 直方图均衡化、自适应直方图均衡化
- 直方图均衡化推导
- 直方图均衡化
- 直方图均衡化
- 直方图均衡化
- 直方图均衡化
- 灰度直方图均衡化
- 直方图均衡化
- 直方图均衡化
- 直方图均衡化
- matlab直方图均衡化
- 直方图均衡化
- opencv直方图均衡化
- 直方图均衡化原理
- 直方图均衡化
- 直方图均衡化
- 直方图的均衡化
- 直方图均衡化ZT
- Openstack安装Dashboard之后无法打开页面
- vue+axios 前端实现登录拦截(路由拦截、http拦截)
- 阅读收获——IT产业的六个规律
- 将cmd里创建的python虚拟环境应用于pycharm
- 简单的实现爬虫爬取网页文本和图片
- 直方图均衡化
- sts控制台输出tomcat启动后网址颜色为黑不为蓝
- ListView的优化
- AndroidStudio控制台搜索栏内输入中文变成方框解决
- C/C++训练1---最大公约数与最小公倍数
- get azure subscriptions‘ all stroages,containers and blobs by PowerShell
- 手机登录界面
- java 导出Excel文件
- Android事件分发机制