我一直在研究手指图像处理,我目前想做标准化。
我在Griuale Biometric 网站上研究了这个链接。
归一化的思想在于改变每个像素的强度,以便将整个图像的均值和方差更改为一些预定义的值。
任何人都可以建议我任何可以帮助我的Java示例代码或算法。
编辑:
我正在考虑图像像素MEAN
并VARIANCE
考虑图像标准化:
这是我的代码:
public class NormalizeHistMeanVariance {
private static BufferedImage original, normalize;
public static void main(String[] args) throws IOException {
final int N = 256; // Number of graylevels
final int M = 250; // Max value in histogram for displaying purposes
int nrows, ncols, size, in_img[][], out_img[][];
int i, j, max, maxgray;
double hist[] = new double[N], norm, mean, var, tmp;
String f1 = "E:/single.jpg";
String f2 = "E:/normImg";
File original_f = new File(f1);
original = ImageIO.read(original_f);
Histogram histogram = new Histogram(original);
in_img = histogram.getPixels(original);
nrows = in_img.length;
ncols = in_img[0].length;
size = in_img.length * in_img[0].length;
// Compute average gray and histogram
for (i = 0; i < N; i++)
hist[i] = 0;
mean = 0;
for (i = 0; i < nrows; i++) {
for (j = 0; j < ncols; j++) {
hist[in_img[i][j]]++;
mean += in_img[i][j];
}
}
mean /= size;
System.out.println("Mean graylevel = " + mean);
// Compute variance
var = 0;
for (i = 0; i < nrows; i++) {
for (j = 0; j < ncols; j++) {
tmp = in_img[i][j] - mean;
var += tmp * tmp;
}
}
var = Math.sqrt(var / (size));
System.out.println("Variance = " + var);
max = maxgray = 0;
for (i = 0; i < N; i++) {
if (max < hist[i]) {
max = (int) hist[i];
maxgray = i;
}
}
System.out.println("Max count " + max + " (graylevel = " + maxgray
+ " )");
// Normalize to M for better display effect
norm = (double) M / maxgray;
System.out.println("Norm = " + norm);
out_img = new int[nrows][ncols];
for (int x = 0; x < in_img.length; x++) {
for (int y = 0; y < in_img[0].length; y++) {
out_img[x][y] = (int) (in_img[x][y] * norm);
}
}
normalize = ImageUtils.CreateImagefromIntArray(out_img);
writeImage(f2);
}
private static void writeImage(String output) throws IOException {
File file = new File(output + ".jpg");
ImageIO.write(normalize, "jpg", file);
}
}
我想要的是正常化后的平滑图像,就像这个链接一样。但我没有得到想要的结果。有人可以帮我吗?