Skip to content

jorditost/ImageFiltering

Repository files navigation

Image Filtering

This repository contains a set of examples and tests for image filtering using Processing and the OpenCV library for Processing by Greg Borenstein.

##Filtering the image for blob detection

The following sketch should help us to filter the source image for blob detection. It requires the controlP5 library.

Code: ImageFiltering.pde

The sketch is doing the following:

  • Adjust contrast: highlight blobs
  • Thresholding: (Basic OR adaptive)
  • Noise reduction: (with dilation and erosion)
  • Blur filter: to remove remaining background noise
  • Set minimal blob size: to eliminate small blobs (spots, etc) that may be in the background.

Using basic thresholding

Thresholding is one of the most important filtering operations.

Using adaptive thresholding

Adaptive thresholding is a more advanced option to filter your image. For environments with changing illumination or if you simply get a source image with shadows or irregular illumination, try better this. You can see an example in the next image, where the

Just open the sketch and do some tests ;)

Color Tracking

Simple color tracking based on the hue channel.

Code: HSVColorTracking.pde

For color tracking with multiple colors, check this sketch:

Code: MultipleColorTracking.pde

Blob persistence (memory) over time

For some applications it may be important to "follow" a blob or an object over time (as markers or TUIO do).

"One of the most common questions I get regarding blob tracking is “memory.” How do I know which blob is which over time? Computer vision libraries, for the most part, simply pass you a list of blobs (with x, y, width, and height properties) for any given moment in time. But the blobs themselves represent only a snapshot of that particular moment and contain no information related to whether the blobs existed before this very moment. This may seem absurd given that as human beings it’s so easy for us to watch a rectangle moving across a screen and understand conceptually that it is the same rectangle. But without additional information (such as color matching, an AR marker, etc.) there’s no way for an algorithm that analyzes one frame of video to know anything about a previous frame. And so we need to apply the same intuitions our brain uses (it was there a moment ago, it’s probably still there now) to our algorithms" (by Daniel Shiffman)

Inside the BlobPersistence repository, the sketch WichFace implements a persistence algorithm that follows faces over time. It is a modification of Daniel Shiffman's algorithm that works the OpenCV library for Processing by Greg.

The same algorithm is also implemented in the ImageFilteringWithBlobPersistence example in this repository to track blobs over time:

Code:

For detailed information about this algorithm visit Daniel Shiffman's blog: http://shiffman.net/2011/04/26/opencv-matching-faces-over-time/

##Future Work In the future this repository will contain more sketches for color tracking, camera calibration, etc.

##More For more info about OpenCV and more examples, visit the library's github repository: https://github.com/atduskgreg/opencv-processing

About

A set of examples and tests for image filtering using Processing and OpenCV

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published