資源簡介
基于JAVA實現的圖像特征提取源代碼,能夠輸出圖像的七個hu不變量特征,打開eclipse,導入工程,運行Test.java,可以把Test里面的注釋弄掉運行更多的功能

代碼片段和文件信息
package?fq;
import?java.awt.image.BufferedImage;
import?java.awt.image.ColorModel;
import?java.awt.image.WritableRaster;
import?java.io.File;
import?javax.imageio.ImageIO;
import?fq.Point;
public?class?FqImage?{
public?static?final?double?SOBELDOOR?=?80.00;
public?BufferedImage imh;
public?int? height;
public?int? width;
public?Point[][] points;
public?double[][] sobels;
public?int[][] edge;
public?double[] colorJuH = new?double[4];
public?double[] colorJuS = new?double[4];
public?double[] colorJuV = new?double[4];
public?double[] huJu = new?double[8];
public?double?getAbsColorDistance(?FqImage?other?){
int?width = FqMath.min(this.width?other.width);
int height = FqMath.min(this.height?other.height);
int sum = 0;
for(?int?i?=?0?;?i? for(?int?j?=?0?;?j? sum?+=?this.points[i][j].pointDistance(other.points[i][j]);
}
}
return sum;
}
public?double?f(?int?i??int?j?){
double temp = this.points[i][j].getGray();
return temp;
}
public?void?toSobel(){
double fx??fy;
double sobel;
int i??j;
for(?i?=?1?;?i? for(?j?=?1?;?j? fx = ( f(i-1j-1)?+?2*f(i-1j)?+?f(i-1j+1) ) - ( f(i+1j-1)?+?2*f(i+1j)?+?f(i+1j+1) );
fy = ( f(i-1j-1)?+?2*f(ij-1)?+?f(i+1j-1) ) - ( f(i-1j+1)?+?2*f(ij+1)?+?f(i+1j+1) );
this.sobels[i][j] = FqMath.max(?Math.abs(fx)?Math.abs(fy)?);
}
}
}
public?void?toEdge(){
int i??j;
for(?i?=?0?;?i? for(?j?=?0?;?j? if(?this.sobels[i][j]?>?SOBELDOOR?)
this.edge[i][j]?=?1;
else
this.edge[i][j]?=?0;
}
}
}
public?FqImage?cutSmallest(){
final?double?EDGEDOOR?=?4;
int i??j;
int?left = 0;
int right = 0;
int top = 0;
int bottom = 0;
int count = 0;
for(?i?=?0?;?i? count?=?0;
for(?j?=?0?;?j? if(?this.edge[i][j]?==?1?)
count++;
}
if(?count?>=?EDGEDOOR?){
left?=?i;
break;
}
}
for(?i?=?this.width?-?1?;?i?>=?0?;?i--?){
count?=?0;
for(?j?=?0?;?j? if(?this.edge[i][j]?==?1?)
count++;
}
if(?count?>=?EDGEDOOR?){
right?=?i;
break;
}
}
for(?j?=?0?;?j? count?=?0;
for(?i?=?0?;?i? if(?this.edge[i][j]?==?1?)
count++;
}
if(?count?>=?EDGEDOOR?){
top?=?j;
break;
}
}
for(?j?=?this.height?-?1?;?j?>=?0?;?j--?){
count?=?0;
for(?i?=?0?;?i? if(?this.edge[i][j]?==?1?)
count++;
}
if(?count?>=?EDGEDOOR?){
bottom?=?j;
break;
}
}
BufferedImage?subImh = this.imh.getSubimage(left?top?right-left??bottom-top);
return?new?FqImage(subImh);
}
public?void?setCo
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2011-12-27?15:45??基于JAVA實現的圖像特征提取源代碼\
?????文件????????6708??2007-07-04?16:28??基于JAVA實現的圖像特征提取源代碼\FqImage.class
?????文件????????9942??2007-07-04?16:24??基于JAVA實現的圖像特征提取源代碼\FqImage.java
?????文件?????????856??2007-07-04?16:28??基于JAVA實現的圖像特征提取源代碼\FqMath.class
?????文件?????????503??2007-04-20?17:16??基于JAVA實現的圖像特征提取源代碼\FqMath.java
?????目錄???????????0??2011-12-27?15:45??基于JAVA實現的圖像特征提取源代碼\images\
?????文件???????14442??2007-04-17?15:39??基于JAVA實現的圖像特征提取源代碼\images\1.jpg
?????文件????????1061??2007-07-03?15:22??基于JAVA實現的圖像特征提取源代碼\images\2.gif
?????文件?????????157??2007-04-03?10:15??基于JAVA實現的圖像特征提取源代碼\images\cross.gif
?????文件?????????158??2007-04-03?10:15??基于JAVA實現的圖像特征提取源代碼\images\not.gif
?????文件????????9216??2008-10-01?12:14??基于JAVA實現的圖像特征提取源代碼\images\Thumbs.db
?????文件????????4075??2007-07-10?15:09??基于JAVA實現的圖像特征提取源代碼\Point.class
?????文件????????4156??2007-07-10?15:09??基于JAVA實現的圖像特征提取源代碼\Point.java
?????文件????????5610??2007-07-10?15:48??基于JAVA實現的圖像特征提取源代碼\Test.class
?????文件????????6819??2011-12-27?14:57??基于JAVA實現的圖像特征提取源代碼\Test.java
?????文件?????????749??2007-07-04?16:21??基于JAVA實現的圖像特征提取源代碼\Test2.class
?????文件?????????345??2007-07-03?17:03??基于JAVA實現的圖像特征提取源代碼\Test2.java
- 上一篇:Java五子棋經典程序,非常詳細
- 下一篇:java圖書館管理系統項目總結PPT
評論
共有 條評論