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 [...]
Browse by category
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 [...]
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]; // [...]
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 [...]
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 [...]
SIFT: Scale Invariant Feature Transform
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.
Subpixel corners in OpenCV
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 [...]
Subpixel Corners: Increasing 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 [...]
Corner Detection in OpenCV
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 [...]
The Shi-Tomasi Corner Detector
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. [...]

