So, I started to look at what it would take to incorporate color management into my rawproc program. It’s a convoluted story I won’t bore you with here, but I ended up coding my own image library. Yes, yes, I know there are many good libraries, but I developed two reasons for taking this path: 1) having all of the LibRaw options available, and 2) assembling a basic set of image operations in one place for others to study. The second reason has roots in my previous career as a teacher, I guess; my personal learning of image processing has been a convoluted journey, and I thought there’d be benefit to consolidating it all in one place for others to capitalize.
(geesh, could do without the picture here…)
I need to give a nod to the FreeImage library; it provided an excellent platform upon which to start my study. Where I ran into roadblocks was with access to the LibRaw options; the 32-bit flags parameter really limited this. I ended up defining options as a c++ map of name=value pairs, which provides both a lot of capability to pass booleans and values, as well as a straightforward path from command line parameters to the library.
In a nod to G’MIC, I simplified my internal image representation to floating-point RGB, 0.0-255.0. This impacts some computational efficiency, but it really simplifies the processing functions for better understanding, as well as promotes better-image quality after repeated manipulations.
The essential reason I’m posting here is to point others who want to study basic image processing to gimage.cpp, where I’ve provided narrative comments for the various functions, as well as cites to the supporting literature. No Richardson-Lucy, no wavelets, no layers, just the basic operations in what I hope is a clear and concise presentation in C++. This part of the endeavor is really a response to the poster of a few months ago who was looking for sources to study basic image processing, A detailed description of the image processing algorithms used by RT.
Also in here is a command line program I’ve used to test as I go, gimg.cpp. I’ve been using its rawproc progenitor, img.cpp, to do batch processing; when I implemented wildcard file processing it became really useful. gimg will do the same sort of thing:
$gimg "*.NEF:gamma=srgb,autobright" contrast:10 resize:640,0 sharpen:1 "*.jpg"
reads all the Nikon NEF raws in the directory, applies LibRaw gamma and autobright, gimage contrast, resize, and sharpen, and saves them as correspondingly named JPEGs. No shell antics, but you do have to put the parameters with “*” in them in quotes to keep the shell processors from expanding them for you.
Compiling gimage may be daunting right now; you first need to download the participating LibRaw, llibtiff, and libjpeg libraries if you don’t already have them in your gcc library paths and compile them. You’ll need to mess with the Makefile to point to the right places. The Makefile recognizes a build/ directory in which you can put a localmake.txt file to define your particular things without disturbing the github-cloned Makefile in the parent directory. And so on. Later, I’ll make it easier to build, but that’s not my first priority.
Anyway, what I’m after here is not code reuse so much as education; if others find such a compendium useful in that regard, that’d make the effort worthwhile.