Search code examples
haskellimage-processinghistogram

Histogram of Oriented Gradients In Haskell


I have never written a single line of Haskell code (except for random stuff in my xmonad configuration file), but I thought the perfect way to learn functional programming is by doing. I want to write a program that reads in an image file of arbitrary file type and size, and also reads in a list of pixel locations. Then it should compute histogram of oriented gradients in a window centered on each of the input list of pixels, and it needs to write these histograms out. I'll start small, so let's assume I am using just text files as the output.

What are some resources online for learning how to do this. In particular, how to read images, work with arrays of pixels, etc. I don't mind needing to build infrastructure myself; but my hope is this is the sort of project where, once I complete it, I'll be reasonably able to make my own Haskell subroutines for scientific computing tasks. Any other thoughts / suggestions are very welcome and encouraged, even if you think this idea is dumb or you're one of those weird OCaml people. My background is all Python. It's easy to do this in Python with NumPy, but I want to learn Haskell for science!


Solution

  • If you've never written any Haskell code before, I wouldn't recommend starting by playing with binary data manipulation, as you would mostly be fighting with the libraries instead of learning the language in itself. Maybe you should instead start by taking a look at Learn You a Haskell, Real World Haskell or Yet Another Haskell Tutorial.

    If you really wish to go forward with that project, I recommend you use PGM as it's very simple image format. I recently implemented a parser for PGM in Haskell, and my biggest difficulty was to understand how to deal with binary data in Haskell. Here are some resources that helped me: