Image Filters

Jun 14, 2010 at 4:30 PM

I just read your post about the Real-time face detection (http://blogs.msdn.com/b/coding4fun/archive/2010/03/24/9984015.aspx) and was interested in the image filters you used Erosion and Dilation.  These might be a good addition to your class WriteableBitmapEx.  Maybe you have others?  Maybe it would be possible to have a method take a filter as a delegate and then we can plug in some library of image filter methods?

Coordinator
Jun 14, 2010 at 6:03 PM
Edited Jun 14, 2010 at 6:03 PM
What you describe can be accomplished with the ForEach extension methods. There are two overloads of the ForEach method available.
It takes a Func and applies it to each pixel:

// Override all pixels with a function that changes the color based on the coordinate
writeableBmp.ForEach((x, y, color) => Color.FromArgb(color.A, (byte)(color.R / 2), (byte)(x * y), 100));