This is a sample of how to apply edge filters to a set of images using F# and Accord.NET. The framework provides several Filters for image manipulating. Since I’m interested in edge enhancement I’ll limit my scope to those filters. In particular I’ve selected the DifferenceEdgeDetector()
.
Using Paket, here is a sample paket.dependencies
file.
1 | source https://nuget.org/api/v2 |
This is the boring setup stuff.
1 | // Ref: http://accord-framework.net/docs/html/N_Accord_Imaging_Filters.htm |
Loading and applying the filter is straight-forward. The only additional point worthy of mention is that most of the edge filters require the image to be in grayscale. That conversion is included in this function.
1 | // Process image and save a result file with edge filter applied |
The below code gets a list of qualifying images, then sends them through the filtering function.
1 | // Is file an image file? |
Below is an example of the edge filter applied.