资源简介
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参考扭矩为例
- 下一篇:防伪码 查询系统源码
相关资源
- 82662.rar
- 储能电池的建模与PSCAD仿真.pdf
- 驾驶证,行车证,9P字体.zip
- monokai.vssettings
- 28028KD5注册机.rar
- QT5.5.1静态编译库(VS2013).txt
-
gba
se8a、8t数据库客户端管理工具G - 毕设ppt.pptx
- 小程序-党规学习.rar
- Workgroup.reg
- 51单片机多功能电压-电流表测量系统
- Apple账号全自动注册激活_Secure.zip
- 资源.txt
- 51单片机Proteus仿真320x240TFT彩屏.rar
- 218O2O.txt
- Keygen.zip
- cbgh7t.docx
- MyWatch.zip
- zkjxa8.docx
- Verilog的135个经典设计.rar
- netcat-1.10_redhat_x86_64.zip
- Symantec_BackupExec2012.7z
- 游戏盾源码.rar
- nokia.rar
- msnildsl_9664769.zip
- IntrotoSecISM.pdf
- opencv分类器.rar
- labviewmyrio2017地址.txt
- bd6c83ef89bd4112bb878cfb80a22251.zip
- b+树查找的实现原代码.doc
评论
共有 条评论