Browse by category

Drawing Histograms in OpenCV

Here we’ll be generating the levels histograms you see in Photoshop. You load an image and the R, G and B histograms are calculated and rendered. We’ll make a very flexible function which you can reuse in your own projects too. Loading and splitting the image First, create a new project. Include the standard OpenCV [...]

Read more

Accessing Histogram Data

If you couldn’t check what value is stored in each bin, a histogram would be useless >.< So here are two methods to access those bins, one easy and one a little hard. The easy way This one is super simple. double cvQueryHistValue_1D(CvHistogram* hist, int idx0 );   double cvQueryHistValue_2D(CvHistogram* hist, int idx0, int idx1 [...]

Read more

Histograms with inbuilt functions of OpenCV

If something is useful for computer vision, you’ll almost definitely find it in OpenCV. Histograms are no exception. And OpenCV comes with a rich set of functions to work with and manipulate histograms. Creating and Releasing Histograms are stored in the CvHistogram data structure: typedef struct CvHistogram { int type; CvArr* bins; float thresh[CV_MAX_DIM][2]; // [...]

Read more

Histograms: From simplest to the most complex

If you’ve used photoshop, you probably know what a histogram is. Even digital cameras have it these days. But a histogram isn’t just about the chart you see there. Histograms have several uses in various fields. In this post, we’ll have a look at histograms from a general perspective. The General Histogram A histogram is [...]

Read more

Implementing SIFT in OpenCV

Okay, now for the coding. I’m assuming you know how SIFT works (if not, check SIFT: Scale Invariant Feature Transform. It’s a series of posts on the SIFT algorithm). I’ll be using C++ and classes to keep things neat and object oriented. OpenCV doesn’t come with inbuilt functions for SIFT, so we’ll be creating our [...]

Read more

SIFT: Scale Invariant Feature Transform

SIFT

Matching features across different images in a common problem in computer vision. When all images are similar in nature (same scale, orientation, etc) simple corner detectors can work.

Read more

Subpixel corners in OpenCV

Subpixel accuracy

OpenCV comes with a function to help you find subpixel corners. It uses the dot product technique to refine corners detected by other techniques, like the Shi-Tomasi corner detector. The function works iteratively, refining the corners till a termination criteria is reached. Refining corners to subpixel level The function that lets you calculate better corner [...]

Read more

Subpixel Corners: Increasing accuracy

Subpixel accuracy

When working with images on a digital system, the smallest part of an image is a pixel. You simply cannot access information “between” pixels. But several application require higher accuracy than a camera can provide. For example, when reconstructing a 3D object from an image, you need accurate measurements. So, mathematical techniques were developed to [...]

Read more

Corner Detection in OpenCV

Features

OpenCV comes with both the Harris corner detector and the Shi-Tomasi corner detector. However, OpenCV uses the Shi-Tomasi corner detector unless you explicitly specify you want to use the other one. You can also get raw eigenvalues and eigenvectors for each pixel if you want, and process the values yourself. For now, we’ll discuss the [...]

Read more

The Shi-Tomasi Corner Detector

Features

The Shi-Tomasi corner detector is based entirely on the Harris corner detector. However, one slight variation in a “selection criteria” made this detector much better than the original. It works quite well where even the Harris corner detector fails. So here’s the minor change that Shi and Tomasi did to the original Harris corner detector. [...]

Read more