Archive

Posts Tagged ‘active contours’

Making Active Contours Fast

July 2nd, 2009 1 comment

Active contours are a method of image segmentation. They are well-loved for their accuracy, ease of implementation, and nice mathematical underpinnings. However, a full level-set implementation can be quite slow, especially when dealing with large data! Here are some tips to speed things up. By combining these ideas and solid programming techniques I’ve been able to get active contour trackers running at hundreds of frames per second!

  1. Use Fast Level-Sets
  2. Start by using a fast level-sets implementation that minimizes the number of required computations [code]. This will already save a huge number of computations per iteration and speed things up quite a bit!

  3. Create better initializations.
  4. The farther the initial contour is from its final position, the more computations must be done for the contour to converge. Hence, if you can start the contour in almost the right place, you’ll drastically reduce the time needed for segmentation. You can use prior knowledge, user input, or other segmentation techniques to create a rough guess that is close to the right answer. Another initialization that can leads to quick initialization is ‘bubbles’ on an evenly-spaced grid.

  5. Use a multi-scale approach.
  6. This is a way to quickly get good initializations using active contours. Say your data is MxN. Instead of segmenting the full data set, downsample the data so that you are dealing with an (M/8)x(N/8) volume. The segmentation should run much quicker on the smaller volume. Next, upsample the result back to MxN and use this as an initialization for the full data. The idea is that the time saved on the full segmentation by having a good estimate based on downsampled data will make up for the time needed to downsample, segment on the small data, and upsample.

  7. Use approximate active contours.
  8. Using an approximate solution for all or part of your segmentation can be helpful. As in 2 and 3, you can use an approximate active contour technique to quickly get close to the right answer. Then you can use an accurate level sets implementation to get the right answer quickly. Alternatively, the discrete methods can work quite well alone! James Malcolm proposed a nice method in “Fast Approximate Surface Evolution in Arbitrary Dimension” [code].

  9. Use another technique entirely.
  10. Active contours are “variational,” so they give nice, principled solutions with analytic geometry, etc. However, if you just want fast segmentations, other techniques such as thresholding/morphology, graph cuts, region growing, etc. can all be viable solutions.

Any other tips or links to good implementations? Leave them in the comments.

Sparse Field Active Contours

April 21st, 2009 54 comments

Active contour methods for image segmentation allow a contour to deform iteratively to partition an image into regions. Active contours are often implemented with level sets. The primary drawback, however, is that they are slow to compute. This post presents a technical report describing, in detail, the sparse field method (SFM) proposed by Ross Whitaker [pdf], which allows one to implement level set active contours very efficiently. The algorithm is described in detail, specific notes are given about implementation, and source code is provided.

Fast Level Sets Demo

The links below point to the technical report and a demo written in C++/MEX that can be run directly in MATLAB. The demo implements the Chan-Vese segmentation energy, but many energies can be minimized using the provided framework.

Sparse Field Method – Technical Report [pdf]
Sparse Field Method – Matlab Demo [zip]

To run the MATLAB demo, simply unzip the file and run:
>>sfm_chanvese_demo
at the command line. On the first run, this will compile the MEX code on your machine and then run the demo. If the MEX compile fails, please check your MEX setup. The demo is for a 2D image, but the codes work for 3D images as well.

My hope is that other researchers wishing to quickly implement Whitaker’s method can use this information to easily understand the intricacies of the algorithm which, in my opinion, were not presented clearly in Whitaker’s original paper. Personally, these codes have SUBSTANTIALLY sped up my segmentations, and are allowing me to make much faster progress towards completing my PhD!

Thanks to Ernst Schwartz and Andy for helping to find small bugs in the codes and documentation. (they’re fixed now!)

For more information regarding active contour, segmentation, and computer vision, check here: Computer Vision Posts

Active Contour Matlab Code Demo

April 7th, 2008 20 comments

UPDATE:
My new post: Sparse Field Active Contours
implements quicker, more accurate active contours.

Today, I added demo code for the Hybrid Segmentation project. This segmentation algorithm (in the publications section) can be used to find the boundary of objects in images. This approach uses localized statistics and sometimes gets better results than classic methods. For an example, see the video below: The contour begins as a rectangle, but deforms over time so that it finally forms the outline of the monkey.

This can be used to segment many different classes of image. To try it out, download the demo below and run >>localized_seg_demo

localized_seg.zip

This code is based on a standard level set segmentation; it just optimizes a different energy. I’ve also made a demo which implements the well-known Chan-Vese segmentation algorithm. This technique is similar to the one above, but it looks at global statistics. This makes it more robust to initialization, but it also means that more constraints are placed on the image. Download it and see what you think! Again, unzip the file and run >>region_seg_demo

sfm_chanvese_demo.zip (New! Described Here)

regionbased_seg.zip (old and slow)

For another Matlab implementation of Active Contours check out: James Malcolm’s Webpage. He has some codes for very fast approximate implementations as well as a full numerical implementation.

Active Contours

May 15th, 2007 25 comments

UPDATE:
My new post: Sparse Field Active Contours
implements quicker, more accurate active contours.

The well-known Chan-Vese segmentation algorithm from the paper “Active Contours Without Edges,” is a great example of active contours. This technique deforms an initial curve so that it separates foreground from background based on the means of the two regions. The technique is very robust to initialization and gives very nice results when there is a difference between the foreground and background means.

In this video, the curve begins as a square. As time goes on the square changes shape so that it does a better and better job of separating the image into a light area and a dark area.

Below is a download-able Matlab demo. The code is very easy to read, and could be the foundation for lots of other active contour segmentation techniques.

sfm_chanvese_demo.zip (New! Described Here)

regionbased_seg.zip (old and slow)

I recently added some new active contour stuff based on a more complex (and sometimes more capable energy). Check out the latest results, and the full project writeup which is a little older!