IPSDK 4.2
IPSDK : Image Processing Software Development Kit
Harris corner detection 2d image
image = harrisCorner2dImg (inImg)
image = harrisCorner2dImg (inImg,inGradStdDev)

Detailed Description

Computes the Harris corner detection response.

This algorithm computes the cornerness for each pixel of the input image, according to the Harris corner detector algorithm [1] or to the Shi-Tomasi [2] [3] corner detector algorithm (with respect to method contained by parameter $InCornerDetectionParams$).

The basic idea of the Harris corner detector is that a corner can be characterized by high intensity variation in all directions. It means that a pixel at position $(u, v)$ is a corner if the energy $E(u, v)$, described by the following equation, reaches a maximum value compared to its neighbourhood $\aleph$ :

\[ E(u, v) = \sum_{x, y \in \aleph}{\omega(x, y) \left( InImg(x+u, y+v) - InImg(x, y) \right)^2} \]

Where $\aleph$ is the pixel's neighbourhood, $InImg$ is the input image and $\omega(x, y)$ is the Gaussian coefficient at the position $(x, y)$. The gaussian coefficients are computed using the parameters $InStdDev$ and $InOptGradientGaussianCoverage$.

The energy can be approximated by a first order Taylor expansion :

\[ E(u, v) \approx \left[ u, v \right] M \left[ \begin{array}{c} u \\ v \end{array} \right] \]

Where

\[ M = \sum_{x, y, \in \aleph}{\omega(x, y) \begin{bmatrix} I_x^2 & IxIy\\ IxIy & Iy^2 \end{bmatrix}} \]

Where $Ix$ and $Iy$ are the spatial derivatives of the input image at the position $(u, v)$ along the directions x and y respectively. In this implementation, the spatial derivatives are computed using the Gaussian Gradient 2d algorithm.

Here is an example of a 2d Harris cornerness calculation applied to an 8-bits grey level input image (with $InStdDev=0.75$ and $k = 0.04$):

harrisCorner2dImg.png

[1] C. Harris and M. Stephens (1988). "A combined corner and edge detector". Proceedings of the 4th Alvey Vision Conference. pp. 147 - 151.
[2] J. Shi and C. Tomasi (June 1994). "Good Features to Track". 9th IEEE Conference on Computer Vision and Pattern Recognition. Springer
[3] C. Tomasi and T. Kanade (2004). "Detection and Tracking of Point Features". Pattern Recognition. 37: 165 - 168

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLFeatureDetection as fd

Code Example

# opening input images
inGeometry = PyIPSDK.geometry2d(PyIPSDK.eImageBufferType.eIBT_UInt8, 510, 509)
inImg = PyIPSDK.loadRawImageFile(inputImgPath, inGeometry)
# images addition
outImg = fd.harrisCorner2dImg(inImg)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLFeatureDetection/Processor/HarrisCorner2dImg/HarrisCorner2dImg.h>

Code Example

// Sample with a generated output image
// ------------------------------------
ImagePtr pAutoOutImg = harrisCorner2dImg(pInImg);
// Sample with a provided output image
// ------------------------------------
// create output image
const ipUInt64 sizeX = pInImg->getSizeX();
const ipUInt64 sizeY = pInImg->getSizeY();
ImageGeometryPtr pOutputImageGeometry = geometry2d(outType, sizeX, sizeY);
boost::shared_ptr<MemoryImage> pOutImg(boost::make_shared<MemoryImage>());
pOutImg->init(*pOutputImageGeometry);
// compute harris image
harrisCorner2dImg(pInImg, stdDev, createGaussianCoverage(gaussRatio, 2), createHarrisParams(sensitivity), pOutImg);