资源简介
使用java语言实现的图像特征提取算法,能够对图像进行特征提取 具有一定的参考性。收分不高,相信可以对你有一定的启示作用。
代码片段和文件信息
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 < width ; i++ ){
for( int j = 0 ; j < height ; 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 < this.width - 1 ; i++ ){
for( j = 1 ; j < this.height - 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 < this.width ; i++ ){
for( j = 0 ; j < this.height ; 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 < this.width ; i++ ){
count = 0;
for( j = 0 ; j < this.height ; 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 < this.height ; j++ ){
if( this.edge[i][j] == 1 )
count++;
}
if( count >= EDGEDOOR ){
right = i;
break;
}
}
for( j = 0 ; j < this.height ; j++ ){
count = 0;
for( i = 0 ; i < this.width ; 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 < this.width ; 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 2007-07-03 16:51 images\
文件 14442 2007-04-17 15:39 images\1.jpg
文件 1061 2007-07-03 15:22 images\2.gif
文件 157 2007-04-03 10:15 images\cross.gif
文件 158 2007-04-03 10:15 images\not.gif
文件 9216 2008-10-01 12:14 images\Thumbs.db
文件 6708 2007-07-04 16:28 FqImage.class
文件 9942 2007-07-04 16:24 FqImage.java
文件 856 2007-07-04 16:28 FqMath.class
文件 503 2007-04-20 17:16 FqMath.java
文件 4075 2007-07-10 15:09 Point.class
文件 4156 2007-07-10 15:09 Point.java
文件 749 2007-07-04 16:21 Test2.class
文件 345 2007-07-03 17:03 Test2.java
文件 5610 2007-07-10 15:48 Test.class
文件 6819 2007-07-10 15:48 Test.java
文件 1223 2008-03-27 10:17 说明.txt
评论
共有 条评论