图像处理之Hessian矩阵提取关键点
2013-11-22 00:06
513 查看
一:大致的算法流程
1. 对每个像素点计算图像在X方向Y方向的二阶偏导数,计算图像的XY方向的导数
2. 根据第一步的计算结果,有Hessian Matrix计算D(h) = Ixx*Iyy - Ixy*Ixy
其中Ixx表示X方向的二阶偏导数
Iyy表示Y方向的二阶偏导数
Ixy表XY方向的二阶导数
3. 根据第二步计算出来的值使用3×3窗口实现非最大信号压制,
我的做法, 直接给了threshold值,这个其实不很对,真的懒,不想弄啦!
二:导数计算实现
关于一阶与二阶高斯偏导数计算请看这里:
/article/1391065.html
三:程序效果
四:算法代码
1. 对每个像素点计算图像在X方向Y方向的二阶偏导数,计算图像的XY方向的导数
2. 根据第一步的计算结果,有Hessian Matrix计算D(h) = Ixx*Iyy - Ixy*Ixy
其中Ixx表示X方向的二阶偏导数
Iyy表示Y方向的二阶偏导数
Ixy表XY方向的二阶导数
3. 根据第二步计算出来的值使用3×3窗口实现非最大信号压制,
我的做法, 直接给了threshold值,这个其实不很对,真的懒,不想弄啦!
二:导数计算实现
关于一阶与二阶高斯偏导数计算请看这里:
/article/1391065.html
三:程序效果
四:算法代码
package com.gloomyfish.image.harris.corner; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; import com.gloomyfish.filter.study.AbstractBufferedImageOp; public class HessianFeatureDetector extends AbstractBufferedImageOp { private GaussianDerivativeFilter gdFilter; private double minRejectThreshold = 4.1; // (r+1)^2/r private List<HessianMatrix> pixelMatrixList; public HessianFeatureDetector() { gdFilter = new GaussianDerivativeFilter(); pixelMatrixList = new ArrayList<HessianMatrix>(); } @Override public BufferedImage filter(BufferedImage src, BufferedImage dest) { int width = src.getWidth(); int height = src.getHeight(); initSettings(height, width); if ( dest == null ) dest = createCompatibleDestImage( src, null ); int[] inPixels = new int[width*height]; gdFilter.setDirectionType(GaussianDerivativeFilter.XX_DIRECTION); BufferedImage bixx = gdFilter.filter(src, null); getRGB( bixx, 0, 0, width, height, inPixels ); extractPixelData(inPixels, GaussianDerivativeFilter.XX_DIRECTION, height, width); // YY Direction gdFilter.setDirectionType(GaussianDerivativeFilter.YY_DIRECTION); BufferedImage biyy = gdFilter.filter(src, null); getRGB( biyy, 0, 0, width, height, inPixels ); extractPixelData(inPixels, GaussianDerivativeFilter.YY_DIRECTION, height, width); // XY Direction gdFilter.setDirectionType(GaussianDerivativeFilter.XY_DIRECTION); BufferedImage bixy = gdFilter.filter(src, null); getRGB( bixy, 0, 0, width, height, inPixels ); extractPixelData(inPixels, GaussianDerivativeFilter.XY_DIRECTION, height, width); int[] outPixels = new int[width*height]; int index = 0; for(int row=0; row<height; row++) { int ta = 0, tr = 0, tg = 0, tb = 0; for(int col=0; col<width; col++) { index = row * width + col; ta = 255; HessianMatrix hm = pixelMatrixList.get(index); double[] t = hm.getThreshold(); if(t[0] > minRejectThreshold) { tr = 127; } else { tr = 0; } if(t[1] > minRejectThreshold) { tg = 127; } else { tg = 0; } if(t[2] > minRejectThreshold) { tb = 127; } else { tb = 0; } outPixels[index] = (ta << 24) | (tr << 16) | (tg << 8) | tb; } } setRGB( dest, 0, 0, width, height, outPixels ); return dest; } private void initSettings(int height, int width) { int index = 0; for(int row=0; row<height; row++) { for(int col=0; col<width; col++) { index = row * width + col; HessianMatrix matrix = new HessianMatrix(); pixelMatrixList.add(index, matrix); } } } private void extractPixelData(int[] pixels, int type, int height, int width) { int index = 0; for(int row=0; row<height; row++) { int ta = 0, tr = 0, tg = 0, tb = 0; for(int col=0; col<width; col++) { index = row * width + col; ta = (pixels[index] >> 24) & 0xff; tr = (pixels[index] >> 16) & 0xff; tg = (pixels[index] >> 8) & 0xff; tb = pixels[index] & 0xff; HessianMatrix matrix = pixelMatrixList.get(index); if(type == GaussianDerivativeFilter.XX_DIRECTION) { matrix.setXx(new double[]{tr, tg, tb}); } if(type == GaussianDerivativeFilter.YY_DIRECTION) { matrix.setYy(new double[]{tr, tg, tb}); } if(type == GaussianDerivativeFilter.XY_DIRECTION) { matrix.setXy(new double[]{tr, tg, tb}); } } } } }转载请注明!
相关文章推荐
- 图像处理之Hessian矩阵提取关键点
- 图像处理之Hessian矩阵提取关键点
- 【OpenCV图像处理】二十一、形态学滤波角点的提取
- 图像处理之基础---小波提取特征
- C#图像的灰度化处理:提取像素法
- MATLAB图像处理-特征提取-形状特征 方法小结
- 基于matlab的图像处理-RGB色彩提取方法
- Hessian矩阵提取特征点原理及其Matlab实现
- 数字图像处理之二维码图像提取算法(一)
- Atitit 图像处理 公共模块 矩阵扫描器
- 图像处理之Matlab特征提取和表达
- 特征点提取-图像处理
- 数字图像处理编成入门笔记——第7章 边沿检测与提取,轮廓跟踪
- 【图像处理】提取图片中的交点数据 [已删除]
- Matlab图像处理(一):二值化、开操作、连通区域提取、重心,ROI(region of interest)
- 图形图像处理之——实现图形图像子区域额提取3
- 【OpenCV3图像处理】强大的矩阵 - Mat类详解
- PCL经典代码赏析六:深度图像及关键点提取
- 图像处理三大特征提取,hog特征,LBP特征,harr特征
- 图像处理特征提取(一):LINK错误的解决