虹膜灰度极坐标直方图

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/billyhhzh/article/details/51516534

灰度极坐标的直方图,可以比较方便的看到灰度的分布图,直观的看出瞳孔、虹膜边缘特点

虹膜的256灰度图如下:


经过极坐标的直方图转换后,如果如下:

100个点,64灰度直方图

200点,32灰度直方图


400点,32灰度直方图



通过对比,可以看出,用32灰度的瞳孔灰度集中度非常高,一致性很好;

边缘效果上,点数越多,识别的效果越精细,400点的边缘识别越准确。


再给出400点的平均灰度直方图的结果:


直观的看出图像以圆点为中心,颜色越来越明亮;


分别对6张不同虹膜图片的进行直方图计算,原图如下:

 

对应的直方图计算结果如下:








参考代码如下:

void GenPlaneHistogram() {
        PlaneHistogram planeHistogram = new PlaneHistogram();
        int c = 100;  //可取不同的值,看到不同的效果100/200/400等
        int count[] = new int[c + 1];
        int countgray[][] = new int[c + 1][(int) (px * py / (Math.sqrt(c)))];
        int countgraymax[] = new int[c + 1];
        int countgraymaxgray[] = new int[c + 1];
        int countgraymaxratio[] = new int[c + 1];
        String text[] = new String[c + 1];
        Color color[] = new Color[c + 1];

        //找出半径最大值,根据半径按照100等分显示
        double maxr = 0;
        double rr = 0;
        for (int i = 0; i < px; i++) {
            for (int j = 0; j < py; j++) {
                if (pixelpolar[i][j] > maxr) {
                    maxr = pixelpolar[i][j];
                }
            }
        }
        rr = maxr / c;
        System.out.println("maxr=" + maxr + ", rr=" + rr);
        //找出各段的计数
        int cc;
        for (int i = 0; i < px; i++) {
            for (int j = 0; j < py; j++) {
                cc = (int) (pixelpolar[i][j] / rr);
                countgray[cc][count[cc]] = pixelgray[i][j];
                count[cc]++;
            }
        }
        float bb;
        for (int i = 0; i < c + 1; i++) {
//            System.out.println("count[" + i + "]=" + count[i]);
            //寻找该区域灰度最大值
            //分为32个灰度区   (可取不同的值,看不同的效果,如64,128,256等,有三处地方需要修改,注意!)
            int countgraycount[] = new int[32];
            for (int j = 0; j < count[i]; j++) {                
//                System.out.println("countgray[" + j + "]=" + countgray[i][j]);
                countgraycount[countgray[i][j]/8]++;
            }
            countgraymax[i] = 0;
            for (int j = 0; j < 32; j++) {
//                System.out.println("countgraycount[" + j + "]=" + countgraycount[j]);
                if (countgraymax[i] < countgraycount[j])
                {
                    countgraymax[i] = countgraycount[j];
                    countgraymaxgray[i] = j;
//                    System.out.println("111 [" + i + "]=" + countgraymax[i] + "," + countgraymaxgray[i]);
                }
            }
            
            countgraymaxratio[i] = countgraymax[i]*100/count[i];
//            System.out.println("222 [" + i + "]=" + countgraymax[i] + "," + countgraymaxgray[i]);
        }
        for (int i = 0; i < c + 1; i++) {
            bb = (float) (Math.round(rr * i * 100)) / 100;
            text[i] = bb + "";
            color[i] = Color.GREEN;
        }
        //极坐标半径直方图
        BufferedImage image = planeHistogram.paintPlaneHistogram("极坐标半径直方图", count, text, color);
        File output = new File("111.jpg");
        try {
            ImageIO.write(image, "jpg", output);
        } catch (IOException e) {
            e.printStackTrace();
        }
        for (int i = 0; i < c + 1; i++) {
            text[i] = countgraymaxgray[i] + "";
            color[i] = Color.GREEN;
        }
        //灰度极坐标的直方图,X轴是极坐标,Y轴是对应灰度密集区最大值的灰度值        
        BufferedImage image2 = planeHistogram.paintPlaneHistogram("灰度极坐标直方图", countgraymaxratio, text, color);
        File output2 = new File("222.jpg");
        try {
            ImageIO.write(image2, "jpg", output2);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


猜你喜欢

转载自blog.csdn.net/billyhhzh/article/details/51516534
今日推荐