资源简介
checkPicture.rar

代码片段和文件信息
package myWeiXinID_simpleit8;
//Download by http://www.codefans.net
import java.awt.image.BufferedImage;
public class PicDataTools {
private int redBins;
private int greenBins;
private int blueBins;
public PicDataTools() {
redBins = greenBins = blueBins = 4;
}
public void setRedBinCount(int redBinCount) {
this.redBins = redBinCount;
}
public void setGreenBinCount(int greenBinCount) {
this.greenBins = greenBinCount;
}
public void setBlueBinCount(int blueBinCount) {
this.blueBins = blueBinCount;
}
public double[] filter(BufferedImage src BufferedImage dest) {
int width = src.getWidth();
int height = src.getHeight();
int[] inPixels = new int[width * height];
double[] histogramData = new double[redBins * greenBins* blueBins];
getRGB(src 0 0 width height inPixels);
int index = 0;
int redIdx = 0 greenIdx = 0 blueIdx = 0;
int singleIndex = 0;
double total = 0;
for (int row = 0; row < height; row++) {
//int ta = 0;
int tr = 0 tg = 0 tb = 0;
for (int col = 0; col < width; col++) {
index = row * width + col;
//ta = (inPixels[index] >> 24) & 0xff;
tr = (inPixels[index] >> 16) & 0xff;
tg = (inPixels[index] >> 8) & 0xff;
tb = inPixels[index] & 0xff;
redIdx = (int) getBinIndex(redBins tr 255);
greenIdx = (int) getBinIndex(greenBins tg 255);
blueIdx = (int) getBinIndex(blueBins tb 255);
singleIndex = redIdx + greenIdx * redBins
+ blueIdx * redBins * greenBins;
histogramData[singleIndex] += 1;
total += 1;
}
}
// start to normalize the histogram data
for (int i = 0; i < histogramData.length; i++) {
histogramData[i] = histogramData[i] / total;
}
return histogramData;
}
private double getBinIndex(int binCount int color int colorMaxValue) {
double binIndex = (((double) color) / ((double) colorMaxValue))
* ((double) binCount);
if (binIndex >= binCount)
binIndex = binCount - 1;
return binIndex;
}
public int[] getRGB(BufferedImage image int x int y int width
int height int[] pixels) {
int type = image.getType();
if (type == BufferedImage.TYPE_INT_ARGB
|| type == BufferedImage.TYPE_INT_RGB)
return (int[]) image.getRaster().getDataElements(x y
width height pixels);
return image.getRGB(x y width height pixels 0 width);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2420 2018-05-26 08:29 checkPicture\PicDataTools.java
文件 4369 2018-05-26 08:29 checkPicture\TestMain.java
目录 0 2018-05-26 08:27 checkPicture
----------- --------- ---------- ----- ----
6789 3
- 上一篇:CAN-J1939多包传输以FEE3参考扭矩为例
- 下一篇:防伪码 查询系统源码
相关资源
- PID_AutoTune_v0.rar
- vspd7.2.308.zip
- 价值2k的H漫画小说系统
- Pythonamp;课堂amp;笔记(高淇amp;400;集第
- ddos压力测试工具99657
- UML建模大全
- 开源1A锂电池充电板TP4056原理图+PCB
- m1卡 ic卡可选择扇区初始化加密软件
- TSCC.exe
- FTP课程设计(服务端+客户端)
- 计算机图形学 边填充算法实现代码
- 电力系统潮流计算程序集合
- oracle数据迁移项目实施方案
- Web Api 通过文件流 文件到本地
- Visio图标-最新最全的网络通信图标库
- Spire API文档
- OpenGL参考手册
- Python中Numpy库最新教程
- SPD博士V5.3.exe
- 直流无刷电机方波驱动 stm32 例程代码
- layui后台管理模板
- 仿知乎界面小程序源代码
- 云平台-阿里云详细介绍
- photoshop经典1000例
- scratch垃圾分类源码(最终版本).sb
- IAR ARM 7.8破解
- TI CCS V5.4 安装步骤及破解文件
- 松下plc FP-XH的驱动
- 局域网硬件信息收集工具
- 加快Windows XP操作系统开机速度
评论
共有 条评论